From 44ce353dac9cde87772ff3c668ae2bde43c0c6fd Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 12 Jan 2026 15:18:09 +0300 Subject: [PATCH] updates --- android/app/build.gradle.kts | 1 + lib/core/utils/utils.dart | 14 +- .../hospital_selection_view_model.dart | 36 ++- .../hmg_services/services_page.dart | 229 +++++++++++------- lib/widgets/appbar/app_bar_widget.dart | 12 +- 5 files changed, 188 insertions(+), 104 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 2987d3b..5d74c4d 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -160,6 +160,7 @@ dependencies { annotationProcessor("com.github.bumptech.glide:compiler:4.16.0") implementation("com.mapbox.maps:android:11.5.0") + implementation("com.mapbox.mapboxsdk:mapbox-sdk-turf:7.3.1") // implementation("com.mapbox.maps:android:11.4.0") // AARs diff --git a/lib/core/utils/utils.dart b/lib/core/utils/utils.dart index a26c4a5..8978fcd 100644 --- a/lib/core/utils/utils.dart +++ b/lib/core/utils/utils.dart @@ -55,11 +55,12 @@ class Utils { "IsActive": true, "IsHmg": true, "IsVidaPlus": false, - "Latitude": "24.8113774", - "Longitude": "46.6239813", + "Latitude": "24.8111548", + "Longitude": "46.6217912", "MainProjectID": 130, "ProjectOutSA": false, - "UsingInDoctorApp": false + "UsingInDoctorApp": false, + "IsHMC": false },{ "Desciption": "Jeddah Fayhaa Hospital", "DesciptionN": "مستشفى جدة الفيحاء", @@ -75,11 +76,12 @@ class Utils { "IsActive": true, "IsHmg": true, "IsVidaPlus": false, - "Latitude": "24.8113774", - "Longitude": "46.6239813", + "Latitude": "21.5086703", + "Longitude": "39.2121855", "MainProjectID": 130, "ProjectOutSA": false, - "UsingInDoctorApp": false + "UsingInDoctorApp": false, + "IsHMC": false } ]; diff --git a/lib/features/hospital/hospital_selection_view_model.dart b/lib/features/hospital/hospital_selection_view_model.dart index 59c881c..c0cab2a 100644 --- a/lib/features/hospital/hospital_selection_view_model.dart +++ b/lib/features/hospital/hospital_selection_view_model.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.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/location_util.dart'; import 'package:hmg_patient_app_new/core/utils/penguin_method_channel.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/features/hospital/AppPermission.dart'; @@ -17,20 +19,32 @@ class HospitalSelectionBottomSheetViewModel extends ChangeNotifier { int hmgCount = 0; TextEditingController searchController = TextEditingController(); final AppState appState; + LocationUtils locationUtils = getIt.get(); HospitalSelectionBottomSheetViewModel(this.appState) { - Utils.navigationProjectsList.forEach((element) { - HospitalsModel model = HospitalsModel.fromJson(element); - if (model.isHMC == true) { - hmcHospitalList.add(model); - } else { - hmgHospitalList.add(model); - } - listOfData.add(model); + locationUtils.getCurrentLocation(onSuccess: (value) { + Utils.navigationProjectsList.forEach((element) { + HospitalsModel model = HospitalsModel.fromJson(element); + + double dist = Utils.distance(value.latitude, value.longitude, double.parse(model.latitude!), double.parse(model.longitude!)).ceilToDouble(); + print(dist); + model.distanceInKilometers = dist; + + if (model.isHMC == true) { + hmcHospitalList.add(model); + } else { + hmgHospitalList.add(model); + } + listOfData.add(model); + }); + hmgCount = hmgHospitalList.length; + hmcCount = hmcHospitalList.length; + + listOfData.sort((a, b) => a.distanceInKilometers.compareTo(b.distanceInKilometers)); + hmgHospitalList.sort((a, b) => a.distanceInKilometers.compareTo(b.distanceInKilometers)); + + getDisplayList(); }); - hmgCount = hmgHospitalList.length; - hmcCount = hmcHospitalList.length; - getDisplayList(); } getDisplayList() { diff --git a/lib/presentation/hmg_services/services_page.dart b/lib/presentation/hmg_services/services_page.dart index 4d74bc7..ab0cced 100644 --- a/lib/presentation/hmg_services/services_page.dart +++ b/lib/presentation/hmg_services/services_page.dart @@ -4,15 +4,18 @@ import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:get_it/get_it.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_export.dart'; +import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/extensions/route_extensions.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/authentication/authentication_view_model.dart'; import 'package:hmg_patient_app_new/features/blood_donation/blood_donation_view_model.dart'; import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; import 'package:hmg_patient_app_new/features/hmg_services/models/ui_models/hmg_services_component_model.dart'; +import 'package:hmg_patient_app_new/features/hospital/hospital_selection_view_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart'; import 'package:hmg_patient_app_new/features/water_monitor/water_monitor_view_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; @@ -36,6 +39,7 @@ import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; import 'package:provider/provider.dart'; import '../../core/dependencies.dart' show getIt; +import '../emergency_services/call_ambulance/widgets/HospitalBottomSheetBody.dart'; class ServicesPage extends StatelessWidget { ServicesPage({super.key}); @@ -44,27 +48,24 @@ class ServicesPage extends StatelessWidget { late MedicalFileViewModel medicalFileViewModel; late final List hmgServices = [ - HmgServicesComponentModel( - 11, - "Emergency Services".needTranslation, - "".needTranslation, - AppAssets.emergency_services_icon, - bgColor: AppColors.primaryRedColor, - true, - route: null, onTap: () { - getIt.get().flushData(); - getIt.get().getTransportationOrders( - showLoader: false, - ); - getIt.get().getRRTOrders( - showLoader: false, - ); - Navigator.of(GetIt.instance().navigatorKey.currentContext!).push( - CustomPageRoute( - page: EmergencyServicesPage(), - settings: const RouteSettings(name: '/EmergencyServicesPage'), - ), - ); + HmgServicesComponentModel(11, "Emergency Services".needTranslation, "".needTranslation, AppAssets.emergency_services_icon, bgColor: AppColors.primaryRedColor, true, route: null, onTap: () async { + if (getIt.get().isAuthenticated) { + getIt.get().flushData(); + getIt.get().getTransportationOrders( + showLoader: false, + ); + getIt.get().getRRTOrders( + showLoader: false, + ); + Navigator.of(GetIt.instance().navigatorKey.currentContext!).push( + CustomPageRoute( + page: EmergencyServicesPage(), + settings: const RouteSettings(name: '/EmergencyServicesPage'), + ), + ); + } else { + await getIt.get().onLoginPressed(); + } }), HmgServicesComponentModel( 11, @@ -75,15 +76,13 @@ class ServicesPage extends StatelessWidget { true, route: AppRoutes.bookAppointmentPage, ), - HmgServicesComponentModel( - 5, - "Complete Checkup".needTranslation, - "".needTranslation, - AppAssets.comprehensiveCheckup, - bgColor: AppColors.bgGreenColor, - true, - route: AppRoutes.comprehensiveCheckupPage, - ), + HmgServicesComponentModel(5, "Complete Checkup".needTranslation, "".needTranslation, AppAssets.comprehensiveCheckup, bgColor: AppColors.bgGreenColor, true, route: null, onTap: () async { + if (getIt.get().isAuthenticated) { + getIt.get().pushPageRoute(AppRoutes.comprehensiveCheckupPage); + } else { + await getIt.get().onLoginPressed(); + } + }), HmgServicesComponentModel( 11, "Indoor Navigation".needTranslation, @@ -92,17 +91,51 @@ class ServicesPage extends StatelessWidget { bgColor: Color(0xff45A2F8), true, route: null, - onTap: () {}, + onTap: () { + showCommonBottomSheetWithoutHeight( + title: LocaleKeys.selectHospital.tr(), + GetIt.instance().navigatorKey.currentContext!, + child: ChangeNotifierProvider( + create: (context) => HospitalSelectionBottomSheetViewModel(getIt()), + child: Consumer( + builder: (_, vm, __) => HospitalBottomSheetBody( + searchText: vm.searchController, + displayList: vm.displayList, + onFacilityClicked: (value) { + vm.setSelectedFacility(value); + vm.getDisplayList(); + }, + onHospitalClicked: (hospital) { + Navigator.pop(GetIt.instance().navigatorKey.currentContext!); + vm.openPenguin(hospital); + }, + onHospitalSearch: (value) { + vm.searchHospitals(value ?? ""); + }, + selectedFacility: vm.selectedFacility, + hmcCount: vm.hmcCount, + hmgCount: vm.hmgCount, + ), + ), + ), + isFullScreen: false, + isCloseButtonVisible: true, + hasBottomPadding: false, + backgroundColor: AppColors.bottomSheetBgColor, + callBackFunc: () { + GetIt.instance().navigatorKey.currentContext!.read().clearSearchText(); + }, + ); + }, ), HmgServicesComponentModel( - 11, - "E-Referral Services".needTranslation, - "".needTranslation, - AppAssets.eReferral, - bgColor: AppColors.eReferralCardColor, - true, - route: AppRoutes.eReferralPage, - ), + 11, "E-Referral Services".needTranslation, "".needTranslation, AppAssets.eReferral, bgColor: AppColors.eReferralCardColor, true, route: null, onTap: () async { + if (getIt.get().isAuthenticated) { + getIt.get().pushPageRoute(AppRoutes.eReferralPage); + } else { + await getIt.get().onLoginPressed(); + } + }), HmgServicesComponentModel( 3, "Blood Donation".needTranslation, @@ -180,7 +213,14 @@ class ServicesPage extends StatelessWidget { AppAssets.general_health, bgColor: AppColors.whiteColor, true, - route: AppRoutes.healthTrackersPage, + route: null, + onTap: () async { + if (getIt.get().isAuthenticated) { + getIt.get().pushPageRoute(AppRoutes.healthTrackersPage); + } else { + await getIt.get().onLoginPressed(); + } + }, ), HmgServicesComponentModel( 11, @@ -191,24 +231,28 @@ class ServicesPage extends StatelessWidget { true, route: null, // Set to null since we handle navigation in onTap onTap: () async { - LoaderBottomSheet.showLoader(loadingText: "Fetching your water intake details.".needTranslation); - final waterMonitorVM = getIt.get(); - final context = getIt.get().navigatorKey.currentContext!; - await waterMonitorVM.fetchUserDetailsForMonitoring( - onSuccess: (userDetail) { - LoaderBottomSheet.hideLoader(); - if (userDetail == null) { - waterMonitorVM.populateFromAuthenticatedUser(); - context.navigateWithName(AppRoutes.waterMonitorSettingsPage); - } else { + if (getIt.get().isAuthenticated) { + LoaderBottomSheet.showLoader(loadingText: "Fetching your water intake details.".needTranslation); + final waterMonitorVM = getIt.get(); + final context = getIt.get().navigatorKey.currentContext!; + await waterMonitorVM.fetchUserDetailsForMonitoring( + onSuccess: (userDetail) { + LoaderBottomSheet.hideLoader(); + if (userDetail == null) { + waterMonitorVM.populateFromAuthenticatedUser(); + context.navigateWithName(AppRoutes.waterMonitorSettingsPage); + } else { + context.navigateWithName(AppRoutes.waterConsumptionPage); + } + }, + onError: (error) { + LoaderBottomSheet.hideLoader(); context.navigateWithName(AppRoutes.waterConsumptionPage); - } - }, - onError: (error) { - LoaderBottomSheet.hideLoader(); - context.navigateWithName(AppRoutes.waterConsumptionPage); - }, - ); + }, + ); + } else { + await getIt.get().onLoginPressed(); + } }, ), HmgServicesComponentModel( @@ -236,7 +280,14 @@ class ServicesPage extends StatelessWidget { AppAssets.smartwatch_icon, bgColor: AppColors.whiteColor, true, - route: AppRoutes.smartWatches, + route: null, + onTap: () async { + if (getIt.get().isAuthenticated) { + getIt.get().pushPageRoute(AppRoutes.smartWatches); + } else { + await getIt.get().onLoginPressed(); + } + }, // route: AppRoutes.huaweiHealthExample, ), ]; @@ -329,14 +380,17 @@ class ServicesPage extends StatelessWidget { ], ), Spacer(), - Consumer(builder: (context, habibWalletVM, child) { - return Utils.getPaymentAmountWithSymbol2(habibWalletVM.habibWalletAmount, isExpanded: false) - .toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.r, width: 80.w, height: 24.h); - }), + getIt.get().isAuthenticated + ? Consumer(builder: (context, habibWalletVM, child) { + return Utils.getPaymentAmountWithSymbol2(habibWalletVM.habibWalletAmount, isExpanded: false) + .toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.r, width: 80.w, height: 24.h); + }) + : "Login to view your wallet balance".needTranslation.toText12(fontWeight: FontWeight.w500, maxLine: 2), Spacer(), - CustomButton( - height: 40.h, - icon: AppAssets.recharge_icon, + getIt.get().isAuthenticated + ? CustomButton( + height: 40.h, + icon: AppAssets.recharge_icon, iconSize: 16.w, iconColor: AppColors.infoColor, textColor: AppColors.infoColor, @@ -350,10 +404,15 @@ class ServicesPage extends StatelessWidget { onPressed: () { Navigator.of(context).push(CustomPageRoute(page: RechargeWalletPage())); }, - ), + ) + : SizedBox.shrink(), ], - ).onPress(() { - Navigator.of(context).push(CustomPageRoute(page: HabibWalletPage())); + ).onPress(() async { + if (getIt.get().isAuthenticated) { + Navigator.of(context).push(CustomPageRoute(page: HabibWalletPage())); + } else { + await getIt.get().onLoginPressed(); + } }), ), ), @@ -375,13 +434,14 @@ class ServicesPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Utils.buildSvgWithAssets(icon: AppAssets.services_medical_file_icon, width: 30.w, height: 30.h), - "Medical Files".needTranslation.toText14(weight: FontWeight.w600, maxlines: 2).expanded, + LocaleKeys.medicalFile.tr().toText14(weight: FontWeight.w600, maxlines: 2).expanded, Utils.buildSvgWithAssets(icon: AppAssets.arrow_forward), ], ), Spacer(), - Wrap( - spacing: -8.h, + getIt.get().isAuthenticated + ? Wrap( + spacing: -8.h, // runSpacing: 0.h, children: [ Utils.buildImgWithAssets( @@ -409,10 +469,12 @@ class ServicesPage extends StatelessWidget { fit: BoxFit.contain, ), ], - ), + ) + : "Login to view your medical file".needTranslation.toText12(fontWeight: FontWeight.w500, maxLine: 2), Spacer(), - CustomButton( - height: 40.h, + getIt.get().isAuthenticated + ? CustomButton( + height: 40.h, icon: AppAssets.add_icon, iconSize: 16.w, iconColor: AppColors.primaryRedColor, @@ -434,14 +496,19 @@ class ServicesPage extends StatelessWidget { medicalFileViewModel.addFamilyFile(otpTypeEnum: OTPTypeEnum.sms); }); }, - ), + ) + : SizedBox.shrink(), ], - ).onPress(() { - Navigator.of(context).push( - CustomPageRoute( - page: MedicalFilePage(), - ), - ); + ).onPress(() async { + if (getIt.get().isAuthenticated) { + Navigator.of(context).push( + CustomPageRoute( + page: MedicalFilePage(), + ), + ); + } else { + await getIt.get().onLoginPressed(); + } }), ), ), diff --git a/lib/widgets/appbar/app_bar_widget.dart b/lib/widgets/appbar/app_bar_widget.dart index b3bc3eb..942a93f 100644 --- a/lib/widgets/appbar/app_bar_widget.dart +++ b/lib/widgets/appbar/app_bar_widget.dart @@ -42,15 +42,15 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { ? RotatedBox( quarterTurns: 90, child: Utils.buildSvgWithAssets( - icon: AppAssets.arrow_back, - width: 32.w, - height: 32.h, + icon: AppAssets.forward_top_nav_icon, + width: 24.w, + height: 24.h, ), ) : Utils.buildSvgWithAssets( - icon: AppAssets.arrow_back, - width: 32.w, - height: 32.h, + icon: AppAssets.forward_top_nav_icon, + width: 24.w, + height: 24.h, ), ), ),