5/3/1
This commit is contained in:
@@ -11,6 +11,8 @@ import 'package:SEFER/controller/functions/secure_storage.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/auth/verify_email_page.dart';
|
||||
import 'package:SEFER/views/home/map_page_passenger.dart';
|
||||
import 'package:location/location.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class LoginController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
@@ -147,8 +149,45 @@ class LoginController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
final location = Location();
|
||||
|
||||
// late PermissionStatus permissionGranted = PermissionStatus.denied;
|
||||
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;
|
||||
}
|
||||
}
|
||||
print('permisson is ${permissionGranted.toString()}');
|
||||
if ('PermissionStatus.granted' == permissionGranted.toString()) {
|
||||
box.write(BoxName.locationPermission, 'true');
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
// permissionLocation = await Permission.locationWhenInUse.isGranted;
|
||||
// print('permisson is ${permissionGranted}');
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1725,13 +1725,39 @@ class MapPassengerController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
dialoge() {
|
||||
Get.defaultDialog(
|
||||
title: 'Location '.tr,
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'We use location to get accurate and nearest driver for you'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
// await Permission.location.request();
|
||||
Get.back();
|
||||
},
|
||||
child: Text(
|
||||
'Grant'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
double speed = 0;
|
||||
Future<void> getLocation() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
|
||||
// dialoge();
|
||||
// Check if location services are enabled
|
||||
serviceEnabled = await location.serviceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
|
||||
@@ -53,7 +53,7 @@ class PaymobManager extends GetxController {
|
||||
// 2. Prepare Payment Data Payload
|
||||
final Map<String, dynamic> data = {
|
||||
"source": {
|
||||
"identifier": "01010101010", // Replace with actual source identifier
|
||||
"identifier": box.read(BoxName.phone), //"01010101010"
|
||||
"subtype": "WALLET",
|
||||
},
|
||||
"payment_token": paymentToken,
|
||||
|
||||
Reference in New Issue
Block a user