You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			314 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			314 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			Dart
		
	
| import 'package:easy_localization/easy_localization.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| import 'package:hmg_patient_app_new/core/app_assets.dart';
 | |
| import 'package:hmg_patient_app_new/core/app_state.dart';
 | |
| import 'package:hmg_patient_app_new/core/dependencies.dart';
 | |
| import 'package:hmg_patient_app_new/core/utils/date_util.dart';
 | |
| import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
 | |
| import 'package:hmg_patient_app_new/core/utils/utils.dart';
 | |
| import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
 | |
| import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
 | |
| import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart';
 | |
| import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
 | |
| import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
 | |
| 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/theme/colors.dart';
 | |
| import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
 | |
| import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
 | |
| import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
 | |
| import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';
 | |
| import 'package:smooth_corner/smooth_corner.dart';
 | |
| 
 | |
| class AppointmentCard extends StatefulWidget {
 | |
|   AppointmentCard(
 | |
|       {super.key,
 | |
|       required this.patientAppointmentHistoryResponseModel,
 | |
|       required this.myAppointmentsViewModel,
 | |
|       this.isLoading = false,
 | |
|       this.isFromHomePage = false,
 | |
|       this.isFromMedicalReport = false,
 | |
|       this.medicalFileViewModel});
 | |
| 
 | |
|   PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel;
 | |
|   MyAppointmentsViewModel myAppointmentsViewModel;
 | |
|   bool isLoading;
 | |
|   bool isFromHomePage;
 | |
|   bool isFromMedicalReport;
 | |
|   MedicalFileViewModel? medicalFileViewModel;
 | |
| 
 | |
|   @override
 | |
|   State<AppointmentCard> createState() => _AppointmentCardState();
 | |
| }
 | |
| 
 | |
