|
|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
|
@ -17,7 +18,6 @@ import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_vie
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/utils/appointment_type.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/appointments/appointment_details_page.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/appointments/widgets/ask_doctor_request_type_select.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/book_appointment/widgets/appointment_calendar.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/medical_file/eye_measurement_details_page.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
@ -27,8 +27,9 @@ import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
|
|
|
|
import 'dart:ui' as ui;
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/appointments/appointment_payment_page.dart';
|
|
|
|
|
|
|
|
|
|
class AppointmentCard extends StatelessWidget {
|
|
|
|
|
class AppointmentCard extends StatefulWidget {
|
|
|
|
|
final PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel;
|
|
|
|
|
final MyAppointmentsViewModel myAppointmentsViewModel;
|
|
|
|
|
final bool isLoading;
|
|
|
|
|
@ -56,6 +57,97 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
this.contactUsViewModel,
|
|
|
|
|
this.isForRate = false});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<AppointmentCard> createState() => _AppointmentCardState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _AppointmentCardState extends State<AppointmentCard> {
|
|
|
|
|
Timer? _countdownTimer;
|
|
|
|
|
Duration? _timeRemaining;
|
|
|
|
|
Function(void Function())? _modalSetState;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
// Start countdown timer if appointment requires payment
|
|
|
|
|
if (widget.patientAppointmentHistoryResponseModel.nextAction == 15) {
|
|
|
|
|
_startCountdownTimer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_countdownTimer?.cancel();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _startCountdownTimer() {
|
|
|
|
|
final appointmentDate = DateUtil.convertStringToDate(widget.patientAppointmentHistoryResponseModel.appointmentDate!);
|
|
|
|
|
final expiryDate = appointmentDate.subtract(const Duration(hours: 4));
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
_timeRemaining = expiryDate.difference(DateTime.now());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_countdownTimer?.cancel();
|
|
|
|
|
_countdownTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
|
|
|
|
final newTimeRemaining = expiryDate.difference(DateTime.now());
|
|
|
|
|
|
|
|
|
|
if (newTimeRemaining.isNegative) {
|
|
|
|
|
timer.cancel();
|
|
|
|
|
setState(() {
|
|
|
|
|
_timeRemaining = Duration.zero;
|
|
|
|
|
});
|
|
|
|
|
_modalSetState?.call(() {
|
|
|
|
|
_timeRemaining = Duration.zero;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
_timeRemaining = newTimeRemaining;
|
|
|
|
|
});
|
|
|
|
|
_modalSetState?.call(() {
|
|
|
|
|
_timeRemaining = newTimeRemaining;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Helper method to build each time unit (number + label)
|
|
|
|
|
Widget _buildTimeUnit(String value, String label) {
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: value.toText32(
|
|
|
|
|
isBold: true,
|
|
|
|
|
color: AppColors.blackColor,
|
|
|
|
|
isEnglishOnly: true,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 4.h),
|
|
|
|
|
Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: label.toText12(
|
|
|
|
|
color: AppColors.greyTextColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Helper method to build time separator (:)
|
|
|
|
|
Widget _buildTimeSeparator() {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.only(bottom: 16.h, left: 6.w, right: 6.w),
|
|
|
|
|
child: ':'.toText32(
|
|
|
|
|
isBold: true,
|
|
|
|
|
color: AppColors.blackColor,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final appState = getIt.get<AppState>();
|
|
|
|
|
@ -66,11 +158,11 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
isForRate ? SizedBox() : _buildHeader(context, appState),
|
|
|
|
|
widget.isForRate ? SizedBox() : _buildHeader(context, appState),
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
_buildDoctorRow(context),
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
isForRate ? SizedBox() : _buildActionArea(context, appState),
|
|
|
|
|
widget.isForRate ? SizedBox() : _buildActionArea(context, appState),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -87,7 +179,7 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildChips(BuildContext context, AppState appState) {
|
|
|
|
|
final isLiveCare = !isLoading && patientAppointmentHistoryResponseModel.isLiveCareAppointment!;
|
|
|
|
|
final isLiveCare = !widget.isLoading && widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!;
|
|
|
|
|
|
|
|
|
|
return Wrap(
|
|
|
|
|
alignment: WrapAlignment.start,
|
|
|
|
|
@ -96,25 +188,25 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
runSpacing: 6.h,
|
|
|
|
|
children: [
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
icon: isLoading ? AppAssets.walkin_appointment_icon : (isLiveCare ? AppAssets.small_livecare_icon : AppAssets.walkin_appointment_icon),
|
|
|
|
|
iconColor: isLoading ? AppColors.textColor : (isLiveCare ? Colors.white : AppColors.textColor),
|
|
|
|
|
labelText: isLoading ? LocaleKeys.walkin.tr(context: context) : (isLiveCare ? LocaleKeys.livecare.tr(context: context) : LocaleKeys.walkin.tr(context: context)),
|
|
|
|
|
backgroundColor: isLoading ? AppColors.greyColor : (isLiveCare ? AppColors.successColor : AppColors.greyColor),
|
|
|
|
|
textColor: isLoading ? AppColors.textColor : (isLiveCare ? Colors.white : AppColors.textColor),
|
|
|
|
|
).toShimmer2(isShow: isLoading),
|
|
|
|
|
icon: widget.isLoading ? AppAssets.walkin_appointment_icon : (isLiveCare ? AppAssets.small_livecare_icon : AppAssets.walkin_appointment_icon),
|
|
|
|
|
iconColor: widget.isLoading ? AppColors.textColor : (isLiveCare ? Colors.white : AppColors.textColor),
|
|
|
|
|
labelText: widget.isLoading ? LocaleKeys.walkin.tr(context: context) : (isLiveCare ? LocaleKeys.livecare.tr(context: context) : LocaleKeys.walkin.tr(context: context)),
|
|
|
|
|
backgroundColor: widget.isLoading ? AppColors.greyColor : (isLiveCare ? AppColors.successColor : AppColors.greyColor),
|
|
|
|
|
textColor: widget.isLoading ? AppColors.textColor : (isLiveCare ? Colors.white : AppColors.textColor),
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
labelText:
|
|
|
|
|
isLoading ? 'OutPatient' : (appState.isArabic() ? patientAppointmentHistoryResponseModel.isInOutPatientDescriptionN! : patientAppointmentHistoryResponseModel.isInOutPatientDescription!),
|
|
|
|
|
widget.isLoading ? 'OutPatient' : (appState.isArabic() ? widget.patientAppointmentHistoryResponseModel.isInOutPatientDescriptionN! : widget.patientAppointmentHistoryResponseModel.isInOutPatientDescription!),
|
|
|
|
|
backgroundColor: AppColors.warningColorYellow.withValues(alpha: 0.1),
|
|
|
|
|
textColor: AppColors.warningColorYellow,
|
|
|
|
|
).toShimmer2(isShow: isLoading),
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
labelText: isLoading ? 'Booked' : AppointmentType.getAppointmentStatusType(patientAppointmentHistoryResponseModel.patientStatusType!),
|
|
|
|
|
labelText: widget.isLoading ? 'Booked' : AppointmentType.getAppointmentStatusType(widget.patientAppointmentHistoryResponseModel.patientStatusType!),
|
|
|
|
|
backgroundColor: AppColors.successColor.withValues(alpha: 0.1),
|
|
|
|
|
textColor: AppColors.successColor,
|
|
|
|
|
).toShimmer2(isShow: isLoading),
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
],
|
|
|
|
|
).toShimmer2(isShow: isLoading);
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildDoctorRow(BuildContext context) {
|
|
|
|
|
@ -125,11 +217,11 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Image.network(
|
|
|
|
|
isLoading ? 'https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png' : patientAppointmentHistoryResponseModel.doctorImageURL!,
|
|
|
|
|
widget.isLoading ? 'https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png' : widget.patientAppointmentHistoryResponseModel.doctorImageURL!,
|
|
|
|
|
width: 63.h,
|
|
|
|
|
height: 63.h,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
).circle(100.r).toShimmer2(isShow: isLoading),
|
|
|
|
|
).circle(100.r).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
Transform.translate(
|
|
|
|
|
offset: Offset(0.0, -20.h),
|
|
|
|
|
child: Container(
|
|
|
|
|
@ -149,11 +241,11 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
Utils.buildSvgWithAssets(icon: AppAssets.rating_icon, width: 15.w, height: 15.h, iconColor: AppColors.ratingColorYellow),
|
|
|
|
|
SizedBox(height: 2.h),
|
|
|
|
|
(isFoldable || isTablet)
|
|
|
|
|
? "${patientAppointmentHistoryResponseModel.decimalDoctorRate}".toText9(isBold: true, color: AppColors.textColor, isEnglishOnly: true)
|
|
|
|
|
: "${patientAppointmentHistoryResponseModel.decimalDoctorRate ?? "0.0"}".toText11(isBold: true, color: AppColors.textColor, isEnglishOnly: true),
|
|
|
|
|
? "${widget.patientAppointmentHistoryResponseModel.decimalDoctorRate}".toText9(isBold: true, color: AppColors.textColor, isEnglishOnly: true)
|
|
|
|
|
: "${widget.patientAppointmentHistoryResponseModel.decimalDoctorRate ?? "0.0"}".toText11(isBold: true, color: AppColors.textColor, isEnglishOnly: true),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).circle(100).toShimmer2(isShow: isLoading),
|
|
|
|
|
).circle(100).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -164,20 +256,20 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
(isLoading ? 'Dr' : "${patientAppointmentHistoryResponseModel.doctorTitle}").toText16(isBold: true, maxlines: 1),
|
|
|
|
|
(isLoading ? 'John Doe' : " ${patientAppointmentHistoryResponseModel.doctorNameObj!.truncate(20)}")
|
|
|
|
|
.toText16(isBold: true, maxlines: 1, isEnglishOnly: !Utils.isArabicText(patientAppointmentHistoryResponseModel.doctorNameObj ?? "John Doe")),
|
|
|
|
|
(widget.isLoading ? 'Dr' : "${widget.patientAppointmentHistoryResponseModel.doctorTitle}").toText16(isBold: true, maxlines: 1),
|
|
|
|
|
(widget.isLoading ? 'John Doe' : " ${widget.patientAppointmentHistoryResponseModel.doctorNameObj!.truncate(20)}")
|
|
|
|
|
.toText16(isBold: true, maxlines: 1, isEnglishOnly: !Utils.isArabicText(widget.patientAppointmentHistoryResponseModel.doctorNameObj ?? "John Doe")),
|
|
|
|
|
SizedBox(width: 12.w),
|
|
|
|
|
(patientAppointmentHistoryResponseModel.doctorNationalityFlagURL != null && patientAppointmentHistoryResponseModel.doctorNationalityFlagURL!.isNotEmpty)
|
|
|
|
|
(widget.patientAppointmentHistoryResponseModel.doctorNationalityFlagURL != null && widget.patientAppointmentHistoryResponseModel.doctorNationalityFlagURL!.isNotEmpty)
|
|
|
|
|
? Image.network(
|
|
|
|
|
patientAppointmentHistoryResponseModel.doctorNationalityFlagURL ?? "https://hmgwebservices.com/Images/flag/SAU.png",
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.doctorNationalityFlagURL ?? "https://hmgwebservices.com/Images/flag/SAU.png",
|
|
|
|
|
width: 20.h,
|
|
|
|
|
height: 15.h,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
)
|
|
|
|
|
: SizedBox.shrink(),
|
|
|
|
|
],
|
|
|
|
|
).toShimmer2(isShow: isLoading),
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
SizedBox(height: 8.h),
|
|
|
|
|
Wrap(
|
|
|
|
|
direction: Axis.horizontal,
|
|
|
|
|
@ -185,29 +277,29 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
runSpacing: 4.h,
|
|
|
|
|
children: [
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
labelText: isLoading
|
|
|
|
|
labelText: widget.isLoading
|
|
|
|
|
? 'Cardiology'
|
|
|
|
|
: (patientAppointmentHistoryResponseModel.clinicName!.length > 20
|
|
|
|
|
? '${patientAppointmentHistoryResponseModel.clinicName!.substring(0, 20)}...'
|
|
|
|
|
: patientAppointmentHistoryResponseModel.clinicName!),
|
|
|
|
|
).toShimmer2(isShow: isLoading),
|
|
|
|
|
: (widget.patientAppointmentHistoryResponseModel.clinicName!.length > 20
|
|
|
|
|
? '${widget.patientAppointmentHistoryResponseModel.clinicName!.substring(0, 20)}...'
|
|
|
|
|
: widget.patientAppointmentHistoryResponseModel.clinicName!),
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
labelText: isLoading
|
|
|
|
|
labelText: widget.isLoading
|
|
|
|
|
? 'Olaya'
|
|
|
|
|
: (patientAppointmentHistoryResponseModel.projectName ?? "Habib Hospital").length > 15
|
|
|
|
|
? '${(patientAppointmentHistoryResponseModel.projectName ?? "Habib Hospital").substring(0, 15)}...'
|
|
|
|
|
: patientAppointmentHistoryResponseModel.projectName ?? "Habib Hospital")
|
|
|
|
|
.toShimmer2(isShow: isLoading),
|
|
|
|
|
: (widget.patientAppointmentHistoryResponseModel.projectName ?? "Habib Hospital").length > 15
|
|
|
|
|
? '${(widget.patientAppointmentHistoryResponseModel.projectName ?? "Habib Hospital").substring(0, 15)}...'
|
|
|
|
|
: widget.patientAppointmentHistoryResponseModel.projectName ?? "Habib Hospital")
|
|
|
|
|
.toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
Directionality(
|
|
|
|
|
textDirection: ui.TextDirection.ltr,
|
|
|
|
|
child: AppCustomChipWidget(
|
|
|
|
|
labelPadding: EdgeInsetsDirectional.only(start: -4.w, end: 6.w),
|
|
|
|
|
icon: AppAssets.appointment_calendar_icon,
|
|
|
|
|
richText: isLoading
|
|
|
|
|
? 'Cardiology'.toText10().toShimmer2(isShow: isLoading)
|
|
|
|
|
: "${DateUtil.formatDateToDate(DateUtil.convertStringToDate(patientAppointmentHistoryResponseModel.appointmentDate), false)} ${DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(patientAppointmentHistoryResponseModel.appointmentDate), false)}"
|
|
|
|
|
richText: widget.isLoading
|
|
|
|
|
? 'Cardiology'.toText10().toShimmer2(isShow: widget.isLoading)
|
|
|
|
|
: "${DateUtil.formatDateToDate(DateUtil.convertStringToDate(widget.patientAppointmentHistoryResponseModel.appointmentDate), false)} ${DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(widget.patientAppointmentHistoryResponseModel.appointmentDate), false)}"
|
|
|
|
|
.toText10(isEnglishOnly: true, isBold: true),
|
|
|
|
|
).toShimmer2(isShow: isLoading),
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// AppCustomChipWidget(
|
|
|
|
|
@ -240,10 +332,10 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildActionArea(BuildContext context, AppState appState) {
|
|
|
|
|
if ((((patientAppointmentHistoryResponseModel.isLiveCareAppointment ?? false) ||
|
|
|
|
|
(patientAppointmentHistoryResponseModel.isExecludeDoctor ?? false) ||
|
|
|
|
|
!Utils.isClinicAllowedForRebook(patientAppointmentHistoryResponseModel.clinicID ?? 0))) &&
|
|
|
|
|
AppointmentType.isArrived(patientAppointmentHistoryResponseModel)) {
|
|
|
|
|
if ((((widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment ?? false) ||
|
|
|
|
|
(widget.patientAppointmentHistoryResponseModel.isExecludeDoctor ?? false) ||
|
|
|
|
|
!Utils.isClinicAllowedForRebook(widget.patientAppointmentHistoryResponseModel.clinicID ?? 0))) &&
|
|
|
|
|
AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel)) {
|
|
|
|
|
// if (((patientAppointmentHistoryResponseModel.isLiveCareAppointment ?? false) &&
|
|
|
|
|
// DateTime.now().difference(DateUtil.convertStringToDate(patientAppointmentHistoryResponseModel.appointmentDate)).inDays <= 15)) {
|
|
|
|
|
// return Row(
|
|
|
|
|
@ -325,25 +417,25 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
// );
|
|
|
|
|
// } else {
|
|
|
|
|
return CustomButton(
|
|
|
|
|
text: isFromMedicalReport ? LocaleKeys.selectAppointment.tr(context: context) : LocaleKeys.viewDetails.tr(context: context),
|
|
|
|
|
text: widget.isFromMedicalReport ? LocaleKeys.selectAppointment.tr(context: context) : LocaleKeys.viewDetails.tr(context: context),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (isFromMedicalReport) {
|
|
|
|
|
if (isForFeedback) {
|
|
|
|
|
contactUsViewModel!.setPatientFeedbackSelectedAppointment(patientAppointmentHistoryResponseModel);
|
|
|
|
|
if (widget.isFromMedicalReport) {
|
|
|
|
|
if (widget.isForFeedback) {
|
|
|
|
|
widget.contactUsViewModel!.setPatientFeedbackSelectedAppointment(widget.patientAppointmentHistoryResponseModel);
|
|
|
|
|
} else {
|
|
|
|
|
medicalFileViewModel!.setSelectedMedicalReportAppointment(patientAppointmentHistoryResponseModel);
|
|
|
|
|
widget.medicalFileViewModel!.setSelectedMedicalReportAppointment(widget.patientAppointmentHistoryResponseModel);
|
|
|
|
|
}
|
|
|
|
|
Navigator.pop(context, false);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel),
|
|
|
|
|
page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.then((_) {
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
widget.myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
widget.myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -356,23 +448,23 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
|
|
|
|
// height: isTablet || isFoldable ? 46.h : 40.h,
|
|
|
|
|
height: 40.h,
|
|
|
|
|
icon: isFromMedicalReport ? AppAssets.checkmark_icon : null,
|
|
|
|
|
icon: widget.isFromMedicalReport ? AppAssets.checkmark_icon : null,
|
|
|
|
|
iconColor: AppColors.primaryRedColor,
|
|
|
|
|
iconSize: 16.h,
|
|
|
|
|
);
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
if (isFromMedicalReport) {
|
|
|
|
|
if (isForEyeMeasurements) {
|
|
|
|
|
if (widget.isFromMedicalReport) {
|
|
|
|
|
if (widget.isForEyeMeasurements) {
|
|
|
|
|
return SizedBox.shrink();
|
|
|
|
|
} else {
|
|
|
|
|
return CustomButton(
|
|
|
|
|
text: LocaleKeys.selectAppointment.tr(context: context),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (isForFeedback) {
|
|
|
|
|
contactUsViewModel!.setPatientFeedbackSelectedAppointment(patientAppointmentHistoryResponseModel);
|
|
|
|
|
if (widget.isForFeedback) {
|
|
|
|
|
widget.contactUsViewModel!.setPatientFeedbackSelectedAppointment(widget.patientAppointmentHistoryResponseModel);
|
|
|
|
|
} else {
|
|
|
|
|
medicalFileViewModel!.setSelectedMedicalReportAppointment(patientAppointmentHistoryResponseModel);
|
|
|
|
|
widget.medicalFileViewModel!.setSelectedMedicalReportAppointment(widget.patientAppointmentHistoryResponseModel);
|
|
|
|
|
}
|
|
|
|
|
Navigator.pop(context, false);
|
|
|
|
|
},
|
|
|
|
|
@ -391,33 +483,33 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (patientAppointmentHistoryResponseModel.isActiveDoctor ?? true)
|
|
|
|
|
? (AppointmentType.isArrived(patientAppointmentHistoryResponseModel) &&
|
|
|
|
|
patientAppointmentHistoryResponseModel.isClinicReBookingAllowed == false)
|
|
|
|
|
return (widget.patientAppointmentHistoryResponseModel.isActiveDoctor ?? true)
|
|
|
|
|
? (AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel) &&
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.isClinicReBookingAllowed == false)
|
|
|
|
|
? // Show only View Details button without arrow when rebooking not allowed
|
|
|
|
|
_getArrivedButton(context)
|
|
|
|
|
: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 6,
|
|
|
|
|
child: (AppointmentType.isArrived(patientAppointmentHistoryResponseModel)
|
|
|
|
|
child: (AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel)
|
|
|
|
|
? _getArrivedButton(context)
|
|
|
|
|
: CustomButton(
|
|
|
|
|
text: AppointmentType.getNextActionText(patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
onPressed: () => _goToDetails(context),
|
|
|
|
|
backgroundColor: AppointmentType.getNextActionButtonColor(patientAppointmentHistoryResponseModel.nextAction).withValues(alpha: 0.15),
|
|
|
|
|
borderColor: AppointmentType.getNextActionButtonColor(patientAppointmentHistoryResponseModel.nextAction).withValues(alpha: 0.01),
|
|
|
|
|
textColor: AppointmentType.getNextActionTextColor(patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
text: AppointmentType.getNextActionText(widget.patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
onPressed: () => handleAppointmentNextAction(widget.patientAppointmentHistoryResponseModel.nextAction, context),
|
|
|
|
|
backgroundColor: AppointmentType.getNextActionButtonColor(widget.patientAppointmentHistoryResponseModel.nextAction).withValues(alpha: 0.15),
|
|
|
|
|
borderColor: AppointmentType.getNextActionButtonColor(widget.patientAppointmentHistoryResponseModel.nextAction).withValues(alpha: 0.01),
|
|
|
|
|
textColor: AppointmentType.getNextActionTextColor(widget.patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
fontSize: (isFoldable || isTablet) ? 12.f : 14.f,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
borderRadius: 12.r,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
|
|
|
|
height: 40.h,
|
|
|
|
|
icon: AppointmentType.getNextActionIcon(patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
iconColor: AppointmentType.getNextActionTextColor(patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
icon: AppointmentType.getNextActionIcon(widget.patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
iconColor: AppointmentType.getNextActionTextColor(widget.patientAppointmentHistoryResponseModel.nextAction),
|
|
|
|
|
iconSize: 15.h,
|
|
|
|
|
))
|
|
|
|
|
.toShimmer2(isShow: isLoading),
|
|
|
|
|
.toShimmer2(isShow: widget.isLoading),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 8.h),
|
|
|
|
|
Expanded(
|
|
|
|
|
@ -442,7 +534,7 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).toShimmer2(isShow: isLoading).onPress(() {
|
|
|
|
|
).toShimmer2(isShow: widget.isLoading).onPress(() {
|
|
|
|
|
_goToDetails(context);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
@ -454,12 +546,12 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel),
|
|
|
|
|
page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.then((_) {
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
widget.myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
widget.myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: AppColors.secondaryLightRedColor,
|
|
|
|
|
@ -471,7 +563,7 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
|
|
|
|
// height: isTablet || isFoldable ? 46.h : 40.h,
|
|
|
|
|
height: 40.h,
|
|
|
|
|
icon: isFromMedicalReport ? AppAssets.checkmark_icon : null,
|
|
|
|
|
icon: widget.isFromMedicalReport ? AppAssets.checkmark_icon : null,
|
|
|
|
|
iconColor: AppColors.primaryRedColor,
|
|
|
|
|
iconSize: 16.h,
|
|
|
|
|
);
|
|
|
|
|
@ -479,7 +571,7 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _getArrivedButton(BuildContext context) {
|
|
|
|
|
if (patientAppointmentHistoryResponseModel.isClinicReBookingAllowed == false) {
|
|
|
|
|
if (widget.patientAppointmentHistoryResponseModel.isClinicReBookingAllowed == false) {
|
|
|
|
|
return CustomButton(
|
|
|
|
|
text: LocaleKeys.viewDetails.tr(context: context),
|
|
|
|
|
onPressed: () => _goToDetails(context),
|
|
|
|
|
@ -518,21 +610,21 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _goToDetails(BuildContext context) {
|
|
|
|
|
if (isFromMedicalReport) return;
|
|
|
|
|
if (isForEyeMeasurements) {
|
|
|
|
|
if (widget.isFromMedicalReport) return;
|
|
|
|
|
if (widget.isForEyeMeasurements) {
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: EyeMeasurementDetailsPage(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel),
|
|
|
|
|
page: EyeMeasurementDetailsPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
if (!AppointmentType.isArrived(patientAppointmentHistoryResponseModel)) {
|
|
|
|
|
bookAppointmentsViewModel.getAppointmentNearestGate(projectID: patientAppointmentHistoryResponseModel.projectID, clinicID: patientAppointmentHistoryResponseModel.clinicID);
|
|
|
|
|
if (!AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel)) {
|
|
|
|
|
widget.bookAppointmentsViewModel.getAppointmentNearestGate(projectID: widget.patientAppointmentHistoryResponseModel.projectID, clinicID: widget.patientAppointmentHistoryResponseModel.clinicID);
|
|
|
|
|
}
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel),
|
|
|
|
|
page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.then((_) {
|
|
|
|
|
@ -544,22 +636,22 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
void openDoctorScheduleCalendar(BuildContext context) async {
|
|
|
|
|
final doctor = DoctorsListResponseModel(
|
|
|
|
|
clinicID: patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
projectID: patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
doctorID: patientAppointmentHistoryResponseModel.doctorID,
|
|
|
|
|
doctorImageURL: patientAppointmentHistoryResponseModel.doctorImageURL,
|
|
|
|
|
doctorTitle: patientAppointmentHistoryResponseModel.doctorTitle,
|
|
|
|
|
name: patientAppointmentHistoryResponseModel.doctorNameObj,
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
doctorID: widget.patientAppointmentHistoryResponseModel.doctorID,
|
|
|
|
|
doctorImageURL: widget.patientAppointmentHistoryResponseModel.doctorImageURL,
|
|
|
|
|
doctorTitle: widget.patientAppointmentHistoryResponseModel.doctorTitle,
|
|
|
|
|
name: widget.patientAppointmentHistoryResponseModel.doctorNameObj,
|
|
|
|
|
nationalityFlagURL: '',
|
|
|
|
|
speciality: [],
|
|
|
|
|
clinicName: patientAppointmentHistoryResponseModel.clinicName,
|
|
|
|
|
projectName: patientAppointmentHistoryResponseModel.projectName,
|
|
|
|
|
clinicName: widget.patientAppointmentHistoryResponseModel.clinicName,
|
|
|
|
|
projectName: widget.patientAppointmentHistoryResponseModel.projectName,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
bookAppointmentsViewModel.setSelectedDoctor(doctor);
|
|
|
|
|
widget.bookAppointmentsViewModel.setSelectedDoctor(doctor);
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
|
|
|
|
|
await bookAppointmentsViewModel.getDoctorFreeSlots(
|
|
|
|
|
await widget.bookAppointmentsViewModel.getDoctorFreeSlots(
|
|
|
|
|
isBookingForLiveCare: false,
|
|
|
|
|
onSuccess: (respData) async {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
@ -584,4 +676,121 @@ class AppointmentCard extends StatelessWidget {
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> handleAppointmentNextAction(nextAction, BuildContext context) async {
|
|
|
|
|
switch (nextAction) {
|
|
|
|
|
case 0:
|
|
|
|
|
// No action needed
|
|
|
|
|
_goToDetails(context);
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
// Confirm appointment - go to details
|
|
|
|
|
_goToDetails(context);
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
// Pending payment - show waiting modal
|
|
|
|
|
// Ensure timer is running before showing modal
|
|
|
|
|
if (_countdownTimer == null || !_countdownTimer!.isActive) {
|
|
|
|
|
_startCountdownTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
title: LocaleKeys.notice.tr(),
|
|
|
|
|
child: StatefulBuilder(
|
|
|
|
|
builder: (context, setModalState) {
|
|
|
|
|
// Store the modal setState callback
|
|
|
|
|
_modalSetState = setModalState;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
// Message text
|
|
|
|
|
LocaleKeys.upcomingPaymentPending.tr(context: context).toText14(
|
|
|
|
|
color: AppColors.textColor,
|
|
|
|
|
isCenter: true,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 24.h),
|
|
|
|
|
// Countdown Timer - DD : HH : MM : SS format with labels
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// Days
|
|
|
|
|
_buildTimeUnit(
|
|
|
|
|
_timeRemaining != null ? _timeRemaining!.inDays.toString().padLeft(2, '0') : '00',
|
|
|
|
|
LocaleKeys.days.tr(context: context),
|
|
|
|
|
),
|
|
|
|
|
_buildTimeSeparator(),
|
|
|
|
|
// Hours
|
|
|
|
|
_buildTimeUnit(
|
|
|
|
|
_timeRemaining != null ? _timeRemaining!.inHours.remainder(24).toString().padLeft(2, '0') : '00',
|
|
|
|
|
LocaleKeys.hours.tr(context: context),
|
|
|
|
|
),
|
|
|
|
|
_buildTimeSeparator(),
|
|
|
|
|
// Minutes
|
|
|
|
|
_buildTimeUnit(
|
|
|
|
|
_timeRemaining != null ? _timeRemaining!.inMinutes.remainder(60).toString().padLeft(2, '0') : '00',
|
|
|
|
|
LocaleKeys.minutes.tr(context: context),
|
|
|
|
|
),
|
|
|
|
|
_buildTimeSeparator(),
|
|
|
|
|
// Seconds
|
|
|
|
|
_buildTimeUnit(
|
|
|
|
|
_timeRemaining != null ? _timeRemaining!.inSeconds.remainder(60).toString().padLeft(2, '0') : '00',
|
|
|
|
|
LocaleKeys.seconds.tr(context: context),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 24.h),
|
|
|
|
|
// Green Acknowledge button with checkmark icon
|
|
|
|
|
CustomButton(
|
|
|
|
|
text: LocaleKeys.acknowledged.tr(context: context),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
_modalSetState = null; // Clear callback when closing
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: AppColors.successColor,
|
|
|
|
|
borderColor: AppColors.successColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
fontSize: 16.f,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
borderRadius: 12.r,
|
|
|
|
|
height: 50.h,
|
|
|
|
|
icon: AppAssets.checkmark_icon,
|
|
|
|
|
iconColor: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
callBackFunc: () {
|
|
|
|
|
_modalSetState = null; // Clear callback when closing
|
|
|
|
|
},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case 20:
|
|
|
|
|
// Pay now - navigate to payment page
|
|
|
|
|
widget.myAppointmentsViewModel.setIsPatientAppointmentShareLoading(true);
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: AppointmentPaymentPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case 50:
|
|
|
|
|
// Confirm livecare - go to details
|
|
|
|
|
_goToDetails(context);
|
|
|
|
|
break;
|
|
|
|
|
case 90:
|
|
|
|
|
// Check-in - go to details
|
|
|
|
|
_goToDetails(context);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// Default - go to details
|
|
|
|
|
_goToDetails(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|