pull/83/head
haroon amjad 3 weeks ago
parent 0441d072fa
commit d755eb0df8

@ -1,16 +1,20 @@
import 'dart:io'; import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:easy_localization/easy_localization.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:gms_check/gms_check.dart'; import 'package:gms_check/gms_check.dart';
import 'package:google_maps_flutter/google_maps_flutter.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/app_state.dart';
import 'package:hmg_patient_app_new/core/cache_consts.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/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/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:huawei_location/huawei_location.dart' as HmsLocation show FusedLocationProviderClient, Location, LocationSettingsRequest, LocationRequest;
import 'package:location/location.dart' show Location, PermissionStatus, LocationData; 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 { class LocationUtils {
NavigationService navigationService; NavigationService navigationService;
@ -68,6 +72,26 @@ class LocationUtils {
onFailure?.call(); onFailure?.call();
return; 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(); Position? currentLocation = await Geolocator.getLastKnownPosition();

@ -1,18 +1,26 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.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/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/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/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_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/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/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.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 { class EmergencyServicesPage extends StatelessWidget {
const EmergencyServicesPage({super.key}); EmergencyServicesPage({super.key});
LocationUtils? locationUtils;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
locationUtils = getIt.get<LocationUtils>();
locationUtils!.isShowConfirmDialog = true;
return CollapsingListView( return CollapsingListView(
title: "Emergency Services", title: "Emergency Services",
requests: () {}, requests: () {},
@ -70,7 +78,15 @@ class EmergencyServicesPage extends StatelessWidget {
SizedBox(width: 12.h), SizedBox(width: 12.h),
Utils.buildSvgWithAssets(icon: AppAssets.forward_chevron_icon, width: 13.h, height: 13.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), SizedBox(height: 16.h),
Container( Container(

@ -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<NearestErPage> createState() => _NearestErPageState();
}
class _NearestErPageState extends State<NearestErPage> {
@override
Widget build(BuildContext context) {
return CollapsingListView(
title: "Nearest ER",
child: Container(),
);
}
}
Loading…
Cancel
Save