From a893e492826d17803dcdb4e9be34e11c297dcf4a Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Mon, 13 Jan 2025 22:10:47 +0300 Subject: [PATCH] 25-1/13/1-securejordan --- android/app/build.gradle | 4 +- bubble-master/android/build.gradle | 2 +- ios/Runner/Info.plist | 4 +- lib/constant/box_name.dart | 1 + lib/constant/links.dart | 13 +- .../auth/captin/history_captain.dart | 6 +- .../auth/captin/invit_controller.dart | 36 ++-- .../auth/captin/login_captin_controller.dart | 97 +++++---- .../captin/register_captin_controller.dart | 41 ++-- lib/controller/auth/google_sign.dart | 19 +- lib/controller/firebase/firbase_messge.dart | 3 +- lib/controller/functions/crud.dart | 6 + lib/controller/functions/device_info.dart | 82 ++++++-- lib/controller/functions/encrypt_decrypt.dart | 52 +++++ lib/controller/functions/face_detect.dart | 5 +- lib/controller/functions/gemeni.dart | 188 +++++++++++------- .../functions/location_controller.dart | 127 +++++++----- lib/controller/functions/log_out.dart | 16 +- lib/controller/functions/secure_storage.dart | 39 ++-- .../functions/sms_egypt_controller.dart | 12 +- lib/controller/functions/upload_image.dart | 7 +- .../home/captin/help/help_controller.dart | 3 +- .../home/captin/map_driver_controller.dart | 82 ++++---- .../home/captin/order_request_controller.dart | 15 +- .../auth/captin/cards/egypt_card_a_i.dart | 86 +++++--- .../auth/captin/invite_driver_screen.dart | 27 ++- .../home/Captin/history/history_captain.dart | 13 +- .../Captin/history/history_details_page.dart | 30 ++- .../Captin/home_captain/drawer_captain.dart | 9 +- .../Captin/home_captain/help_captain.dart | 15 +- .../help_details_replay_page.dart | 15 +- .../home/Captin/home_captain/home_captin.dart | 33 +-- .../Captin/home_captain/widget/connect.dart | 54 ++--- .../widget/left_menu_map_captain.dart | 53 +++-- .../orderCaptin/order_request_page.dart | 25 ++- .../home/profile/cars_inserting_page.dart | 30 ++- 36 files changed, 803 insertions(+), 447 deletions(-) create mode 100644 lib/controller/functions/encrypt_decrypt.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index bcd4137..4629d02 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -55,8 +55,8 @@ android { // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdk = 23 targetSdk = flutter.targetSdkVersion - versionCode = 128 - versionName = '1.5.28' + versionCode = 129 + versionName = '1.5.29' multiDexEnabled =true } diff --git a/bubble-master/android/build.gradle b/bubble-master/android/build.gradle index 328bd9b..a5d8c0b 100755 --- a/bubble-master/android/build.gradle +++ b/bubble-master/android/build.gradle @@ -23,7 +23,7 @@ apply plugin: 'com.android.library' android { namespace 'com.dsaved.bubblehead.bubble' - compileSdkVersion 30 + compileSdkVersion 33 defaultConfig { minSdkVersion 16 diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 7698285..0c244ef 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -35,7 +35,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 86 + 87 CFBundleSignature ???? CFBundleURLTypes @@ -50,7 +50,7 @@ CFBundleVersion - 4.0.86 + 4.0.87 FirebaseAppDelegateProxyEnabled NO GMSApiKey diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index e552c81..20d6a20 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -10,6 +10,7 @@ class BoxName { static const String bodyOrder = "bodyOrder"; static const String gender = "gender"; static const String phoneWallet = "phoneWallet"; + static const String locationName = "locationName"; static const String isSavedPhones = "IsSavedPhones"; static const String isTest = "isTest"; static const String carType = "carType"; diff --git a/lib/constant/links.dart b/lib/constant/links.dart index 00299ef..bc6b41b 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -5,10 +5,9 @@ import 'box_name.dart'; class AppLink { static String serverPHP = box.read('serverPHP'); - static String seferCairoServer = box.read('seferCairoServer'); - static String seferGizaServer = box.read('seferGizaServer'); - static String seferAlexandriaServer = box.read('seferAlexandriaServer'); - static String seferPaymentServer = box.read('seferPaymentServer'); + + static String seferPaymentServer = + 'https://wallet.sefer.live/seferpw.shop/sefer/'; static String seferPaymentServer0 = box.read('seferPaymentServer'); // static final String seferPaymentServer0 = Env.seferPaymentServer; // static final String seferPaymentServer = '${Env.seferPaymentServer}/ride'; @@ -24,7 +23,9 @@ class AppLink { // static final String seferGizaServer = Env.seferGizaServer; static final String endPoint = box.read(BoxName.serverChosen); static final String server = endPoint; - + static String seferCairoServer = endPoint; + static String seferGizaServer = box.read('seferGizaServer'); + static String seferAlexandriaServer = box.read('seferAlexandriaServer'); // static final String server = Env.serverPHP; static String googleMapsLink = 'https://maps.googleapis.com/maps/api/'; @@ -240,6 +241,8 @@ class AppLink { static String location = '$endPoint/ride/location'; static String getCarsLocationByPassenger = "$location/get.php"; static String addpassengerLocation = "$location/addpassengerLocation.php"; + static String getLocationAreaLinks = + "https://server.sefer.live/sefer.click/sefer/ride/location/get_location_area_links.php"; static String getLatestLocationPassenger = "$location/getLatestLocationPassenger.php"; static String getFemalDriverLocationByPassenger = diff --git a/lib/controller/auth/captin/history_captain.dart b/lib/controller/auth/captin/history_captain.dart index 35b13f2..82e9011 100644 --- a/lib/controller/auth/captin/history_captain.dart +++ b/lib/controller/auth/captin/history_captain.dart @@ -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(); diff --git a/lib/controller/auth/captin/invit_controller.dart b/lib/controller/auth/captin/invit_controller.dart index e39a57f..077914e 100644 --- a/lib/controller/auth/captin/invit_controller.dart +++ b/lib/controller/auth/captin/invit_controller.dart @@ -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().addDriverPayment( 'paymentMethod', - '500', + encryptionHelper.encryptData('500'), '', ); // add for invitor too await Get.find().addDriverWalletToInvitor( 'paymentMethod', - driverInvitationData[index]['driverInviterId'], - '500', + encryptionHelper + .encryptData(driverInvitationData[index]['driverInviterId']), + encryptionHelper.encryptData('500'), ); - await Get.find() - .addSeferWallet('giftInvitation', '-1000'); + await Get.find().addSeferWallet( + 'giftInvitation', encryptionHelper.encryptData('-1000')); NotificationCaptainController().addNotificationCaptain( driverInvitationData[index]['driverInviterId'].toString(), "You have got a gift for invitation".tr, diff --git a/lib/controller/auth/captin/login_captin_controller.dart b/lib/controller/auth/captin/login_captin_controller.dart index 1b8b877..21f76a1 100644 --- a/lib/controller/auth/captin/login_captin_controller.dart +++ b/lib/controller/auth/captin/login_captin_controller.dart @@ -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(); @@ -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( diff --git a/lib/controller/auth/captin/register_captin_controller.dart b/lib/controller/auth/captin/register_captin_controller.dart index 5a15351..5ed8d52 100644 --- a/lib/controller/auth/captin/register_captin_controller.dart +++ b/lib/controller/auth/captin/register_captin_controller.dart @@ -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().emailController.text.toString() - : emailController.text, - 'token': verifyCode.text, + ? encryptionHelper.encryptData( + Get.find().emailController.text.toString()) + : encryptionHelper.encryptData(emailController.text), + 'token': encryptionHelper.encryptData(verifyCode.text), }); if (res != 'failure') { diff --git a/lib/controller/auth/google_sign.dart b/lib/controller/auth/google_sign.dart index 0899569..ff5db07 100644 --- a/lib/controller/auth/google_sign.dart +++ b/lib/controller/auth/google_sign.dart @@ -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 _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 diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 20fa060..d2f1f32 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -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) { diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index 92866c9..e9a9a02 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -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') { diff --git a/lib/controller/functions/device_info.dart b/lib/controller/functions/device_info.dart index 9dcfbdc..dac977b 100644 --- a/lib/controller/functions/device_info.dart +++ b/lib/controller/functions/device_info.dart @@ -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 toJson() => { + 'manufacturer': manufacturer, + 'model': model, + 'deviceId': deviceId, + 'osVersion': osVersion, + 'platform': platform, + 'deviceName': deviceName, + 'isPhysicalDevice': isPhysicalDevice, + }; +} + +class DeviceController { + final box = GetStorage(); + final _deviceInfo = DeviceInfoPlugin(); + + Future 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 _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 _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; } } diff --git a/lib/controller/functions/encrypt_decrypt.dart b/lib/controller/functions/encrypt_decrypt.dart new file mode 100644 index 0000000..7c64fbb --- /dev/null +++ b/lib/controller/functions/encrypt_decrypt.dart @@ -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 ''; + } + } +} diff --git a/lib/controller/functions/face_detect.dart b/lib/controller/functions/face_detect.dart index 798307b..9b10461 100644 --- a/lib/controller/functions/face_detect.dart +++ b/lib/controller/functions/face_detect.dart @@ -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 faceDetector() async { @@ -23,9 +24,9 @@ Future 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); diff --git a/lib/controller/functions/gemeni.dart b/lib/controller/functions/gemeni.dart index c939179..f90fd68 100644 --- a/lib/controller/functions/gemeni.dart +++ b/lib/controller/functions/gemeni.dart @@ -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(), diff --git a/lib/controller/functions/location_controller.dart b/lib/controller/functions/location_controller.dart index d186044..e73c926 100644 --- a/lib/controller/functions/location_controller.dart +++ b/lib/controller/functions/location_controller.dart @@ -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; + + // 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 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() .mapHomeCaptainController diff --git a/lib/controller/functions/log_out.dart b/lib/controller/functions/log_out.dart index 8010ffb..6fb3021 100644 --- a/lib/controller/functions/log_out.dart +++ b/lib/controller/functions/log_out.dart @@ -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); } })); } diff --git a/lib/controller/functions/secure_storage.dart b/lib/controller/functions/secure_storage.dart index 5342d16..926e405 100644 --- a/lib/controller/functions/secure_storage.dart +++ b/lib/controller/functions/secure_storage.dart @@ -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 keysToFetch = [ ]; class AppInitializer { - // final FlutterSecureStorage _storage = const FlutterSecureStorage(); + List> links = []; Future 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 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 getKey() async { + try { + var res = + await CRUD().get(link: AppLink.getLocationAreaLinks, payload: {}); + Log.print('res: ${res}'); + if (res != 'failure') { + links = List>.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; } } diff --git a/lib/controller/functions/sms_egypt_controller.dart b/lib/controller/functions/sms_egypt_controller.dart index 5c76968..39c4f58 100644 --- a/lib/controller/functions/sms_egypt_controller.dart +++ b/lib/controller/functions/sms_egypt_controller.dart @@ -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().phoneController.text}' + "phone_number": encryptionHelper.encryptData( + '+2${Get.find().phoneController.text}') }); - box.write(BoxName.phoneDriver, - '+2${Get.find().phoneController.text}'); + box.write( + BoxName.phoneDriver, + encryptionHelper.encryptData( + '+2${Get.find().phoneController.text}')); box.write(BoxName.phoneVerified, '1'); await Get.put(LoginDriverController()).loginWithGoogleCredential( diff --git a/lib/controller/functions/upload_image.dart b/lib/controller/functions/upload_image.dart index 19b3cd1..8b3beb2 100644 --- a/lib/controller/functions/upload_image.dart +++ b/lib/controller/functions/upload_image.dart @@ -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) { diff --git a/lib/controller/home/captin/help/help_controller.dart b/lib/controller/home/captin/help/help_controller.dart index eb8ad7d..2f91130 100644 --- a/lib/controller/home/captin/help/help_controller.dart +++ b/lib/controller/home/captin/help/help_controller.dart @@ -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; diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index 7c0d563..a171dd3 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -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().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().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']; diff --git a/lib/controller/home/captin/order_request_controller.dart b/lib/controller/home/captin/order_request_controller.dart index c09b4cc..fbf71d7 100644 --- a/lib/controller/home/captin/order_request_controller.dart +++ b/lib/controller/home/captin/order_request_controller.dart @@ -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, diff --git a/lib/views/auth/captin/cards/egypt_card_a_i.dart b/lib/views/auth/captin/cards/egypt_card_a_i.dart index 9e3fff2..f83d69c 100644 --- a/lib/views/auth/captin/cards/egypt_card_a_i.dart +++ b/lib/views/auth/captin/cards/egypt_card_a_i.dart @@ -10,6 +10,7 @@ import 'package:url_launcher/url_launcher.dart'; import '../../../../constant/colors.dart'; import '../../../../constant/links.dart'; import '../../../../constant/style.dart'; +import '../../../../controller/functions/encrypt_decrypt.dart'; import '../../../../controller/functions/package_info.dart'; import '../../../../main.dart'; import '../../../widgets/my_scafold.dart'; @@ -321,7 +322,8 @@ class EgyptCardAI extends StatelessWidget { IconButton( onPressed: () async { await ai.allMethodForAI( - ai.prompts[0]['prompt'].toString(), + encryptionHelper.encryptData( + ai.prompts[0]['prompt'].toString()), AppLink.uploadEgypt, 'driver_license'); //egypt }, @@ -382,8 +384,11 @@ class EgyptCardAI extends StatelessWidget { return Card( child: InkWell( onTap: () async { - await ai.allMethodForAI(ai.prompts[0]['prompt'].toString(), - AppLink.uploadEgypt, 'driver_license'); //egypt + await ai.allMethodForAI( + encryptionHelper + .encryptData(ai.prompts[0]['prompt'].toString()), + AppLink.uploadEgypt, + 'driver_license'); //egypt }, child: Column( children: [ @@ -436,7 +441,8 @@ class EgyptCardAI extends StatelessWidget { IconButton( onPressed: () async { await ai.allMethodForAI( - ai.prompts[1]['prompt'].toString(), + encryptionHelper.encryptData( + ai.prompts[1]['prompt'].toString()), AppLink.uploadEgypt, 'id_back'); //egypt }, @@ -506,8 +512,11 @@ class EgyptCardAI extends StatelessWidget { return Card( child: InkWell( onTap: () async { - await ai.allMethodForAI(ai.prompts[1]['prompt'].toString(), - AppLink.uploadEgypt, 'id_back'); //egypt + await ai.allMethodForAI( + encryptionHelper + .encryptData(ai.prompts[1]['prompt'].toString()), + AppLink.uploadEgypt, + 'id_back'); //egypt }, child: Column( children: [ @@ -558,7 +567,9 @@ class EgyptCardAI extends StatelessWidget { IconButton( onPressed: () async { await ai.allMethodForAI( - ai.prompts[7]['prompt'].toString(), + encryptionHelper.decryptData( + encryptionHelper.encryptData( + ai.prompts[7]['prompt'].toString())), AppLink.uploadEgypt, 'non_id_back'); }, @@ -609,8 +620,11 @@ class EgyptCardAI extends StatelessWidget { return Card( child: InkWell( onTap: () async { - await ai.allMethodForAI(ai.prompts[7]['prompt'].toString(), - AppLink.uploadEgypt, 'non_id_back'); + await ai.allMethodForAI( + encryptionHelper + .encryptData(ai.prompts[7]['prompt'].toString()), + AppLink.uploadEgypt, + 'non_id_back'); }, child: Column( children: [ @@ -653,7 +667,8 @@ class EgyptCardAI extends StatelessWidget { IconButton( onPressed: () async { await ai.allMethodForAI( - ai.prompts[2]['id_front'].toString(), + encryptionHelper.encryptData( + ai.prompts[2]['id_front'].toString()), AppLink.uploadEgypt, 'id_front'); //egypt }, @@ -708,8 +723,11 @@ class EgyptCardAI extends StatelessWidget { return Card( child: InkWell( onTap: () async { - await ai.allMethodForAI(ai.prompts[2]['prompt'].toString(), - AppLink.uploadEgypt, 'id_front'); //egypt + await ai.allMethodForAI( + encryptionHelper + .encryptData(ai.prompts[2]['prompt'].toString()), + AppLink.uploadEgypt, + 'id_front'); //egypt }, child: Column( children: [ @@ -752,7 +770,8 @@ class EgyptCardAI extends StatelessWidget { IconButton( onPressed: () async { await ai.allMethodForAI( - ai.prompts[6]['prompt'].toString(), + encryptionHelper.encryptData( + ai.prompts[6]['prompt'].toString()), AppLink.uploadEgypt, 'non_id_front'); }, @@ -807,8 +826,11 @@ class EgyptCardAI extends StatelessWidget { return Card( child: InkWell( onTap: () async { - await ai.allMethodForAI(ai.prompts[6]['prompt'].toString(), - AppLink.uploadEgypt, 'non_id_front'); + await ai.allMethodForAI( + encryptionHelper + .encryptData(ai.prompts[6]['prompt'].toString()), + AppLink.uploadEgypt, + 'non_id_front'); }, child: Column( children: [ @@ -858,8 +880,11 @@ class EgyptCardAI extends StatelessWidget { style: AppStyle.headTitle2), IconButton( onPressed: () async { - ai.allMethodForAI(ai.prompts[3]['prompt'].toString(), - AppLink.uploadEgypt, 'car_front'); + ai.allMethodForAI( + encryptionHelper.encryptData( + ai.prompts[3]['prompt'].toString()), + AppLink.uploadEgypt, + 'car_front'); }, icon: const Icon(Icons.refresh), ), @@ -903,8 +928,11 @@ class EgyptCardAI extends StatelessWidget { return Card( child: InkWell( onTap: () async { - ai.allMethodForAI(ai.prompts[3]['prompt'].toString(), - AppLink.uploadEgypt, 'car_front'); + ai.allMethodForAI( + encryptionHelper + .encryptData(ai.prompts[3]['prompt'].toString()), + AppLink.uploadEgypt, + 'car_front'); }, child: Column( children: [ @@ -971,8 +999,11 @@ class EgyptCardAI extends StatelessWidget { style: AppStyle.headTitle2), IconButton( onPressed: () async { - ai.allMethodForAI(ai.prompts[4]['prompt'].toString(), - AppLink.uploadEgypt, 'car_back'); + ai.allMethodForAI( + encryptionHelper.encryptData( + ai.prompts[4]['prompt'].toString()), + AppLink.uploadEgypt, + 'car_back'); }, icon: const Icon(Icons.refresh), ), @@ -1042,8 +1073,11 @@ class EgyptCardAI extends StatelessWidget { return Card( child: InkWell( onTap: () async { - ai.allMethodForAI(ai.prompts[4]['prompt'].toString(), - AppLink.uploadEgypt, 'car_back'); + ai.allMethodForAI( + encryptionHelper + .encryptData(ai.prompts[4]['prompt'].toString()), + AppLink.uploadEgypt, + 'car_back'); }, child: Column( children: [ @@ -1086,7 +1120,8 @@ class EgyptCardAI extends StatelessWidget { IconButton( onPressed: () async { await ai.allMethodForAI( - ai.prompts[5]['prompt'].toString(), + encryptionHelper.encryptData( + ai.prompts[5]['prompt'].toString()), AppLink.uploadEgypt, 'criminalRecord', ); @@ -1124,7 +1159,8 @@ class EgyptCardAI extends StatelessWidget { child: InkWell( onTap: () async { await ai.allMethodForAI( - ai.prompts[5]['prompt'].toString(), + encryptionHelper + .encryptData(ai.prompts[5]['prompt'].toString()), AppLink.uploadEgypt, 'criminalRecord', ); diff --git a/lib/views/auth/captin/invite_driver_screen.dart b/lib/views/auth/captin/invite_driver_screen.dart index 2c689de..6596dd6 100644 --- a/lib/views/auth/captin/invite_driver_screen.dart +++ b/lib/views/auth/captin/invite_driver_screen.dart @@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import '../../../controller/auth/captin/invit_controller.dart'; +import '../../../controller/functions/encrypt_decrypt.dart'; class InviteScreen extends StatelessWidget { final InviteController controller = Get.put(InviteController()); @@ -367,8 +368,9 @@ class InviteScreen extends StatelessWidget { } Widget _buildInvitationItem(BuildContext context, int index) { - int countOfInvitDriver = int.tryParse(controller.driverInvitationData[index] - ['countOfInvitDriver'] + int countOfInvitDriver = int.tryParse(encryptionHelper + .decryptData(controller.driverInvitationData[index] + ['countOfInvitDriver']) ?.toString() ?? '0') ?? 0; @@ -389,7 +391,8 @@ class InviteScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - controller.driverInvitationData[index]['invitorName'], + encryptionHelper.decryptData( + controller.driverInvitationData[index]['invitorName']), style: const TextStyle( fontSize: 17, fontWeight: FontWeight.w600, @@ -425,8 +428,11 @@ class InviteScreen extends StatelessWidget { // Extracting the data from the sample JSON-like structure var invitation = controller.driverInvitationDataToPassengers[index]; - int countOfInvitDriver = - int.tryParse(invitation['countOfInvitDriver']?.toString() ?? '0') ?? 0; + int countOfInvitDriver = int.tryParse(encryptionHelper + .decryptData(invitation['countOfInvitDriver']) + ?.toString() ?? + '0') ?? + 0; double progressValue = (countOfInvitDriver / 10.0).clamp(0.0, 1.0); return GestureDetector( @@ -444,7 +450,8 @@ class InviteScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - invitation['passengerName'] + encryptionHelper + .decryptData(invitation['passengerName']) .toString(), // Handle null or missing data style: const TextStyle( fontSize: 17, @@ -499,13 +506,17 @@ class InviteScreen extends StatelessWidget { _buildStatItem( context, "Total Invites".tr, - controller.driverInvitationDataToPassengers[0]['countOfInvitDriver'] + encryptionHelper + .decryptData(controller.driverInvitationDataToPassengers[0] + ['countOfInvitDriver']) .toString(), ), _buildStatItem( context, "Active Users".tr, - controller.driverInvitationDataToPassengers[0]['passengerName'] + encryptionHelper + .decryptData(controller.driverInvitationDataToPassengers[0] + ['passengerName']) .toString(), ), ], diff --git a/lib/views/home/Captin/history/history_captain.dart b/lib/views/home/Captin/history/history_captain.dart index 4a67023..b60d128 100644 --- a/lib/views/home/Captin/history/history_captain.dart +++ b/lib/views/home/Captin/history/history_captain.dart @@ -6,6 +6,8 @@ import '../../../../controller/auth/captin/history_captain.dart'; import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; +import '../../../../controller/functions/encrypt_decrypt.dart'; + class HistoryCaptain extends StatelessWidget { const HistoryCaptain({super.key}); @@ -78,7 +80,8 @@ class HistoryCaptain extends StatelessWidget { .navTitleTextStyle, ), Text( - list['order_id'], + encryptionHelper + .decryptData(list['order_id']), style: CupertinoTheme.of(context) .textTheme .textStyle, @@ -105,14 +108,18 @@ class HistoryCaptain extends StatelessWidget { ), Text( list['status'], - style: list['status'] == 'Apply' + style: encryptionHelper.decryptData( + list['status']) == + 'Apply' ? CupertinoTheme.of(context) .textTheme .navTitleTextStyle .copyWith( color: CupertinoColors .systemGreen) - : list['status'] == 'Refused' + : encryptionHelper.decryptData( + list['status']) == + 'Refused' ? CupertinoTheme.of(context) .textTheme .navTitleTextStyle diff --git a/lib/views/home/Captin/history/history_details_page.dart b/lib/views/home/Captin/history/history_details_page.dart index 8b31d42..3f15d59 100644 --- a/lib/views/home/Captin/history/history_details_page.dart +++ b/lib/views/home/Captin/history/history_details_page.dart @@ -7,6 +7,8 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:flutter/cupertino.dart'; +import '../../../../controller/functions/encrypt_decrypt.dart'; + class HistoryDetailsPage extends StatelessWidget { HistoryDetailsPage({super.key}); HistoryCaptainController historyCaptainController = @@ -44,7 +46,7 @@ class HistoryDetailsPage extends StatelessWidget { CupertinoButton( onPressed: () { String mapUrl = - 'https://www.google.com/maps/dir/${res['start_location']}/${res['end_location']}/'; + 'https://www.google.com/maps/dir/${encryptionHelper.decryptData(res['start_location'])}/${encryptionHelper.decryptData(res['end_location'])}/'; showInBrowser(mapUrl); }, child: Container( @@ -77,18 +79,26 @@ class HistoryDetailsPage extends StatelessWidget { polylineId: const PolylineId('route'), points: [ LatLng( - double.parse(res['start_location'] + double.parse(encryptionHelper + .decryptData( + res['start_location']) .toString() .split(',')[0]), - double.parse(res['start_location'] + double.parse(encryptionHelper + .decryptData( + res['start_location']) .toString() .split(',')[1]), ), LatLng( - double.parse(res['end_location'] + double.parse(encryptionHelper + .decryptData( + res['end_location']) .toString() .split(',')[0]), - double.parse(res['end_location'] + double.parse(encryptionHelper + .decryptData( + res['end_location']) .toString() .split(',')[1]), ) @@ -105,7 +115,7 @@ class HistoryDetailsPage extends StatelessWidget { MainAxisAlignment.spaceBetween, children: [ Text( - '${'Order ID'.tr} ${res['id']}', + '${'Order ID'.tr} ${encryptionHelper.decryptData(res['id'])}', style: CupertinoTheme.of(context) .textTheme .navActionTextStyle, @@ -135,13 +145,13 @@ class HistoryDetailsPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '${'Price is'.tr} ${res['price_for_driver']}', + '${'Price is'.tr} ${encryptionHelper.decryptData(res['price_for_driver'])}', style: CupertinoTheme.of(context) .textTheme .textStyle, ), Text( - '${'Distance is'.tr} ${res['distance']} KM', + '${'Distance is'.tr} ${encryptionHelper.decryptData(res['distance'])} KM', style: CupertinoTheme.of(context) .textTheme .textStyle, @@ -200,7 +210,7 @@ class HistoryDetailsPage extends StatelessWidget { ), child: Center( child: Text( - '${'Passenger Name is'.tr} ${res['first_name']} ${res['last_name']}', + '${'Passenger Name is'.tr} ${encryptionHelper.decryptData(res['first_name'])} ${encryptionHelper.decryptData(res['last_name'])}', style: CupertinoTheme.of(context) .textTheme .textStyle, @@ -219,7 +229,7 @@ class HistoryDetailsPage extends StatelessWidget { ), child: Center( child: Text( - '${'Status is'.tr} ${res['status']}', + '${'Status is'.tr} ${encryptionHelper.decryptData(res['status'])}', style: CupertinoTheme.of(context) .textTheme .textStyle, diff --git a/lib/views/home/Captin/home_captain/drawer_captain.dart b/lib/views/home/Captin/home_captain/drawer_captain.dart index 458328d..68b42bb 100644 --- a/lib/views/home/Captin/home_captain/drawer_captain.dart +++ b/lib/views/home/Captin/home_captain/drawer_captain.dart @@ -1,6 +1,7 @@ import 'package:sefer_driver/constant/api_key.dart'; import 'package:sefer_driver/constant/links.dart'; import 'package:sefer_driver/constant/style.dart'; +import 'package:sefer_driver/controller/functions/encrypt_decrypt.dart'; import 'package:sefer_driver/controller/home/captin/home_captain_controller.dart'; import 'package:sefer_driver/views/Rate/rate_app_page.dart'; import 'package:sefer_driver/views/auth/captin/contact_us_page.dart'; @@ -485,7 +486,7 @@ class UserAccountHeader extends StatelessWidget { : ClipRRect( borderRadius: BorderRadius.circular(50), child: Image.network( - '${AppLink.seferCairoServer}/portrate_captain_image/${box.read(BoxName.driverID)}.jpg', + '${AppLink.seferCairoServer}/portrate_captain_image/${encryptionHelper.decryptData(box.read(BoxName.driverID))}.jpg', fit: BoxFit.cover, ), ), @@ -519,7 +520,7 @@ class UserAccountHeader extends StatelessWidget { ), const SizedBox(height: 16), Text( - '${box.read(BoxName.nameDriver).toString().split(' ')[0]} ${box.read(BoxName.nameDriver).toString().split(' ')[1]}', + box.read(BoxName.nameDriver).toString(), style: const TextStyle( color: Colors.white, fontSize: 24, @@ -535,7 +536,9 @@ class UserAccountHeader extends StatelessWidget { ), const SizedBox(height: 4), Text( - box.read(BoxName.emailDriver), + encryptionHelper.decryptData( + box.read(BoxName.emailDriver), + ), style: TextStyle( color: Colors.white.withOpacity(0.9), fontSize: 14, diff --git a/lib/views/home/Captin/home_captain/help_captain.dart b/lib/views/home/Captin/home_captain/help_captain.dart index 09e10ab..9f431f6 100644 --- a/lib/views/home/Captin/home_captain/help_captain.dart +++ b/lib/views/home/Captin/home_captain/help_captain.dart @@ -4,11 +4,8 @@ import 'package:sefer_driver/controller/home/captin/help/help_controller.dart'; import 'package:sefer_driver/views/home/Captin/home_captain/help_details_replay_page.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:sefer_driver/controller/home/captin/help/help_controller.dart'; -import 'package:sefer_driver/views/home/Captin/home_captain/help_details_replay_page.dart'; + +import '../../../../controller/functions/encrypt_decrypt.dart'; class HelpCaptain extends StatelessWidget { HelpCaptain({super.key}); @@ -128,7 +125,8 @@ class HelpCaptain extends StatelessWidget { .helpQuestionDate['message'][index]; return CupertinoListTile( title: Text( - list['helpQuestion'], + encryptionHelper + .decryptData(list['helpQuestion']), overflow: TextOverflow.ellipsis, ), trailing: Row( @@ -145,7 +143,10 @@ class HelpCaptain extends StatelessWidget { ), onTap: () { helpController.getIndex( - list['id'], list['helpQuestion']); + int.parse(encryptionHelper + .decryptData(list['id'])), + encryptionHelper + .decryptData(list['helpQuestion'])); helpController .getHelpRepley(list['id'].toString()); Get.to(() => const HelpDetailsReplayPage()); diff --git a/lib/views/home/Captin/home_captain/help_details_replay_page.dart b/lib/views/home/Captin/home_captain/help_details_replay_page.dart index fc655b6..c277f25 100644 --- a/lib/views/home/Captin/home_captain/help_details_replay_page.dart +++ b/lib/views/home/Captin/home_captain/help_details_replay_page.dart @@ -3,6 +3,7 @@ import 'package:get/get.dart'; import 'package:sefer_driver/constant/style.dart'; import 'package:sefer_driver/views/widgets/mycircular.dart'; +import '../../../../controller/functions/encrypt_decrypt.dart'; import '../../../../controller/home/captin/help/help_controller.dart'; import '../../../widgets/my_scafold.dart'; @@ -53,9 +54,10 @@ class HelpDetailsReplayPage extends StatelessWidget { padding: const EdgeInsets.all(8.0), child: helpController.status == 'not yet' || - helpController - .helpQuestionRepleyDate[ - 'message']['replay'] + encryptionHelper + .decryptData(helpController + .helpQuestionRepleyDate[ + 'message']['replay']) .toString() == 'not yet' ? Text( @@ -63,9 +65,10 @@ class HelpDetailsReplayPage extends StatelessWidget { style: AppStyle.title, ) : Text( - helpController - .helpQuestionRepleyDate[ - 'message']['replay'] + encryptionHelper + .decryptData(helpController + .helpQuestionRepleyDate[ + 'message']['replay']) .toString(), style: AppStyle.title, ), diff --git a/lib/views/home/Captin/home_captain/home_captin.dart b/lib/views/home/Captin/home_captain/home_captin.dart index cc62d95..cb4c046 100644 --- a/lib/views/home/Captin/home_captain/home_captin.dart +++ b/lib/views/home/Captin/home_captain/home_captin.dart @@ -15,6 +15,7 @@ import 'package:bubble_head/bubble.dart'; import '../../../../constant/colors.dart'; import '../../../../constant/info.dart'; import '../../../../constant/style.dart'; +import '../../../../controller/functions/encrypt_decrypt.dart'; import '../../../../controller/functions/location_controller.dart'; import '../../../../controller/functions/overlay_permisssion.dart'; import '../../../../controller/functions/package_info.dart'; @@ -73,7 +74,7 @@ class HomeCaptain extends StatelessWidget { ), const SizedBox(width: 8), Text( - 'SEFER'.tr, + AppInformation.appName.split(' ')[0].toString().tr, style: AppStyle.title.copyWith( fontSize: 22, fontWeight: FontWeight.w600, @@ -228,7 +229,7 @@ class HomeCaptain extends StatelessWidget { ), const SizedBox(width: 8), Text( - '${"Today".tr}: ${homeCaptainController.totalMoneyToday}', + '${"Today".tr}: ${encryptionHelper.decryptData(homeCaptainController.totalMoneyToday)}', style: AppStyle.title.copyWith( color: AppColor.greenColor, fontWeight: FontWeight.bold, @@ -252,7 +253,7 @@ class HomeCaptain extends StatelessWidget { ), const SizedBox(width: 8), Text( - '${AppInformation.appName}: ${homeCaptainController.totalMoneyInSEFER}', + '${AppInformation.appName}: ${encryptionHelper.decryptData(homeCaptainController.totalMoneyInSEFER)}', style: AppStyle.title.copyWith( color: AppColor.yellowColor, fontWeight: FontWeight.bold, @@ -267,7 +268,7 @@ class HomeCaptain extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '${'Total Points is'.tr}: ${homeCaptainController.totalPoints}', + '${'Total Points is'.tr}: ${encryptionHelper.decryptData(homeCaptainController.totalPoints)}', style: AppStyle.title.copyWith( fontSize: 16, fontWeight: FontWeight.w600, @@ -278,15 +279,19 @@ class HomeCaptain extends StatelessWidget { horizontal: 12, vertical: 6), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), - color: int.parse(homeCaptainController - .countRideToday) < + color: int.parse(encryptionHelper.decryptData( + homeCaptainController + .countRideToday)) < 5 ? AppColor.accentColor - : int.parse(homeCaptainController - .countRideToday) > + : int.parse(encryptionHelper.decryptData( + homeCaptainController + .countRideToday)) > 5 && - int.parse(homeCaptainController - .countRideToday) < + int.parse( + encryptionHelper.decryptData( + homeCaptainController + .countRideToday)) < 10 ? AppColor.yellowColor : AppColor.greenColor, @@ -300,7 +305,7 @@ class HomeCaptain extends StatelessWidget { ), const SizedBox(width: 4), Text( - '${"Ride Today : ".tr}: ${homeCaptainController.countRideToday}', + '${"Ride Today : ".tr}: ${encryptionHelper.decryptData(homeCaptainController.countRideToday)}', style: AppStyle.title.copyWith( color: Colors.white, fontWeight: FontWeight.bold, @@ -351,7 +356,8 @@ class HomeCaptain extends StatelessWidget { ), const SizedBox(width: 4), Text( - homeCaptainController.stringActiveDuration, + encryptionHelper.decryptData( + homeCaptainController.stringActiveDuration), style: AppStyle.title.copyWith( fontWeight: FontWeight.bold, color: AppColor.greenColor, @@ -372,7 +378,8 @@ class HomeCaptain extends StatelessWidget { ), const SizedBox(width: 4), Text( - homeCaptainController.totalDurationToday, + encryptionHelper.decryptData( + homeCaptainController.totalDurationToday), style: AppStyle.title.copyWith( fontWeight: FontWeight.bold, color: AppColor.accentColor, diff --git a/lib/views/home/Captin/home_captain/widget/connect.dart b/lib/views/home/Captin/home_captain/widget/connect.dart index 3fe3d90..aad54f8 100644 --- a/lib/views/home/Captin/home_captain/widget/connect.dart +++ b/lib/views/home/Captin/home_captain/widget/connect.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:sefer_driver/controller/home/payment/captain_wallet_controller.dart'; import '../../../../../constant/style.dart'; +import '../../../../../controller/functions/encrypt_decrypt.dart'; import '../../../../widgets/elevated_btn.dart'; import '../../../../../controller/home/captin/home_captain_controller.dart'; @@ -23,26 +24,27 @@ class ConnectWidget extends StatelessWidget { captainWalletController.getCaptainWalletFromBuyPoints(); return Center( child: GetBuilder( - builder: (homeCaptainController) => double.parse( - captainWalletController.totalPoints) < + builder: (homeCaptainController) => double.parse(encryptionHelper + .decryptData(captainWalletController.totalPoints)) < -300 ? CupertinoButton( onPressed: () { Get.defaultDialog( // backgroundColor: CupertinoColors.destructiveRed, barrierDismissible: false, - title: - double.parse(captainWalletController.totalPoints) < - -300 - ? 'You dont have Points'.tr - : 'You Are Stopped For this Day !'.tr, + title: double.parse(encryptionHelper.decryptData( + captainWalletController.totalPoints)) < + -300 + ? 'You dont have Points'.tr + : 'You Are Stopped For this Day !'.tr, titleStyle: AppStyle.title, content: Column( children: [ IconButton( onPressed: () async { - double.parse(captainWalletController - .totalPoints) < + double.parse(encryptionHelper.decryptData( + captainWalletController + .totalPoints)) < -300 ? await Get.find() .speakText( @@ -56,8 +58,9 @@ class ConnectWidget extends StatelessWidget { icon: const Icon(Icons.headphones), ), Text( - double.parse( - captainWalletController.totalPoints) < + double.parse(encryptionHelper.decryptData( + captainWalletController + .totalPoints)) < -300 ? 'You must be recharge your Account'.tr : 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!' @@ -66,21 +69,20 @@ class ConnectWidget extends StatelessWidget { ), ], ), - confirm: - double.parse(captainWalletController.totalPoints) < - -300 - ? MyElevatedButton( - title: 'Recharge my Account'.tr, - onPressed: () { - homeCaptainController - .goToWalletFromConnect(); - }) - : MyElevatedButton( - title: 'Ok , See you Tomorrow'.tr, - onPressed: () { - Get.back(); - Get.back(); - })); + confirm: double.parse(encryptionHelper.decryptData( + captainWalletController.totalPoints)) < + -300 + ? MyElevatedButton( + title: 'Recharge my Account'.tr, + onPressed: () { + homeCaptainController.goToWalletFromConnect(); + }) + : MyElevatedButton( + title: 'Ok , See you Tomorrow'.tr, + onPressed: () { + Get.back(); + Get.back(); + })); }, color: CupertinoColors.destructiveRed, child: Text( diff --git a/lib/views/home/Captin/home_captain/widget/left_menu_map_captain.dart b/lib/views/home/Captin/home_captain/widget/left_menu_map_captain.dart index 343c00f..e125a46 100644 --- a/lib/views/home/Captin/home_captain/widget/left_menu_map_captain.dart +++ b/lib/views/home/Captin/home_captain/widget/left_menu_map_captain.dart @@ -8,6 +8,7 @@ import 'package:get/get.dart'; import 'package:sefer_driver/controller/home/captin/home_captain_controller.dart'; import '../../../../../constant/colors.dart'; +import '../../../../../controller/functions/encrypt_decrypt.dart'; import '../../../../Rate/ride_calculate_driver.dart'; GetBuilder leftMainMenuCaptainIcons() { @@ -90,26 +91,38 @@ GetBuilder leftMainMenuCaptainIcons() { ) : const SizedBox(), // : const SizedBox(), - // AnimatedContainer( - // duration: const Duration(microseconds: 200), - // width: controller.widthMapTypeAndTraffic, - // decoration: BoxDecoration( - // color: AppColor.secondaryColor, - // border: Border.all(color: AppColor.blueColor), - // borderRadius: BorderRadius.circular(15)), - // child: Builder(builder: (context) { - // return IconButton( - // onPressed: () async { - // MyCircularProgressIndicator(); - // }, - // icon: const Icon( - // FontAwesome5.grin_tears, - // size: 29, - // color: AppColor.blueColor, - // ), - // ); - // }), - // ), + AnimatedContainer( + duration: const Duration(microseconds: 200), + width: controller.widthMapTypeAndTraffic, + decoration: BoxDecoration( + color: AppColor.secondaryColor, + border: Border.all(color: AppColor.blueColor), + borderRadius: BorderRadius.circular(15)), + child: Builder(builder: (context) { + return IconButton( + onPressed: () async { + final plainText = 'Al-sayyd'; + debugPrint('Plain Text: $plainText'); + + // Encrypt the data + final encryptedData = encryptionHelper.encryptData(plainText); + debugPrint('Encrypted: $encryptedData'); + + // Decrypt the data + final decryptedData = encryptionHelper.decryptData( + encryptedData); // Use the encryptedData variable + debugPrint('Decrypted: $decryptedData'); + // rlyouFVUqI7TEhu9UEMangaIViglSgxLk3/d1c0Yo7g= + // rlyouFVUqI7TEhu9UEMangaIViglSgxLk3/d1c0Yo7g= + }, + icon: const Icon( + FontAwesome5.grin_tears, + size: 29, + color: AppColor.blueColor, + ), + ); + }), + ), const SizedBox( height: 5, diff --git a/lib/views/home/Captin/orderCaptin/order_request_page.dart b/lib/views/home/Captin/orderCaptin/order_request_page.dart index 8753f2b..72de0db 100644 --- a/lib/views/home/Captin/orderCaptin/order_request_page.dart +++ b/lib/views/home/Captin/orderCaptin/order_request_page.dart @@ -14,6 +14,7 @@ import '../../../../constant/colors.dart'; import '../../../../constant/links.dart'; import '../../../../constant/style.dart'; import '../../../../controller/functions/crud.dart'; +import '../../../../controller/functions/encrypt_decrypt.dart'; import '../../../../controller/functions/launch.dart'; import '../../../../controller/home/captin/order_request_controller.dart'; import '../../../widgets/elevated_btn.dart'; @@ -222,7 +223,7 @@ class _OrderRequestPageState extends State { var res = await CRUD().post( link: AppLink.updateStausFromSpeed, payload: { - 'id': controller.myList[16], + 'id': (controller.myList[16]), 'rideTimeStart': DateTime.now().toString(), 'status': 'Apply', 'driver_id': box.read(BoxName.driverID), @@ -232,7 +233,7 @@ class _OrderRequestPageState extends State { link: "${AppLink.endPoint}/ride/rides/updateStausFromSpeed.php", payload: { - 'id': controller.myList[16], + 'id': (controller.myList[16]), 'rideTimeStart': DateTime.now().toString(), 'status': 'Apply', 'driver_id': box.read(BoxName.driverID), @@ -250,9 +251,9 @@ class _OrderRequestPageState extends State { link: AppLink.addDriverOrder, payload: { 'driver_id': - controller.myList[6].toString(), + (controller.myList[6].toString()), 'order_id': - controller.myList[16].toString(), + (controller.myList[16].toString()), 'status': 'Apply' }); if (AppLink.endPoint != @@ -262,9 +263,9 @@ class _OrderRequestPageState extends State { '${AppLink.endPoint}/rides/driver_order/add.php', payload: { 'driver_id': - controller.myList[6].toString(), + (controller.myList[6].toString()), 'order_id': - controller.myList[16].toString(), + (controller.myList[16].toString()), 'status': 'Apply' }); } @@ -300,9 +301,12 @@ class _OrderRequestPageState extends State { 'https://www.google.com/maps/dir/${controller.myList[0]}/${controller.myList[1]}/', 'DurationToPassenger': controller.myList[15].toString(), - 'rideId': controller.myList[16].toString(), - 'passengerId': controller.myList[7].toString(), - 'driverId': controller.myList[18].toString(), + 'rideId': encryptionHelper.decryptData( + controller.myList[16].toString()), + 'passengerId': encryptionHelper.decryptData( + controller.myList[7].toString()), + 'driverId': encryptionHelper.decryptData( + controller.myList[18].toString()), 'durationOfRideValue': controller.myList[19].toString(), 'paymentAmount': @@ -374,7 +378,8 @@ class _OrderRequestPageState extends State { 'notification.wav'); controller.refuseOrder( - controller.myList[16].toString(), + encryptionHelper.encryptData( + controller.myList[16].toString()), ); controller.addRideToNotificationDriverString( controller.myList[16].toString(), diff --git a/lib/views/home/profile/cars_inserting_page.dart b/lib/views/home/profile/cars_inserting_page.dart index 8d9ae7a..2e7ec2a 100644 --- a/lib/views/home/profile/cars_inserting_page.dart +++ b/lib/views/home/profile/cars_inserting_page.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import '../../../constant/colors.dart'; import '../../../constant/links.dart'; import '../../../constant/style.dart'; +import '../../../controller/functions/encrypt_decrypt.dart'; import '../../../controller/functions/gemeni.dart'; import '../../auth/captin/driver_car_controller.dart'; @@ -93,8 +94,11 @@ GetBuilder egyptCarLicenceFront() { style: AppStyle.headTitle2), IconButton( onPressed: () async { - ai.allMethodForAI(ai.prompts[3]['prompt'].toString(), - AppLink.uploadEgypt, 'car_front'); + ai.allMethodForAI( + encryptionHelper.decryptData( + ai.prompts[3]['prompt'].toString()), + AppLink.uploadEgypt, + 'car_front'); }, icon: const Icon(Icons.refresh), ), @@ -138,8 +142,12 @@ GetBuilder egyptCarLicenceFront() { return Card( child: InkWell( onTap: () async { - ai.allMethodForAINewCar(ai.prompts[3]['prompt'].toString(), - AppLink.uploadEgypt1, 'car_front', 'carId'); //todo + ai.allMethodForAINewCar( + encryptionHelper + .decryptData(ai.prompts[3]['prompt'].toString()), + AppLink.uploadEgypt1, + 'car_front', + 'carId'); //todo }, child: Column( children: [ @@ -205,8 +213,11 @@ GetBuilder egyptCarLicenceBack() { Text('Vehicle Details Back'.tr, style: AppStyle.headTitle2), IconButton( onPressed: () async { - ai.allMethodForAI(ai.prompts[4]['prompt'].toString(), - AppLink.uploadEgypt, 'car_back'); + ai.allMethodForAI( + encryptionHelper.decryptData( + ai.prompts[4]['prompt'].toString()), + AppLink.uploadEgypt, + 'car_back'); }, icon: const Icon(Icons.refresh), ), @@ -275,8 +286,11 @@ GetBuilder egyptCarLicenceBack() { return Card( child: InkWell( onTap: () async { - ai.allMethodForAI(ai.prompts[4]['prompt'].toString(), - AppLink.uploadEgypt, 'car_back'); + ai.allMethodForAI( + encryptionHelper + .decryptData(ai.prompts[4]['prompt'].toString()), + AppLink.uploadEgypt, + 'car_back'); }, child: Column( children: [