From 2be696b952a97a1bc974d31bddf349837b304da6 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sat, 8 Aug 2026 21:26:58 +0300 Subject: [PATCH 1/2] Updates & fixes --- lib/core/api_consts.dart | 2 +- .../authentication_view_model.dart | 18 +++++++++--------- .../appointments/widgets/appointment_card.dart | 9 +++++++++ .../book_appointment/doctor_profile_page.dart | 9 +++++++++ .../widgets/appointment_calendar.dart | 2 +- pubspec.yaml | 4 ++-- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 8f1455ad..7744dee7 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -301,7 +301,7 @@ class ApiConsts { static String googleCloudStorageENTranslationFileBaseURL = "https://storage.googleapis.com/hmg-patientapp-translations"; // ************ static values for Api **************** - static final double appVersionID = 21.7; + static final double appVersionID = 21.8; // static final double appVersionID = 50.7; static final int appChannelId = 3; diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index fdc16943..7688cfa4 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -980,15 +980,15 @@ class AuthenticationViewModel extends ChangeNotifier { // TODO: GET APP SMS SIGNATURE HERE request.sMSSignature = await getSignature(); - if(!kDebugMode) { - // Get Turnstile token if configured - final turnstileToken = await _turnstileService.getTurnstileToken(); - if (turnstileToken != null) { - request.turnstileToken = turnstileToken; - } else { - request.turnstileToken = ""; - } - } + // if(!kDebugMode) { + // // Get Turnstile token if configured + // final turnstileToken = await _turnstileService.getTurnstileToken(); + // if (turnstileToken != null) { + // request.turnstileToken = turnstileToken; + // } else { + // request.turnstileToken = ""; + // } + // } if (isNeedLoading) { LoaderBottomSheet.showLoader(); diff --git a/lib/presentation/appointments/widgets/appointment_card.dart b/lib/presentation/appointments/widgets/appointment_card.dart index e98eda82..91ebaa14 100644 --- a/lib/presentation/appointments/widgets/appointment_card.dart +++ b/lib/presentation/appointments/widgets/appointment_card.dart @@ -14,6 +14,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/book_appointments/book_appointments_view_model.dart'; import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/doctors_list_response_model.dart'; +import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/get_clinic_list_response_model.dart'; import 'package:hmg_patient_app_new/features/contact_us/contact_us_view_model.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'; @@ -677,7 +678,15 @@ class _AppointmentCardState extends State { projectName: widget.patientAppointmentHistoryResponseModel.projectName, ); + final clinic = GetClinicsListResponseModel( + clinicID: widget.patientAppointmentHistoryResponseModel.clinicID, + clinicDescription: widget.patientAppointmentHistoryResponseModel.clinicName, + clinicDescriptionN: widget.patientAppointmentHistoryResponseModel.clinicName, + ); + widget.bookAppointmentsViewModel.setSelectedDoctor(doctor); + widget.bookAppointmentsViewModel.setSelectedClinic(clinic); + LoaderBottomSheet.showLoader(); await widget.bookAppointmentsViewModel.getDoctorFreeSlots( diff --git a/lib/presentation/book_appointment/doctor_profile_page.dart b/lib/presentation/book_appointment/doctor_profile_page.dart index 6be110ec..a3b4aa48 100644 --- a/lib/presentation/book_appointment/doctor_profile_page.dart +++ b/lib/presentation/book_appointment/doctor_profile_page.dart @@ -8,6 +8,7 @@ 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/book_appointments/book_appointments_view_model.dart'; +import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/get_clinic_list_response_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/widgets/appointment_calendar.dart'; @@ -240,6 +241,14 @@ class DoctorProfilePage extends StatelessWidget { bookAppointmentsViewModel.selectedDoctor.clinicName = bookAppointmentsViewModel.doctorsProfileResponseModel.clinicDescription; bookAppointmentsViewModel.selectedDoctor.projectName = bookAppointmentsViewModel.doctorsProfileResponseModel.projectName; + final clinic = GetClinicsListResponseModel( + clinicID: bookAppointmentsViewModel.doctorsProfileResponseModel.clinicID, + clinicDescription: bookAppointmentsViewModel.doctorsProfileResponseModel.clinicDescription, + clinicDescriptionN: bookAppointmentsViewModel.doctorsProfileResponseModel.clinicDescription, + ); + + bookAppointmentsViewModel.setSelectedClinic(clinic); + LoaderBottomSheet.showLoader(); bookAppointmentsViewModel.isLiveCareSchedule ? await bookAppointmentsViewModel.getLiveCareDoctorFreeSlots( diff --git a/lib/presentation/book_appointment/widgets/appointment_calendar.dart b/lib/presentation/book_appointment/widgets/appointment_calendar.dart index 11092c79..bc6e214c 100644 --- a/lib/presentation/book_appointment/widgets/appointment_calendar.dart +++ b/lib/presentation/book_appointment/widgets/appointment_calendar.dart @@ -268,7 +268,7 @@ class _AppointmentCalendarState extends State { ), ); } else { - if (bookAppointmentsViewModel.selectedClinic.clinicID! == 17 && bookAppointmentsViewModel.selectedChiefComplaintID == 0) { + if (bookAppointmentsViewModel.selectedClinic.clinicID == 17 && bookAppointmentsViewModel.selectedChiefComplaintID == 0) { GetClinicsListResponseModel selectedClinic = GetClinicsListResponseModel( clinicID: bookAppointmentsViewModel.selectedClinic.clinicID, clinicDescription: bookAppointmentsViewModel.selectedClinic.clinicDescription, diff --git a/pubspec.yaml b/pubspec.yaml index 006aca7f..df7ce33e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,8 +2,8 @@ name: hmg_patient_app_new description: "New HMG Patient App" publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.39+38 -#version: 0.0.8+1 +#version: 0.0.40+41 +version: 0.0.11+1 environment: sdk: ">=3.6.0 <4.0.0" From d2718c1e279d865cf22a7a6637cfddc87c0c648e Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Sun, 9 Aug 2026 10:30:52 +0300 Subject: [PATCH 2/2] saved login issue fixed. --- lib/main.dart | 1 + .../authentication/saved_login_screen.dart | 51 +++++++++++++++---- lib/services/navigation_service.dart | 1 + 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index aa266871..87746f14 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -370,6 +370,7 @@ class MyApp extends StatelessWidget { darkTheme: AppTheme.getDarkTheme(isArabic), themeMode: profileVm.isDarkMode ? ThemeMode.dark : ThemeMode.light, navigatorKey: getIt.get().navigatorKey, + navigatorObservers: [getIt.get().routeObserver], ); }, ); diff --git a/lib/presentation/authentication/saved_login_screen.dart b/lib/presentation/authentication/saved_login_screen.dart index 19080ae8..bea93d36 100644 --- a/lib/presentation/authentication/saved_login_screen.dart +++ b/lib/presentation/authentication/saved_login_screen.dart @@ -16,6 +16,7 @@ import 'package:hmg_patient_app_new/features/authentication/authentication_view_ import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/authentication/login.dart'; import 'package:hmg_patient_app_new/presentation/home/navigation_screen.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/appbar/app_bar_widget.dart'; import 'package:hmg_patient_app_new/widgets/bottomsheet/generic_bottom_sheet.dart'; @@ -30,11 +31,24 @@ class SavedLogin extends StatefulWidget { _SavedLogin createState() => _SavedLogin(); } -class _SavedLogin extends State { +class _SavedLogin extends State with RouteAware { LoginTypeEnum loginType = LoginTypeEnum.sms; late AuthenticationViewModel authVm; late AppState appState; bool? isOther; + PageRoute? _pageRoute; + + void _assignSavedLoginData() { + authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!.startsWith("0") + ? appState.getSelectDeviceByImeiRespModelElement!.mobile!.replaceFirst("0", "") + : appState.getSelectDeviceByImeiRespModelElement!.mobile!; + authVm.nationalIdController.text = appState.getSelectDeviceByImeiRespModelElement!.identificationNo!; + + if (isOther == true) { + authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!; + authVm.selectedCountrySignup = CountryEnum.others; + } + } @override void initState() { @@ -43,19 +57,10 @@ class _SavedLogin extends State { appState = getIt.get(); loginType = LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.logInType!)!; - authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!.startsWith("0") - ? appState.getSelectDeviceByImeiRespModelElement!.mobile!.replaceFirst("0", "") - : appState.getSelectDeviceByImeiRespModelElement!.mobile!; - authVm.nationalIdController.text = appState.getSelectDeviceByImeiRespModelElement!.identificationNo!; - // Check if this is an "Others" country user isOther = appState.getSelectDeviceByImeiRespModelElement!.isOther == true; - // Set country to Others if isOther flag is true - this ensures _Others APIs are called - if (isOther!) { - authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!; - authVm.selectedCountrySignup = CountryEnum.others; - } + _assignSavedLoginData(); if (loginType == LoginTypeEnum.fingerprint || loginType == LoginTypeEnum.face) { authVm.loginWithFingerPrintFace(() {}); @@ -63,6 +68,30 @@ class _SavedLogin extends State { super.initState(); } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + final route = ModalRoute.of(context); + if (route is PageRoute && route != _pageRoute) { + if (_pageRoute != null) { + getIt.get().routeObserver.unsubscribe(this); + } + _pageRoute = route; + getIt.get().routeObserver.subscribe(this, route); + } + } + + @override + void didPopNext() { + _assignSavedLoginData(); + } + + @override + void dispose() { + getIt.get().routeObserver.unsubscribe(this); + super.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/services/navigation_service.dart b/lib/services/navigation_service.dart index a83d4e3d..018e46b6 100644 --- a/lib/services/navigation_service.dart +++ b/lib/services/navigation_service.dart @@ -6,6 +6,7 @@ import 'package:hmg_patient_app_new/routes/app_routes.dart'; class NavigationService { final GlobalKey navigatorKey = GlobalKey(); + final RouteObserver> routeObserver = RouteObserver>(); BuildContext? get context => navigatorKey.currentContext;