5/11/1
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:SEFER/controller/functions/secure_storage.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/auth/captin/verify_email_captain.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/home_captin.dart';
|
||||
import 'package:location/location.dart';
|
||||
|
||||
class LoginCaptinController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
@@ -20,7 +21,7 @@ class LoginCaptinController extends GetxController {
|
||||
bool isAgreeTerms = false;
|
||||
bool isloading = false;
|
||||
final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||
|
||||
final location = Location();
|
||||
void changeAgreeTerm() {
|
||||
isAgreeTerms = !isAgreeTerms;
|
||||
print(isAgreeTerms);
|
||||
@@ -37,6 +38,38 @@ class LoginCaptinController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void login() async {
|
||||
isloading = true;
|
||||
update();
|
||||
@@ -46,7 +79,8 @@ class LoginCaptinController extends GetxController {
|
||||
'password': passwordController.text
|
||||
});
|
||||
print(res);
|
||||
if (res == 'Failure') {
|
||||
if (res == 'failure') {
|
||||
//Failure
|
||||
isloading = false;
|
||||
update();
|
||||
Get.snackbar('Failure', '', backgroundColor: Colors.red);
|
||||
|
||||
Reference in New Issue
Block a user