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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/controller/auth/captin/login_captin_controller.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/auth/captin/cards_egypt/egypt_card_a_i.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
|
||||
import '../../views/auth/captin/ai_page.dart';
|
||||
import '../../views/auth/captin/cards/egypt_card_a_i.dart';
|
||||
|
||||
class GoogleSignInHelper {
|
||||
static final GoogleSignIn _googleSignIn = GoogleSignIn(
|
||||
@@ -33,6 +34,27 @@ class GoogleSignInHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<GoogleSignInAccount?> signInFromLogin() async {
|
||||
try {
|
||||
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
|
||||
if (googleUser != null) {
|
||||
await _handleSignUp(googleUser);
|
||||
// if (box.read(BoxName.countryCode) == 'Egypt') {
|
||||
Get.find<LoginCaptinController>().loginFromSignInGoogle(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
);
|
||||
// } else if (box.read(BoxName.countryCode) == 'Jordan') {
|
||||
// // Get.to(() => AiPage());
|
||||
// }
|
||||
}
|
||||
return googleUser;
|
||||
} catch (error) {
|
||||
print('Google Sign-In error: $error');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to handle Google Sign-Out
|
||||
static Future<void> signOut() async {
|
||||
try {
|
||||
|
||||
@@ -138,7 +138,7 @@ class CRUD {
|
||||
}) async {
|
||||
var headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Ocp-Apim-Subscription-Key': '21010e54b50f41a4904708c526e102df'
|
||||
'Ocp-Apim-Subscription-Key': AK.ocpApimSubscriptionKey
|
||||
};
|
||||
|
||||
String imagePathFull =
|
||||
|
||||
@@ -1,104 +1,25 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
class DeviceInfoPlus {
|
||||
static List<Map<String, dynamic>> deviceDataList = [];
|
||||
import '../../constant/box_name.dart';
|
||||
|
||||
static Future<List<Map<String, dynamic>>> getDeviceInfo() async {
|
||||
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
class DeviceController {
|
||||
String deviceSerialNumber = '';
|
||||
final box = GetStorage();
|
||||
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
Map<String, dynamic> deviceData = {
|
||||
'platform': 'Android',
|
||||
'brand': androidInfo.brand,
|
||||
'model': androidInfo.model,
|
||||
'androidId': androidInfo.device,
|
||||
'versionRelease': androidInfo.version.release,
|
||||
'sdkVersion': androidInfo.version.sdkInt,
|
||||
'manufacturer': androidInfo.manufacturer,
|
||||
'isPhysicalDevice': androidInfo.isPhysicalDevice,
|
||||
'serialNumber': androidInfo.serialNumber,
|
||||
'fingerprint': androidInfo.fingerprint,
|
||||
'type': androidInfo.type,
|
||||
'data': androidInfo.data,
|
||||
'version': androidInfo.version,
|
||||
'tags': androidInfo.tags,
|
||||
'display': androidInfo.display,
|
||||
};
|
||||
deviceDataList.add(deviceData);
|
||||
} else if (Platform.isIOS) {
|
||||
IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
||||
Map<String, dynamic> deviceData = {
|
||||
'brand': 'Apple',
|
||||
'model': iosInfo.model,
|
||||
'systemName': iosInfo.systemName,
|
||||
'systemVersion': iosInfo.systemVersion,
|
||||
'utsname': iosInfo.utsname,
|
||||
'isPhysicalDevice': iosInfo.isPhysicalDevice,
|
||||
'identifierForVendor': iosInfo.identifierForVendor,
|
||||
'name': iosInfo.name,
|
||||
'localizedModel': iosInfo.localizedModel,
|
||||
};
|
||||
deviceDataList.add(deviceData);
|
||||
} else if (Platform.isMacOS) {
|
||||
MacOsDeviceInfo macInfo = await deviceInfoPlugin.macOsInfo;
|
||||
Map<String, dynamic> deviceData = {
|
||||
'platform': 'macOS',
|
||||
'model': macInfo.model,
|
||||
'version': macInfo.systemGUID,
|
||||
};
|
||||
deviceDataList.add(deviceData);
|
||||
} else if (Platform.isWindows) {
|
||||
WindowsDeviceInfo windowsInfo = await deviceInfoPlugin.windowsInfo;
|
||||
Map<String, dynamic> deviceData = {
|
||||
'platform': 'Windows',
|
||||
'manufacturer': windowsInfo.computerName,
|
||||
'version': windowsInfo.majorVersion,
|
||||
'deviceId': windowsInfo.deviceId,
|
||||
'userName': windowsInfo.userName,
|
||||
'productName': windowsInfo.productName,
|
||||
'installDate': windowsInfo.installDate,
|
||||
'productId': windowsInfo.productId,
|
||||
'numberOfCores': windowsInfo.numberOfCores,
|
||||
'systemMemoryInMegabytes': windowsInfo.systemMemoryInMegabytes,
|
||||
};
|
||||
deviceDataList.add(deviceData);
|
||||
} else if (Platform.isLinux) {
|
||||
LinuxDeviceInfo linuxInfo = await deviceInfoPlugin.linuxInfo;
|
||||
Map<String, dynamic> deviceData = {
|
||||
'platform': 'Linux',
|
||||
'manufacturer': linuxInfo.name,
|
||||
'version': linuxInfo.version,
|
||||
};
|
||||
deviceDataList.add(deviceData);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Failed to get device info: $e');
|
||||
}
|
||||
|
||||
return deviceDataList;
|
||||
}
|
||||
|
||||
// Method to print all device data
|
||||
static void printDeviceInfo() {
|
||||
for (Map<String, dynamic> deviceData in deviceDataList) {
|
||||
print('Platform: ${deviceData['platform']}');
|
||||
print('Brand: ${deviceData['brand']}');
|
||||
print('Model: ${deviceData['model']}');
|
||||
print(
|
||||
'Version: ${deviceData['version'] ?? deviceData['versionRelease'] ?? 'N/A'}');
|
||||
print('Manufacturer: ${deviceData['manufacturer'] ?? 'N/A'}');
|
||||
print('Is Physical Device: ${deviceData['isPhysicalDevice']}');
|
||||
print('Serial Number: ${deviceData['serialNumber'] ?? 'N/A'}');
|
||||
print('Fingerprint: ${deviceData['fingerprint'] ?? 'N/A'}');
|
||||
print('Type: ${deviceData['type'] ?? 'N/A'}');
|
||||
print('Data: ${deviceData['data'] ?? 'N/A'}');
|
||||
print('Tags: ${deviceData['tags'] ?? 'N/A'}');
|
||||
print('Display: ${deviceData['display'] ?? 'N/A'}');
|
||||
print('--------------------');
|
||||
void getDeviceSerialNumber() async {
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
if (Platform.isAndroid) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
deviceSerialNumber = androidInfo.serialNumber;
|
||||
box.write(BoxName.deviceInfo, deviceSerialNumber.toString());
|
||||
} else if (Platform.isIOS) {
|
||||
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
deviceSerialNumber = iosInfo.identifierForVendor!;
|
||||
box.write(BoxName.deviceInfo, deviceSerialNumber.toString());
|
||||
}
|
||||
print(deviceSerialNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/functions/device_info.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/home_captin.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -197,7 +198,10 @@ class AI extends GetxController {
|
||||
await addRegistrationCarEgypt();
|
||||
|
||||
if (isCarSaved && isDriverSaved) {
|
||||
Get.to(() => HomeCaptain());
|
||||
DeviceController().getDeviceSerialNumber();
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
Get.offAll(() => const MyApp());
|
||||
// Get.offAll(() => HomeCaptain());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -520,8 +524,7 @@ class AI extends GetxController {
|
||||
final response = await http.post(
|
||||
Uri.parse('https://api.anthropic.com/v1/messages'),
|
||||
headers: {
|
||||
'x-api-key':
|
||||
'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',
|
||||
'x-api-key': AK.anthropicAIkeySeferNew,
|
||||
'anthropic-version': '2023-06-01',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/controller/auth/captin/login_captin_controller.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:background_location/background_location.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
@@ -13,7 +12,7 @@ class LocationBackgroundController extends GetxController {
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
// await requestLocationPermission();
|
||||
await requestLocationPermission();
|
||||
await configureBackgroundLocation();
|
||||
}
|
||||
|
||||
@@ -23,10 +22,33 @@ class LocationBackgroundController extends GetxController {
|
||||
|
||||
if (status == PermissionStatus.denied ||
|
||||
status == PermissionStatus.restricted) {
|
||||
// Request permission
|
||||
status = await Permission.locationAlways.request();
|
||||
print('Requested status: $status');
|
||||
// Show dialog to inform the driver about background GPS location usage
|
||||
await Get.dialog(
|
||||
AlertDialog(
|
||||
title: Text('Location Permission'.tr),
|
||||
content: Text(
|
||||
'We use GPS location in the background to enable you to receive orders.'
|
||||
.tr),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back(); // Close the dialog
|
||||
// Request permission
|
||||
status = await Permission.locationAlways.request();
|
||||
print('Requested status: $status');
|
||||
_handlePermissionStatus(status);
|
||||
},
|
||||
child: Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
_handlePermissionStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
void _handlePermissionStatus(PermissionStatus status) async {
|
||||
status = await Permission.locationAlways.status;
|
||||
if (!status.isGranted) {
|
||||
// Open app settings if permission is permanently denied
|
||||
|
||||
@@ -15,7 +15,7 @@ class SmsEgyptController extends GetxController {
|
||||
Future<dynamic> sendSmsEgypt(String phone, otp) async {
|
||||
var body = jsonEncode({
|
||||
"username": AppInformation.appName,
|
||||
"password": AK.smsPassword,
|
||||
"password": 'E)Pu=an/@Z', // AK.smsPasswordEgypt,
|
||||
"message": "${AppInformation.appName} app code is $otp\ncopy it to app",
|
||||
"language": box.read(BoxName.lang) == 'en' ? "e" : 'r',
|
||||
"sender": "Kazumi", // todo add sefer sender name
|
||||
@@ -31,6 +31,7 @@ class SmsEgyptController extends GetxController {
|
||||
print(res.reasonPhrase);
|
||||
print(res.request);
|
||||
print(res.body);
|
||||
print(body);
|
||||
if (res.statusCode == 200) {
|
||||
Get.defaultDialog(
|
||||
title: 'You will recieve code in sms message'.tr,
|
||||
@@ -48,7 +49,7 @@ class SmsEgyptController extends GetxController {
|
||||
Uri.parse(AppLink.checkCredit),
|
||||
body: {
|
||||
"username": AppInformation.appName,
|
||||
"password": AK.smsPassword,
|
||||
"password": AK.smsPasswordEgypt,
|
||||
},
|
||||
headers: headers,
|
||||
);
|
||||
@@ -60,7 +61,7 @@ class SmsEgyptController extends GetxController {
|
||||
Uri.parse(AppLink.checkCredit),
|
||||
body: {
|
||||
"username": AppInformation.appName,
|
||||
"password": AK.smsPassword,
|
||||
"password": AK.smsPasswordEgypt,
|
||||
"message": "This is an example SMS message.",
|
||||
"language": box.read(BoxName.lang) == 'en' ? "e" : 'r',
|
||||
"sender": "Kazumi", // todo add sefer sender name
|
||||
@@ -78,7 +79,7 @@ class SmsEgyptController extends GetxController {
|
||||
Uri.parse(AppLink.checkCredit),
|
||||
body: {
|
||||
"username": AppInformation.appName,
|
||||
"password": AK.smsPassword,
|
||||
"password": AK.smsPasswordEgypt,
|
||||
"smsid": smsid //"00b77dfc-5b8f-474d-9def-9f0158b70f98"
|
||||
},
|
||||
headers: headers,
|
||||
|
||||
@@ -19,7 +19,13 @@ class ImageController extends GetxController {
|
||||
final picker = ImagePicker();
|
||||
var image;
|
||||
choosImage(String link, String imageType) async {
|
||||
final pickedImage = await picker.pickImage(source: ImageSource.gallery);
|
||||
final pickedImage = await picker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
preferredCameraDevice: CameraDevice.rear,
|
||||
// maxHeight: Get.height * .3,
|
||||
// maxWidth: Get.width * .9,
|
||||
// imageQuality: 100,
|
||||
);
|
||||
image = File(pickedImage!.path);
|
||||
|
||||
croppedFile = await ImageCropper().cropImage(
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:SEFER/controller/functions/gemeni.dart';
|
||||
import 'package:SEFER/views/auth/captin/register_captin.dart';
|
||||
import 'package:SEFER/views/auth/captin/cards/sms_signup.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/views/auth/login_page.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../../onbording_page.dart';
|
||||
import '../../views/auth/captin/cards_egypt/sms_signup.dart';
|
||||
import '../../views/auth/captin/login_captin.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
|
||||
@@ -50,9 +47,12 @@ class SplashScreenController extends GetxController
|
||||
Timer(const Duration(seconds: 5), () {
|
||||
box.read(BoxName.onBoarding) == null
|
||||
? Get.off(() => OnBoardingPage())
|
||||
: box.read(BoxName.emailDriver) != null
|
||||
? Get.off(() => SmsSignupEgypt())
|
||||
: Get.off(() => LoginCaptin());
|
||||
: box.read(BoxName.emailDriver) != null &&
|
||||
box.read(BoxName.deviceInfo) != null &&
|
||||
box.read(BoxName.phoneVerified) == '1'
|
||||
// ? Get.off(() => SmsSignupEgypt())
|
||||
? Get.off(() => HomeCaptain())
|
||||
: Get.off(() => SmsSignupEgypt());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user