diff --git a/lib/core/location_util.dart b/lib/core/location_util.dart index db8bef4..61c581e 100644 --- a/lib/core/location_util.dart +++ b/lib/core/location_util.dart @@ -1,16 +1,20 @@ import 'dart:io'; import 'dart:ui'; +import 'package:easy_localization/easy_localization.dart'; import 'package:geolocator/geolocator.dart'; import 'package:gms_check/gms_check.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/cache_consts.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/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; +import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; import 'package:huawei_location/huawei_location.dart' as HmsLocation show FusedLocationProviderClient, Location, LocationSettingsRequest, LocationRequest; import 'package:location/location.dart' show Location, PermissionStatus, LocationData; -import 'package:permission_handler/permission_handler.dart' show Permission, PermissionListActions, PermissionStatusGetters; +import 'package:permission_handler/permission_handler.dart' show Permission, PermissionListActions, PermissionStatusGetters, openAppSettings; class LocationUtils { NavigationService navigationService; @@ -68,6 +72,26 @@ class LocationUtils { onFailure?.call(); return; } + } else if (permissionGranted == LocationPermission.deniedForever) { + if (isShowConfirmDialog) { + showCommonBottomSheetWithoutHeight( + title: LocaleKeys.notice.tr(context: navigationService.navigatorKey.currentContext!), + navigationService.navigatorKey.currentContext!, + child: Utils.getWarningWidget( + loadingText: "Please grant location permission from app settings to see the nearest ER location details".needTranslation, + isShowActionButtons: true, + onCancelTap: () { + navigationService.pop(); + }, + onConfirmTap: () async { + navigationService.pop(); + openAppSettings(); + }), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + } } Position? currentLocation = await Geolocator.getLastKnownPosition(); diff --git a/lib/presentation/emergency_services/emergency_services_page.dart b/lib/presentation/emergency_services/emergency_services_page.dart index bae1e6c..0052930 100644 --- a/lib/presentation/emergency_services/emergency_services_page.dart +++ b/lib/presentation/emergency_services/emergency_services_page.dart @@ -1,18 +1,26 @@ import 'package:flutter/material.dart'; import 'package:hmg_patient_app_new/core/app_assets.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/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/generated/locale_keys.g.dart'; +import 'package:hmg_patient_app_new/presentation/emergency_services/nearest_er_page.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; +import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; class EmergencyServicesPage extends StatelessWidget { - const EmergencyServicesPage({super.key}); + EmergencyServicesPage({super.key}); + + LocationUtils? locationUtils; @override Widget build(BuildContext context) { + locationUtils = getIt.get(); + locationUtils!.isShowConfirmDialog = true; return CollapsingListView( title: "Emergency Services", requests: () {}, @@ -70,7 +78,15 @@ class EmergencyServicesPage extends StatelessWidget { SizedBox(width: 12.h), Utils.buildSvgWithAssets(icon: AppAssets.forward_chevron_icon, width: 13.h, height: 13.h), ], - ), + ).onPress(() { + locationUtils!.getLocation(onSuccess: (position) { + Navigator.of(context).push( + CustomPageRoute( + page: NearestErPage(), + ), + ); + }); + }), ), SizedBox(height: 16.h), Container( diff --git a/lib/presentation/emergency_services/nearest_er_page.dart b/lib/presentation/emergency_services/nearest_er_page.dart new file mode 100644 index 0000000..ebf1c91 --- /dev/null +++ b/lib/presentation/emergency_services/nearest_er_page.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; + +class NearestErPage extends StatefulWidget { + const NearestErPage({super.key}); + + @override + State createState() => _NearestErPageState(); +} + +class _NearestErPageState extends State { + @override + Widget build(BuildContext context) { + return CollapsingListView( + title: "Nearest ER", + child: Container(), + ); + } +}