5/19/1
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:SEFER/controller/functions/location_background_controller.dart';
|
||||
import 'package:SEFER/views/auth/captin/register_captin.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -113,6 +114,42 @@ class LoginCaptinController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void loginFromSignInGoogle(String driverID, email) async {
|
||||
isloading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.loginFromGoogleCaptin, payload: {
|
||||
'email': email,
|
||||
'id': driverID,
|
||||
});
|
||||
print(res);
|
||||
if (res == 'failure') {
|
||||
//Failure
|
||||
Get.offAll(const RegisterCaptin());
|
||||
isloading = false;
|
||||
update();
|
||||
Get.snackbar('Failure', '', backgroundColor: Colors.red);
|
||||
} else {
|
||||
var jsonDecoeded = jsonDecode(res);
|
||||
// print(jsonDecoeded['data'][0]['is_verified']);
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success' &&
|
||||
jsonDecoeded['data'][0]['is_verified'] == 1) {
|
||||
//
|
||||
Get.offAll(const MyApp());
|
||||
} else {
|
||||
Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'],
|
||||
backgroundColor: Colors.redAccent);
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
print('res is null');
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loginByBoxData() async {
|
||||
Get.to(() => HomeCaptain());
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
|
||||
@@ -84,29 +84,36 @@ class RegisterCaptainController extends GetxController {
|
||||
isLoading = true;
|
||||
update();
|
||||
if (formKey3.currentState!.validate()) {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': phoneController.text,
|
||||
'token_code': randomNumber.toString(),
|
||||
});
|
||||
if (box.read(BoxName.countryCode) == 'Egypt') {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
});
|
||||
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.toString(), randomNumber.toString());
|
||||
isSent = true;
|
||||
isLoading = false;
|
||||
update();
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
isSent = true;
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
verifySMSCode() async {
|
||||
if (formKey3.currentState!.validate()) {
|
||||
var res = await CRUD().post(link: AppLink.verifyOtpMessage, payload: {
|
||||
'phone_number': phoneController.text,
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': verifyCode.text.toString(),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
// var dec = jsonDecode(res);
|
||||
box.write(BoxName.phoneDriver, '+2${phoneController.text}');
|
||||
Get.to(const RegisterCaptin());
|
||||
var res1 = await CRUD().post(
|
||||
link: AppLink.updateAccountBank,
|
||||
payload: {'phone': '+2${phoneController.text}'});
|
||||
if (jsonDecode(res1)['status'] == 'success') {
|
||||
Get.to(LoginCaptin());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user