9/24/1-backLocation

This commit is contained in:
Hamza-Ayed
2024-09-24 13:32:36 +03:00
parent 3313cb0203
commit f5b7307f86
27 changed files with 880 additions and 343 deletions

View File

@@ -3,10 +3,12 @@ import 'dart:io';
import 'package:SEFER/views/widgets/mydialoug.dart';
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:location/location.dart';
// import 'package:permission_handler/permission_handler.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
import '../../print.dart';
import '../auth/captin/login_captin_controller.dart';
Future<void> getPermissionOverlay() async {
@@ -26,24 +28,55 @@ Future<void> getPermissionOverlay() async {
}
}
Future<void> getPermissionLocation() async {
final PermissionStatus status = await Permission.location.status;
if (!status.isGranted) {
// Log.print('status.isGranted: ${status.isGranted}');
box.write(BoxName.locationPermission, 'true');
await Permission.location.request();
Get.find<LoginDriverController>().update();
// MyDialog().getDialog(
// 'Enable Location Permission'.tr, // {en:ar}
// 'Allowing location access will help us display orders near you. Please enable it now.'
// .tr, // {en:ar}
// () async {
// Get.back();
// box.write(BoxName.locationPermission, 'true');
// await Permission.location.request();
// },
// );
// Future<void> getPermissionLocation() async {
// // final PermissionStatus status = await Permission.location.status;
// // if (!status.isGranted) {
// // Log.print('status.isGranted: ${status.isGranted}');
// // // box.write(BoxName.locationPermission, 'true');
// // await Permission.location.request();
// // Get.find<LoginDriverController>().update();
// // MyDialog().getDialog(
// // 'Enable Location Permission'.tr, // {en:ar}
// // 'Allowing location access will help us display orders near you. Please enable it now.'
// // .tr, // {en:ar}
// // () async {
// // Get.back();
// // box.write(BoxName.locationPermission, 'true');
// // await Permission.location.request();
// // },
// // );
// // }
// }
final location = Location();
Future<void> getLocationPermission() async {
bool serviceEnabled;
PermissionStatus permissionGranted;
// Check if location services are enabled
serviceEnabled = await location.serviceEnabled();
if (!serviceEnabled) {
serviceEnabled = await location.requestService();
if (!serviceEnabled) {
// Location services are still not enabled, handle the error
return;
}
}
// Check if the app has permission to access location
permissionGranted = await location.hasPermission();
if (permissionGranted == PermissionStatus.denied) {
permissionGranted = await location.requestPermission();
if (permissionGranted != PermissionStatus.granted) {
// Location permission is still not granted, handle the error
permissionGranted = await location.requestPermission();
return;
}
}
if (permissionGranted.toString() == 'PermissionStatus.granted') {
box.write(BoxName.locationPermission, 'true');
Get.find<LoginDriverController>().update();
}
// update();
}
Future<void> getOverLay(String myListString) async {