| class _AppointmentCardState extends State<AppointmentCard> {
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     AppState appState = getIt.get<AppState>();
 | |
|     return InkWell(
 | |
|       onTap: () {
 | |
|         Navigator.of(context)
 | |
|             .push(
 | |
|           CustomPageRoute(
 | |
|             page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
 | |
|           ),
 | |
|         )
 | |
|             .then((val) {
 | |
|           widget.myAppointmentsViewModel.initAppointmentsViewModel();
 | |
|           widget.myAppointmentsViewModel.getPatientAppointments(true, false);
 | |
|         });
 | |
|       },
 | |
|       child: Padding(
 | |
|         padding: EdgeInsets.all(14.h),
 | |
|         child: Column(
 | |
|           crossAxisAlignment: CrossAxisAlignment.start,
 | |
|           children: [
 | |
|             Row(
 | |
|               mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | |
|               children: [
 | |
|                 Expanded(
 | |
|                   child: Wrap(
 | |
|                     alignment: WrapAlignment.start,
 | |
|                     direction: Axis.horizontal,
 | |
|                     spacing: 6.h,
 | |
|                     runSpacing: 6.h,
 | |
|                     children: [
 | |
|                       AppCustomChipWidget(
 | |
|                         icon: widget.isLoading
 | |
|                             ? AppAssets.walkin_appointment_icon
 | |
|                             : (!widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment! ? AppAssets.walkin_appointment_icon : AppAssets.small_livecare_icon),
 | |
|                         iconColor: widget.isLoading
 | |
|                             ? AppColors.textColor
 | |
|                             : !widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!
 | |
|                                 ? AppColors.textColor
 | |
|                                 : AppColors.whiteColor,
 | |
|                         labelText: widget.isLoading
 | |
|                             ? "Walk In"
 | |
|                             : widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!
 | |
|                                 ? LocaleKeys.livecare.tr(context: context)
 | |
|                                 : "Walk In".needTranslation,
 | |
|                         backgroundColor:
 | |
|                             widget.isLoading ? AppColors.greyColor : (!widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment! ? AppColors.greyColor : AppColors.successColor),
 | |
|                         textColor: widget.isLoading ? AppColors.textColor : (!widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment! ? AppColors.textColor : AppColors.whiteColor),
 | |
|                       ).toShimmer2(isShow: widget.isLoading),
 | |
|                       AppCustomChipWidget(
 | |
|                         labelText: widget.isLoading
 | |
|                             ? "OutPatient"
 | |
|                             : appState.isArabic()
 | |
|                                 ? widget.patientAppointmentHistoryResponseModel.isInOutPatientDescriptionN!
 | |
|                                 : widget.patientAppointmentHistoryResponseModel.isInOutPatientDescription!,
 | |
|                         backgroundColor: AppColors.primaryRedColor.withOpacity(0.1),
 | |
|                         textColor: AppColors.primaryRedColor,
 | |
|                       ).toShimmer2(isShow: widget.isLoading),
 | |
|                       AppCustomChipWidget(
 | |
|                         labelText: widget.isLoading ? "Booked" : AppointmentType.getAppointmentStatusType(widget.patientAppointmentHistoryResponseModel.patientStatusType!),
 | |
|                         backgroundColor: AppColors.successColor.withOpacity(0.1),
 | |
|                         textColor: AppColors.successColor,
 | |
|                       ).toShimmer2(isShow: widget.isLoading),
 | |
|                     ],
 | |
|                   ).toShimmer2(isShow: widget.isLoading),
 | |
|                 ),
 | |
|                 // TODO: Implement the logic to enable/disable the switch based on reminder status
 | |
|                 AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel)
 | |
|                     ? SizedBox().toShimmer2(isShow: widget.isLoading)
 | |
|                     : Switch(
 | |
|                         activeColor: AppColors.successColor,
 | |
|                         activeTrackColor: AppColors.successColor.withValues(alpha: .15),
 | |
|                         thumbIcon: WidgetStateProperty.resolveWith<Icon?>(
 | |
|                           (Set<WidgetState> states) {
 | |
|                             if (states.contains(WidgetState.selected)) {
 | |
|                               return const Icon(Icons.check); // Icon when switch is ON
 | |
|                             }
 | |
|                             return const Icon(Icons.close); // Icon when switch is OFF
 | |
|                           },
 | |
|                         ),
 | |
|                         value: widget.isLoading ? false : widget.patientAppointmentHistoryResponseModel.hasReminder!,
 | |
|                         onChanged: (newValue) {
 | |
|                           setState(() {
 | |
|                             widget.myAppointmentsViewModel.setAppointmentReminder(newValue, widget.patientAppointmentHistoryResponseModel);
 | |
|                           });
 | |
|                         },
 | |
|                       ).toShimmer2(isShow: widget.isLoading),
 | |
|               ],
 | |
|             ),
 | |
|             SizedBox(height: 16.h),
 | |
|             Row(
 | |
|               crossAxisAlignment: CrossAxisAlignment.start,
 | |
|               children: [
 | |
|                 Image.network(
 | |
|                   widget.isLoading ? "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png" : widget.patientAppointmentHistoryResponseModel.doctorImageURL!,
 | |
|                   width: 63.h,
 | |
|                   height: 63.h,
 | |
|                   fit: BoxFit.fill,
 | |
|                 ).circle(100).toShimmer2(isShow: widget.isLoading),
 | |
|                 SizedBox(width: 16.h),
 | |
|                 Expanded(
 | |
|                   child: Column(
 | |
|                     crossAxisAlignment: CrossAxisAlignment.start,
 | |
|                     children: [
 | |
|                       (widget.isLoading ? "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png" : widget.patientAppointmentHistoryResponseModel.doctorNameObj!)
 | |
|                           .toText16(isBold: true)
 | |
|                           .toShimmer2(isShow: widget.isLoading),
 | |
|                       SizedBox(height: 8.h),
 | |
|                       Wrap(
 | |
|                         direction: Axis.horizontal,
 | |
|                         spacing: 3.h,
 | |
|                         runSpacing: 4.h,
 | |
|                         children: [
 | |
|                           widget.isFromHomePage
 | |
|                               ? SizedBox.shrink()
 | |
|                               : AppCustomChipWidget(labelText: widget.isLoading ? "Cardiology" : widget.patientAppointmentHistoryResponseModel.clinicName!).toShimmer2(isShow: widget.isLoading),
 | |
|                           widget.isFromHomePage
 | |
|                               ? SizedBox.shrink()
 | |
|                               : AppCustomChipWidget(labelText: widget.isLoading ? "Olaya" : widget.patientAppointmentHistoryResponseModel.projectName!).toShimmer2(isShow: widget.isLoading),
 | |
|                           AppCustomChipWidget(
 | |
|                                   icon: AppAssets.appointment_calendar_icon,
 | |
|                                   labelText:
 | |
|                                       widget.isLoading ? "Cardiology" : DateUtil.formatDateToDate(DateUtil.convertStringToDate(widget.patientAppointmentHistoryResponseModel.appointmentDate), false))
 | |
|                               .toShimmer2(isShow: widget.isLoading),
 | |
|                           AppCustomChipWidget(
 | |
|                                   icon: AppAssets.appointment_time_icon,
 | |
|                                   labelText: widget.isLoading
 | |
|                                       ? "Cardiology"
 | |
|                                       : DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(widget.patientAppointmentHistoryResponseModel.appointmentDate), false))
 | |
|                               .toShimmer2(isShow: widget.isLoading),
 | |
|                         ],
 | |
|                       ),
 | |
|                     ],
 | |
|                   ),
 | |
|                 ),
 | |
|               ],
 | |
|             ),
 | |
|             SizedBox(height: 16.h),
 | |
|             widget.isFromMedicalReport
 | |
|                 ? CustomButton(
 | |
|                     text: "Select appointment".needTranslation,
 | |
|                     onPressed: () {
 | |
|                       widget.medicalFileViewModel!.setSelectedMedicalReportAppointment(widget.patientAppointmentHistoryResponseModel);
 | |
|                       Navigator.pop(context, false);
 | |
|                     },
 | |
|                     backgroundColor: AppColors.secondaryLightRedColor,
 | |
|                     borderColor: AppColors.secondaryLightRedColor,
 | |
|                     textColor: AppColors.primaryRedColor,
 | |
|                     fontSize: 14,
 | |
|                     fontWeight: FontWeight.w500,
 | |
|                     borderRadius: 12,
 | |
|                     padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
 | |
|                     height: 40.h,
 | |
|                     icon: AppAssets.checkmark_icon,
 | |
|                     iconColor: AppColors.primaryRedColor,
 | |
|                     iconSize: 16.h,
 | |
|                   )
 | |
|                 : Row(
 | |
|                     children: [
 | |
|                       Expanded(
 | |
|                         flex: 6,
 | |
|                         child: AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel)
 | |
|                             ? getArrivedAppointmentButton().toShimmer2(isShow: widget.isLoading)
 | |
|                             : CustomButton(
 | |
|                                 text: AppointmentType.getNextActionText(widget.patientAppointmentHistoryResponseModel.nextAction),
 | |
|                                 onPressed: () {
 | |
|                                   Navigator.of(context)
 | |
|                                       .push(CustomPageRoute(
 | |
|                                     page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
 | |
|                                   ))
 | |
|                                       .then((val) {
 | |
|                                     widget.myAppointmentsViewModel.initAppointmentsViewModel();
 | |
|                                     widget.myAppointmentsViewModel.getPatientAppointments(true, false);
 | |
|                                   });
 | |
|                                 },
 | |
|                                 backgroundColor: AppointmentType.getNextActionButtonColor(widget.patientAppointmentHistoryResponseModel.nextAction).withOpacity(0.15),
 | |
|                                 borderColor: AppointmentType.getNextActionButtonColor(widget.patientAppointmentHistoryResponseModel.nextAction).withOpacity(0.01),
 | |
|                                 textColor: AppointmentType.getNextActionTextColor(widget.patientAppointmentHistoryResponseModel.nextAction),
 | |
|                                 fontSize: 14,
 | |
|                                 fontWeight: FontWeight.w500,
 | |
|                                 borderRadius: 12,
 | |
|                                 padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
 | |
|                                 height: 40.h,
 | |
|                                 icon: AppointmentType.getNextActionIcon(widget.patientAppointmentHistoryResponseModel.nextAction),
 | |
|                                 iconColor: AppointmentType.getNextActionTextColor(widget.patientAppointmentHistoryResponseModel.nextAction),
 | |
|                                 iconSize: 15.h,
 | |
|                               ).toShimmer2(isShow: widget.isLoading),
 | |
|                       ),
 | |
|                       SizedBox(width: 8.h),
 | |
|                       Expanded(
 | |
|                         flex: 1,
 | |
|                         child: Container(
 | |
|                           height: 40.h,
 | |
|                           width: 40.h,
 | |
|                           decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
 | |
|                             color: AppColors.textColor,
 | |
|                             borderRadius: 10.h,
 | |
|                           ),
 | |
|                           child: Padding(
 | |
|                             padding: EdgeInsets.all(10.h),
 | |
|                             child: Transform.flip(
 | |
|                               flipX: appState.isArabic() ? true : false,
 | |
|                               child: Utils.buildSvgWithAssets(
 | |
|                                 icon: AppAssets.forward_arrow_icon,
 | |
|                                 iconColor: AppColors.whiteColor,
 | |
|                                 width: 10.h,
 | |
|                                 height: 10.h,
 | |
|                                 fit: BoxFit.contain,
 | |
|                               ),
 | |
|                             ),
 | |
|                           ),
 | |
|                         ).toShimmer2(isShow: widget.isLoading).onPress(() {
 | |
|                           Navigator.of(context)
 | |
|                               .push(
 | |
|                             CustomPageRoute(
 | |
|                               page: AppointmentDetailsPage(patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel),
 | |
|                             ),
 | |
|                           )
 | |
|                               .then((val) {
 | |
|                             widget.myAppointmentsViewModel.initAppointmentsViewModel();
 | |
|                             widget.myAppointmentsViewModel.getPatientAppointments(true, false);
 | |
|                           });
 | |
|                         }),
 | |
|                       ),
 | |
|                     ],
 | |
|                   ),
 | |
|           ],
 | |
