Update: 2026-07-10 22:31:26
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:siro_rider/services/geofencing_service.dart';
|
||||||
|
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:siro_rider/constant/api_key.dart';
|
import 'package:siro_rider/constant/api_key.dart';
|
||||||
@@ -566,11 +567,20 @@ class LoginController extends GetxController {
|
|||||||
// Check if the app has permission to access location
|
// Check if the app has permission to access location
|
||||||
permissionGranted = await location.hasPermission();
|
permissionGranted = await location.hasPermission();
|
||||||
if (permissionGranted == loc.PermissionStatus.denied) {
|
if (permissionGranted == loc.PermissionStatus.denied) {
|
||||||
|
|
||||||
|
|
||||||
permissionGranted = await location.requestPermission();
|
permissionGranted = await location.requestPermission();
|
||||||
if (permissionGranted != loc.PermissionStatus.granted) {
|
if (permissionGranted != loc.PermissionStatus.granted) {
|
||||||
// Location permission is still not granted, handle the error
|
// Location permission is still not granted, handle the error
|
||||||
permissionGranted = await location.requestPermission();
|
permissionGranted = await location.requestPermission();
|
||||||
return;
|
if (permissionGranted != loc.PermissionStatus.granted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize geofencing now that we have permission
|
||||||
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
|
await SiroGeofencingService.initAndStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (permissionGranted.toString() == 'PermissionStatus.granted' ||
|
if (permissionGranted.toString() == 'PermissionStatus.granted' ||
|
||||||
|
|||||||
@@ -159,11 +159,9 @@ class CountryLogic {
|
|||||||
if (!serviceEnabled) return null;
|
if (!serviceEnabled) return null;
|
||||||
|
|
||||||
LocationPermission permission = await Geolocator.checkPermission();
|
LocationPermission permission = await Geolocator.checkPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied || permission == LocationPermission.deniedForever) {
|
||||||
permission = await Geolocator.requestPermission();
|
return null;
|
||||||
if (permission == LocationPermission.denied) return null;
|
|
||||||
}
|
}
|
||||||
if (permission == LocationPermission.deniedForever) return null;
|
|
||||||
|
|
||||||
final pos = await Geolocator.getCurrentPosition(
|
final pos = await Geolocator.getCurrentPosition(
|
||||||
desiredAccuracy: LocationAccuracy.low,
|
desiredAccuracy: LocationAccuracy.low,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:siro_rider/services/geofencing_service.dart';
|
import 'package:siro_rider/services/geofencing_service.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class GeoLocation {
|
class GeoLocation {
|
||||||
Future<Position> getCurrentLocation() async {
|
Future<Position> getCurrentLocation() async {
|
||||||
@@ -15,6 +17,23 @@ class GeoLocation {
|
|||||||
|
|
||||||
permission = await Geolocator.checkPermission();
|
permission = await Geolocator.checkPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
|
// Prominent Disclosure for Background Location
|
||||||
|
bool? userAgreed = await Get.defaultDialog<bool>(
|
||||||
|
title: 'صلاحية الموقع'.tr,
|
||||||
|
middleText: 'يجمع تطبيق سيرو بيانات الموقع لتفعيل ميزة التتبع الجغرافي (Geofence) ولتمكين السائق من الوصول إليك بدقة وتتبع رحلتك حتى عندما يكون التطبيق في الخلفية أو مغلقاً.'.tr,
|
||||||
|
titleStyle: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
textConfirm: 'موافق'.tr,
|
||||||
|
textCancel: 'إلغاء'.tr,
|
||||||
|
confirmTextColor: Colors.white,
|
||||||
|
onConfirm: () => Get.back(result: true),
|
||||||
|
onCancel: () => Get.back(result: false),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (userAgreed != true) {
|
||||||
|
return Future.error('Location permissions are denied');
|
||||||
|
}
|
||||||
|
|
||||||
permission = await Geolocator.requestPermission();
|
permission = await Geolocator.requestPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
// Permissions are denied, we cannot fetch the location.
|
// Permissions are denied, we cannot fetch the location.
|
||||||
|
|||||||
@@ -96,9 +96,12 @@ void main() {
|
|||||||
// ✅ تهيئة خدمة Android Live Update (Progress Style)
|
// ✅ تهيئة خدمة Android Live Update (Progress Style)
|
||||||
await AndroidLiveUpdateService.init();
|
await AndroidLiveUpdateService.init();
|
||||||
|
|
||||||
// Initialize Geofencing Service
|
// Initialize Geofencing Service only if permission is already granted to avoid auto-prompt
|
||||||
if (Platform.isAndroid || Platform.isIOS) {
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
await SiroGeofencingService.initAndStart();
|
LocationPermission permission = await Geolocator.checkPermission();
|
||||||
|
if (permission != LocationPermission.denied && permission != LocationPermission.deniedForever) {
|
||||||
|
await SiroGeofencingService.initAndStart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock screen orientation.
|
// Lock screen orientation.
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ class LoginPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 14),
|
const SizedBox(height: 14),
|
||||||
Text(
|
Text(
|
||||||
'We need your location to find nearby drivers for pickups and drop-offs.'
|
'يجمع تطبيق سيرو بيانات الموقع لتفعيل ميزة التتبع الجغرافي (Geofence) ولتمكين السائق من الوصول إليك بدقة وتتبع رحلتك حتى عندما يكون التطبيق في الخلفية أو مغلقاً.'
|
||||||
.tr,
|
.tr,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: AppStyle.title.copyWith(
|
style: AppStyle.title.copyWith(
|
||||||
|
|||||||
Reference in New Issue
Block a user