25-1/13/1-securejordan
This commit is contained in:
@@ -8,6 +8,7 @@ import '../../../constant/links.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/home/Captin/history/history_details_page.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
|
||||
class HistoryCaptainController extends GetxController {
|
||||
bool isloading = false;
|
||||
@@ -44,8 +45,9 @@ class HistoryCaptainController extends GetxController {
|
||||
|
||||
getHistoryDetails(String orderId) async {
|
||||
isloading = true;
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getRideOrderID, payload: {'id': orderId});
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getRideOrderID,
|
||||
payload: {'id': encryptionHelper.encryptData(orderId)});
|
||||
historyDetailsData = jsonDecode(res);
|
||||
isloading = false;
|
||||
update();
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:sefer_driver/constant/colors.dart';
|
||||
import 'package:sefer_driver/constant/links.dart';
|
||||
import 'package:sefer_driver/controller/firebase/local_notification.dart';
|
||||
import 'package:sefer_driver/controller/functions/crud.dart';
|
||||
import 'package:sefer_driver/controller/functions/encrypt_decrypt.dart';
|
||||
import 'package:sefer_driver/controller/home/payment/captain_wallet_controller.dart';
|
||||
import 'package:sefer_driver/views/widgets/mydialoug.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -149,33 +150,42 @@ Download the SEFER app now and enjoy your ride!
|
||||
|
||||
void onSelectDriverInvitation(int index) async {
|
||||
MyDialog().getDialog(
|
||||
driverInvitationData[index]['countOfInvitDriver'] < 100
|
||||
? '${'When'.tr} ${driverInvitationData[index]['invitorName']} ${"complete, you can claim your gift".tr} '
|
||||
int.parse(encryptionHelper.decryptData(
|
||||
driverInvitationData[index]['countOfInvitDriver'])) <
|
||||
100
|
||||
? '${'When'.tr} ${encryptionHelper.decryptData(driverInvitationData[index]['invitorName'])} ${"complete, you can claim your gift".tr} '
|
||||
: 'You deserve the gift'.tr,
|
||||
'${driverInvitationData[index]['invitorName']} ${driverInvitationData[index]['countOfInvitDriver']} / 100 ${'Trip'.tr}',
|
||||
'${encryptionHelper.decryptData(driverInvitationData[index]['invitorName'])} ${encryptionHelper.decryptData(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
|
||||
() async {
|
||||
if (driverInvitationData[index]['countOfInvitDriver'] < 100) {
|
||||
if (int.parse(encryptionHelper.decryptData(
|
||||
driverInvitationData[index]['countOfInvitDriver'])) <
|
||||
100) {
|
||||
Get.back();
|
||||
} else {
|
||||
//claim your gift
|
||||
if (driverInvitationData[index]['isGiftToken'].toString() == '0') {
|
||||
if (encryptionHelper
|
||||
.decryptData(driverInvitationData[index]['isGiftToken'])
|
||||
.toString() ==
|
||||
'0') {
|
||||
Get.back();
|
||||
await CRUD().post(
|
||||
link: AppLink.updateInviteDriver,
|
||||
payload: {'id': driverInvitationData[index]['id']});
|
||||
await CRUD().post(link: AppLink.updateInviteDriver, payload: {
|
||||
'id': encryptionHelper
|
||||
.encryptData(driverInvitationData[index]['id'])
|
||||
});
|
||||
await Get.find<CaptainWalletController>().addDriverPayment(
|
||||
'paymentMethod',
|
||||
'500',
|
||||
encryptionHelper.encryptData('500'),
|
||||
'',
|
||||
);
|
||||
// add for invitor too
|
||||
await Get.find<CaptainWalletController>().addDriverWalletToInvitor(
|
||||
'paymentMethod',
|
||||
driverInvitationData[index]['driverInviterId'],
|
||||
'500',
|
||||
encryptionHelper
|
||||
.encryptData(driverInvitationData[index]['driverInviterId']),
|
||||
encryptionHelper.encryptData('500'),
|
||||
);
|
||||
await Get.find<CaptainWalletController>()
|
||||
.addSeferWallet('giftInvitation', '-1000');
|
||||
await Get.find<CaptainWalletController>().addSeferWallet(
|
||||
'giftInvitation', encryptionHelper.encryptData('-1000'));
|
||||
NotificationCaptainController().addNotificationCaptain(
|
||||
driverInvitationData[index]['driverInviterId'].toString(),
|
||||
"You have got a gift for invitation".tr,
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'package:location/location.dart';
|
||||
import '../../../constant/info.dart';
|
||||
import '../../../views/auth/captin/cards/egypt_card_a_i.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
|
||||
class LoginDriverController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
@@ -138,30 +139,36 @@ class LoginDriverController extends GetxController {
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success' &&
|
||||
jsonDecoeded['data'][0]['is_verified'].toString() == '1') {
|
||||
box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']);
|
||||
box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']);
|
||||
box.write(BoxName.emailDriver, (jsonDecoeded['data'][0]['email']));
|
||||
box.write(BoxName.driverID, (jsonDecoeded['data'][0]['id']));
|
||||
box.write(BoxName.isTest, '1');
|
||||
box.write(BoxName.gender, jsonDecoeded['data'][0]['gender']);
|
||||
box.write(BoxName.gender, (jsonDecoeded['data'][0]['gender']));
|
||||
box.write(BoxName.phoneVerified,
|
||||
jsonDecoeded['data'][0]['is_verified'].toString());
|
||||
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
|
||||
box.write(BoxName.phoneDriver, (jsonDecoeded['data'][0]['phone']));
|
||||
box.write(BoxName.is_claimed, jsonDecoeded['data'][0]['is_claimed']);
|
||||
box.write(BoxName.isInstall, jsonDecoeded['data'][0]['isInstall']);
|
||||
// box.write(
|
||||
// BoxName.isGiftToken, jsonDecoeded['data'][0]['isGiftToken']);
|
||||
box.write(BoxName.nameArabic, jsonDecoeded['data'][0]['name_arabic']);
|
||||
box.write(
|
||||
BoxName.nameArabic, (jsonDecoeded['data'][0]['name_arabic']));
|
||||
box.write(BoxName.carYear, jsonDecoeded['data'][0]['year']);
|
||||
box.write(
|
||||
BoxName.bankCodeDriver, jsonDecoeded['data'][0]['bankCode']);
|
||||
BoxName.bankCodeDriver, (jsonDecoeded['data'][0]['bankCode']));
|
||||
box.write(BoxName.accountBankNumberDriver,
|
||||
jsonDecoeded['data'][0]['accountBank']);
|
||||
(jsonDecoeded['data'][0]['accountBank']));
|
||||
box.write(
|
||||
BoxName.nameDriver,
|
||||
'${jsonDecoeded['data'][0]['first_name']}'
|
||||
' ${jsonDecoeded['data'][0]['last_name']}');
|
||||
if ((jsonDecoeded['data'][0]['model'].toString().contains('دراجه') ||
|
||||
'${encryptionHelper.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${encryptionHelper.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
if (((jsonDecoeded['data'][0]['model'])
|
||||
.toString()
|
||||
.contains('دراجه') ||
|
||||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
|
||||
if (jsonDecoeded['data'][0]['gender'].toString() == 'Male') {
|
||||
if (encryptionHelper
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() ==
|
||||
'Male') {
|
||||
box.write(BoxName.carTypeOfDriver, 'Scooter');
|
||||
} else {
|
||||
box.write(BoxName.carTypeOfDriver, 'Pink Bike');
|
||||
@@ -183,17 +190,22 @@ class LoginDriverController extends GetxController {
|
||||
}
|
||||
updateAppTester(AppInformation.appName);
|
||||
|
||||
var token = await CRUD().get(
|
||||
link: AppLink.getDriverToken,
|
||||
payload: {'captain_id': box.read(BoxName.driverID).toString()});
|
||||
var token = await CRUD().get(link: AppLink.getDriverToken, payload: {
|
||||
'captain_id': encryptionHelper
|
||||
.encryptData(box.read(BoxName.driverID))
|
||||
.toString()
|
||||
});
|
||||
|
||||
if (token != 'failure') {
|
||||
if (jsonDecode(token)['data'][0]['token'] !=
|
||||
box.read(BoxName.tokenDriver)) {
|
||||
if (encryptionHelper
|
||||
.decryptData(jsonDecode(token)['data'][0]['token']) !=
|
||||
encryptionHelper.decryptData(box.read(BoxName.tokenDriver))) {
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'token change'.tr,
|
||||
'change device'.tr,
|
||||
jsonDecode(token)['data'][0]['token'].toString(),
|
||||
encryptionHelper
|
||||
.decryptData(jsonDecode(token)['data'][0]['token'])
|
||||
.toString(),
|
||||
[],
|
||||
'promo.wav');
|
||||
Get.defaultDialog(
|
||||
@@ -204,16 +216,16 @@ class LoginDriverController extends GetxController {
|
||||
onPressed: () async {
|
||||
await CRUD()
|
||||
.post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
'token': (box.read(BoxName.tokenDriver)),
|
||||
'captain_id': (box.read(BoxName.driverID)).toString()
|
||||
});
|
||||
await CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferAlexandriaServer}/ride/firebase/addDriver.php",
|
||||
payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'token': (box.read(BoxName.tokenDriver)),
|
||||
'captain_id':
|
||||
box.read(BoxName.driverID).toString()
|
||||
(box.read(BoxName.driverID)).toString()
|
||||
});
|
||||
// await CRUD().post(
|
||||
// link:
|
||||
@@ -250,10 +262,11 @@ class LoginDriverController extends GetxController {
|
||||
update();
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.loginUsingCredentialsWithoutGoogle, payload: {
|
||||
'email': email,
|
||||
'email': encryptionHelper.encryptData(email),
|
||||
'password': password,
|
||||
});
|
||||
box.write(BoxName.emailDriver, email.toString());
|
||||
box.write(
|
||||
BoxName.emailDriver, encryptionHelper.encryptData(email).toString());
|
||||
print(res);
|
||||
if (res == 'failure') {
|
||||
//Failure
|
||||
@@ -270,32 +283,41 @@ class LoginDriverController extends GetxController {
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success' &&
|
||||
jsonDecoeded['data'][0]['is_verified'].toString() == '1') {
|
||||
box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']);
|
||||
box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']);
|
||||
box.write(BoxName.emailDriver, (jsonDecoeded['data'][0]['email']));
|
||||
box.write(BoxName.driverID, (jsonDecoeded['data'][0]['id']));
|
||||
box.write(BoxName.isTest, '1');
|
||||
box.write(BoxName.gender, jsonDecoeded['data'][0]['gender']);
|
||||
box.write(BoxName.gender, (jsonDecoeded['data'][0]['gender']));
|
||||
box.write(BoxName.phoneVerified,
|
||||
jsonDecoeded['data'][0]['is_verified'].toString());
|
||||
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
|
||||
box.write(BoxName.nameArabic, jsonDecoeded['data'][0]['name_arabic']);
|
||||
box.write(BoxName.phoneDriver, (jsonDecoeded['data'][0]['phone']));
|
||||
box.write(
|
||||
BoxName.bankCodeDriver, jsonDecoeded['data'][0]['bankCode']);
|
||||
BoxName.nameArabic,
|
||||
encryptionHelper
|
||||
.decryptData(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,
|
||||
'${jsonDecoeded['data'][0]['first_name']}'
|
||||
' ${jsonDecoeded['data'][0]['last_name']}');
|
||||
'${encryptionHelper.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${encryptionHelper.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
if ((jsonDecoeded['data'][0]['model'].toString().contains('دراجه') ||
|
||||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
|
||||
if (jsonDecoeded['data'][0]['gender'].toString() == 'Male') {
|
||||
if (encryptionHelper
|
||||
.decryptData(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 (jsonDecoeded['data'][0]['gender'].toString() != 'Male') {
|
||||
if (encryptionHelper
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() !=
|
||||
'Male') {
|
||||
box.write(BoxName.carTypeOfDriver, 'Lady');
|
||||
} else {
|
||||
box.write(BoxName.carTypeOfDriver, 'Comfort');
|
||||
@@ -315,12 +337,15 @@ class LoginDriverController extends GetxController {
|
||||
payload: {'captain_id': box.read(BoxName.driverID).toString()});
|
||||
|
||||
if (token != 'failure') {
|
||||
if (jsonDecode(token)['data'][0]['token'] !=
|
||||
box.read(BoxName.tokenDriver)) {
|
||||
if (encryptionHelper
|
||||
.decryptData(jsonDecode(token)['data'][0]['token']) !=
|
||||
encryptionHelper.decryptData(box.read(BoxName.tokenDriver))) {
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'token change'.tr,
|
||||
'change device'.tr,
|
||||
jsonDecode(token)['data'][0]['token'].toString(),
|
||||
encryptionHelper
|
||||
.decryptData(jsonDecode(token)['data'][0]['token'])
|
||||
.toString(),
|
||||
[],
|
||||
'ding.wav');
|
||||
Get.defaultDialog(
|
||||
|
||||
@@ -19,6 +19,7 @@ import '../../../constant/colors.dart';
|
||||
import '../../../views/auth/captin/ai_page.dart';
|
||||
import '../../../views/auth/captin/car_license_page.dart';
|
||||
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
import '../../functions/sms_egypt_controller.dart';
|
||||
|
||||
class RegisterCaptainController extends GetxController {
|
||||
@@ -107,7 +108,8 @@ class RegisterCaptainController extends GetxController {
|
||||
if (isValidEgyptianPhoneNumber(phoneController.text)) {
|
||||
var responseCheker = await CRUD()
|
||||
.post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
});
|
||||
if (responseCheker != 'failure') {
|
||||
var d = jsonDecode(responseCheker);
|
||||
@@ -115,15 +117,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, '+2${phoneController.text}');
|
||||
box.write(BoxName.phone,
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'));
|
||||
await Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
);
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
'token_code':
|
||||
encryptionHelper.encryptData(randomNumber.toString()),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
@@ -138,8 +143,10 @@ class RegisterCaptainController extends GetxController {
|
||||
}
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': randomNumber.toString(),
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
'token_code':
|
||||
encryptionHelper.encryptData(randomNumber.toString()),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
@@ -239,7 +246,8 @@ class RegisterCaptainController extends GetxController {
|
||||
_handleAlreadyVerified() {
|
||||
mySnackbarSuccess('Phone number is already verified'.tr);
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
box.write(BoxName.phone, '+2${phoneController.text}');
|
||||
box.write(BoxName.phone,
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'));
|
||||
Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
@@ -254,8 +262,8 @@ class RegisterCaptainController extends GetxController {
|
||||
await CRUD().post(
|
||||
link: AppLink.sendVerifyOtpMessage,
|
||||
payload: {
|
||||
'phone_number': '+2$phoneNumber',
|
||||
'token_code': randomNumber.toString(),
|
||||
'phone_number': encryptionHelper.encryptData('+2$phoneNumber'),
|
||||
'token_code': encryptionHelper.encryptData(randomNumber.toString()),
|
||||
'driverId': box.read(BoxName.driverID),
|
||||
'email': box.read(BoxName.emailDriver),
|
||||
},
|
||||
@@ -273,12 +281,14 @@ class RegisterCaptainController extends GetxController {
|
||||
// var loginDriverController = Get.put(LoginDriverController());
|
||||
if (formKey3.currentState!.validate()) {
|
||||
var res = await CRUD().post(link: AppLink.verifyOtpDriver, payload: {
|
||||
'phone_number': '+2${phoneController.text}',
|
||||
'token_code': verifyCode.text.toString(),
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
'token_code': encryptionHelper.encryptData(verifyCode.text.toString()),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
// var dec = jsonDecode(res);
|
||||
box.write(BoxName.phoneDriver, '+2${phoneController.text}');
|
||||
box.write(BoxName.phoneDriver,
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'));
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
|
||||
// loginDriverController.isGoogleLogin == true
|
||||
@@ -303,9 +313,10 @@ class RegisterCaptainController extends GetxController {
|
||||
sendVerifications() async {
|
||||
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
|
||||
'email': emailController.text.isEmpty
|
||||
? Get.find<LoginDriverController>().emailController.text.toString()
|
||||
: emailController.text,
|
||||
'token': verifyCode.text,
|
||||
? encryptionHelper.encryptData(
|
||||
Get.find<LoginDriverController>().emailController.text.toString())
|
||||
: encryptionHelper.encryptData(emailController.text),
|
||||
'token': encryptionHelper.encryptData(verifyCode.text),
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:sefer_driver/constant/box_name.dart';
|
||||
import 'package:sefer_driver/constant/colors.dart';
|
||||
import 'package:sefer_driver/constant/links.dart';
|
||||
import 'package:sefer_driver/controller/auth/captin/login_captin_controller.dart';
|
||||
import 'package:sefer_driver/controller/functions/crud.dart';
|
||||
import 'package:sefer_driver/main.dart';
|
||||
import 'package:sefer_driver/views/auth/captin/cards/sms_signup.dart';
|
||||
import 'package:sefer_driver/views/home/on_boarding_page.dart';
|
||||
@@ -10,9 +7,9 @@ import 'package:sefer_driver/views/widgets/error_snakbar.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
|
||||
import '../../onbording_page.dart';
|
||||
import '../../views/auth/captin/ai_page.dart';
|
||||
import '../functions/add_error.dart';
|
||||
import '../functions/encrypt_decrypt.dart';
|
||||
|
||||
class GoogleSignInHelper {
|
||||
static final GoogleSignIn _googleSignIn = GoogleSignIn(
|
||||
@@ -95,9 +92,10 @@ class GoogleSignInHelper {
|
||||
await _handleSignUp(googleUser);
|
||||
|
||||
// Retrieve driverID and emailDriver with added validation
|
||||
final driverID = box.read(BoxName.driverID)?.toString() ?? 'Unknown ID';
|
||||
final driverID =
|
||||
(box.read(BoxName.driverID)!.toString()) ?? 'Unknown ID';
|
||||
final emailDriver =
|
||||
box.read(BoxName.emailDriver)?.toString() ?? 'Unknown Email';
|
||||
(box.read(BoxName.emailDriver)!.toString()) ?? 'Unknown Email';
|
||||
|
||||
// Debug print statements
|
||||
print('Driver ID: $driverID');
|
||||
@@ -125,9 +123,12 @@ class GoogleSignInHelper {
|
||||
|
||||
static Future<void> _handleSignUp(GoogleSignInAccount user) async {
|
||||
// Store driver information
|
||||
box.write(BoxName.driverID,
|
||||
user.id ?? 'Unknown ID'); // Ensure there's a fallback value
|
||||
box.write(BoxName.emailDriver, user.email ?? 'Unknown Email');
|
||||
box.write(
|
||||
BoxName.driverID,
|
||||
encryptionHelper.encryptData(user.id) ??
|
||||
'Unknown ID'); // Ensure there's a fallback value
|
||||
box.write(BoxName.emailDriver,
|
||||
encryptionHelper.encryptData(user.email) ?? 'Unknown Email');
|
||||
}
|
||||
|
||||
// Method to handle Google Sign-Out
|
||||
|
||||
@@ -20,6 +20,7 @@ import '../../views/home/Captin/orderCaptin/order_speed_request.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../../views/home/Captin/orderCaptin/vip_order_page.dart';
|
||||
import '../auth/google_sign.dart';
|
||||
import '../functions/encrypt_decrypt.dart';
|
||||
import '../functions/face_detect.dart';
|
||||
import 'access_token.dart';
|
||||
import 'local_notification.dart';
|
||||
@@ -70,7 +71,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Future getToken() async {
|
||||
fcmToken.getToken().then((token) {
|
||||
// Log.print('token: ${token}');
|
||||
box.write(BoxName.tokenDriver, token);
|
||||
box.write(BoxName.tokenDriver, encryptionHelper.encryptData(token!));
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
|
||||
@@ -28,6 +28,9 @@ class CRUD {
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
Log.print('request: ${response.request}');
|
||||
Log.print('response: ${response.body}');
|
||||
Log.print('payload: ${payload}');
|
||||
// if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
@@ -221,6 +224,9 @@ class CRUD {
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
},
|
||||
);
|
||||
Log.print('request: ${response.request}');
|
||||
Log.print('response: ${response.body}');
|
||||
Log.print('payload: ${payload}');
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (response.statusCode == 200) {
|
||||
if (jsonData['status'] == 'success') {
|
||||
|
||||
@@ -1,24 +1,80 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
|
||||
class DeviceController {
|
||||
String deviceSerialNumber = '';
|
||||
final box = GetStorage();
|
||||
class DeviceInfo {
|
||||
final String? manufacturer;
|
||||
final String? model;
|
||||
final String? deviceId;
|
||||
final String? osVersion;
|
||||
final String? platform;
|
||||
final String? deviceName;
|
||||
final bool? isPhysicalDevice;
|
||||
|
||||
void getDeviceSerialNumber() async {
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
DeviceInfo({
|
||||
this.manufacturer,
|
||||
this.model,
|
||||
this.deviceId,
|
||||
this.osVersion,
|
||||
this.platform,
|
||||
this.deviceName,
|
||||
this.isPhysicalDevice,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'manufacturer': manufacturer,
|
||||
'model': model,
|
||||
'deviceId': deviceId,
|
||||
'osVersion': osVersion,
|
||||
'platform': platform,
|
||||
'deviceName': deviceName,
|
||||
'isPhysicalDevice': isPhysicalDevice,
|
||||
};
|
||||
}
|
||||
|
||||
class DeviceController {
|
||||
final box = GetStorage();
|
||||
final _deviceInfo = DeviceInfoPlugin();
|
||||
|
||||
Future<DeviceInfo> getDeviceInfo() async {
|
||||
if (Platform.isAndroid) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
deviceSerialNumber = androidInfo.serialNumber;
|
||||
box.write(BoxName.deviceInfo, deviceSerialNumber.toString());
|
||||
return await _getAndroidDeviceInfo();
|
||||
} else if (Platform.isIOS) {
|
||||
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
deviceSerialNumber = iosInfo.identifierForVendor!;
|
||||
box.write(BoxName.deviceInfo, deviceSerialNumber.toString());
|
||||
return await _getIosDeviceInfo();
|
||||
}
|
||||
throw UnsupportedError('Unsupported platform');
|
||||
}
|
||||
|
||||
Future<DeviceInfo> _getAndroidDeviceInfo() async {
|
||||
final androidInfo = await _deviceInfo.androidInfo;
|
||||
final deviceInfo = DeviceInfo(
|
||||
manufacturer: androidInfo.manufacturer,
|
||||
model: androidInfo.model,
|
||||
deviceId: androidInfo.serialNumber,
|
||||
osVersion: androidInfo.version.release,
|
||||
platform: 'Android',
|
||||
deviceName: androidInfo.device,
|
||||
isPhysicalDevice: androidInfo.isPhysicalDevice,
|
||||
);
|
||||
|
||||
box.write(BoxName.deviceInfo, deviceInfo.toJson());
|
||||
return deviceInfo;
|
||||
}
|
||||
|
||||
Future<DeviceInfo> _getIosDeviceInfo() async {
|
||||
final iosInfo = await _deviceInfo.iosInfo;
|
||||
final deviceInfo = DeviceInfo(
|
||||
manufacturer: 'Apple',
|
||||
model: iosInfo.model,
|
||||
deviceId: iosInfo.identifierForVendor,
|
||||
osVersion: iosInfo.systemVersion,
|
||||
platform: 'iOS',
|
||||
deviceName: iosInfo.name,
|
||||
isPhysicalDevice: iosInfo.isPhysicalDevice,
|
||||
);
|
||||
|
||||
box.write(BoxName.deviceInfo, deviceInfo.toJson());
|
||||
return deviceInfo;
|
||||
}
|
||||
}
|
||||
|
||||
52
lib/controller/functions/encrypt_decrypt.dart
Normal file
52
lib/controller/functions/encrypt_decrypt.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:encrypt/encrypt.dart' as encrypt;
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../env/env.dart';
|
||||
|
||||
var secretKey = Env.keyOfApp
|
||||
.toString()
|
||||
.split('XrXlBl')[0]; // Must be 16 characters for AES-128
|
||||
const initializationVector = 'abcdefghijklmnop'; // Must be 16 characters
|
||||
final encryptionHelper = EncryptionHelper(
|
||||
secretKey: secretKey,
|
||||
initializationVector: initializationVector,
|
||||
);
|
||||
|
||||
class EncryptionHelper {
|
||||
final encrypt.Key key;
|
||||
final encrypt.IV iv;
|
||||
|
||||
EncryptionHelper(
|
||||
{required String secretKey, required String initializationVector})
|
||||
: key = encrypt.Key.fromUtf8(secretKey),
|
||||
iv = encrypt.IV.fromUtf8(initializationVector);
|
||||
|
||||
// Initialize the helper
|
||||
|
||||
/// Encrypts the given plain text
|
||||
String encryptData(String plainText) {
|
||||
try {
|
||||
final encrypter = encrypt.Encrypter(encrypt.AES(key,
|
||||
mode: encrypt.AESMode.cbc)); // Explicitly use CBC mode
|
||||
final encrypted = encrypter.encrypt(plainText, iv: iv);
|
||||
return encrypted.base64;
|
||||
} catch (e) {
|
||||
debugPrint('Encryption Error: $e');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/// Decrypts the given encrypted text
|
||||
String decryptData(String encryptedText) {
|
||||
try {
|
||||
final encrypter = encrypt.Encrypter(encrypt.AES(key,
|
||||
mode: encrypt.AESMode.cbc)); // Explicitly use CBC mode
|
||||
final encrypted = encrypt.Encrypted.fromBase64(encryptedText);
|
||||
final decrypted = encrypter.decrypt(encrypted, iv: iv);
|
||||
return decrypted;
|
||||
} catch (e) {
|
||||
debugPrint('Decryption Error: $e');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import 'package:sefer_driver/main.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../constant/links.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
import 'upload_image.dart';
|
||||
|
||||
Future<String> faceDetector() async {
|
||||
@@ -23,9 +24,9 @@ Future<String> faceDetector() async {
|
||||
|
||||
request.body = json.encode({
|
||||
"url1":
|
||||
"https://api.sefer.live/sefer/card_image/id_front-${box.read(BoxName.driverID)}.jpg",
|
||||
"${AppLink.seferCairoServer}/card_image/id_front-${encryptionHelper.decryptData(box.read(BoxName.driverID))}.jpg",
|
||||
"url2":
|
||||
"https://api.sefer.live/sefer/card_image/face_detect-${box.read(BoxName.driverID)}.jpg"
|
||||
"https://api.sefer.live/sefer/card_image/face_detect-${encryptionHelper.decryptData(box.read(BoxName.driverID))}.jpg"
|
||||
});
|
||||
print('request.body: ${request.body}');
|
||||
request.headers.addAll(headers);
|
||||
|
||||
@@ -29,6 +29,7 @@ import '../../constant/api_key.dart';
|
||||
import '../../constant/char_map.dart';
|
||||
import '../../constant/colors.dart';
|
||||
import '../../print.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
import 'tts.dart';
|
||||
import 'upload_image.dart';
|
||||
|
||||
@@ -393,12 +394,12 @@ class AI extends GetxController {
|
||||
update();
|
||||
|
||||
var payload = {
|
||||
'first_name':
|
||||
responseNonIdCardFront['full_name']?.toString().split(' ')[0] ??
|
||||
'Not specified',
|
||||
'last_name':
|
||||
responseNonIdCardFront['full_name']?.toString().split(' ').last ??
|
||||
'Not specified',
|
||||
'first_name': encryptionHelper.encryptData(
|
||||
responseNonIdCardFront['full_name'].toString().split(' ')[0]) ??
|
||||
'Not specified',
|
||||
'last_name': encryptionHelper.encryptData(
|
||||
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',
|
||||
@@ -409,12 +410,16 @@ class AI extends GetxController {
|
||||
.passwordController
|
||||
.text
|
||||
.toString(),
|
||||
'gender': responseNonIdCardFront['gender']?.toString() ?? 'Not specified',
|
||||
'gender': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['gender'].toString()) ??
|
||||
'Not specified',
|
||||
'license_type': 'Foreign',
|
||||
'national_number':
|
||||
responseNonIdCardFront['passport_no']?.toString() ?? 'Not specified',
|
||||
'name_arabic':
|
||||
responseNonIdCardFront['full_name']?.toString() ?? 'Not specified',
|
||||
'national_number': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['passport_no'].toString()) ??
|
||||
'Not specified',
|
||||
'name_arabic': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['full_name'].toString()) ??
|
||||
'Not specified',
|
||||
'name_english': 'Not specified',
|
||||
'issue_date':
|
||||
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
|
||||
@@ -426,24 +431,32 @@ class AI extends GetxController {
|
||||
? responseIdEgyptDriverLicense['license_categories'].join(', ')
|
||||
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
|
||||
'Not specified',
|
||||
'address':
|
||||
responseNonIdCardFront['address']?.toString() ?? 'Not specified',
|
||||
'card_id':
|
||||
responseNonIdCardFront['card_id']?.toString() ?? 'Not specified',
|
||||
'occupation':
|
||||
responseNonIdCardBack['workStatus']?.toString() ?? 'Not specified',
|
||||
'address': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['address'].toString()) ??
|
||||
'Not specified',
|
||||
'card_id': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['card_id'].toString()) ??
|
||||
'Not specified',
|
||||
'occupation': encryptionHelper
|
||||
.encryptData(responseNonIdCardBack['workStatus'].toString()) ??
|
||||
'Not specified',
|
||||
'education': 'Not specified',
|
||||
'licenseIssueDate':
|
||||
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
|
||||
'religion':
|
||||
responseNonIdCardFront['country']?.toString() ?? 'Not specified',
|
||||
'religion': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['country'].toString()) ??
|
||||
'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate':
|
||||
responseNonIdCardFront['birthdate']?.toString() ?? 'Not specified',
|
||||
'birthdate': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['birthdate'].toString()) ??
|
||||
'Not specified',
|
||||
'maritalStatus': 'Not specified',
|
||||
'site': responseNonIdCardFront['address']?.toString() ?? 'Not specified',
|
||||
'employmentType':
|
||||
responseNonIdCardBack['residencyType']?.toString() ?? 'Not specified',
|
||||
'site': encryptionHelper
|
||||
.encryptData(responseNonIdCardFront['address'].toString()) ??
|
||||
'Not specified',
|
||||
'employmentType': encryptionHelper
|
||||
.encryptData(responseNonIdCardBack['residencyType'].toString()) ??
|
||||
'Not specified',
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -486,9 +499,11 @@ class AI extends GetxController {
|
||||
update();
|
||||
|
||||
var payload = {
|
||||
'first_name': responseIdEgyptDriverLicense['firstName']?.toString() ??
|
||||
'first_name': encryptionHelper.encryptData(
|
||||
responseIdEgyptDriverLicense['firstName'].toString()) ??
|
||||
'Not specified',
|
||||
'last_name': responseIdEgyptDriverLicense['lastName']?.toString() ??
|
||||
'last_name': encryptionHelper.encryptData(
|
||||
responseIdEgyptDriverLicense['lastName'].toString()) ??
|
||||
'Not specified',
|
||||
'email': box.read(BoxName.emailDriver)?.toString() ?? 'Not specified',
|
||||
'phone': box.read(BoxName.phoneDriver)?.toString() ?? 'Not specified',
|
||||
@@ -500,17 +515,21 @@ class AI extends GetxController {
|
||||
.passwordController
|
||||
.text
|
||||
.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() ??
|
||||
'gender': encryptionHelper
|
||||
.encryptData(responseIdEgyptBack['gender'].toString()) ??
|
||||
'Not specified',
|
||||
'license_type': encryptionHelper.encryptData(
|
||||
responseIdEgyptDriverLicense['license_type'].toString()) ??
|
||||
'Not specified',
|
||||
'national_number': encryptionHelper
|
||||
.encryptData(responseIdEgyptBack['nationalID'].toString()) ??
|
||||
'Not specified',
|
||||
'name_arabic': encryptionHelper.encryptData(
|
||||
responseIdEgyptDriverLicense['name_arabic'].toString()) ??
|
||||
'Not specified',
|
||||
'name_english': encryptionHelper.encryptData(
|
||||
responseIdEgyptDriverLicense['name_english'].toString()) ??
|
||||
'Not specified',
|
||||
'name_english':
|
||||
responseIdEgyptDriverLicense['name_english']?.toString() ??
|
||||
'Not specified',
|
||||
'issue_date': responseIdEgyptDriverLicense['issue_date']?.toString() ??
|
||||
'Not specified',
|
||||
'expiry_date': responseIdEgyptDriverLicense['expiry_date']?.toString() ??
|
||||
@@ -520,27 +539,36 @@ class AI extends GetxController {
|
||||
? responseIdEgyptDriverLicense['license_categories'].join(', ')
|
||||
: responseIdEgyptDriverLicense['license_categories']?.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':
|
||||
responseIdEgyptBack['religion']?.toString() ?? 'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate': extractDOB(
|
||||
responseIdEgyptDriverLicense['national_number'].toString()),
|
||||
'maritalStatus':
|
||||
responseIdEgyptBack['maritalStatus']?.toString() ?? 'Not specified',
|
||||
'site': responseIdEgyptDriverLicense['address']?.toString() ??
|
||||
'address': encryptionHelper
|
||||
.encryptData(responseIdEgyptFront['address'].toString()) ??
|
||||
'Not specified',
|
||||
'employmentType':
|
||||
responseIdEgyptDriverLicense['employmentType']?.toString() ??
|
||||
'card_id': encryptionHelper
|
||||
.encryptData(responseIdEgyptFront['card_id'].toString()) ??
|
||||
'Not specified',
|
||||
'occupation': encryptionHelper
|
||||
.encryptData(responseIdEgyptBack['occupation'].toString()) ??
|
||||
'Not specified',
|
||||
'education': encryptionHelper
|
||||
.encryptData(responseIdEgyptBack['occupation'].toString()) ??
|
||||
'Not specified',
|
||||
'licenseIssueDate':
|
||||
responseIdEgyptDriverLicense['issue_date'].toString() ??
|
||||
'Not specified',
|
||||
'religion': encryptionHelper
|
||||
.encryptData(responseIdEgyptBack['religion'].toString()) ??
|
||||
'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate': encryptionHelper.encryptData(extractDOB(
|
||||
responseIdEgyptDriverLicense['national_number'].toString())),
|
||||
'maritalStatus': encryptionHelper
|
||||
.encryptData(responseIdEgyptBack['maritalStatus'].toString()) ??
|
||||
'Not specified',
|
||||
'site': encryptionHelper.encryptData(
|
||||
responseIdEgyptDriverLicense['address'].toString()) ??
|
||||
'Not specified',
|
||||
'employmentType': encryptionHelper.encryptData(
|
||||
responseIdEgyptDriverLicense['employmentType'].toString()) ??
|
||||
'Not specified',
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -583,7 +611,8 @@ class AI extends GetxController {
|
||||
var res = await CRUD().post(link: AppLink.addCriminalDocuments, payload: {
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"IssueDate": responseCriminalRecordEgypt['IssueDate'],
|
||||
"InspectionResult": responseCriminalRecordEgypt['InspectionResult'],
|
||||
"InspectionResult": encryptionHelper
|
||||
.encryptData(responseCriminalRecordEgypt['InspectionResult']),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
mySnackbarSuccess('uploaded sucssefuly'.tr);
|
||||
@@ -597,16 +626,21 @@ class AI extends GetxController {
|
||||
var res = await CRUD().post(link: AppLink.addRegisrationCar, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate': responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
'model': responseIdCardDriverEgyptBack['model'],
|
||||
'car_plate': encryptionHelper.encryptData(
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'make': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptBack['make'].toString()),
|
||||
'model': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptBack['model']),
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
'expiration_date':
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate'].toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
'owner': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptFront['owner']),
|
||||
'color_hex': responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
'address': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'displacement': responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
'registration_date':
|
||||
@@ -624,19 +658,23 @@ class AI extends GetxController {
|
||||
payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate':
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
'model': responseIdCardDriverEgyptBack['model'],
|
||||
'car_plate': encryptionHelper.encryptData(
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'make': encryptionHelper.encryptData(
|
||||
responseIdCardDriverEgyptBack['make'].toString()),
|
||||
'model': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptBack['model']),
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
'expiration_date':
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
.toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
'owner': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptFront['owner']),
|
||||
'color_hex':
|
||||
responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
'address': encryptionHelper.encryptData(
|
||||
responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'displacement':
|
||||
responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
@@ -648,19 +686,23 @@ class AI extends GetxController {
|
||||
payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
'car_plate':
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
'model': responseIdCardDriverEgyptBack['model'],
|
||||
'car_plate': encryptionHelper.encryptData(
|
||||
responseIdCardDriverEgyptFront['car_plate'].toString()),
|
||||
'make': encryptionHelper.encryptData(
|
||||
responseIdCardDriverEgyptBack['make'].toString()),
|
||||
'model': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptBack['model']),
|
||||
'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
'expiration_date':
|
||||
responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
.toString(),
|
||||
'color': responseIdCardDriverEgyptBack['color'],
|
||||
'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
'owner': encryptionHelper
|
||||
.encryptData(responseIdCardDriverEgyptFront['owner']),
|
||||
'color_hex':
|
||||
responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
'address': encryptionHelper.encryptData(
|
||||
responseIdCardDriverEgyptFront['address'].toString()),
|
||||
'displacement':
|
||||
responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
|
||||
@@ -43,25 +43,62 @@ class LocationController extends GetxController {
|
||||
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) {
|
||||
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';
|
||||
final locations = box.read(BoxName.locationName) ?? [];
|
||||
for (final location in locations) {
|
||||
final locationData = location as Map<String, dynamic>;
|
||||
|
||||
// Debugging: Print location data
|
||||
print('Location Data: $locationData');
|
||||
|
||||
// Convert string values to double
|
||||
final minLatitude =
|
||||
double.tryParse(locationData['min_latitude'].toString()) ?? 0.0;
|
||||
final maxLatitude =
|
||||
double.tryParse(locationData['max_latitude'].toString()) ?? 0.0;
|
||||
final minLongitude =
|
||||
double.tryParse(locationData['min_longitude'].toString()) ?? 0.0;
|
||||
final maxLongitude =
|
||||
double.tryParse(locationData['max_longitude'].toString()) ?? 0.0;
|
||||
|
||||
// Debugging: Print converted values
|
||||
// print(
|
||||
// 'Converted Values: minLatitude=$minLatitude, maxLatitude=$maxLatitude, minLongitude=$minLongitude, maxLongitude=$maxLongitude');
|
||||
|
||||
if (latitude >= minLatitude &&
|
||||
latitude <= maxLatitude &&
|
||||
longitude >= minLongitude &&
|
||||
longitude <= maxLongitude) {
|
||||
box.write(BoxName.serverChosen, locationData['server_link']);
|
||||
// Log.print(
|
||||
// 'locationData----server_link: ${locationData['server_link']}');
|
||||
return locationData['name'];
|
||||
}
|
||||
}
|
||||
|
||||
// Default case
|
||||
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
|
||||
return 'Cairo';
|
||||
}
|
||||
|
||||
Future<void> startLocationUpdates() async {
|
||||
@@ -83,50 +120,30 @@ class LocationController extends GetxController {
|
||||
if (myLocation == null) {
|
||||
return;
|
||||
}
|
||||
print(
|
||||
'Latitude: ${myLocation.latitude}, Longitude: ${myLocation.longitude}');
|
||||
// print(
|
||||
// 'Latitude: ${myLocation.latitude}, Longitude: ${myLocation.longitude}');
|
||||
|
||||
String area =
|
||||
getLocationArea(myLocation.latitude, myLocation.longitude);
|
||||
print('Determined Area: $area');
|
||||
|
||||
String endpoint;
|
||||
|
||||
switch (area) {
|
||||
case 'Cairo':
|
||||
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
|
||||
endpoint = AppLink.addCarsLocationCairoEndpoint;
|
||||
break;
|
||||
case 'Giza':
|
||||
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
|
||||
endpoint = AppLink.addCarsLocationGizaEndpoint;
|
||||
break;
|
||||
case 'Alexandria':
|
||||
box.write(
|
||||
BoxName.serverChosen, AppLink.seferAlexandriaServer);
|
||||
endpoint = AppLink.addCarsLocationAlexandriaEndpoint;
|
||||
break;
|
||||
default:
|
||||
endpoint = AppLink.addCarsLocationCairoEndpoint;
|
||||
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
|
||||
}
|
||||
|
||||
Log.print('Final Endpoint: $endpoint');
|
||||
|
||||
if (box.read(BoxName.driverID) != null) {
|
||||
await CRUD().post(link: endpoint, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'latitude': myLocation.latitude.toString(),
|
||||
'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),
|
||||
'status': box.read(BoxName.statusDriverLocation).toString(),
|
||||
});
|
||||
await CRUD().post(
|
||||
link: box.read(BoxName.serverChosen) +
|
||||
'/ride/location/add.php',
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'latitude': myLocation.latitude.toString(),
|
||||
'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),
|
||||
'status': box.read(BoxName.statusDriverLocation) ?? 'off',
|
||||
});
|
||||
|
||||
Get.find<HomeCaptainController>()
|
||||
.mapHomeCaptainController
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:sefer_driver/views/widgets/elevated_btn.dart';
|
||||
import 'package:sefer_driver/views/widgets/my_textField.dart';
|
||||
|
||||
import '../../constant/style.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
|
||||
class LogOutController extends GetxController {
|
||||
TextEditingController checkTxtController = TextEditingController();
|
||||
@@ -30,7 +31,8 @@ class LogOutController extends GetxController {
|
||||
checkBeforeDelete() async {
|
||||
var res = await CRUD().post(
|
||||
link: AppLink.deletecaptainAccounr,
|
||||
payload: {'id': box.read(BoxName.driverID)}).then((value) => exit(0));
|
||||
payload: {'id': box.read(BoxName.driverID)});
|
||||
return res['message'][0]['id'];
|
||||
}
|
||||
|
||||
deletecaptainAccount() {
|
||||
@@ -72,9 +74,15 @@ class LogOutController extends GetxController {
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Delete'.tr,
|
||||
onPressed: () {
|
||||
if (checkTxtController.text == box.read(BoxName.nameDriver)) {
|
||||
deletecaptainAccount();
|
||||
onPressed: () async {
|
||||
if (checkTxtController.text ==
|
||||
encryptionHelper.decryptData(box.read(BoxName.nameDriver))) {
|
||||
// deletecaptainAccount();
|
||||
|
||||
var id = await checkBeforeDelete();
|
||||
deleteMyAccountDriver(id);
|
||||
} else {
|
||||
mySnackeBarError('Your Name is Wrong'.tr);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import 'crud.dart';
|
||||
|
||||
class SecureStorage {
|
||||
@@ -28,35 +30,24 @@ const List<String> keysToFetch = [
|
||||
];
|
||||
|
||||
class AppInitializer {
|
||||
// final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||
List<Map<String, dynamic>> links = [];
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
// Check if app is running for the first time
|
||||
|
||||
// Loop through the keys and fetch their values
|
||||
for (String key in keysToFetch) {
|
||||
try {
|
||||
String? value = await getKey(key); // Fetch from server
|
||||
if (value != null) {
|
||||
await box.write(key, value); // Save securely
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching or saving key $key: $e');
|
||||
}
|
||||
}
|
||||
await getKey();
|
||||
}
|
||||
|
||||
Future<String?> getKey(String key) async {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key});
|
||||
if (res != 'failure') {
|
||||
try {
|
||||
var data = jsonDecode(res)['message'];
|
||||
return data[key]?.toString();
|
||||
} catch (e) {
|
||||
print('Error parsing response for $key: $e');
|
||||
Future<void> getKey() async {
|
||||
try {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getLocationAreaLinks, payload: {});
|
||||
Log.print('res: ${res}');
|
||||
if (res != 'failure') {
|
||||
links = List<Map<String, dynamic>>.from(jsonDecode(res)['message']);
|
||||
await box.remove(BoxName.locationName);
|
||||
await box.write(BoxName.locationName, links);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching or decoding location data: $e');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import 'package:sefer_driver/views/widgets/elevated_btn.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../print.dart';
|
||||
import '../auth/captin/login_captin_controller.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
|
||||
class SmsEgyptController extends GetxController {
|
||||
var headers = {'Content-Type': 'application/json'};
|
||||
@@ -46,11 +46,13 @@ class SmsEgyptController extends GetxController {
|
||||
|
||||
if (jsonDecode(res.body)['message'].toString() != "Success") {
|
||||
await CRUD().post(link: AppLink.updatePhoneInvalidSMS, payload: {
|
||||
"phone_number":
|
||||
'+2${Get.find<RegisterCaptainController>().phoneController.text}'
|
||||
"phone_number": encryptionHelper.encryptData(
|
||||
'+2${Get.find<RegisterCaptainController>().phoneController.text}')
|
||||
});
|
||||
box.write(BoxName.phoneDriver,
|
||||
'+2${Get.find<RegisterCaptainController>().phoneController.text}');
|
||||
box.write(
|
||||
BoxName.phoneDriver,
|
||||
encryptionHelper.encryptData(
|
||||
'+2${Get.find<RegisterCaptainController>().phoneController.text}'));
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
|
||||
await Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../../constant/box_name.dart';
|
||||
import '../../constant/colors.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
|
||||
class ImageController extends GetxController {
|
||||
File? myImage;
|
||||
@@ -419,7 +420,8 @@ class ImageController extends GetxController {
|
||||
compressedImage,
|
||||
{
|
||||
'driverID':
|
||||
box.read(BoxName.driverID) ?? box.read(BoxName.passengerID),
|
||||
encryptionHelper.decryptData(box.read(BoxName.driverID)) ??
|
||||
encryptionHelper.decryptData(box.read(BoxName.passengerID)),
|
||||
'imageType': imageType
|
||||
},
|
||||
link,
|
||||
@@ -458,7 +460,8 @@ class ImageController extends GetxController {
|
||||
'image',
|
||||
stream,
|
||||
length,
|
||||
filename: '${box.read(BoxName.driverID)}.jpg',
|
||||
filename:
|
||||
'${encryptionHelper.decryptData(box.read(BoxName.driverID))}.jpg',
|
||||
),
|
||||
);
|
||||
data.forEach((key, value) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../../constant/style.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../../views/widgets/elevated_btn.dart';
|
||||
import '../../../functions/crud.dart';
|
||||
import '../../../functions/encrypt_decrypt.dart';
|
||||
|
||||
class HelpController extends GetxController {
|
||||
bool isLoading = false;
|
||||
@@ -30,7 +31,7 @@ class HelpController extends GetxController {
|
||||
update();
|
||||
var res = await CRUD().post(link: AppLink.addhelpCenter, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'helpQuestion': helpQuestionController.text
|
||||
'helpQuestion': encryptionHelper.encryptData(helpQuestionController.text)
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
isLoading = false;
|
||||
|
||||
@@ -22,6 +22,7 @@ import '../../../views/Rate/rate_passenger.dart';
|
||||
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
|
||||
class MapDriverController extends GetxController {
|
||||
@@ -182,7 +183,9 @@ class MapDriverController extends GetxController {
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"id": encryptionHelper
|
||||
.encryptData(rideId)
|
||||
.toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().postFromDialogue(
|
||||
@@ -190,22 +193,26 @@ class MapDriverController extends GetxController {
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': rideId.toString(),
|
||||
'order_id': encryptionHelper.encryptData(rideId).toString(),
|
||||
'status': 'CancelFromDriverAfterApply'
|
||||
});
|
||||
await CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferCairoServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
payload: {
|
||||
"order_id": rideId.toString(),
|
||||
"order_id": encryptionHelper.encryptData(rideId).toString(),
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
"status": 'reject After Applied',
|
||||
"notes": cancelTripCotroller.text.toString()
|
||||
"notes": encryptionHelper
|
||||
.encryptData(cancelTripCotroller.text)
|
||||
.toString()
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD()
|
||||
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"id": encryptionHelper
|
||||
.encryptData(rideId)
|
||||
.toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().postFromDialogue(
|
||||
@@ -213,22 +220,24 @@ class MapDriverController extends GetxController {
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': rideId.toString(),
|
||||
'order_id': encryptionHelper.encryptData(rideId).toString(),
|
||||
'status': 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.endPoint}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
payload: {
|
||||
"order_id": rideId.toString(),
|
||||
"order_id": encryptionHelper.encryptData(rideId).toString(),
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
"status": 'reject After Applied',
|
||||
"notes": cancelTripCotroller.text.toString()
|
||||
"notes": encryptionHelper
|
||||
.encryptData(cancelTripCotroller.text)
|
||||
.toString()
|
||||
});
|
||||
}
|
||||
|
||||
sql.insertData({
|
||||
'order_id': rideId,
|
||||
'order_id': encryptionHelper.encryptData(rideId),
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
@@ -299,13 +308,13 @@ class MapDriverController extends GetxController {
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
payload: {
|
||||
'id': rideId,
|
||||
'id': encryptionHelper.encryptData(rideId),
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
'id': rideId,
|
||||
'id': encryptionHelper.encryptData(rideId),
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
@@ -313,8 +322,8 @@ class MapDriverController extends GetxController {
|
||||
// Get.find<HomeCaptainController>().changeToAppliedRide('Applied');
|
||||
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'DriverIsGoingToPassenger',
|
||||
box.read(BoxName.name).toString(),
|
||||
'Driver Is Going To Passenger'.tr,
|
||||
box.read(BoxName.nameDriver).toString(), //todo name driver
|
||||
tokenPassenger,
|
||||
[],
|
||||
'start.wav');
|
||||
@@ -392,18 +401,18 @@ class MapDriverController extends GetxController {
|
||||
// Get.find<HomeCaptainController>().update();
|
||||
update();
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': rideId,
|
||||
'id': encryptionHelper.encryptData(rideId),
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Begin',
|
||||
});
|
||||
CRUD().post(link: AppLink.addDriverOrder, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'order_id': rideId.toString(),
|
||||
'order_id': encryptionHelper.encryptData(rideId).toString(),
|
||||
'status': 'Begin'
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
|
||||
'id': rideId,
|
||||
'id': encryptionHelper.encryptData(rideId),
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Begin',
|
||||
});
|
||||
@@ -411,13 +420,13 @@ class MapDriverController extends GetxController {
|
||||
link: '${AppLink.endPoint}/rides/driver_order/add.php',
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'order_id': rideId.toString(),
|
||||
'order_id': encryptionHelper.encryptData(rideId).toString(),
|
||||
'status': 'Begin'
|
||||
});
|
||||
}
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Trip is Begin'.tr,
|
||||
box.read(BoxName.name).toString(),
|
||||
box.read(BoxName.nameDriver).toString(),
|
||||
tokenPassenger,
|
||||
[],
|
||||
'start.wav');
|
||||
@@ -482,7 +491,8 @@ class MapDriverController extends GetxController {
|
||||
calculateDistanceBetweenDriverAndPassengerLocation() async {
|
||||
Get.put(LocationController());
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getLatestLocationPassenger, payload: {'rideId': rideId});
|
||||
link: AppLink.getLatestLocationPassenger,
|
||||
payload: {'rideId': encryptionHelper.encryptData(rideId)});
|
||||
if (res != 'failure') {
|
||||
var passengerLatestLocationString = jsonDecode(res)['message'];
|
||||
|
||||
@@ -519,35 +529,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': rideId,
|
||||
'id': encryptionHelper.encryptData(rideId),
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'CancelAfterWait',
|
||||
});
|
||||
CRUD().post(link: AppLink.addDriverOrder, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'order_id': rideId.toString(),
|
||||
'order_id': encryptionHelper.encryptData(rideId).toString(),
|
||||
'status': 'CancelAfterWait'
|
||||
});
|
||||
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
|
||||
'id': rideId,
|
||||
'id': encryptionHelper.encryptData(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': rideId.toString(),
|
||||
'order_id': encryptionHelper.encryptData(rideId).toString(),
|
||||
'status': 'CancelAfterWait'
|
||||
});
|
||||
}
|
||||
var paymentTokenWait =
|
||||
await generateTokenDriver(costOfWaiting5Minute.toString());
|
||||
var res = await CRUD().post(link: AppLink.addDrivePayment, payload: {
|
||||
'rideId': rideId,
|
||||
'amount': costOfWaiting5Minute.toString(),
|
||||
'rideId': encryptionHelper.encryptData(rideId),
|
||||
'amount': (costOfWaiting5Minute.toString()),
|
||||
'payment_method': 'wait-cancel',
|
||||
'passengerID': passengerId,
|
||||
'passengerID': encryptionHelper.encryptData(passengerId),
|
||||
'token': paymentTokenWait,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
@@ -555,7 +565,7 @@ class MapDriverController extends GetxController {
|
||||
await generateTokenDriver(costOfWaiting5Minute.toString());
|
||||
var res1 =
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'paymentID': 'rideId${encryptionHelper.encryptData(rideId)}',
|
||||
'amount': (costOfWaiting5Minute).toStringAsFixed(0),
|
||||
'paymentMethod': 'wait',
|
||||
'token': paymentTokenWait1,
|
||||
@@ -571,7 +581,7 @@ class MapDriverController extends GetxController {
|
||||
var paymentTokenWaitPassenger1 =
|
||||
await generateTokenPassenger((costOfWaiting5Minute * -1).toString());
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'passenger_id': encryptionHelper.encryptData(passengerId),
|
||||
'balance': (costOfWaiting5Minute * -1).toString(),
|
||||
'token': paymentTokenWaitPassenger1,
|
||||
});
|
||||
@@ -657,13 +667,13 @@ class MapDriverController extends GetxController {
|
||||
// Prepare data for API calls
|
||||
final nowString = DateTime.now().toString();
|
||||
final basePayload = {
|
||||
'id': rideId,
|
||||
'id': encryptionHelper.encryptData(rideId),
|
||||
'rideTimeFinish': nowString,
|
||||
'status': 'Finished',
|
||||
'price': totalCost,
|
||||
};
|
||||
final driverOrderPayload = {
|
||||
'order_id': rideId.toString(),
|
||||
'order_id': encryptionHelper.encryptData(rideId.toString()),
|
||||
'status': 'Finished'
|
||||
};
|
||||
|
||||
@@ -696,7 +706,7 @@ class MapDriverController extends GetxController {
|
||||
paymentToken = await generateTokenPassenger(
|
||||
((-1) * double.parse(paymentAmount)).toString());
|
||||
futures.add(CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'passenger_id': encryptionHelper.encryptData(passengerId),
|
||||
'balance': ((-1) * double.parse(paymentAmount)).toString(),
|
||||
'token': paymentToken,
|
||||
}));
|
||||
@@ -704,11 +714,11 @@ class MapDriverController extends GetxController {
|
||||
|
||||
paymentToken = await generateTokenDriver(paymentAmount.toString());
|
||||
futures.add(CRUD().post(link: AppLink.addDrivePayment, payload: {
|
||||
'rideId': rideId,
|
||||
'rideId': encryptionHelper.encryptData(rideId),
|
||||
'amount': paymentAmount,
|
||||
'payment_method':
|
||||
walletChecked == 'true' ? "${paymentMethod}Ride" : paymentMethod,
|
||||
'passengerID': passengerId,
|
||||
'passengerID': encryptionHelper.encryptData(passengerId),
|
||||
'token': paymentToken,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
}));
|
||||
@@ -717,7 +727,7 @@ class MapDriverController extends GetxController {
|
||||
final paymentToken1 = await generateTokenPassenger(
|
||||
((-1) * double.parse(passengerWalletBurc)).toString());
|
||||
futures.add(CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'passenger_id': encryptionHelper.encryptData(passengerId),
|
||||
'token': paymentToken1,
|
||||
'balance': ((-1) * double.parse(passengerWalletBurc)).toString()
|
||||
}));
|
||||
@@ -727,7 +737,7 @@ class MapDriverController extends GetxController {
|
||||
final paymentToken2 =
|
||||
await generateTokenDriver((pointsSubtraction).toStringAsFixed(0));
|
||||
futures.add(CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'paymentID': 'rideId${encryptionHelper.encryptData(rideId)}',
|
||||
'amount': (pointsSubtraction).toStringAsFixed(0),
|
||||
'paymentMethod': paymentMethod,
|
||||
'token': paymentToken2,
|
||||
@@ -884,7 +894,7 @@ class MapDriverController extends GetxController {
|
||||
var res = await CRUD().get(
|
||||
link: "${AppLink.endPoint}/ride/driver_order/getOrderCancelStatus.php",
|
||||
payload: {
|
||||
'order_id': rideId,
|
||||
'order_id': encryptionHelper.encryptData(rideId),
|
||||
}); //.then((value) {
|
||||
var response = jsonDecode(res);
|
||||
canelString = response['data']['status'];
|
||||
|
||||
@@ -11,6 +11,7 @@ import '../../../constant/box_name.dart';
|
||||
import '../../../print.dart';
|
||||
import '../../functions/audio_controller.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
import 'home_captain_controller.dart';
|
||||
|
||||
@@ -210,17 +211,17 @@ class OrderRequestController extends GetxController {
|
||||
) async {
|
||||
await CRUD().postFromDialogue(link: AppLink.addDriverOrder, payload: {
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
'order_id': orderID,
|
||||
'order_id': (orderID),
|
||||
'status': 'Refused'
|
||||
});
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': orderID,
|
||||
'id': (orderID),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: '${AppLink.endPoint}/rides/update.php', payload: {
|
||||
'id': orderID,
|
||||
'id': (orderID),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
@@ -244,13 +245,13 @@ class OrderRequestController extends GetxController {
|
||||
String duration,
|
||||
) async {
|
||||
await CRUD().post(link: AppLink.addWaitingRide, payload: {
|
||||
'id': orderID,
|
||||
'id': (orderID),
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'passenger_id': (passengerId),
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
@@ -262,13 +263,13 @@ class OrderRequestController extends GetxController {
|
||||
CRUD().post(
|
||||
link: '${AppLink.endPoint}/notificationCaptain/addWaitingRide.php',
|
||||
payload: {
|
||||
'id': orderID,
|
||||
'id': (orderID),
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'passenger_id': (passengerId),
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
|
||||
Reference in New Issue
Block a user