|         ),
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   Widget getArrivedAppointmentButton() {
 | |
|     return DateTime.now().difference(DateUtil.convertStringToDate(widget.patientAppointmentHistoryResponseModel.appointmentDate)).inDays <= 15
 | |
|         ? CustomButton(
 | |
|             text: LocaleKeys.askDoctor.tr(context: context),
 | |
|             onPressed: () {},
 | |
|             backgroundColor: AppColors.secondaryLightRedColor,
 | |
|             borderColor: AppColors.secondaryLightRedColor,
 | |
|             textColor: AppColors.primaryRedColor,
 | |
|             fontSize: 14,
 | |
|             fontWeight: FontWeight.w500,
 | |
|             borderRadius: 12,
 | |
|             padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
 | |
|             height: 40.h,
 | |
|             icon: AppAssets.ask_doctor_icon,
 | |
|             iconColor: AppColors.primaryRedColor,
 | |
|             iconSize: 16.h,
 | |
|           )
 | |
|         : CustomButton(
 | |
|             text: "Rebook with same doctor".needTranslation,
 | |
|             onPressed: () {},
 | |
|             backgroundColor: AppColors.greyColor,
 | |
|             borderColor: AppColors.greyColor,
 | |
|             textColor: AppColors.blackColor,
 | |
|             fontSize: 14,
 | |
|             fontWeight: FontWeight.w500,
 | |
|             borderRadius: 12,
 | |
|             padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
 | |
|             height: 40.h,
 | |
|             icon: AppAssets.rebook_appointment_icon,
 | |
|             iconColor: AppColors.blackColor,
 | |
|             iconSize: 16.h,
 | |
|           );
 | |
|   }
 | |
| 
 | |
|   void performAppointmentNextAction(nextAction) {}
 | |
| }
 |