From f08775cbd4f51545936ac329734478e100804006 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 20 May 2026 13:15:28 +0300 Subject: [PATCH] Updates & fixes --- android/app/proguard-rules.pro | 10 +++- ios/Podfile | 3 +- lib/core/utils/utils.dart | 10 ++++ .../authentication_view_model.dart | 7 ++- .../widgets/appointment_card.dart | 4 +- lib/presentation/authentication/register.dart | 2 +- .../book_appointment/widgets/clinic_card.dart | 1 + lib/presentation/home/landing_page.dart | 46 +++++++++++-------- .../widgets/preferred_language_widget.dart | 4 +- .../update_emergency_contact_widget.dart | 6 ++- .../ancillary_procedures_details_page.dart | 3 +- 11 files changed, 64 insertions(+), 32 deletions(-) diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index 94ad242d..b2ea0470 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -77,4 +77,12 @@ -keep class com.peng.pennavmap.db.** { *; } -keep class com.hiennv.flutter_callkit_incoming.** { *; } --keepattributes Signature, Annotation, InnerClasses, EnclosingMethod \ No newline at end of file +-keepattributes Signature, Annotation, InnerClasses, EnclosingMethod + +-keep class com.peng.pennavmap.** { *; } +-keep class com.peng.bus.** { *; } +# EventBus subscribers (reflection-based) +-keepclassmembers class * { + @com.peng.bus.PISubscribe ; +} +-keep class com.peng.pennavmap.models.bus.BackButtonEventBusData { *; } diff --git a/ios/Podfile b/ios/Podfile index 4c8bed13..a74c7fb2 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '14.0' +platform :ios, '15.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -54,6 +54,7 @@ post_install do |installer| 'PERMISSION_EVENTS_FULL_ACCESS=1', ## dart: PermissionGroup.reminders 'PERMISSION_REMINDERS=1', + 'PERMISSION_PHOTOS=1', ## dart: PermissionGroup.notification 'PERMISSION_NOTIFICATIONS=1', ] diff --git a/lib/core/utils/utils.dart b/lib/core/utils/utils.dart index ef83cb9f..6ab5865a 100644 --- a/lib/core/utils/utils.dart +++ b/lib/core/utils/utils.dart @@ -771,6 +771,7 @@ class Utils { double height = 24, BoxFit fit = BoxFit.cover, bool applyThemeColor = true, + String? errorAsset, }) { final Color? resolvedColor = iconColor ?? (applyThemeColor && AppColors.isDarkMode ? AppColors.textColor : null); return SvgPicture.asset( @@ -779,6 +780,15 @@ class Utils { width: width, height: height, fit: fit, + errorBuilder: errorAsset != null + ? (context, error, stackTrace) => SvgPicture.asset( + errorAsset, + colorFilter: resolvedColor != null ? ColorFilter.mode(isDisabled ? resolvedColor.withOpacity(0.5) : resolvedColor, BlendMode.srcIn) : null, + width: width, + height: height, + fit: fit, + ) + : null, ); } diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 262f7063..9254f1a8 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -1377,15 +1377,14 @@ class AuthenticationViewModel extends ChangeNotifier { checkLastLoginStatus(Function() onSuccess) async { Future.delayed(Duration(seconds: 1), () async { if (cacheService.getBool(key: CacheConst.quickLoginEnabled) == null) { - if (_appState.getSelectDeviceByImeiRespModelElement != null && - (_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) { + final deviceElement = _appState.getSelectDeviceByImeiRespModelElement; + if (deviceElement != null && (deviceElement.logInType == 1 || deviceElement.logInType == 4)) { phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; nationalIdController.text = _appState.getAuthenticatedUser()!.patientIdentificationNo!; onSuccess(); - } else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) && - _appState.getAuthenticatedUser() != null) { + } else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && deviceElement == null) && _appState.getAuthenticatedUser() != null) { phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; diff --git a/lib/presentation/appointments/widgets/appointment_card.dart b/lib/presentation/appointments/widgets/appointment_card.dart index e17d52dd..03c12c3b 100644 --- a/lib/presentation/appointments/widgets/appointment_card.dart +++ b/lib/presentation/appointments/widgets/appointment_card.dart @@ -639,7 +639,9 @@ class _AppointmentCardState extends State { ), ); } else { - if (!AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel)) { + if (!AppointmentType.isArrived(widget.patientAppointmentHistoryResponseModel) && + widget.patientAppointmentHistoryResponseModel.projectID != null && + widget.patientAppointmentHistoryResponseModel.clinicID != null) { widget.bookAppointmentsViewModel.getAppointmentNearestGate( projectID: widget.patientAppointmentHistoryResponseModel.projectID, clinicID: widget.patientAppointmentHistoryResponseModel.clinicID); } diff --git a/lib/presentation/authentication/register.dart b/lib/presentation/authentication/register.dart index 61b5924e..57c8b3b5 100644 --- a/lib/presentation/authentication/register.dart +++ b/lib/presentation/authentication/register.dart @@ -51,7 +51,7 @@ class _RegisterNew extends State { // Clear errors when leaving register screen // Use post frame callback to avoid calling notifyListeners during dispose WidgetsBinding.instance.addPostFrameCallback((_) { - final authVm = context.read(); + final authVm = getIt.get(); authVm.clearNationalIdError(); authVm.clearDobError(); authVm.clearPhoneNumberError(); diff --git a/lib/presentation/book_appointment/widgets/clinic_card.dart b/lib/presentation/book_appointment/widgets/clinic_card.dart index fb3e2c79..68b9b1e0 100644 --- a/lib/presentation/book_appointment/widgets/clinic_card.dart +++ b/lib/presentation/book_appointment/widgets/clinic_card.dart @@ -49,6 +49,7 @@ class ClinicCard extends StatelessWidget { width: 24.w, height: 24.h, fit: BoxFit.contain, + errorAsset: "assets/images/clinicIcons/1.svg" // Note: Add error handling in the Utils.buildSvgWithAssets if possible // or use a try-catch wrapper ), diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 5219cda6..441dd770 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -59,6 +59,7 @@ import 'package:hmg_patient_app_new/presentation/todo_section/todo_page.dart'; import 'package:hmg_patient_app_new/presentation/todo_section/widgets/ancillary_orders_list.dart'; import 'package:hmg_patient_app_new/routes/app_routes.dart'; import 'package:hmg_patient_app_new/services/cache_service.dart'; +import 'package:hmg_patient_app_new/services/navigation_service.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'; @@ -156,9 +157,13 @@ class _LandingPageState extends State { appointmentRatingViewModel.getLastRatingAppointment( onSuccess: (response) { if (appointmentRatingViewModel.appointmentRatedList.isNotEmpty) { + final lastAppointment = appointmentRatingViewModel.appointmentRatedList.last; + final appointmentNo = lastAppointment.appointmentNo; + final projectID = lastAppointment.projectID; + if (appointmentNo == null || projectID == null) return; appointmentRatingViewModel.getAppointmentDetails( - appointmentRatingViewModel.appointmentRatedList.last.appointmentNo!, - appointmentRatingViewModel.appointmentRatedList.last.projectID!, + appointmentNo, + projectID, onSuccess: ((response) { appointmentRatingViewModel.setClinicOrDoctor(false); appointmentRatingViewModel.setTitle(LocaleKeys.rateDoctor.tr(context: context)); @@ -214,23 +219,24 @@ class _LandingPageState extends State { immediateLiveCareViewModel.initImmediateLiveCare(); immediateLiveCareViewModel.getPatientLiveCareHistory(); - appointmentRatingViewModel.getLastRatingAppointment( - onSuccess: (response) { - if (appointmentRatingViewModel.appointmentRatedList.isNotEmpty) { - appointmentRatingViewModel.getAppointmentDetails( - appointmentRatingViewModel.appointmentRatedList.last.appointmentNo!, - appointmentRatingViewModel.appointmentRatedList.last.projectID!, - onSuccess: ((response) { - appointmentRatingViewModel.setClinicOrDoctor(false); - appointmentRatingViewModel.setTitle(LocaleKeys.rateDoctor.tr(context: context)); - appointmentRatingViewModel.setSubTitle(LocaleKeys.howWasYourLastVisitWithDoctor.tr(context: context)); - openLastRating(); - appState.setRatedVisible(true); - }), - ); - } - }, - ); + // appointmentRatingViewModel.getLastRatingAppointment( + // onSuccess: (response) { + // if (appointmentRatingViewModel.appointmentRatedList.isNotEmpty) { + // appointmentRatingViewModel.getAppointmentDetails( + // appointmentRatingViewModel.appointmentRatedList.last.appointmentNo!, + // appointmentRatingViewModel.appointmentRatedList.last.projectID!, + // onSuccess: ((response) { + // appointmentRatingViewModel.setClinicOrDoctor(false); + // appointmentRatingViewModel.setTitle(LocaleKeys.rateDoctor.tr(context: context)); + // appointmentRatingViewModel.setSubTitle(LocaleKeys.howWasYourLastVisitWithDoctor.tr(context: context)); + // openLastRating(); + // appState.setRatedVisible(true); + // }), + // ); + // } + // }, + // ); + } }, child: SingleChildScrollView( @@ -1394,7 +1400,7 @@ class _LandingPageState extends State { void showQuickLogin(BuildContext context) { showCommonBottomSheetWithoutHeight( - context, + getIt().navigatorKey.currentContext!, // title: "", isCloseButtonVisible: false, child: StatefulBuilder( diff --git a/lib/presentation/profile_settings/widgets/preferred_language_widget.dart b/lib/presentation/profile_settings/widgets/preferred_language_widget.dart index 32dcc57b..d0f85090 100644 --- a/lib/presentation/profile_settings/widgets/preferred_language_widget.dart +++ b/lib/presentation/profile_settings/widgets/preferred_language_widget.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:get_it/get_it.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/int_extensions.dart'; @@ -7,6 +8,7 @@ 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/profile_settings/profile_settings_view_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; +import 'package:hmg_patient_app_new/services/navigation_service.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/common_bottom_sheet.dart'; @@ -70,7 +72,7 @@ class _PreferredLanguageWidgetState extends State { LoaderBottomSheet.hideLoader(); showCommonBottomSheetWithoutHeight(context, title: LocaleKeys.success.tr(context: context), child: Utils.getSuccessWidget(loadingText: LocaleKeys.success.tr()), callBackFunc: () async { - Navigator.of(context).pop(); + Navigator.of(GetIt.instance().navigatorKey.currentContext!).pop(); profileSettingsViewModel.getProfileSettings(); }, isFullScreen: false, isAutoDismiss: true); }, diff --git a/lib/presentation/profile_settings/widgets/update_emergency_contact_widget.dart b/lib/presentation/profile_settings/widgets/update_emergency_contact_widget.dart index e1faadca..f1a34565 100644 --- a/lib/presentation/profile_settings/widgets/update_emergency_contact_widget.dart +++ b/lib/presentation/profile_settings/widgets/update_emergency_contact_widget.dart @@ -130,9 +130,11 @@ class _UpdateEmergencyContactDialogState extends State().navigatorKey.currentContext; + if (navContext == null) return; + showCommonBottomSheetWithoutHeight(navContext, title: LocaleKeys.success.tr(context: navContext), child: Utils.getSuccessWidget(loadingText: LocaleKeys.success.tr()), callBackFunc: () async { - Navigator.of(getIt.get().navigatorKey.currentContext!).pop(); + Navigator.of(navContext).pop(); profileSettingsViewModel!.getProfileSettings(); }, isFullScreen: false, isAutoDismiss: true); }, diff --git a/lib/presentation/todo_section/ancillary_procedures_details_page.dart b/lib/presentation/todo_section/ancillary_procedures_details_page.dart index 41428a6e..65e1bdaf 100644 --- a/lib/presentation/todo_section/ancillary_procedures_details_page.dart +++ b/lib/presentation/todo_section/ancillary_procedures_details_page.dart @@ -66,6 +66,7 @@ class _AncillaryOrderDetailsListState extends State { } void _autoSelectEligibleProcedures() { + if (!mounted) return; selectedProcedures.clear(); if (todoSectionViewModel.patientAncillaryOrderProceduresList.isNotEmpty) { final procedures = todoSectionViewModel.patientAncillaryOrderProceduresList[0].ancillaryOrderProcDetailsList; @@ -77,7 +78,7 @@ class _AncillaryOrderDetailsListState extends State { } } } - setState(() {}); + if (mounted) setState(() {}); } bool _isProcedureDisabled(AncillaryOrderProcDetail procedure) {