25-5-30/1
This commit is contained in:
@@ -45,9 +45,8 @@ class HistoryCaptainController extends GetxController {
|
||||
|
||||
getHistoryDetails(String orderId) async {
|
||||
isloading = true;
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getRideOrderID,
|
||||
payload: {'id': EncryptionHelper.instance.encryptData(orderId)});
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getRideOrderID, payload: {'id': (orderId)});
|
||||
historyDetailsData = jsonDecode(res);
|
||||
isloading = false;
|
||||
update();
|
||||
|
||||
@@ -150,9 +150,9 @@ Download the Tripz app now and enjoy your ride!
|
||||
void onSelectDriverInvitation(int index) async {
|
||||
MyDialog().getDialog(
|
||||
int.parse((driverInvitationData[index]['countOfInvitDriver'])) < 100
|
||||
? '${'When'.tr} ${EncryptionHelper.instance.decryptData(driverInvitationData[index]['invitorName'])} ${"complete, you can claim your gift".tr} '
|
||||
? '${'When'.tr} ${(driverInvitationData[index]['invitorName'])} ${"complete, you can claim your gift".tr} '
|
||||
: 'You deserve the gift'.tr,
|
||||
'${EncryptionHelper.instance.decryptData(driverInvitationData[index]['invitorName'])} ${(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
|
||||
'${(driverInvitationData[index]['invitorName'])} ${(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
|
||||
() async {
|
||||
bool isAvailable = await LocalAuthentication().isDeviceSupported();
|
||||
if (int.parse((driverInvitationData[index]['countOfInvitDriver'])) <
|
||||
@@ -173,10 +173,9 @@ Download the Tripz app now and enjoy your ride!
|
||||
if ((driverInvitationData[index]['isGiftToken']).toString() ==
|
||||
'0') {
|
||||
Get.back();
|
||||
await CRUD().post(link: AppLink.updateInviteDriver, payload: {
|
||||
'id': EncryptionHelper.instance
|
||||
.encryptData(driverInvitationData[index]['id'])
|
||||
});
|
||||
await CRUD().post(
|
||||
link: AppLink.updateInviteDriver,
|
||||
payload: {'id': (driverInvitationData[index]['id'])});
|
||||
await Get.find<CaptainWalletController>().addDriverPayment(
|
||||
'paymentMethod',
|
||||
('500'),
|
||||
@@ -186,8 +185,7 @@ Download the Tripz app now and enjoy your ride!
|
||||
await Get.find<CaptainWalletController>()
|
||||
.addDriverWalletToInvitor(
|
||||
'paymentMethod',
|
||||
EncryptionHelper.instance.encryptData(
|
||||
driverInvitationData[index]['driverInviterId']),
|
||||
(driverInvitationData[index]['driverInviterId']),
|
||||
('500'),
|
||||
);
|
||||
await Get.find<CaptainWalletController>()
|
||||
@@ -231,9 +229,9 @@ Download the Tripz app now and enjoy your ride!
|
||||
int.parse(driverInvitationDataToPassengers[index]['countOfInvitDriver']
|
||||
.toString()) <
|
||||
3
|
||||
? '${'When'.tr} ${EncryptionHelper.instance.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${"complete, you can claim your gift".tr} '
|
||||
? '${'When'.tr} ${(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${"complete, you can claim your gift".tr} '
|
||||
: 'You deserve the gift'.tr,
|
||||
'${EncryptionHelper.instance.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${driverInvitationDataToPassengers[index]['countOfInvitDriver']} / 3 ${'Trip'.tr}',
|
||||
'${(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${driverInvitationDataToPassengers[index]['countOfInvitDriver']} / 3 ${'Trip'.tr}',
|
||||
() async {
|
||||
if (int.parse(driverInvitationDataToPassengers[index]
|
||||
['countOfInvitDriver']
|
||||
@@ -342,7 +340,7 @@ Download the Tripz app now and enjoy your ride!
|
||||
});
|
||||
|
||||
if (response != 'failure') {
|
||||
var d = jsonDecode(response);
|
||||
var d = (response);
|
||||
mySnackbarSuccess('Invite sent successfully'.tr);
|
||||
String message = '${'*Tripz DRIVER CODE*'.tr}\n\n'
|
||||
'${"Use this code in registration".tr}\n'
|
||||
|
||||
@@ -98,11 +98,12 @@ class LoginDriverController extends GetxController {
|
||||
final random = Random();
|
||||
|
||||
if (random.nextBool()) {
|
||||
await SecurityHelper.performSecurityChecks();
|
||||
// await SecurityHelper.performSecurityChecks();
|
||||
} else {
|
||||
await SecurityChecks.isDeviceRootedFromNative(Get.context!);
|
||||
}
|
||||
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
// print('fingerPrint: ${fingerPrint}');
|
||||
dev = Platform.isAndroid ? 'android' : 'ios';
|
||||
var payload = {
|
||||
'id': box.read(BoxName.driverID),
|
||||
@@ -118,7 +119,7 @@ class LoginDriverController extends GetxController {
|
||||
// Log.print('response.body: ${response1.body}');
|
||||
// print(payload);
|
||||
// Log.print(
|
||||
// 'jsonDecode(response1.body)["jwt"]: ${jsonDecode(response1.body)['jwt']}');
|
||||
// 'jsonDecode(response1.body)["jwt"]: ${jsonDecode(response1.body)['jwt']}');
|
||||
await box.write(BoxName.hmac, jsonDecode(response1.body)['hmac']);
|
||||
return jsonDecode(response1.body)['jwt'].toString();
|
||||
}
|
||||
@@ -144,9 +145,11 @@ class LoginDriverController extends GetxController {
|
||||
);
|
||||
if (response0.statusCode == 200) {
|
||||
final decodedResponse1 = jsonDecode(response0.body);
|
||||
// Log.print('decodedResponse1: ${decodedResponse1}');
|
||||
|
||||
final jwt = decodedResponse1['jwt'];
|
||||
box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
|
||||
// await box.write(BoxName.hmac, decodedResponse1['hmac']);
|
||||
|
||||
await AppInitializer().getAIKey(Driver.keyOfApp);
|
||||
await AppInitializer().getAIKey(Driver.initializationVector);
|
||||
@@ -183,6 +186,7 @@ class LoginDriverController extends GetxController {
|
||||
// Log.print('decodedResponse1: ${decodedResponse1}');
|
||||
|
||||
final jwt = decodedResponse1['jwt'];
|
||||
// await box.write(BoxName.hmac, decodedResponse1['hmac']);
|
||||
await box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
|
||||
await AppInitializer().getKey();
|
||||
}
|
||||
@@ -230,7 +234,7 @@ class LoginDriverController extends GetxController {
|
||||
var res = await CRUD().get(link: AppLink.loginFromGoogleCaptin, payload: {
|
||||
'email': email.toString().contains('@')
|
||||
// ? (box.read(BoxName.emailDriver))
|
||||
? EncryptionHelper.instance.encryptData(email)
|
||||
? (email)
|
||||
: email,
|
||||
'id': driverID,
|
||||
});
|
||||
@@ -252,10 +256,7 @@ class LoginDriverController extends GetxController {
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success' &&
|
||||
jsonDecoeded['data'][0]['is_verified'].toString() == '1') {
|
||||
box.write(
|
||||
BoxName.emailDriver,
|
||||
EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['email']));
|
||||
box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']);
|
||||
box.write(BoxName.firstTimeLoadKey, 'false');
|
||||
box.write(BoxName.driverID, (jsonDecoeded['data'][0]['id']));
|
||||
box.write(BoxName.isTest, '1');
|
||||
@@ -276,16 +277,13 @@ class LoginDriverController extends GetxController {
|
||||
(jsonDecoeded['data'][0]['accountBank']));
|
||||
box.write(
|
||||
BoxName.nameDriver,
|
||||
'${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
'${(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${(jsonDecoeded['data'][0]['last_name'])}');
|
||||
if (((jsonDecoeded['data'][0]['model'])
|
||||
.toString()
|
||||
.contains('دراجه') ||
|
||||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() ==
|
||||
'Male') {
|
||||
if ((jsonDecoeded['data'][0]['gender']).toString() == 'Male') {
|
||||
box.write(BoxName.carTypeOfDriver, 'Scooter');
|
||||
} else {
|
||||
box.write(BoxName.carTypeOfDriver, 'Pink Bike');
|
||||
@@ -311,8 +309,9 @@ class LoginDriverController extends GetxController {
|
||||
link: AppLink.getDriverToken,
|
||||
payload: {'captain_id': (box.read(BoxName.driverID)).toString()});
|
||||
|
||||
String? fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
await storage.write(key: BoxName.fingerPrint, value: fingerPrint);
|
||||
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
await storage.write(
|
||||
key: BoxName.fingerPrint, value: fingerPrint.toString());
|
||||
|
||||
if (token != 'failure') {
|
||||
if ((jsonDecode(token)['data'][0]['token']) !=
|
||||
@@ -320,9 +319,7 @@ class LoginDriverController extends GetxController {
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'token change'.tr,
|
||||
'change device'.tr,
|
||||
EncryptionHelper.instance
|
||||
.decryptData(jsonDecode(token)['data'][0]['token'])
|
||||
.toString(),
|
||||
(jsonDecode(token)['data'][0]['token']).toString(),
|
||||
[],
|
||||
'promo.wav');
|
||||
await Get.defaultDialog(
|
||||
@@ -337,9 +334,10 @@ class LoginDriverController extends GetxController {
|
||||
'captain_id': (box.read(BoxName.driverID)).toString(),
|
||||
'fingerPrint': (fingerPrint).toString()
|
||||
});
|
||||
// to save in payment server fingerprint
|
||||
await CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferAlexandriaServer}/ride/firebase/addDriver.php",
|
||||
"${AppLink.seferPaymentServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': (box.read(BoxName.tokenDriver)),
|
||||
'captain_id':
|
||||
@@ -381,7 +379,7 @@ class LoginDriverController extends GetxController {
|
||||
update();
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.loginUsingCredentialsWithoutGoogle, payload: {
|
||||
'email': EncryptionHelper.instance.encryptData(email),
|
||||
'email': (email),
|
||||
'password': password,
|
||||
});
|
||||
box.write(BoxName.emailDriver, (email).toString());
|
||||
@@ -409,33 +407,25 @@ class LoginDriverController extends GetxController {
|
||||
jsonDecoeded['data'][0]['is_verified'].toString());
|
||||
box.write(BoxName.phoneDriver, (jsonDecoeded['data'][0]['phone']));
|
||||
box.write(
|
||||
BoxName.nameArabic,
|
||||
EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['name_arabic']));
|
||||
BoxName.nameArabic, (jsonDecoeded['data'][0]['name_arabic']));
|
||||
box.write(
|
||||
BoxName.bankCodeDriver, (jsonDecoeded['data'][0]['bankCode']));
|
||||
box.write(BoxName.accountBankNumberDriver,
|
||||
jsonDecoeded['data'][0]['accountBank']);
|
||||
box.write(
|
||||
BoxName.nameDriver,
|
||||
'${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
'${(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${(jsonDecoeded['data'][0]['last_name'])}');
|
||||
if ((jsonDecoeded['data'][0]['model'].toString().contains('دراجه') ||
|
||||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() ==
|
||||
'Male') {
|
||||
if ((jsonDecoeded['data'][0]['gender']).toString() == 'Male') {
|
||||
box.write(BoxName.carTypeOfDriver, 'Scooter');
|
||||
} else {
|
||||
box.write(BoxName.carTypeOfDriver, 'Pink Bike');
|
||||
}
|
||||
} else if (int.parse(jsonDecoeded['data'][0]['year'].toString()) >
|
||||
2017) {
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() !=
|
||||
'Male') {
|
||||
if ((jsonDecoeded['data'][0]['gender']).toString() != 'Male') {
|
||||
box.write(BoxName.carTypeOfDriver, 'Lady');
|
||||
} else {
|
||||
box.write(BoxName.carTypeOfDriver, 'Comfort');
|
||||
@@ -463,9 +453,7 @@ class LoginDriverController extends GetxController {
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'token change'.tr,
|
||||
'change device'.tr,
|
||||
EncryptionHelper.instance
|
||||
.decryptData(jsonDecode(token)['data'][0]['token'])
|
||||
.toString(),
|
||||
(jsonDecode(token)['data'][0]['token']).toString(),
|
||||
[],
|
||||
'ding.wav');
|
||||
Get.defaultDialog(
|
||||
|
||||
@@ -100,7 +100,6 @@ class RegisterCaptainController extends GetxController {
|
||||
SmsEgyptController smsEgyptController = Get.put(SmsEgyptController());
|
||||
isLoading = true;
|
||||
update();
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
isLoading = true;
|
||||
update();
|
||||
if (formKey3.currentState!.validate()) {
|
||||
@@ -108,8 +107,7 @@ class RegisterCaptainController extends GetxController {
|
||||
if (isValidEgyptianPhoneNumber(phoneController.text)) {
|
||||
var responseCheker = await CRUD()
|
||||
.post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
|
||||
'phone_number': EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'),
|
||||
'phone_number': ('+2${phoneController.text}'),
|
||||
});
|
||||
if (responseCheker != 'failure') {
|
||||
var d = jsonDecode(responseCheker);
|
||||
@@ -117,29 +115,18 @@ class RegisterCaptainController extends GetxController {
|
||||
Get.snackbar('Phone number is verified before'.tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
box.write(
|
||||
BoxName.phone,
|
||||
EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'));
|
||||
box.write(BoxName.phone, ('+2${phoneController.text}'));
|
||||
await Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
EncryptionHelper.instance
|
||||
.encryptData(box.read(BoxName.emailDriver).toString()),
|
||||
(box.read(BoxName.emailDriver).toString()),
|
||||
);
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'),
|
||||
'token_code': EncryptionHelper.instance
|
||||
.encryptData(randomNumber.toString()),
|
||||
'phone_number': ('+2${phoneController.text}'),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": EncryptionHelper.instance
|
||||
.encryptData(box.read(BoxName.emailDriver)),
|
||||
"email": (box.read(BoxName.emailDriver)),
|
||||
});
|
||||
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
isSent = true;
|
||||
|
||||
isLoading = false;
|
||||
@@ -147,17 +134,11 @@ class RegisterCaptainController extends GetxController {
|
||||
}
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'),
|
||||
'token_code': EncryptionHelper.instance
|
||||
.encryptData(randomNumber.toString()),
|
||||
'phone_number': ('+2${phoneController.text}'),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
|
||||
await smsEgyptController.sendSmsEgypt(
|
||||
phoneController.text.toString(), randomNumber.toString());
|
||||
|
||||
isSent = true;
|
||||
|
||||
isLoading = false;
|
||||
@@ -250,8 +231,7 @@ class RegisterCaptainController extends GetxController {
|
||||
_handleAlreadyVerified() {
|
||||
mySnackbarSuccess('Phone number is already verified'.tr);
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
box.write(BoxName.phone,
|
||||
EncryptionHelper.instance.encryptData('+2${phoneController.text}'));
|
||||
box.write(BoxName.phone, ('+2${phoneController.text}'));
|
||||
Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
@@ -266,15 +246,14 @@ class RegisterCaptainController extends GetxController {
|
||||
await CRUD().post(
|
||||
link: AppLink.sendVerifyOtpMessage,
|
||||
payload: {
|
||||
'phone_number': EncryptionHelper.instance.encryptData('+2$phoneNumber'),
|
||||
'token_code':
|
||||
EncryptionHelper.instance.encryptData(randomNumber.toString()),
|
||||
'phone_number': ('+2$phoneNumber'),
|
||||
'token_code': (randomNumber.toString()),
|
||||
'driverId': box.read(BoxName.driverID),
|
||||
'email': box.read(BoxName.emailDriver),
|
||||
},
|
||||
);
|
||||
|
||||
await smsEgyptController.sendSmsEgypt(phoneNumber, randomNumber.toString());
|
||||
await smsEgyptController.sendSmsEgypt(phoneNumber);
|
||||
|
||||
lastOtpSentTime = DateTime.now(); // Update the last OTP sent time
|
||||
isSent = true;
|
||||
@@ -286,15 +265,12 @@ class RegisterCaptainController extends GetxController {
|
||||
// var loginDriverController = Get.put(LoginDriverController());
|
||||
if (formKey3.currentState!.validate()) {
|
||||
var res = await CRUD().post(link: AppLink.verifyOtpDriver, payload: {
|
||||
'phone_number':
|
||||
EncryptionHelper.instance.encryptData('+2${phoneController.text}'),
|
||||
'token_code':
|
||||
EncryptionHelper.instance.encryptData(verifyCode.text.toString()),
|
||||
'phone_number': ('+2${phoneController.text}'),
|
||||
'token_code': (verifyCode.text.toString()),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
// var dec = jsonDecode(res);
|
||||
box.write(BoxName.phoneDriver,
|
||||
EncryptionHelper.instance.encryptData('+2${phoneController.text}'));
|
||||
box.write(BoxName.phoneDriver, ('+2${phoneController.text}'));
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
|
||||
// loginDriverController.isGoogleLogin == true
|
||||
@@ -319,10 +295,9 @@ class RegisterCaptainController extends GetxController {
|
||||
sendVerifications() async {
|
||||
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
|
||||
'email': emailController.text.isEmpty
|
||||
? EncryptionHelper.instance.encryptData(
|
||||
Get.find<LoginDriverController>().emailController.text.toString())
|
||||
: EncryptionHelper.instance.encryptData(emailController.text),
|
||||
'token': EncryptionHelper.instance.encryptData(verifyCode.text),
|
||||
? (Get.find<LoginDriverController>().emailController.text.toString())
|
||||
: (emailController.text),
|
||||
'token': (verifyCode.text),
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
|
||||
@@ -94,9 +94,8 @@ class GoogleSignInHelper {
|
||||
// Retrieve driverID and emailDriver with added validation
|
||||
final driverID =
|
||||
(box.read(BoxName.driverID)!.toString()) ?? 'Unknown ID';
|
||||
final emailDriver = EncryptionHelper.instance
|
||||
.encryptData(box.read(BoxName.emailDriver)!.toString()) ??
|
||||
'Unknown Email';
|
||||
final emailDriver =
|
||||
(box.read(BoxName.emailDriver)!.toString()) ?? 'Unknown Email';
|
||||
|
||||
// Debug print statements
|
||||
print('Driver ID: $driverID');
|
||||
|
||||
@@ -60,10 +60,7 @@ class LoginController extends GetxController {
|
||||
if (jsonDecoeded['status'] == 'success') {
|
||||
if (jsonDecoeded['data'][0]['verified'] == 1) {
|
||||
box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']);
|
||||
box.write(
|
||||
BoxName.emailDriver,
|
||||
EncryptionHelper.instance
|
||||
.encryptData(jsonDecoeded['data'][0]['email']));
|
||||
box.write(BoxName.emailDriver, (jsonDecoeded['data'][0]['email']));
|
||||
box.write(
|
||||
BoxName.nameDriver,
|
||||
jsonDecoeded['data'][0]['first_name'] +
|
||||
|
||||
@@ -71,8 +71,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Future getToken() async {
|
||||
fcmToken.getToken().then((token) {
|
||||
// Log.print('token: ${token}');
|
||||
box.write(
|
||||
BoxName.tokenDriver, EncryptionHelper.instance.encryptData(token!));
|
||||
box.write(BoxName.tokenDriver, (token!));
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
@@ -409,8 +408,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
var encryptedKey = await storage.read(key: 'FCM_PRIVATE_KEY');
|
||||
// Log.print('encryptedKey: ${encryptedKey}');
|
||||
if (encryptedKey != null) {
|
||||
serviceAccountKeyJson =
|
||||
EncryptionHelper.instance.decryptData(encryptedKey);
|
||||
serviceAccountKeyJson = (encryptedKey);
|
||||
// Log.print('serviceAccountKeyJson: ${serviceAccountKeyJson}');
|
||||
} else {
|
||||
print('🔴 Error: FCM_PRIVATE_KEY not found in Secure Storage');
|
||||
|
||||
@@ -66,12 +66,12 @@ class CRUD {
|
||||
return 'token_expired'; // Return a specific value for token expiration
|
||||
} else {
|
||||
// Other 401 errors
|
||||
addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
return 'failure';
|
||||
}
|
||||
} else {
|
||||
addError('Non-200 response code: ${response.statusCode}',
|
||||
'crud().post - Other');
|
||||
// addError('Non-200 response code: ${response.statusCode}',
|
||||
// 'crud().post - Other');
|
||||
return 'failure';
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class CRUD {
|
||||
},
|
||||
);
|
||||
// print(response.request);
|
||||
// Log.print('response.request: ${response.request}');
|
||||
// // Log.print('response.request: ${response.request}');
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
@@ -117,12 +117,12 @@ class CRUD {
|
||||
return 'token_expired'; // Return a specific value for token expiration
|
||||
} else {
|
||||
// Other 401 errors
|
||||
addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
return 'failure';
|
||||
}
|
||||
} else {
|
||||
addError('Non-200 response code: ${response.statusCode}',
|
||||
'crud().post - Other');
|
||||
// addError('Non-200 response code: ${response.statusCode}',
|
||||
// 'crud().post - Other');
|
||||
return 'failure';
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class CRUD {
|
||||
return jsonData['status'];
|
||||
}
|
||||
} catch (e) {
|
||||
addError(e.toString(), 'crud().post - JSON decoding');
|
||||
// addError(e.toString(), 'crud().post - JSON decoding');
|
||||
return 'failure';
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
@@ -168,16 +168,16 @@ class CRUD {
|
||||
return 'token_expired'; // Return a specific value for token expiration
|
||||
} else {
|
||||
// Other 401 errors
|
||||
addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
return 'failure';
|
||||
}
|
||||
} else {
|
||||
addError('Non-200 response code: ${response.statusCode}',
|
||||
'crud().post - Other');
|
||||
// addError('Non-200 response code: ${response.statusCode}',
|
||||
// 'crud().post - Other');
|
||||
return 'failure';
|
||||
}
|
||||
} catch (e) {
|
||||
addError('HTTP request error: $e', 'crud().post - HTTP');
|
||||
// addError('HTTP request error: $e', 'crud().post - HTTP');
|
||||
return 'failure';
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ class CRUD {
|
||||
return jsonData['status'];
|
||||
}
|
||||
} catch (e) {
|
||||
addError(e.toString(), url);
|
||||
// addError(e.toString(), url);
|
||||
return 'failure';
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
@@ -238,16 +238,16 @@ class CRUD {
|
||||
return 'token_expired'; // Return a specific value for token expiration
|
||||
} else {
|
||||
// Other 401 errors
|
||||
addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
return 'failure';
|
||||
}
|
||||
} else {
|
||||
addError('Non-200 response code: ${response.statusCode}',
|
||||
'crud().post - Other');
|
||||
// addError('Non-200 response code: ${response.statusCode}',
|
||||
// 'crud().post - Other');
|
||||
return 'failure';
|
||||
}
|
||||
} catch (e) {
|
||||
addError('HTTP request error: $e', 'crud().post - HTTP');
|
||||
// addError('HTTP request error: $e', 'crud().post - HTTP');
|
||||
return 'failure';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ Future<String> faceDetector() async {
|
||||
|
||||
request.body = json.encode({
|
||||
"url1":
|
||||
"${AppLink.seferCairoServer}/card_image/id_front-${EncryptionHelper.instance.decryptData(box.read(BoxName.driverID))}.jpg",
|
||||
"${AppLink.seferCairoServer}/card_image/id_front-${(box.read(BoxName.driverID))}.jpg",
|
||||
"url2":
|
||||
"https://api.sefer.live/sefer/card_image/face_detect-${EncryptionHelper.instance.decryptData(box.read(BoxName.driverID))}.jpg"
|
||||
"https://api.sefer.live/sefer/card_image/face_detect-${(box.read(BoxName.driverID))}.jpg"
|
||||
});
|
||||
print('request.body: ${request.body}');
|
||||
request.headers.addAll(headers);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:convert';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
@@ -13,8 +12,6 @@ import 'package:sefer_driver/controller/auth/captin/login_captin_controller.dart
|
||||
import 'package:sefer_driver/controller/firebase/firbase_messge.dart';
|
||||
import 'package:sefer_driver/controller/firebase/local_notification.dart';
|
||||
import 'package:sefer_driver/controller/functions/crud.dart';
|
||||
import 'package:sefer_driver/controller/functions/device_info.dart';
|
||||
import 'package:sefer_driver/controller/notification/notification_captain_controller.dart';
|
||||
import 'package:sefer_driver/main.dart';
|
||||
import 'package:sefer_driver/views/home/Captin/home_captain/home_captin.dart';
|
||||
import 'package:sefer_driver/views/widgets/error_snakbar.dart';
|
||||
@@ -397,16 +394,13 @@ class AI extends GetxController {
|
||||
update();
|
||||
|
||||
var payload = {
|
||||
'first_name': EncryptionHelper.instance.encryptData(
|
||||
responseNonIdCardFront['full_name'].toString().split(' ')[0]) ??
|
||||
'Not specified',
|
||||
'last_name': EncryptionHelper.instance.encryptData(
|
||||
responseNonIdCardFront['full_name'].toString().split(' ').last) ??
|
||||
'Not specified',
|
||||
'email': EncryptionHelper.instance
|
||||
.encryptData(box.read(BoxName.emailDriver))
|
||||
?.toString() ??
|
||||
'Not specified',
|
||||
'first_name':
|
||||
(responseNonIdCardFront['full_name'].toString().split(' ')[0]) ??
|
||||
'Not specified',
|
||||
'last_name':
|
||||
(responseNonIdCardFront['full_name'].toString().split(' ').last) ??
|
||||
'Not specified',
|
||||
'email': (box.read(BoxName.emailDriver))?.toString() ?? 'Not specified',
|
||||
'phone': box.read(BoxName.phoneDriver)?.toString() ?? 'Not specified',
|
||||
'id': box.read(BoxName.driverID)?.toString() ?? 'Not specified',
|
||||
'password':
|
||||
@@ -416,16 +410,13 @@ class AI extends GetxController {
|
||||
.passwordController
|
||||
.text
|
||||
.toString(),
|
||||
'gender': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['gender'].toString()) ??
|
||||
'Not specified',
|
||||
'gender':
|
||||
(responseNonIdCardFront['gender'].toString()) ?? 'Not specified',
|
||||
'license_type': 'Foreign',
|
||||
'national_number': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['passport_no'].toString()) ??
|
||||
'Not specified',
|
||||
'name_arabic': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['full_name'].toString()) ??
|
||||
'Not specified',
|
||||
'national_number':
|
||||
(responseNonIdCardFront['passport_no'].toString()) ?? 'Not specified',
|
||||
'name_arabic':
|
||||
(responseNonIdCardFront['full_name'].toString()) ?? 'Not specified',
|
||||
'name_english': 'Not specified',
|
||||
'issue_date':
|
||||
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
|
||||
@@ -437,31 +428,23 @@ class AI extends GetxController {
|
||||
? responseIdEgyptDriverLicense['license_categories'].join(', ')
|
||||
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
|
||||
'Not specified',
|
||||
'address': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['address'].toString()) ??
|
||||
'Not specified',
|
||||
'card_id': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['card_id'].toString()) ??
|
||||
'Not specified',
|
||||
'occupation': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardBack['workStatus'].toString()) ??
|
||||
'Not specified',
|
||||
'address':
|
||||
(responseNonIdCardFront['address'].toString()) ?? 'Not specified',
|
||||
'card_id':
|
||||
(responseNonIdCardFront['card_id'].toString()) ?? 'Not specified',
|
||||
'occupation':
|
||||
(responseNonIdCardBack['workStatus'].toString()) ?? 'Not specified',
|
||||
'education': 'Not specified',
|
||||
'licenseIssueDate':
|
||||
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
|
||||
'religion': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['country'].toString()) ??
|
||||
'Not specified',
|
||||
'religion':
|
||||
(responseNonIdCardFront['country'].toString()) ?? 'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['birthdate'].toString()) ??
|
||||
'Not specified',
|
||||
'birthdate':
|
||||
(responseNonIdCardFront['birthdate'].toString()) ?? 'Not specified',
|
||||
'maritalStatus': 'Not specified',
|
||||
'site': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardFront['address'].toString()) ??
|
||||
'Not specified',
|
||||
'employmentType': EncryptionHelper.instance
|
||||
.encryptData(responseNonIdCardBack['residencyType'].toString()) ??
|
||||
'site': (responseNonIdCardFront['address'].toString()) ?? 'Not specified',
|
||||
'employmentType': (responseNonIdCardBack['residencyType'].toString()) ??
|
||||
'Not specified',
|
||||
};
|
||||
|
||||
@@ -517,32 +500,22 @@ class AI extends GetxController {
|
||||
String hashedPassword = shortHash(pass);
|
||||
|
||||
var payload = {
|
||||
'first_name': EncryptionHelper.instance.encryptData(
|
||||
responseIdEgyptDriverLicense['firstName'].toString()) ??
|
||||
'first_name': (responseIdEgyptDriverLicense['firstName'].toString()) ??
|
||||
'Not specified',
|
||||
'last_name': EncryptionHelper.instance.encryptData(
|
||||
responseIdEgyptDriverLicense['lastName'].toString()) ??
|
||||
'Not specified',
|
||||
'email': EncryptionHelper.instance
|
||||
.encryptData(box.read(BoxName.emailDriver))
|
||||
.toString() ??
|
||||
'last_name': (responseIdEgyptDriverLicense['lastName'].toString()) ??
|
||||
'Not specified',
|
||||
'email': (box.read(BoxName.emailDriver)).toString() ?? 'Not specified',
|
||||
'phone': box.read(BoxName.phoneDriver)?.toString() ?? 'Not specified',
|
||||
'id': box.read(BoxName.driverID)?.toString() ?? 'Not specified',
|
||||
'password': hashedPassword.toString(),
|
||||
'gender': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptBack['gender'].toString()) ??
|
||||
'Not specified',
|
||||
'license_type': EncryptionHelper.instance.encryptData(
|
||||
responseIdEgyptDriverLicense['license_type'].toString()) ??
|
||||
'Not specified',
|
||||
'national_number': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptBack['nationalID'].toString()) ??
|
||||
'Not specified',
|
||||
'name_arabic': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptDriverLicense['name_arabic'].toString()),
|
||||
'name_english': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptDriverLicense['name_english'].toString()),
|
||||
'gender': (responseIdEgyptBack['gender'].toString()) ?? 'Not specified',
|
||||
'license_type':
|
||||
(responseIdEgyptDriverLicense['license_type'].toString()) ??
|
||||
'Not specified',
|
||||
'national_number':
|
||||
(responseIdEgyptBack['nationalID'].toString()) ?? 'Not specified',
|
||||
'name_arabic': (responseIdEgyptDriverLicense['name_arabic'].toString()),
|
||||
'name_english': (responseIdEgyptDriverLicense['name_english'].toString()),
|
||||
'issue_date': responseIdEgyptDriverLicense['issue_date']?.toString() ??
|
||||
'Not specified',
|
||||
'expiry_date': responseIdEgyptDriverLicense['expiry_date']?.toString() ??
|
||||
@@ -552,36 +525,29 @@ class AI extends GetxController {
|
||||
? responseIdEgyptDriverLicense['license_categories'].join(', ')
|
||||
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
|
||||
'Not specified',
|
||||
'address': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptFront['address'].toString()) ??
|
||||
'Not specified',
|
||||
'card_id': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptFront['card_id'].toString()) ??
|
||||
'Not specified',
|
||||
'occupation': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptBack['occupation'].toString()) ??
|
||||
'Not specified',
|
||||
'education': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptBack['occupation'].toString()) ??
|
||||
'Not specified',
|
||||
'address':
|
||||
(responseIdEgyptFront['address'].toString()) ?? 'Not specified',
|
||||
'card_id':
|
||||
(responseIdEgyptFront['card_id'].toString()) ?? 'Not specified',
|
||||
'occupation':
|
||||
(responseIdEgyptBack['occupation'].toString()) ?? 'Not specified',
|
||||
'education':
|
||||
(responseIdEgyptBack['occupation'].toString()) ?? 'Not specified',
|
||||
'licenseIssueDate':
|
||||
responseIdEgyptDriverLicense['issue_date'].toString() ??
|
||||
'Not specified',
|
||||
'religion': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptBack['religion'].toString()) ??
|
||||
'Not specified',
|
||||
'religion':
|
||||
(responseIdEgyptBack['religion'].toString()) ?? 'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate': EncryptionHelper.instance.encryptData(extractDOB(
|
||||
'birthdate': (extractDOB(
|
||||
responseIdEgyptDriverLicense['national_number'].toString())),
|
||||
'maritalStatus': EncryptionHelper.instance
|
||||
.encryptData(responseIdEgyptBack['maritalStatus'].toString()) ??
|
||||
'Not specified',
|
||||
'site': EncryptionHelper.instance.encryptData(
|
||||
responseIdEgyptDriverLicense['address'].toString()) ??
|
||||
'Not specified',
|
||||
'employmentType': EncryptionHelper.instance.encryptData(
|
||||
responseIdEgyptDriverLicense['employmentType'].toString()) ??
|
||||
'maritalStatus':
|
||||
(responseIdEgyptBack['maritalStatus'].toString()) ?? 'Not specified',
|
||||
'site': (responseIdEgyptDriverLicense['address'].toString()) ??
|
||||
'Not specified',
|
||||
'employmentType':
|
||||
(responseIdEgyptDriverLicense['employmentType'].toString()) ??
|
||||
'Not specified',
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -624,8 +590,7 @@ class AI extends GetxController {
|
||||
var res = await CRUD().post(link: AppLink.addCriminalDocuments, payload: {
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"IssueDate": responseCriminalRecordEgypt['IssueDate'],
|
||||
"InspectionResult": EncryptionHelper.instance
|
||||
.encryptData(responseCriminalRecordEgypt['InspectionResult']),
|
||||
"InspectionResult": (responseCriminalRecordEgypt['InspectionResult']),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
mySnackbarSuccess('uploaded sucssefuly'.tr);
|
||||
@@ -639,19 +604,16 @@ class AI extends GetxController {
|
||||
var res = await CRUD().post(link: AppLink.addRegisrationCar, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate': EncryptionHelper.instance.encryptData(
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'car_plate': (responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'make': (responseIdCardDriverEgyptBack['make'].toString()),
|
||||
'model': (responseIdCardDriverEgyptBack['model']),
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
'expiration_date':
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate'].toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': EncryptionHelper.instance
|
||||
.encryptData(responseIdCardDriverEgyptFront['owner']),
|
||||
'owner': (responseIdCardDriverEgyptFront['owner']),
|
||||
'color_hex': responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': EncryptionHelper.instance
|
||||
.encryptData(responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'address': (responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'displacement': responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
'registration_date':
|
||||
@@ -669,8 +631,8 @@ class AI extends GetxController {
|
||||
payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate': EncryptionHelper.instance.encryptData(
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'car_plate':
|
||||
(responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'make': (responseIdCardDriverEgyptBack['make'].toString()),
|
||||
'model': (responseIdCardDriverEgyptBack['model']),
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
@@ -678,12 +640,10 @@ class AI extends GetxController {
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
.toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': EncryptionHelper.instance
|
||||
.encryptData(responseIdCardDriverEgyptFront['owner']),
|
||||
'owner': (responseIdCardDriverEgyptFront['owner']),
|
||||
'color_hex':
|
||||
responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': EncryptionHelper.instance.encryptData(
|
||||
responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'address': (responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'displacement':
|
||||
responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
@@ -695,8 +655,8 @@ class AI extends GetxController {
|
||||
payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate': EncryptionHelper.instance.encryptData(
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'car_plate':
|
||||
(responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'make': (responseIdCardDriverEgyptBack['make'].toString()),
|
||||
'model': (responseIdCardDriverEgyptBack['model']),
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
@@ -704,12 +664,10 @@ class AI extends GetxController {
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
.toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': EncryptionHelper.instance
|
||||
.encryptData(responseIdCardDriverEgyptFront['owner']),
|
||||
'owner': (responseIdCardDriverEgyptFront['owner']),
|
||||
'color_hex':
|
||||
responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': EncryptionHelper.instance.encryptData(
|
||||
responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'address': (responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'displacement':
|
||||
responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
@@ -7,7 +8,6 @@ import 'package:location/location.dart';
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../home/captin/home_captain_controller.dart';
|
||||
import '../home/payment/captain_wallet_controller.dart';
|
||||
import 'crud.dart';
|
||||
@@ -18,64 +18,37 @@ class LocationController extends GetxController {
|
||||
late Location location = Location();
|
||||
bool isLoading = false;
|
||||
late double heading = 0;
|
||||
late double accuracy = 0;
|
||||
late double previousTime = 0;
|
||||
late double latitude;
|
||||
late double totalDistance = 0;
|
||||
late double longitude;
|
||||
late DateTime time;
|
||||
late double speed = 0;
|
||||
late double speedAccuracy = 0;
|
||||
late double headingAccuracy = 0;
|
||||
bool isActive = false;
|
||||
late LatLng myLocation = LatLng(0, 0); // Default value
|
||||
late LatLng myLocation = LatLng(0, 0);
|
||||
String totalPoints = '0';
|
||||
LocationData? get currentLocation => _currentLocation;
|
||||
Timer? _locationTimer;
|
||||
|
||||
LatLng? _lastSavedPosition;
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
location = Location(); // Initialize the location object
|
||||
location = Location();
|
||||
await location.changeSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
interval: 5000, // 5 seconds
|
||||
distanceFilter: 0);
|
||||
await getLocation(); // Fetch the location immediately
|
||||
await startLocationUpdates(); // Start periodic location updates
|
||||
accuracy: LocationAccuracy.high, interval: 5000, distanceFilter: 0);
|
||||
await getLocation();
|
||||
await startLocationUpdates();
|
||||
|
||||
totalPoints = Get.put(CaptainWalletController()).totalPoints.toString();
|
||||
isActive = Get.put(HomeCaptainController()).isActive;
|
||||
}
|
||||
|
||||
// String getLocationArea(double latitude, double longitude) {
|
||||
// if (latitude >= 29.918901 &&
|
||||
// latitude <= 30.198857 &&
|
||||
// longitude >= 31.215009 &&
|
||||
// longitude <= 31.532186) {
|
||||
// return 'Cairo';
|
||||
// } else if (latitude >= 29.904975 &&
|
||||
// latitude <= 30.143372 &&
|
||||
// longitude >= 30.787030 &&
|
||||
// longitude <= 31.215009) {
|
||||
// return 'Giza';
|
||||
// } else if (latitude >= 30.396286 &&
|
||||
// latitude <= 31.654458 &&
|
||||
// longitude >= 29.041139 &&
|
||||
// longitude <= 32.626259) {
|
||||
// return 'Alexandria';
|
||||
// } else {
|
||||
// return 'Cairo';
|
||||
// }
|
||||
// }
|
||||
String getLocationArea(double latitude, double longitude) {
|
||||
final locations = box.read(BoxName.locationName) ?? [];
|
||||
for (final location in locations) {
|
||||
final locationData = location as Map<String, dynamic>;
|
||||
|
||||
// Debugging: Print location data
|
||||
|
||||
// Convert string values to double
|
||||
final minLatitude =
|
||||
double.tryParse(locationData['min_latitude'].toString()) ?? 0.0;
|
||||
final maxLatitude =
|
||||
@@ -85,21 +58,15 @@ class LocationController extends GetxController {
|
||||
final maxLongitude =
|
||||
double.tryParse(locationData['max_longitude'].toString()) ?? 0.0;
|
||||
|
||||
// Debugging: Print converted values
|
||||
// 'Converted Values: minLatitude=$minLatitude, maxLatitude=$maxLatitude, minLongitude=$minLongitude, maxLongitude=$maxLongitude');
|
||||
|
||||
if (latitude >= minLatitude &&
|
||||
latitude <= maxLatitude &&
|
||||
longitude >= minLongitude &&
|
||||
longitude <= maxLongitude) {
|
||||
box.write(BoxName.serverChosen,
|
||||
EncryptionHelper.instance.decryptData(locationData['server_link']));
|
||||
// 'locationData----server_link: ${locationData['server_link']}');
|
||||
box.write(BoxName.serverChosen, (locationData['server_link']));
|
||||
return locationData['name'];
|
||||
}
|
||||
}
|
||||
|
||||
// Default case
|
||||
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
|
||||
return 'Cairo';
|
||||
}
|
||||
@@ -108,10 +75,6 @@ class LocationController extends GetxController {
|
||||
|
||||
Future<void> startLocationUpdates() async {
|
||||
if (box.read(BoxName.driverID) != null) {
|
||||
if (location == null) {
|
||||
location = Location(); // Ensure location is initialized
|
||||
}
|
||||
|
||||
_locationTimer =
|
||||
Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
try {
|
||||
@@ -121,7 +84,7 @@ class LocationController extends GetxController {
|
||||
|
||||
if (isActive && double.parse(totalPoints) > -300) {
|
||||
await getLocation();
|
||||
if (myLocation == null) return;
|
||||
if (myLocation.latitude == 0 && myLocation.longitude == 0) return;
|
||||
|
||||
String area =
|
||||
getLocationArea(myLocation.latitude, myLocation.longitude);
|
||||
@@ -132,22 +95,35 @@ class LocationController extends GetxController {
|
||||
'longitude': myLocation.longitude.toString(),
|
||||
'heading': heading.toString(),
|
||||
'speed': (speed * 3.6).toStringAsFixed(1),
|
||||
'distance': totalDistance == 0 && (speed * 3.6) < 5
|
||||
? '0.0'
|
||||
: totalDistance < 7
|
||||
? totalDistance.toStringAsFixed(3)
|
||||
: totalDistance.toStringAsFixed(1),
|
||||
'distance': totalDistance.toStringAsFixed(2),
|
||||
'status': box.read(BoxName.statusDriverLocation) ?? 'off',
|
||||
};
|
||||
|
||||
// 🔁 كل 5 ثواني - تحديث الموقع
|
||||
// ✅ تحديث للسيرفر
|
||||
await CRUD().post(
|
||||
link:
|
||||
box.read(BoxName.serverChosen) + '/ride/location/update.php',
|
||||
payload: payload,
|
||||
);
|
||||
|
||||
// 📍 كل 60 ثانية - إدخال جديد
|
||||
// ✅ تخزين في SQLite فقط إذا الرحلة On + تحرك أكثر من 10 متر
|
||||
if ((box.read(BoxName.statusDriverLocation) ?? 'off') == 'on') {
|
||||
if (_lastSavedPosition == null ||
|
||||
_calculateDistanceInMeters(_lastSavedPosition!, myLocation) >=
|
||||
10) {
|
||||
await sql.insertData({
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'latitude': myLocation.latitude,
|
||||
'longitude': myLocation.longitude,
|
||||
'created_at': DateTime.now().toIso8601String(),
|
||||
'updated_at': DateTime.now().toIso8601String(),
|
||||
}, 'car_locations');
|
||||
|
||||
_lastSavedPosition = myLocation;
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ إدخال للسيرفر كل دقيقة
|
||||
_insertCounter++;
|
||||
if (_insertCounter >= 12) {
|
||||
_insertCounter = 0;
|
||||
@@ -157,14 +133,14 @@ class LocationController extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
// 🔄 تحديث الكاميرا
|
||||
// ✅ تحديث الكاميرا
|
||||
Get.find<HomeCaptainController>()
|
||||
.mapHomeCaptainController
|
||||
?.animateCamera(
|
||||
CameraUpdate.newLatLng(
|
||||
LatLng(
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
myLocation.latitude,
|
||||
myLocation.longitude,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -181,30 +157,18 @@ class LocationController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getLocation() async {
|
||||
if (location == null) {
|
||||
location = Location(); // تأكد من أن `Location` مهيأ
|
||||
}
|
||||
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
|
||||
serviceEnabled = await location.serviceEnabled();
|
||||
bool serviceEnabled = await location.serviceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
serviceEnabled = await location.requestService();
|
||||
if (!serviceEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!serviceEnabled) return;
|
||||
}
|
||||
|
||||
permissionGranted = await location.hasPermission();
|
||||
PermissionStatus permissionGranted = await location.hasPermission();
|
||||
if (permissionGranted == PermissionStatus.denied) {
|
||||
permissionGranted = await location.requestPermission();
|
||||
if (permissionGranted != PermissionStatus.granted) {
|
||||
return;
|
||||
}
|
||||
if (permissionGranted != PermissionStatus.granted) return;
|
||||
}
|
||||
|
||||
/// **تجنب استدعاء `getLocation()` مباشرة على الـ Main Thread**
|
||||
Future.delayed(Duration(milliseconds: 500), () async {
|
||||
try {
|
||||
LocationData _locationData = await location.getLocation();
|
||||
@@ -212,80 +176,27 @@ class LocationController extends GetxController {
|
||||
myLocation =
|
||||
LatLng(_locationData.latitude!, _locationData.longitude!);
|
||||
} else {
|
||||
myLocation = LatLng(0, 0); // Default value
|
||||
myLocation = LatLng(0, 0);
|
||||
}
|
||||
|
||||
speed = _locationData.speed ?? 0;
|
||||
heading = _locationData.heading ?? 0;
|
||||
|
||||
if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
if (previousTime > 0) {
|
||||
double distance = calculateDistanceInKmPerHour(
|
||||
previousTime, _locationData.time, speed);
|
||||
totalDistance += distance;
|
||||
}
|
||||
previousTime = _locationData.time ?? 0;
|
||||
}
|
||||
|
||||
update();
|
||||
} catch (e) {
|
||||
print("Error getting location: $e");
|
||||
}
|
||||
});
|
||||
}
|
||||
// Future<void> getLocation() async {
|
||||
// if (location == null) {
|
||||
// location = Location(); // Ensure location is initialized
|
||||
// }
|
||||
|
||||
// bool serviceEnabled;
|
||||
// PermissionStatus permissionGranted;
|
||||
|
||||
// serviceEnabled = await location.serviceEnabled();
|
||||
// if (!serviceEnabled) {
|
||||
// serviceEnabled = await location.requestService();
|
||||
// if (!serviceEnabled) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// permissionGranted = await location.hasPermission();
|
||||
// if (permissionGranted == PermissionStatus.denied) {
|
||||
// permissionGranted = await location.requestPermission();
|
||||
// if (permissionGranted != PermissionStatus.granted) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// LocationData _locationData = await location.getLocation();
|
||||
// if (_locationData.latitude != null && _locationData.longitude != null) {
|
||||
// myLocation = LatLng(_locationData.latitude!, _locationData.longitude!);
|
||||
// } else {
|
||||
// myLocation = LatLng(0, 0); // Default value
|
||||
// }
|
||||
|
||||
// speed = _locationData.speed ?? 0;
|
||||
// heading = _locationData.heading ?? 0;
|
||||
|
||||
// if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// if (previousTime > 0) {
|
||||
// double distance = calculateDistanceInKmPerHour(
|
||||
// previousTime, _locationData.time, speed);
|
||||
// totalDistance += distance;
|
||||
// }
|
||||
// previousTime = _locationData.time ?? 0;
|
||||
// }
|
||||
|
||||
// update();
|
||||
// }
|
||||
|
||||
double calculateDistanceInKmPerHour(
|
||||
double? startTime, double? endTime, double speedInMetersPerSecond) {
|
||||
double timeDifferenceInHours =
|
||||
(endTime ?? 0 - startTime! ?? 0) / 1000 / 3600;
|
||||
double speedInKmPerHour = speedInMetersPerSecond * 3.6;
|
||||
double distanceInKilometers = speedInKmPerHour * timeDifferenceInHours;
|
||||
double distanceInMeters = distanceInKilometers * 1000;
|
||||
return distanceInMeters < 5 ? 0 : distanceInKilometers;
|
||||
double _calculateDistanceInMeters(LatLng start, LatLng end) {
|
||||
const p = 0.017453292519943295;
|
||||
final a = 0.5 -
|
||||
cos((end.latitude - start.latitude) * p) / 2 +
|
||||
cos(start.latitude * p) *
|
||||
cos(end.latitude * p) *
|
||||
(1 - cos((end.longitude - start.longitude) * p)) /
|
||||
2;
|
||||
return 12742 * 1000 * asin(sqrt(a)); // meters
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,7 @@ class LogOutController extends GetxController {
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Delete'.tr,
|
||||
onPressed: () async {
|
||||
if (checkTxtController.text ==
|
||||
EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.nameDriver))) {
|
||||
if (checkTxtController.text == (box.read(BoxName.nameDriver))) {
|
||||
// deletecaptainAccount();
|
||||
|
||||
var id = await checkBeforeDelete();
|
||||
|
||||
@@ -197,8 +197,8 @@ class DeviceHelper {
|
||||
|
||||
// Generate and return the encrypted fingerprint
|
||||
final String fingerprint = '${deviceId}_${deviceModel}_$osVersion';
|
||||
print(EncryptionHelper.instance.encryptData(fingerprint));
|
||||
return EncryptionHelper.instance.encryptData(fingerprint);
|
||||
// print(EncryptionHelper.instance.encryptData(fingerprint));
|
||||
return (fingerprint);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to generate device fingerprint');
|
||||
}
|
||||
@@ -247,15 +247,15 @@ class SecurityHelper {
|
||||
await box.write('isTampered', isTampered); // Use await
|
||||
await box.write('isJailBroken', isJailBroken); // Use await
|
||||
|
||||
// debugPrint("Security Check Results:");
|
||||
// debugPrint("isNotTrust: $isNotTrust");
|
||||
// debugPrint("isJailBroken: $isJailBroken");
|
||||
// debugPrint("isRealDevice: $isRealDevice");
|
||||
// debugPrint("isOnExternalStorage: $isOnExternalStorage");
|
||||
// debugPrint("checkForIssues: $checkForIssues");
|
||||
// debugPrint("isDevMode: $isDevMode");
|
||||
// debugPrint("isTampered: $isTampered");
|
||||
// debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
|
||||
debugPrint("Security Check Results:");
|
||||
debugPrint("isNotTrust: $isNotTrust");
|
||||
debugPrint("isJailBroken: $isJailBroken");
|
||||
debugPrint("isRealDevice: $isRealDevice");
|
||||
debugPrint("isOnExternalStorage: $isOnExternalStorage");
|
||||
debugPrint("checkForIssues: $checkForIssues");
|
||||
debugPrint("isDevMode: $isDevMode");
|
||||
debugPrint("isTampered: $isTampered");
|
||||
debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
|
||||
|
||||
// Check for security risks and potentially show a warning
|
||||
if (isJailBroken || isRealDevice == false || isTampered) {
|
||||
|
||||
@@ -40,6 +40,7 @@ class AppInitializer {
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
if (box.read(BoxName.jwt) == null) {
|
||||
Log.print('box.read(BoxName.jwt): ${box.read(BoxName.jwt)}');
|
||||
await LoginDriverController().getJWT();
|
||||
} else {
|
||||
bool isTokenExpired = JwtDecoder.isExpired(X
|
||||
@@ -74,16 +75,11 @@ class AppInitializer {
|
||||
links = List<Map<String, dynamic>>.from(jsonDecode(res)['message']);
|
||||
|
||||
await box.write(BoxName.locationName, links);
|
||||
await box.write(BoxName.basicLink,
|
||||
EncryptionHelper.instance.decryptData(links[0]['server_link']));
|
||||
await box.write(links[2]['name'],
|
||||
EncryptionHelper.instance.decryptData(links[2]['server_link']));
|
||||
await box.write(links[1]['name'],
|
||||
EncryptionHelper.instance.decryptData(links[3]['server_link']));
|
||||
await box.write(links[3]['name'],
|
||||
EncryptionHelper.instance.decryptData(links[1]['server_link']));
|
||||
await box.write(BoxName.paymentLink,
|
||||
EncryptionHelper.instance.decryptData(links[4]['server_link']));
|
||||
await box.write(BoxName.basicLink, (links[0]['server_link']));
|
||||
await box.write(links[2]['name'], (links[2]['server_link']));
|
||||
await box.write(links[1]['name'], (links[3]['server_link']));
|
||||
await box.write(links[3]['name'], (links[1]['server_link']));
|
||||
await box.write(BoxName.paymentLink, (links[4]['server_link']));
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@@ -27,16 +27,9 @@ class SmsEgyptController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> sendSmsEgypt(String phone, otp) async {
|
||||
Future<dynamic> sendSmsEgypt(String phone) async {
|
||||
String sender = await getSender();
|
||||
var body = jsonEncode({
|
||||
"username": 'Sefer',
|
||||
"password": AK.smsPasswordEgypt,
|
||||
"message": "${AppInformation.appName} app code is $otp\ncopy it to app",
|
||||
"language": box.read(BoxName.lang) == 'en' ? "e" : 'r',
|
||||
"sender": sender, //"Sefer Egy", // todo add sefer sender name
|
||||
"receiver": "2$phone"
|
||||
});
|
||||
var body = jsonEncode({"receiver": "2$phone"});
|
||||
|
||||
var res = await http.post(
|
||||
Uri.parse(AppLink.sendSms),
|
||||
@@ -46,19 +39,16 @@ class SmsEgyptController extends GetxController {
|
||||
|
||||
if (jsonDecode(res.body)['message'].toString() != "Success") {
|
||||
await CRUD().post(link: AppLink.updatePhoneInvalidSMS, payload: {
|
||||
"phone_number": EncryptionHelper.instance.encryptData(
|
||||
'+2${Get.find<RegisterCaptainController>().phoneController.text}')
|
||||
"phone_number":
|
||||
('+2${Get.find<RegisterCaptainController>().phoneController.text}')
|
||||
});
|
||||
box.write(
|
||||
BoxName.phoneDriver,
|
||||
EncryptionHelper.instance.encryptData(
|
||||
'+2${Get.find<RegisterCaptainController>().phoneController.text}'));
|
||||
box.write(BoxName.phoneDriver,
|
||||
('+2${Get.find<RegisterCaptainController>().phoneController.text}'));
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
|
||||
await Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
EncryptionHelper.instance
|
||||
.encryptData(box.read(BoxName.emailDriver).toString()),
|
||||
(box.read(BoxName.emailDriver).toString()),
|
||||
);
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
|
||||
@@ -419,10 +419,8 @@ class ImageController extends GetxController {
|
||||
await uploadImage(
|
||||
compressedImage,
|
||||
{
|
||||
'driverID': EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.driverID)) ??
|
||||
EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.passengerID)),
|
||||
'driverID':
|
||||
(box.read(BoxName.driverID)) ?? (box.read(BoxName.passengerID)),
|
||||
'imageType': imageType
|
||||
},
|
||||
link,
|
||||
@@ -461,8 +459,7 @@ class ImageController extends GetxController {
|
||||
'image',
|
||||
stream,
|
||||
length,
|
||||
filename:
|
||||
'${EncryptionHelper.instance.decryptData(box.read(BoxName.driverID))}.jpg',
|
||||
filename: '${(box.read(BoxName.driverID))}.jpg',
|
||||
),
|
||||
);
|
||||
data.forEach((key, value) {
|
||||
|
||||
115
lib/controller/home/captin/behavior_controller.dart
Normal file
115
lib/controller/home/captin/behavior_controller.dart
Normal file
@@ -0,0 +1,115 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:sefer_driver/constant/box_name.dart';
|
||||
import 'package:sefer_driver/constant/links.dart';
|
||||
import 'package:sefer_driver/controller/functions/crud.dart';
|
||||
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../../main.dart';
|
||||
|
||||
class DriverBehaviorController extends GetxController {
|
||||
Future<List<Map<String, dynamic>>> getAllData() async {
|
||||
return await sql.getAllData(TableName.behavior);
|
||||
}
|
||||
|
||||
var isLoading = false.obs;
|
||||
var overallScore = 100.0.obs;
|
||||
var lastTrips = [].obs;
|
||||
|
||||
Future<void> fetchDriverBehavior() async {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
final response = await CRUD().get(
|
||||
link: AppLink.get_driver_behavior,
|
||||
payload: {"driver_id": box.read(BoxName.driverID).toString()},
|
||||
);
|
||||
|
||||
if (response != 'failure') {
|
||||
final json = jsonDecode(response.body);
|
||||
|
||||
overallScore.value =
|
||||
double.parse(json['data']['overall_behavior_score'].toString());
|
||||
lastTrips.value = json['data']['last_10_trips'];
|
||||
} else {
|
||||
// Get.snackbar("Error", json['message'] ?? "Unknown error");
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar("Error", "Exception: $e");
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> analyzeData() async {
|
||||
final data = await getAllData();
|
||||
if (data.isEmpty) return {};
|
||||
|
||||
double maxSpeed = 0;
|
||||
double totalSpeed = 0;
|
||||
int hardBrakes = 0;
|
||||
double totalDistance = 0;
|
||||
double? prevLat, prevLng;
|
||||
|
||||
for (var item in data) {
|
||||
double speed = item['speed'] ?? 0;
|
||||
double lat = item['lat'] ?? 0;
|
||||
double lng = item['lng'] ?? 0;
|
||||
double acc = item['acceleration'] ?? 0;
|
||||
|
||||
if (speed > maxSpeed) maxSpeed = speed;
|
||||
totalSpeed += speed;
|
||||
|
||||
// ✅ Hard brake threshold
|
||||
if (acc.abs() > 3.0) hardBrakes++;
|
||||
|
||||
// ✅ Distance between points
|
||||
if (prevLat != null && prevLng != null) {
|
||||
totalDistance += _calculateDistance(prevLat, prevLng, lat, lng);
|
||||
}
|
||||
prevLat = lat;
|
||||
prevLng = lng;
|
||||
}
|
||||
|
||||
double avgSpeed = totalSpeed / data.length;
|
||||
double behaviorScore = 100 - (hardBrakes * 5) - ((maxSpeed > 100) ? 10 : 0);
|
||||
behaviorScore = behaviorScore.clamp(0, 100);
|
||||
|
||||
return {
|
||||
'max_speed': maxSpeed,
|
||||
'avg_speed': avgSpeed,
|
||||
'hard_brakes': hardBrakes,
|
||||
'total_distance': totalDistance,
|
||||
'behavior_score': behaviorScore,
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> sendSummaryToServer(String driverId, String tripId) async {
|
||||
final summary = await analyzeData();
|
||||
if (summary.isEmpty) return;
|
||||
|
||||
final body = {
|
||||
'driver_id': driverId,
|
||||
'trip_id': tripId,
|
||||
...summary,
|
||||
};
|
||||
|
||||
CRUD().post(link: AppLink.saveBehavior, payload: (body));
|
||||
|
||||
await clearData();
|
||||
}
|
||||
|
||||
Future<void> clearData() async {
|
||||
await sql.deleteAllData(TableName.behavior);
|
||||
}
|
||||
|
||||
double _calculateDistance(
|
||||
double lat1, double lon1, double lat2, double lon2) {
|
||||
const p = 0.017453292519943295;
|
||||
final a = 0.5 -
|
||||
cos((lat2 - lat1) * p) / 2 +
|
||||
cos(lat1 * p) * cos(lat2 * p) * (1 - cos((lon2 - lon1) * p)) / 2;
|
||||
return 12742 * asin(sqrt(a)); // distance in km
|
||||
}
|
||||
}
|
||||
@@ -31,8 +31,7 @@ class HelpController extends GetxController {
|
||||
update();
|
||||
var res = await CRUD().post(link: AppLink.addhelpCenter, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'helpQuestion':
|
||||
EncryptionHelper.instance.encryptData(helpQuestionController.text)
|
||||
'helpQuestion': (helpQuestionController.text)
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
isLoading = false;
|
||||
|
||||
@@ -198,9 +198,7 @@ class HomeCaptainController extends GetxController {
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
} else {
|
||||
print("Controller is null, cannot proceed.");
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
|
||||
void savePeriod(Duration period) {
|
||||
@@ -299,7 +297,6 @@ class HomeCaptainController extends GetxController {
|
||||
// List<Map<String, dynamic>> results =
|
||||
// await sql.getCustomQuery(customQuery);
|
||||
// countRefuse = results[0]['count'].toString();
|
||||
// print(countRefuse);
|
||||
// update();
|
||||
// if (int.parse(countRefuse) > 3) {
|
||||
// box.write(BoxName.statusDriverLocation, 'on');
|
||||
@@ -324,34 +321,34 @@ class HomeCaptainController extends GetxController {
|
||||
|
||||
addToken() async {
|
||||
String? fingerPrint = await storage.read(key: BoxName.fingerPrint);
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': (box.read(BoxName.tokenDriver)),
|
||||
'captain_id': (box.read(BoxName.driverID)).toString(),
|
||||
'fingerPrint': (fingerPrint).toString()
|
||||
});
|
||||
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferAlexandriaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString(),
|
||||
'fingerPrint': (fingerPrint).toString()
|
||||
});
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferGizaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString(),
|
||||
'fingerPrint': (fingerPrint).toString()
|
||||
});
|
||||
await CRUD().post(
|
||||
// CRUD().post(
|
||||
// link: "${AppLink.seferAlexandriaServer}/ride/firebase/addDriver.php",
|
||||
// payload: {
|
||||
// 'token': box.read(BoxName.tokenDriver),
|
||||
// 'captain_id': box.read(BoxName.driverID).toString(),
|
||||
// 'fingerPrint': (fingerPrint).toString()
|
||||
// });
|
||||
// CRUD().post(
|
||||
// link: "${AppLink.seferGizaServer}/ride/firebase/addDriver.php",
|
||||
// payload: {
|
||||
// 'token': box.read(BoxName.tokenDriver),
|
||||
// 'captain_id': box.read(BoxName.driverID).toString(),
|
||||
// 'fingerPrint': (fingerPrint).toString()
|
||||
// });
|
||||
await CRUD().postWallet(
|
||||
link: "${AppLink.seferPaymentServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString(),
|
||||
'fingerPrint': (fingerPrint).toString()
|
||||
});
|
||||
MapDriverController().driverCallPassenger();
|
||||
// MapDriverController().driverCallPassenger();
|
||||
// box.write(BoxName.statusDriverLocation, 'off');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:sefer_driver/controller/home/captin/behavior_controller.dart';
|
||||
import 'package:sefer_driver/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:sefer_driver/views/widgets/mydialoug.dart';
|
||||
import 'package:bubble_head/bubble.dart';
|
||||
@@ -183,9 +184,7 @@ class MapDriverController extends GetxController {
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
payload: {
|
||||
"id": EncryptionHelper.instance
|
||||
.encryptData(rideId)
|
||||
.toString(), // Convert to String
|
||||
"id": (rideId).toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().postFromDialogue(
|
||||
@@ -193,28 +192,22 @@ class MapDriverController extends GetxController {
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id':
|
||||
EncryptionHelper.instance.encryptData(rideId).toString(),
|
||||
'order_id': (rideId).toString(),
|
||||
'status': 'CancelFromDriverAfterApply'
|
||||
});
|
||||
await CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferCairoServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
payload: {
|
||||
"order_id":
|
||||
EncryptionHelper.instance.encryptData(rideId).toString(),
|
||||
"order_id": (rideId).toString(),
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
"status": 'reject After Applied',
|
||||
"notes": EncryptionHelper.instance
|
||||
.encryptData(cancelTripCotroller.text)
|
||||
.toString()
|
||||
"notes": (cancelTripCotroller.text).toString()
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD()
|
||||
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
"id": EncryptionHelper.instance
|
||||
.encryptData(rideId)
|
||||
.toString(), // Convert to String
|
||||
"id": (rideId).toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().postFromDialogue(
|
||||
@@ -222,26 +215,22 @@ class MapDriverController extends GetxController {
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id':
|
||||
EncryptionHelper.instance.encryptData(rideId).toString(),
|
||||
'order_id': (rideId).toString(),
|
||||
'status': 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.endPoint}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
payload: {
|
||||
"order_id":
|
||||
EncryptionHelper.instance.encryptData(rideId).toString(),
|
||||
"order_id": (rideId).toString(),
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
"status": 'reject After Applied',
|
||||
"notes": EncryptionHelper.instance
|
||||
.encryptData(cancelTripCotroller.text)
|
||||
.toString()
|
||||
"notes": (cancelTripCotroller.text).toString()
|
||||
});
|
||||
}
|
||||
|
||||
sql.insertData({
|
||||
'order_id': EncryptionHelper.instance.encryptData(rideId),
|
||||
'order_id': (rideId),
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
@@ -312,13 +301,13 @@ class MapDriverController extends GetxController {
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
payload: {
|
||||
'id': EncryptionHelper.instance.encryptData(rideId),
|
||||
'id': (rideId),
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
'id': EncryptionHelper.instance.encryptData(rideId),
|
||||
'id': (rideId),
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
@@ -533,35 +522,35 @@ class MapDriverController extends GetxController {
|
||||
: (distanceBetweenDriverAndPassengerWhenConfirm * .06) +
|
||||
(5 * .06); //for Eygpt other like jordan .06 per minute
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': EncryptionHelper.instance.encryptData(rideId),
|
||||
'id': (rideId),
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'CancelAfterWait',
|
||||
});
|
||||
CRUD().post(link: AppLink.addDriverOrder, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'order_id': EncryptionHelper.instance.encryptData(rideId).toString(),
|
||||
'order_id': (rideId).toString(),
|
||||
'status': 'CancelAfterWait'
|
||||
});
|
||||
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
|
||||
'id': EncryptionHelper.instance.encryptData(rideId),
|
||||
'id': (rideId),
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'CancelAfterWait',
|
||||
});
|
||||
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'order_id': EncryptionHelper.instance.encryptData(rideId).toString(),
|
||||
'order_id': (rideId).toString(),
|
||||
'status': 'CancelAfterWait'
|
||||
});
|
||||
}
|
||||
var paymentTokenWait =
|
||||
await generateTokenDriver(costOfWaiting5Minute.toString());
|
||||
var res = await CRUD().post(link: AppLink.addDrivePayment, payload: {
|
||||
'rideId': EncryptionHelper.instance.encryptData(rideId),
|
||||
'rideId': (rideId),
|
||||
'amount': (costOfWaiting5Minute.toString()),
|
||||
'payment_method': 'wait-cancel',
|
||||
'passengerID': EncryptionHelper.instance.encryptData(passengerId),
|
||||
'passengerID': (passengerId),
|
||||
'token': paymentTokenWait,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
@@ -569,7 +558,7 @@ class MapDriverController extends GetxController {
|
||||
await generateTokenDriver(costOfWaiting5Minute.toString());
|
||||
var res1 =
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId${EncryptionHelper.instance.encryptData(rideId)}',
|
||||
'paymentID': 'rideId${(rideId)}',
|
||||
'amount': (costOfWaiting5Minute).toStringAsFixed(0),
|
||||
'paymentMethod': 'wait',
|
||||
'token': paymentTokenWait1,
|
||||
@@ -585,7 +574,7 @@ class MapDriverController extends GetxController {
|
||||
var paymentTokenWaitPassenger1 =
|
||||
await generateTokenPassenger((costOfWaiting5Minute * -1).toString());
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': EncryptionHelper.instance.encryptData(passengerId),
|
||||
'passenger_id': (passengerId),
|
||||
'balance': (costOfWaiting5Minute * -1).toString(),
|
||||
'token': paymentTokenWaitPassenger1,
|
||||
});
|
||||
@@ -671,13 +660,13 @@ class MapDriverController extends GetxController {
|
||||
// Prepare data for API calls
|
||||
final nowString = DateTime.now().toString();
|
||||
final basePayload = {
|
||||
'id': EncryptionHelper.instance.encryptData(rideId),
|
||||
'id': (rideId),
|
||||
'rideTimeFinish': nowString,
|
||||
'status': 'Finished',
|
||||
'price': totalCost,
|
||||
};
|
||||
final driverOrderPayload = {
|
||||
'order_id': EncryptionHelper.instance.encryptData(rideId.toString()),
|
||||
'order_id': (rideId.toString()),
|
||||
'status': 'Finished'
|
||||
};
|
||||
|
||||
@@ -710,7 +699,7 @@ class MapDriverController extends GetxController {
|
||||
paymentToken = await generateTokenPassenger(
|
||||
((-1) * double.parse(paymentAmount)).toString());
|
||||
futures.add(CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': EncryptionHelper.instance.encryptData(passengerId),
|
||||
'passenger_id': (passengerId),
|
||||
'balance': ((-1) * double.parse(paymentAmount)).toString(),
|
||||
'token': paymentToken,
|
||||
}));
|
||||
@@ -718,11 +707,11 @@ class MapDriverController extends GetxController {
|
||||
|
||||
paymentToken = await generateTokenDriver(paymentAmount.toString());
|
||||
futures.add(CRUD().post(link: AppLink.addDrivePayment, payload: {
|
||||
'rideId': EncryptionHelper.instance.encryptData(rideId),
|
||||
'rideId': (rideId),
|
||||
'amount': paymentAmount,
|
||||
'payment_method':
|
||||
walletChecked == 'true' ? "${paymentMethod}Ride" : paymentMethod,
|
||||
'passengerID': EncryptionHelper.instance.encryptData(passengerId),
|
||||
'passengerID': (passengerId),
|
||||
'token': paymentToken,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
}));
|
||||
@@ -731,7 +720,7 @@ class MapDriverController extends GetxController {
|
||||
final paymentToken1 = await generateTokenPassenger(
|
||||
((-1) * double.parse(passengerWalletBurc)).toString());
|
||||
futures.add(CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': EncryptionHelper.instance.encryptData(passengerId),
|
||||
'passenger_id': (passengerId),
|
||||
'token': paymentToken1,
|
||||
'balance': ((-1) * double.parse(passengerWalletBurc)).toString()
|
||||
}));
|
||||
@@ -741,7 +730,7 @@ class MapDriverController extends GetxController {
|
||||
final paymentToken2 =
|
||||
await generateTokenDriver((pointsSubtraction).toStringAsFixed(0));
|
||||
futures.add(CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId${EncryptionHelper.instance.encryptData(rideId)}',
|
||||
'paymentID': 'rideId${(rideId)}',
|
||||
'amount': (pointsSubtraction).toStringAsFixed(0),
|
||||
'paymentMethod': paymentMethod,
|
||||
'token': paymentToken2,
|
||||
@@ -750,6 +739,7 @@ class MapDriverController extends GetxController {
|
||||
|
||||
// Wait for all independent API calls to complete
|
||||
await Future.wait(futures);
|
||||
Get.put(DriverBehaviorController()).sendSummaryToServer(driverId, rideId);
|
||||
|
||||
// Send notification (this likely depends on previous steps)
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
@@ -898,7 +888,7 @@ class MapDriverController extends GetxController {
|
||||
var res = await CRUD().get(
|
||||
link: "${AppLink.endPoint}/ride/driver_order/getOrderCancelStatus.php",
|
||||
payload: {
|
||||
'order_id': EncryptionHelper.instance.encryptData(rideId),
|
||||
'order_id': (rideId),
|
||||
}); //.then((value) {
|
||||
var response = jsonDecode(res);
|
||||
canelString = response['data']['status'];
|
||||
|
||||
@@ -32,6 +32,7 @@ class DriverWalletHistoryController extends GetxController {
|
||||
));
|
||||
}
|
||||
archive = jsonDecode(res)['message'];
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -157,11 +157,9 @@ class PaymentController extends GetxController {
|
||||
paymentIntentClientSecret: clientSecret,
|
||||
merchantDisplayName: AppInformation.appName,
|
||||
billingDetails: BillingDetails(
|
||||
name: EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.nameDriver)),
|
||||
name: (box.read(BoxName.nameDriver)),
|
||||
email: (box.read(BoxName.emailDriver)),
|
||||
phone: EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.phoneDriver)),
|
||||
phone: (box.read(BoxName.phoneDriver)),
|
||||
address: Address(
|
||||
city: 'city',
|
||||
country: box.read(BoxName.countryCode), //'United States'
|
||||
|
||||
@@ -133,13 +133,10 @@ class PaymobManager extends GetxController {
|
||||
"amount_cents": amount,
|
||||
"currency": currency,
|
||||
"billing_data": {
|
||||
"first_name":
|
||||
EncryptionHelper.instance.decryptData(box.read(BoxName.nameDriver)),
|
||||
"last_name": EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.lastNameDriver)),
|
||||
"first_name": (box.read(BoxName.nameDriver)),
|
||||
"last_name": (box.read(BoxName.lastNameDriver)),
|
||||
"email": (box.read(BoxName.emailDriver)),
|
||||
"phone_number": EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.phoneDriver)),
|
||||
"phone_number": (box.read(BoxName.phoneDriver)),
|
||||
"apartment": "NA",
|
||||
"floor": "NA",
|
||||
"street": "NA",
|
||||
|
||||
@@ -227,8 +227,7 @@ class PaymobBillingData {
|
||||
"email": (box.read(BoxName.emailDriver)),
|
||||
"first_name": box.read(BoxName.nameDriver),
|
||||
"last_name": box.read(BoxName.nameDriver),
|
||||
"phone_number":
|
||||
EncryptionHelper.instance.decryptData(box.read(BoxName.phoneDriver)),
|
||||
"phone_number": (box.read(BoxName.phoneDriver)),
|
||||
"apartment": apartment ?? "NA",
|
||||
"floor": floor ?? "NA",
|
||||
"building": building ?? "NA",
|
||||
|
||||
@@ -43,9 +43,7 @@ class RatingController extends GetxController {
|
||||
? box.read(BoxName.nameDriver)
|
||||
: box.read(BoxName.name),
|
||||
"email": (box.read(BoxName.emailDriver)).toString(),
|
||||
"phone": EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.phoneDriver))
|
||||
.toString(),
|
||||
"phone": (box.read(BoxName.phoneDriver)).toString(),
|
||||
"userId": box.read(BoxName.driverID),
|
||||
"userType": "driver",
|
||||
"rating": rating.toString(),
|
||||
|
||||
Reference in New Issue
Block a user