diff --git a/.env b/.env index 07042e8..d0621d2 100644 --- a/.env +++ b/.env @@ -30,7 +30,7 @@ passwordPayMob='g@nkD2#99!hD_.wXrXlBl' integrationIdPayMob=0237730XrXlBl payMobApikey='MDrGqKEWS1rVqHvEPDvPjJ7vZDBExrO7S3BEBgrlfUwTA3i5RnP5ZnvoL3M2S9rEBgrlNTdexH5pTPf7NJrvy1reZJv1Tn7zf7vTIDywjHg1C7Ley38HTDyNA3v7TPfdxJrax1rwPmPtMJyzqKEYZeghq3MuLUrFH3A1AgHcH15CZ9UaZTLOxnw0BTdzHHrBArisZerUMUUzZ1BnBeEijHvNjYLnS1BUICMhSmPhA15ifHyVqKEMHWyKLbyuIPvcH9UeL3vZyDf=XrXlBl' integrationIdPayMobWallet=0237739XrXlBl -ocpApimSubscriptionKey=17373j50x53u07q0830634f512j731yuXrXlBl +ocpApimSubscriptionKey=0f5dacccdbce4131b1a5f952996302e3 smsPasswordEgypt="J)Vh=qb/@MXrXlBl" chatGPTkeySeferNew4=zg-vlie-2l1ZlpxiLJ6wQOvbb4TnC9XrxgUEyVQIu6TID4qP4FUUqoS5XrXlBl anthropicAIkeySeferNew=zg-qbc-qvo39-n4VdMQ5nuJeIYhMN4PDYr7qox3-t2i1Lh7aNTDfYF-Gf8whUJZCs47EeelKn8_UcmUMmiSLaf0UJg0DvUlQrDt-76CRrkQQXrXlBl diff --git a/android/app/build.gradle b/android/app/build.gradle index 9a56511..db05599 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -32,7 +32,7 @@ def keystorePropertiesFile = rootProject.file('key.properties') android { namespace "com.sefer_driver" - compileSdkVersion 34 + compileSdkVersion 33 ndkVersion flutter.ndkVersion compileOptions { @@ -54,9 +54,9 @@ android { // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 23 - targetSdkVersion flutter.targetSdkVersion - versionCode 40 - versionName '1.5.40' + targetSdkVersion 33 + versionCode 43 + versionName '1.5.43' // manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml'] } diff --git a/android/app/src/main/res/raw/ding.wav b/android/app/src/main/res/raw/ding.wav new file mode 100644 index 0000000..c53cd50 Binary files /dev/null and b/android/app/src/main/res/raw/ding.wav differ diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 4735433..e6ef576 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ C624C4682BD56D34002834AF /* cancel.wav in Resources */ = {isa = PBXBuildFile; fileRef = C624C4602BD56D34002834AF /* cancel.wav */; }; C624C4692BD56D34002834AF /* iphone_ringtone.wav in Resources */ = {isa = PBXBuildFile; fileRef = C624C4612BD56D34002834AF /* iphone_ringtone.wav */; }; C624C46A2BD56D34002834AF /* order1.wav in Resources */ = {isa = PBXBuildFile; fileRef = C624C4622BD56D34002834AF /* order1.wav */; }; + C628BC3F2C31427000E4D33B /* ding.wav in Resources */ = {isa = PBXBuildFile; fileRef = C628BC3E2C31427000E4D33B /* ding.wav */; }; C690B4752A80554500E1D66E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C690B4742A80554500E1D66E /* GoogleService-Info.plist */; }; C6B15AA12B5FB24600746405 /* order.wav in Resources */ = {isa = PBXBuildFile; fileRef = C6B15A9F2B5FB24600746405 /* order.wav */; }; C6B15AA22B5FB24600746405 /* tone2.wav in Resources */ = {isa = PBXBuildFile; fileRef = C6B15AA02B5FB24600746405 /* tone2.wav */; }; @@ -78,6 +79,7 @@ C624C4602BD56D34002834AF /* cancel.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = cancel.wav; path = ../../android/app/src/main/res/raw/cancel.wav; sourceTree = ""; }; C624C4612BD56D34002834AF /* iphone_ringtone.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = iphone_ringtone.wav; path = ../../android/app/src/main/res/raw/iphone_ringtone.wav; sourceTree = ""; }; C624C4622BD56D34002834AF /* order1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = order1.wav; path = ../../android/app/src/main/res/raw/order1.wav; sourceTree = ""; }; + C628BC3E2C31427000E4D33B /* ding.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = ding.wav; path = ../../android/app/src/main/res/raw/ding.wav; sourceTree = ""; }; C690B4742A80554500E1D66E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; C69588332A8C1F6B00C3AC67 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; C6B15A9F2B5FB24600746405 /* order.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = order.wav; sourceTree = ""; }; @@ -167,6 +169,7 @@ C6B15AA02B5FB24600746405 /* tone2.wav */, C624C4602BD56D34002834AF /* cancel.wav */, C624C4612BD56D34002834AF /* iphone_ringtone.wav */, + C628BC3E2C31427000E4D33B /* ding.wav */, C624C4622BD56D34002834AF /* order1.wav */, C624C45F2BD56D34002834AF /* promo.wav */, C624C45D2BD56D34002834AF /* start.wav */, @@ -297,6 +300,7 @@ C624C4682BD56D34002834AF /* cancel.wav in Resources */, C6B15AA12B5FB24600746405 /* order.wav in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + C628BC3F2C31427000E4D33B /* ding.wav in Resources */, C690B4752A80554500E1D66E /* GoogleService-Info.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, C624C4692BD56D34002834AF /* iphone_ringtone.wav in Resources */, diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 3101804..780b27e 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 37 + 40 CFBundleSignature ???? CFBundleURLTypes @@ -36,7 +36,7 @@ CFBundleVersion - 4.0.37 + 4.0.40 FirebaseAppDelegateProxyEnabled NO GMSApiKey diff --git a/lib/constant/api_key.dart b/lib/constant/api_key.dart index f8ae211..d49b40b 100644 --- a/lib/constant/api_key.dart +++ b/lib/constant/api_key.dart @@ -54,8 +54,7 @@ class AK { a.r(a.r(a.r(Env.integrationIdPayMobWallet, cn), cC), cs); static final String smsPasswordEgypt = a.r(a.r(a.r(Env.smsPasswordEgypt, cn), cC), cs); - static final String ocpApimSubscriptionKey = - a.r(a.r(a.r(Env.ocpApimSubscriptionKey, cn), cC), cs); + static final String ocpApimSubscriptionKey = Env.ocpApimSubscriptionKey; static final String chatGPTkeySeferNew4 = a.r(a.r(a.r(Env.chatGPTkeySeferNew4, cn), cC), cs); static final String anthropicAIkeySeferNew = diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index f8c9b44..dc7a43f 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -4,6 +4,7 @@ class BoxName { static const String googlaMapApp = "googlaMapApp"; static const String lang = "lang"; + static const String gender = "gender"; static const String carType = "carType"; static const String deviceInfo = "deviceInfo"; static const String phoneVerified = "phoneVerified"; diff --git a/lib/constant/links.dart b/lib/constant/links.dart index df70f6b..58ffee1 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -96,6 +96,8 @@ class AppLink { //-----------------Driver NotificationCaptain------------------ static String addNotificationCaptain = "$ride/notificationCaptain/add.php"; static String addWaitingRide = "$ride/notificationCaptain/addWaitingRide.php"; + static String updateWaitingRide = + "$ride/notificationCaptain/updateWaitingTrip.php"; static String getRideWaiting = "$ride/notificationCaptain/getRideWaiting.php"; static String getNotificationCaptain = "$ride/notificationCaptain/get.php"; static String updateNotificationCaptain = diff --git a/lib/controller/auth/captin/login_captin_controller.dart b/lib/controller/auth/captin/login_captin_controller.dart index bd2e052..91e4488 100644 --- a/lib/controller/auth/captin/login_captin_controller.dart +++ b/lib/controller/auth/captin/login_captin_controller.dart @@ -4,6 +4,7 @@ import 'dart:math'; import 'package:SEFER/constant/colors.dart'; import 'package:SEFER/controller/functions/location_background_controller.dart'; import 'package:SEFER/views/auth/captin/cards/sms_signup.dart'; +import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:get/get.dart'; @@ -48,68 +49,6 @@ class LoginDriverController extends GetxController { update(); } - void login() async { - isloading = true; - update(); - var res = await CRUD().get(link: AppLink.loginCaptin, payload: { - 'email': emailController.text, - 'phone': phoneController.text, - 'password': passwordController.text - }); - if (res == 'failure') { - //Failure - isloading = false; - update(); - Get.snackbar('Failure', '', backgroundColor: Colors.red); - } else { - var jsonDecoeded = jsonDecode(res); - if (jsonDecoeded.isNotEmpty) { - if (jsonDecoeded['status'] == 'success') { - if (jsonDecoeded['data'][0]['verified'] == 1) { - box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']); - box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']); - box.write( - BoxName.nameDriver, jsonDecoeded['data'][0]['first_name']); - box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']); - SecureStorage() - .saveData(BoxName.passwordDriver, passwordController.text); - Get.offAll(() => HomeCaptain()); - isloading = false; - update(); - await CRUD().post(link: AppLink.addTokensDriver, payload: { - 'token': box.read(BoxName.tokenDriver), - 'captain_id': box.read(BoxName.driverID).toString() - }); - } else { - isloading = false; - update(); - Get.defaultDialog( - title: 'You must Verify email !.'.tr, - middleText: '', - backgroundColor: Colors.yellow[300], - onConfirm: () async { - int randomNumber = Random().nextInt(100000) + 1; - await CRUD().post(link: AppLink.sendVerifyEmail, payload: { - 'email': emailController.text, - 'token': randomNumber.toString(), - }); - Get.to(() => VerifyEmailCaptainPage()); - }, - ); - } - } else if (jsonDecoeded['status'] == 'Failure') { - Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'], - backgroundColor: Colors.redAccent); - isloading = false; - update(); - } - } else { - isloading = false; - update(); - } - } - } - loginUsingCredentials(String driverID, email) async { isloading = true; update(); @@ -129,6 +68,7 @@ class LoginDriverController extends GetxController { if (jsonDecoeded['status'] == 'success' && jsonDecoeded['data'][0]['is_verified'] == 1) { box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']); + 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']); @@ -150,14 +90,23 @@ class LoginDriverController extends GetxController { box.read(BoxName.tokenDriver)) { Get.put(FirebaseMessagesController()) .sendNotificationToAnyWithoutData( - 'token change', - 'change device', - jsonDecode(token)['data'][0]['token'].toString(), - ); - await CRUD().post(link: AppLink.addTokensDriver, payload: { - 'token': box.read(BoxName.tokenDriver), - 'captain_id': box.read(BoxName.driverID).toString() - }); + 'token change'.tr, + 'change device'.tr, + jsonDecode(token)['data'][0]['token'].toString(), + 'promo.wav'); + Get.defaultDialog( + title: 'you will use this device?'.tr, + middleText: '', + confirm: MyElevatedButton( + title: 'Ok'.tr, + onPressed: () async { + await CRUD() + .post(link: AppLink.addTokensDriver, payload: { + 'token': box.read(BoxName.tokenDriver), + 'captain_id': box.read(BoxName.driverID).toString() + }); + Get.back(); + })); } } @@ -184,13 +133,4 @@ class LoginDriverController extends GetxController { 'captain_id': box.read(BoxName.driverID).toString() }); } - - @override - void onInit() async { - super.onInit(); - - // if (box.read(BoxName.driverID).toString() != null) { - // loginByBoxData(); - // } - } } diff --git a/lib/controller/auth/captin/register_captin_controller.dart b/lib/controller/auth/captin/register_captin_controller.dart index d2810db..44dc978 100644 --- a/lib/controller/auth/captin/register_captin_controller.dart +++ b/lib/controller/auth/captin/register_captin_controller.dart @@ -111,12 +111,14 @@ class RegisterCaptainController extends GetxController { box.write(BoxName.phoneDriver, '+2${phoneController.text}'); box.write(BoxName.phoneVerified, 1); - var res1 = await CRUD().post( - link: AppLink.updateAccountBank, - payload: {'phone': '+2${phoneController.text}'}); - if (jsonDecode(res1)['status'] == 'success') { - Get.to(EgyptCardAI()); - } + // var res1 = await CRUD().post( + // link: AppLink.updateAccountBank, + // payload: {'phone': '+2${phoneController.text}'}); + // if (res1 != 'failure') { + Get.to(EgyptCardAI()); + // } else { + // Get.snackbar('title', 'message'); + // } } } } diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 7e22f98..efd5ab2 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -90,9 +90,9 @@ class FirebaseMessagesController extends GetxController { } void fireBaseTitles(RemoteMessage message) { - if (message.notification!.title! == 'Order') { + if (message.notification!.title! == 'Order'.tr) { if (Platform.isAndroid) { - NotificationController().showNotification('Order', '', 'order'); + NotificationController().showNotification('Order'.tr, '', 'order'); } var myListString = message.data['DriverList']; // var points = message.data['PolylineJson']; @@ -109,27 +109,27 @@ class FirebaseMessagesController extends GetxController { // 'PolylineJson': myPoints, 'body': message.notification!.body }); - } else if (message.notification!.title == 'Cancel Trip') { + } else if (message.notification!.title == 'Cancel Trip'.tr) { NotificationController().showNotification( 'Cancel Trip'.tr, 'Passenger Cancel Trip'.tr, 'cancel'); cancelTripDialog(); - } else if (message.notification!.title! == 'token change') { + } else if (message.notification!.title! == 'token change'.tr) { NotificationController() - .showNotification('token change', 'token change', 'cancel'); + .showNotification('token change'.tr, 'token change', 'cancel'); GoogleSignInHelper.signOut(); - } else if (message.notification!.title! == 'message From passenger') { + } else if (message.notification!.title! == 'message From passenger'.tr) { NotificationController() .showNotification('message From passenger'.tr, ''.tr, 'tone2'); passengerDialog(message.notification!.body!); update(); - } else if (message.notification!.title! == 'Hi ,I will go now') { + } else if (message.notification!.title! == 'Hi ,I will go now'.tr) { // Get.snackbar('Hi ,I will go now', '', // backgroundColor: AppColor.greenColor); NotificationController().showNotification( 'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'tone2'); update(); - } else if (message.notification!.title! == 'Call Income') { + } else if (message.notification!.title! == 'Call Income'.tr) { try { var myListString = message.data['passengerList']; var driverList = jsonDecode(myListString) as List; @@ -147,7 +147,8 @@ class FirebaseMessagesController extends GetxController { // remoteID: driverList[2].toString(), // )); } catch (e) {} - } else if (message.notification!.title! == 'Call Income from Passenger') { + } else if (message.notification!.title! == + 'Call Income from Passenger'.tr) { try { var myListString = message.data['passengerList']; var driverList = jsonDecode(myListString) as List; @@ -165,7 +166,7 @@ class FirebaseMessagesController extends GetxController { // remoteID: driverList[2].toString(), )); } catch (e) {} - } else if (message.notification!.title! == 'Call End') { + } else if (message.notification!.title! == 'Call End'.tr) { try { var myListString = message.data['passengerList']; var driverList = jsonDecode(myListString) as List; @@ -179,7 +180,7 @@ class FirebaseMessagesController extends GetxController { // Assuming GetMaterialApp is initialized and context is valid for navigation Get.off(const CallPage()); } catch (e) {} - } else if (message.notification!.title! == 'Order Applied') { + } else if (message.notification!.title! == 'Order Applied'.tr) { Get.snackbar( "The order has been accepted by another driver." .tr, // Corrected grammar @@ -202,7 +203,7 @@ class FirebaseMessagesController extends GetxController { // 'PolylineJson': myPoints, 'body': message.notification!.body }); - } else if (message.notification!.title! == 'Order Applied') { + } else if (message.notification!.title! == 'Order Applied'.tr) { NotificationController().showNotification( 'The order Accepted by another Driver'.tr, 'We regret to inform you that another driver has accepted this order.' @@ -361,7 +362,7 @@ class FirebaseMessagesController extends GetxController { 'notification': { 'title': title, 'body': body, - 'sound': 'start.wav' + 'sound': 'ding.wav' }, 'priority': 'high', 'data': { @@ -404,7 +405,7 @@ class FirebaseMessagesController extends GetxController { // } //android/app/src/main/res/raw/iphone_ringtone.wav void sendNotificationToPassengerToken( - String title, body, token, List map) async { + String title, body, token, List map, String tone) async { try { final response = await http.post( Uri.parse('https://fcm.googleapis.com/fcm/send'), @@ -416,7 +417,7 @@ class FirebaseMessagesController extends GetxController { 'notification': { 'title': title, 'body': body, - 'sound': 'tone2.wav' + 'sound': tone }, 'data': { 'passengerList': map, @@ -472,7 +473,7 @@ class FirebaseMessagesController extends GetxController { } void sendNotificationToAnyWithoutData( - String title, String body, String token) async { + String title, String body, String token, String tone) async { try { final response = await http.post( Uri.parse('https://fcm.googleapis.com/fcm/send'), @@ -484,7 +485,7 @@ class FirebaseMessagesController extends GetxController { 'notification': { 'title': title, 'body': body, - 'sound': 'promo.wav' + 'sound': tone }, 'data': { 'click_action': 'FLUTTER_NOTIFICATION_CLICK', @@ -507,8 +508,8 @@ class FirebaseMessagesController extends GetxController { } } - void sendNotificationToDriverMAP( - String title, String body, String token, List data) async { + void sendNotificationToDriverMAP(String title, String body, String token, + List data, String tone) async { try { final response = await http.post( Uri.parse('https://fcm.googleapis.com/fcm/send'), @@ -521,7 +522,7 @@ class FirebaseMessagesController extends GetxController { 'title': title, 'body': body, // 'sound': 'tone2.wav', - 'sound': 'order.wav' + 'sound': tone }, 'data': { 'DriverList': data, diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index 5331f22..d31ea1a 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -98,6 +98,7 @@ class CRUD { await arabicTextExtractByVisionAndAI(imagePath: imagePath); var json = jsonDecode(extractedString); var textValues = extractTextFromLines(json); + print(textValues); // await Get.put(AI()).geminiAiExtraction(prompt, textValues); await Get.put(AI()).anthropicAI(textValues, prompt, imagePath); } @@ -129,8 +130,9 @@ class CRUD { }; String imagePathFull = - '${AppLink.server}card_image/$imagePath-${box.read(BoxName.driverID)}.jpg'; - + '${AppLink.server}/card_image/$imagePath-${box.read(BoxName.driverID)}.jpg'; + // print(box.read(BoxName.driverID)); + // print(imagePathFull); var request = http.Request('POST', Uri.parse( // 'https://ocrhamza.cognitiveservices.azure.com/vision/v2.1/ocr?language=ar')); // 'https://eastus.api.cognitive.microsoft.com/vision/v3.2/ocr' @@ -141,6 +143,7 @@ class CRUD { http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { + // print(await response.stream.bytesToString()); return await response.stream.bytesToString(); } else {} } @@ -218,7 +221,9 @@ class CRUD { 'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}', }, ); - + print(response.request); + print(response.body); + print(response.statusCode); var jsonData = jsonDecode(response.body); if (response.statusCode == 200) { if (jsonData['status'] == 'success') { diff --git a/lib/controller/functions/gemeni.dart b/lib/controller/functions/gemeni.dart index cedae7c..0e66334 100644 --- a/lib/controller/functions/gemeni.dart +++ b/lib/controller/functions/gemeni.dart @@ -393,10 +393,13 @@ class AI extends GetxController { update(); await ImageController().choosImage(linkPHP, imagePath); Future.delayed(const Duration(seconds: 2)); + // print(imagePath); var extractedString = await CRUD().arabicTextExtractByVisionAndAI(imagePath: imagePath); + print(extractedString); var json = jsonDecode(extractedString); var textValues = CRUD().extractTextFromLines(json); + print(textValues); // await Get.put(AI()).geminiAiExtraction(prompt, textValues, imagePath); await Get.put(AI()).anthropicAI(textValues, prompt, imagePath); isLoading = false; diff --git a/lib/controller/functions/launch.dart b/lib/controller/functions/launch.dart index eaeecd2..26a7026 100644 --- a/lib/controller/functions/launch.dart +++ b/lib/controller/functions/launch.dart @@ -7,6 +7,14 @@ void showInBrowser(String url) async { } else {} } +Future makePhoneCall(String phoneNumber) async { + final Uri launchUri = Uri( + scheme: 'tel', + path: phoneNumber, + ); + await launchUrl(launchUri); +} + void launchCommunication( String method, String contactInfo, String message) async { String url; diff --git a/lib/controller/functions/upload_image.dart b/lib/controller/functions/upload_image.dart index 6e6e45b..115eb1c 100644 --- a/lib/controller/functions/upload_image.dart +++ b/lib/controller/functions/upload_image.dart @@ -54,6 +54,7 @@ class ImageController extends GetxController { update(); // Save the cropped image File savedCroppedImage = File(croppedFile!.path); + print('link =$link'); try { await uploadImage( savedCroppedImage, diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index 151906c..1ad17b5 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -222,7 +222,8 @@ class MapDriverController extends GetxController { FirebaseMessagesController().sendNotificationToAnyWithoutData( 'DriverIsGoingToPassenger', box.read(BoxName.name).toString(), - tokenPassenger); + tokenPassenger, + 'start.wav'); if (box.read(BoxName.googlaMapApp) == true) { await openGoogleMapFromDriverToPassenger(); } @@ -288,7 +289,10 @@ class MapDriverController extends GetxController { }); FirebaseMessagesController().sendNotificationToAnyWithoutData( - 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger); + 'RideIsBegin', + box.read(BoxName.name).toString(), + tokenPassenger, + 'start.wav'); rideIsBeginPassengerTimer(); // var d = jsonDecode(res); @@ -352,6 +356,7 @@ class MapDriverController extends GetxController { } calculateDistanceBetweenDriverAndPassengerLocation() { + Get.put(LocationController()); double distance2 = Geolocator.distanceBetween( latLngPassengerLocation.latitude, latLngPassengerLocation.longitude, @@ -533,19 +538,19 @@ class MapDriverController extends GetxController { }); Future.delayed(const Duration(milliseconds: 300)); FirebaseMessagesController().sendNotificationToPassengerToken( - 'Driver Finish Trip', - '${'you will pay to Driver'.tr} $paymentAmount \$', - tokenPassenger, - [ - box.read(BoxName.driverID), - rideId, - box.read(BoxName.tokenDriver), - // carType == 'Comfort' || carType == 'Mashwari' - // ? price.toStringAsFixed(2) - // : totalPassenger - paymentAmount.toString() - ], - ); + 'Driver Finish Trip', + '${'you will pay to Driver'.tr} $paymentAmount \$', + tokenPassenger, + [ + box.read(BoxName.driverID), + rideId, + box.read(BoxName.tokenDriver), + // carType == 'Comfort' || carType == 'Mashwari' + // ? price.toStringAsFixed(2) + // : totalPassenger + paymentAmount.toString() + ], + 'ding.wav'); Get.to(() => RatePassenger(), arguments: { 'passengerId': passengerId, 'rideId': rideId, diff --git a/lib/controller/home/captin/order_request_controller.dart b/lib/controller/home/captin/order_request_controller.dart index 8460e35..ab74524 100644 --- a/lib/controller/home/captin/order_request_controller.dart +++ b/lib/controller/home/captin/order_request_controller.dart @@ -95,21 +95,29 @@ class OrderRequestController extends GetxController { List> results = await sql.getCustomQuery(customQuery); } - void startTimer(String driverID, orderID) async { - for (int i = 0; i <= duration; i++) { + bool _timerActive = false; + + Future startTimer(String driverID, String orderID) async { + _timerActive = true; + for (int i = 0; i <= duration && _timerActive; i++) { await Future.delayed(const Duration(seconds: 1)); progress = i / duration; remainingTime = duration - i; update(); } - if (remainingTime == 0) { + if (remainingTime == 0 && _timerActive) { if (applied == false) { + endTimer(); refuseOrder(orderID); } } } + void endTimer() { + _timerActive = false; + } + void startTimerSpeed(String driverID, orderID) async { for (int i = 0; i <= durationSpeed; i++) { await Future.delayed(const Duration(seconds: 1)); @@ -144,15 +152,16 @@ class OrderRequestController extends GetxController { }); // applied = true; - sql.insertData({ - 'order_id': orderID, - 'created_at': DateTime.now().toString(), - 'driver_id': box.read(BoxName.driverID).toString(), - }, TableName.driverOrdersRefuse); - getRefusedOrderByCaptain(); - + if (box.read(BoxName.gender).toString() != 'Female') { + sql.insertData({ + 'order_id': orderID, + 'created_at': DateTime.now().toString(), + 'driver_id': box.read(BoxName.driverID).toString(), + }, TableName.driverOrdersRefuse); + getRefusedOrderByCaptain(); + } update(); - Get.back(); + // Get.back(); // Get.offAll(HomeCaptain()); } diff --git a/lib/controller/home/payment/captain_wallet_controller.dart b/lib/controller/home/payment/captain_wallet_controller.dart index f043b1d..89b286d 100644 --- a/lib/controller/home/payment/captain_wallet_controller.dart +++ b/lib/controller/home/payment/captain_wallet_controller.dart @@ -223,12 +223,12 @@ class CaptainWalletController extends GetxController { }); if (res1 != 'failure') { FirebaseMessagesController().sendNotificationToDriverMAP( - 'Transfer', - '${'You have transfer to your wallet from'.tr}' - '${box.read(BoxName.nameDriver)}', - amountToNewDriverMap[0]['token'].toString(), - [], - ); + 'Transfer', + '${'You have transfer to your wallet from'.tr}' + '${box.read(BoxName.nameDriver)}', + amountToNewDriverMap[0]['token'].toString(), + [], + 'order1.wav'); await addSeferWallet('payout fee', '5'); Get.defaultDialog( diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index ec6980e..4949cce 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -4,7 +4,16 @@ class MyTranslation extends Translations { @override Map> get keys => { "ar": { - 'Add Question': '', + "Heading your way now. Please be ready.": + "في طريقي إليك الآن. يرجى الاستعداد.", + "Approaching your area. Should be there in 3 minutes.": + "اقترب من منطقتك. يجب أن أكون هناك خلال 3 دقائق.", + "There's heavy traffic here. Can you suggest an alternate pickup point?": + "هناك حركة مرور كثيفة هنا. هل يمكنك اقتراح نقطة استلام بديلة؟", + "This ride is already taken by another driver.": + "تم حجز هذه الرحلة من قبل سائق آخر.", + 'Price: ': 'السعر ', + 'Add Question': "أضف سؤالاً", "Please enter a valid card 16-digit number.": "الرجاء إدخال رقم بطاقة صحيح مكون من 16 رقمًا.", "Insert card number": "أدخل رقم البطاقة", @@ -199,7 +208,7 @@ class MyTranslation extends Translations { "Invalid OTP": "رمز التحقق غير صالح", "Enter your email address": "أدخل عنوان بريدك الإلكتروني", "Please enter Your Email.": "يُرجى إدخال...", - "Enter your phone number": "أدخلي رقم هاتفك", + "Enter your phone number": "أدخل رقم هاتفك", "Please enter your phone number.": "الرجاء إدخال رقم هاتفك.", "Please enter Your Password.": "إدخال كلمة المرور الخاصة بك", "Submit": "إرسال", @@ -284,7 +293,7 @@ class MyTranslation extends Translations { "Send Verfication Code": "إرسال رمز التحقق", "End Ride": "‏إنهاء الرحلة", "Minute": "الدقيقة", - "Go to passenger Location now": "انتقل إلى موقع الراكب الآن", + "Go to passenger Location": "انتقل إلى موقع الراكب ", "Duration of the Ride is": "مدة المشوار هي", "Distance of the Ride is": "مسافة المشوار هي", "Name of the Passenger is": "اسم الراكب هو", @@ -375,7 +384,7 @@ class MyTranslation extends Translations { "Driver Applied the Ride for You": "سائق قدم الرحلة من أجلك", "Show latest promo": "أظهر أحدث عرض ترويجي", "Cancel Trip": "إلغاء الرحلة", - "Passenger Cancel Trip": "راكب يلغي الرحلة", + "Passenger Cancel Trip": "الرحلة ألغيت من قبل المسافر", "Please stay on the picked point.": "يرجى البقاء على النقطة المحددة.", "Trip is Begin": "الرحلة بدأت", "Hi ,I will go now": "مرحبًا، سأذهب الآن", diff --git a/lib/controller/notification/passenger_notification_controller.dart b/lib/controller/notification/passenger_notification_controller.dart index 1ed0009..c23bb24 100644 --- a/lib/controller/notification/passenger_notification_controller.dart +++ b/lib/controller/notification/passenger_notification_controller.dart @@ -54,7 +54,7 @@ class PassengerNotificationController extends GetxController { 'body': body, }); FirebaseMessagesController() - .sendNotificationToPassengerToken(title, body, 'token', []); + .sendNotificationToPassengerToken(title, body, 'token', [], 'ding.wav'); } @override diff --git a/lib/controller/rate/rate_conroller.dart b/lib/controller/rate/rate_conroller.dart index 2b0ec0f..469a72e 100644 --- a/lib/controller/rate/rate_conroller.dart +++ b/lib/controller/rate/rate_conroller.dart @@ -83,13 +83,14 @@ class RateController extends GetxController { 'token': paymentToken4, 'driverID': box.read(BoxName.driverID).toString(), }); + FirebaseMessagesController().sendNotificationToAnyWithoutData( + 'Wallet Added'.tr, + 'Wallet Added${(pointsSubtraction).toStringAsFixed(0)}'.tr, + Get.find().tokenPassenger, + 'tone2.wav'); + walletChecked = 'true'; } - FirebaseMessagesController().sendNotificationToAnyWithoutData( - 'Wallet Added', - 'Wallet Added'.tr, - Get.find().tokenPassenger); - walletChecked = 'true'; update(); } }); diff --git a/lib/views/home/Captin/home_captain/widget/call_page.dart b/lib/views/home/Captin/home_captain/widget/call_page.dart index ecc6b36..906db0d 100644 --- a/lib/views/home/Captin/home_captain/widget/call_page.dart +++ b/lib/views/home/Captin/home_captain/widget/call_page.dart @@ -56,11 +56,11 @@ GetBuilder callPage() { GestureDetector( onTap: () async { FirebaseMessagesController().sendNotificationToPassengerToken( - 'Call End'.tr, - 'Call End', - Get.find().tokenPassenger, - [], - ); + 'Call End'.tr, + 'Call End', + Get.find().tokenPassenger, + [], + 'iphone_ringtone.wav'); callController.leave(); Get.back(); }, 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 2c1e806..426693d 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 @@ -10,6 +10,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; import '../../../../../constant/char_map.dart'; import '../../../../../constant/colors.dart'; import '../../../../../constant/credential.dart'; +import '../../../../../controller/functions/launch.dart'; import '../../../../Rate/ride_calculate_driver.dart'; import '../../../../../controller/functions/location_controller.dart'; @@ -166,8 +167,7 @@ GetBuilder leftMainMenuCaptainIcons() { // borderRadius: BorderRadius.circular(15)), // child: IconButton( // onPressed: () { - // Get.to(() => PassengerLocationMapPage(), - // arguments: box.read(BoxName.rideArguments)); + // launchCommunication('phone', '+201023248456', ''); // }, // icon: const Icon( // FontAwesome5.grin_tears, diff --git a/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart b/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart index 12ed1ee..964fbab 100644 --- a/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart +++ b/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart @@ -47,7 +47,7 @@ class PassengerInfoWindow extends StatelessWidget { MainAxisAlignment.spaceBetween, children: [ Text( - 'Go to passenger Location now'.tr, + 'Go to passenger Location'.tr, style: AppStyle.title .copyWith(color: AppColor.greenColor), ), @@ -63,10 +63,16 @@ class PassengerInfoWindow extends StatelessWidget { true; await controller .driverCallPassenger(); // to check from scam - Get.to( - () => const CallPage()); - // launchCommunication('phone', - // controller.phone.toString(), ''); + // Get.to( + // () => const CallPage()); + makePhoneCall(controller + .passengerPhone + .toString()); + // launchCommunication( + // 'phone', + // controller.passengerPhone + // , + // ''); }, child: const Icon( Icons.phone, @@ -76,17 +82,113 @@ class PassengerInfoWindow extends StatelessWidget { width: 25, ), GestureDetector( - onTap: () { - controller.isSocialPressed = - true; - launchCommunication( - 'email', - controller.passengerPhone - .toString(), - '${'Hello this is Driver'.tr} ${box.read(BoxName.nameDriver)}'); + onTap: () async { + Get.defaultDialog( + title: + 'Select one message' + .tr, + titleStyle: + AppStyle.title, + content: SizedBox( + height: Get.height * .5, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, + children: [ + InkWell( + onTap: () { + FirebaseMessagesController().sendNotificationToAnyWithoutData( + 'message From Driver' + .tr, + "There's heavy traffic here. Can you suggest an alternate pickup point?" + .tr, + controller + .tokenPassenger, + 'ding.wav'); + Get.back(); + }, + child: Container( + decoration: AppStyle + .boxDecoration1, + child: Padding( + padding: + const EdgeInsets + .all( + 10), + child: Text( + "There's heavy traffic here. Can you suggest an alternate pickup point?" + .tr, + style: AppStyle + .title, + ), + ), + ), + ), + InkWell( + onTap: () { + FirebaseMessagesController().sendNotificationToAnyWithoutData( + 'message From Driver' + .tr, + "Heading your way now. Please be ready." + .tr, + controller + .tokenPassenger, + 'ding.wav'); + Get.back(); + }, + child: Container( + decoration: AppStyle + .boxDecoration1, + child: Padding( + padding: + const EdgeInsets + .all( + 10), + child: Text( + "Heading your way now. Please be ready." + .tr, + style: AppStyle + .title, + ), + ), + ), + ), + InkWell( + onTap: () { + FirebaseMessagesController().sendNotificationToAnyWithoutData( + 'message From Driver' + .tr, + 'Approaching your area. Should be there in 3 minutes.' + .tr, + controller + .tokenPassenger, + 'ding.wav'); + Get.back(); + }, + child: Container( + decoration: AppStyle + .boxDecoration1, + child: Padding( + padding: + const EdgeInsets + .all( + 10), + child: Text( + 'Approaching your area. Should be there in 3 minutes.' + .tr, + style: AppStyle + .title, + ), + ), + ), + ), + ], + ), + )); }, child: const Icon( - Icons.email, + Icons.message, color: AppColor.redColor, )), const SizedBox( @@ -269,7 +371,8 @@ class PassengerInfoWindow extends StatelessWidget { .tr, controller .tokenPassenger, - []); + [], + 'start.wav'); controller .startTimerToShowDriverWaitPassengerDuration(); controller @@ -356,7 +459,8 @@ class PassengerInfoWindow extends StatelessWidget { .tr, controller .tokenPassenger, - []); + [], + 'cancel.wav'); await controller .addWaitingTimeCostFromPassengerToDriverWallet(); controller diff --git a/lib/views/home/Captin/orderCaptin/order_request_page.dart b/lib/views/home/Captin/orderCaptin/order_request_page.dart index 4619e26..d84b614 100644 --- a/lib/views/home/Captin/orderCaptin/order_request_page.dart +++ b/lib/views/home/Captin/orderCaptin/order_request_page.dart @@ -296,6 +296,7 @@ class OrderRequestPage extends StatelessWidget { onPressed: () async { box.write(BoxName.statusDriverLocation, 'on'); + orderRequestController.endTimer(); orderRequestController.changeApplied(); await CRUD().postFromDialogue( link: AppLink.addDriverOrder, @@ -320,12 +321,13 @@ class OrderRequestPage extends StatelessWidget { ]; FirebaseMessagesController() .sendNotificationToPassengerToken( - 'Apply Ride', 'your ride is applied'.tr, - // arguments['DriverList'][9].toString(), - arguments['DriverList'][9].toString(), - // box.read(BoxName.tokenDriver).toString(), - bodyToPassenger, - ); + 'Apply Ride', + 'your ride is applied'.tr, + // arguments['DriverList'][9].toString(), + arguments['DriverList'][9].toString(), + // box.read(BoxName.tokenDriver).toString(), + bodyToPassenger, + 'start.wav'); Get.back(); box.write(BoxName.rideArguments, { 'passengerLocation': myList[0].toString(), @@ -392,6 +394,7 @@ class OrderRequestPage extends StatelessWidget { MyElevatedButton( title: 'Refuse Order'.tr, onPressed: () async { + orderRequestController.endTimer(); List bodyToPassenger = [ box.read(BoxName.driverID).toString(), box.read(BoxName.nameDriver).toString(), @@ -400,12 +403,12 @@ class OrderRequestPage extends StatelessWidget { FirebaseMessagesController() .sendNotificationToPassengerToken( - 'Refused Ride', - '${box.read(BoxName.nameDriver)} ${'reject your order.'.tr}', - arguments['DriverList'][9].toString(), - // box.read(BoxName.tokenDriver).toString(), - bodyToPassenger, - ); + 'Refused Ride'.tr, + '${box.read(BoxName.nameDriver)} ${'reject your order.'.tr}', + arguments['DriverList'][9].toString(), + // box.read(BoxName.tokenDriver).toString(), + bodyToPassenger, + 'cancel.wav'); orderRequestController.refuseOrder( myList[16].toString(), ); diff --git a/lib/views/home/Captin/orderCaptin/order_speed_request.dart b/lib/views/home/Captin/orderCaptin/order_speed_request.dart index 4b5e398..f96a3b1 100644 --- a/lib/views/home/Captin/orderCaptin/order_speed_request.dart +++ b/lib/views/home/Captin/orderCaptin/order_speed_request.dart @@ -350,12 +350,13 @@ class OrderSpeedRequest extends StatelessWidget { }); FirebaseMessagesController() .sendNotificationToPassengerToken( - 'Apply Ride', 'your ride is applied'.tr, - // arguments['DriverList'][9].toString(), - arguments['DriverList'][9].toString(), - // box.read(BoxName.tokenDriver).toString(), - bodyToPassenger, - ); + 'Apply Ride', + 'your ride is applied'.tr, + // arguments['DriverList'][9].toString(), + arguments['DriverList'][9].toString(), + // box.read(BoxName.tokenDriver).toString(), + bodyToPassenger, + 'start.wav'); Get.back(); // 'Arguments passed to PassengerLocationMapPage:'); @@ -397,42 +398,7 @@ class OrderSpeedRequest extends StatelessWidget { 'endNameLocation': myList[30].toString(), }); Get.to(() => PassengerLocationMapPage(), - arguments: box.read(BoxName.rideArguments) - // { - // 'passengerLocation': myList[0].toString(), - // 'passengerDestination': myList[1].toString(), - // 'Duration': myList[4].toString(), - // 'totalCost': myList[26].toString(), - // 'Distance': myList[5].toString(), - // 'name': myList[8].toString(), - // 'phone': myList[10].toString(), - // 'email': myList[28].toString(), - // 'WalletChecked': myList[13].toString(), - // 'tokenPassenger': myList[9].toString(), - // 'direction': - // 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/', - // 'DurationToPassenger': myList[15].toString(), - // 'rideId': myList[16].toString(), - // 'passengerId': myList[7].toString(), - // 'driverId': myList[18].toString(), - // 'durationOfRideValue': myList[19].toString(), - // 'paymentAmount': myList[2].toString(), - // 'paymentMethod': myList[13].toString() == 'true' - // ? 'visa' - // : 'cash', - // 'isHaveSteps': myList[20].toString(), - // 'step0': myList[21].toString(), - // 'step1': myList[22].toString(), - // 'step2': myList[23].toString(), - // 'step3': myList[24].toString(), - // 'step4': myList[25].toString(), - // 'passengerWalletBurc': myList[26].toString(), - // 'timeOfOrder': DateTime.now().toString(), - // 'totalPassenger': myList[2].toString(), - // 'carType': myList[31].toString(), - // 'kazan': myList[32].toString(), - // } - ); + arguments: box.read(BoxName.rideArguments)); } // }); // Get.back(); diff --git a/lib/views/notification/available_rides_page.dart b/lib/views/notification/available_rides_page.dart index a82cb4c..8fbe8c2 100644 --- a/lib/views/notification/available_rides_page.dart +++ b/lib/views/notification/available_rides_page.dart @@ -30,233 +30,235 @@ class AvailableRidesPage extends StatelessWidget { body: [ rideAvailableController.isLoading ? const MyCircularProgressIndicator() - : Padding( - padding: const EdgeInsets.all(8.0), - child: ListView.builder( - itemCount: rideAvailableController - .rideAvailableMap['message'].length, - itemBuilder: (BuildContext context, int index) { - var list = rideAvailableController - .rideAvailableMap['message'][index]; - return Container( - width: Get.width * .9, - decoration: AppStyle.boxDecoration1, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '🟢 ', + : ListView.builder( + itemCount: rideAvailableController + .rideAvailableMap['message'].length, + itemBuilder: (BuildContext context, int index) { + var list = rideAvailableController + .rideAvailableMap['message'][index]; + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + width: Get.width * .9, + decoration: AppStyle.boxDecoration1, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '🟢 ', + style: AppStyle.subtitle, + ), + SizedBox( + height: Get.height * .06, + width: Get.width * .8, + child: Text( + '${list['startName']}', style: AppStyle.subtitle, ), - SizedBox( - height: Get.height * .06, - width: Get.width * .8, - child: Text( - '${list['startName']}', - style: AppStyle.subtitle, - ), - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '🔴 ', + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '🔴 ', + style: AppStyle.subtitle, + ), + SizedBox( + height: Get.height * .06, + width: Get.width * .8, + child: Text( + '${list['endName']}', style: AppStyle.subtitle, ), - SizedBox( - height: Get.height * .06, - width: Get.width * .8, - child: Text( - '${list['endName']}', - style: AppStyle.subtitle, - ), - ), - ], - ), - const SizedBox(height: 4), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - Text('${'Price: '.tr}${list['price']} \$'), - const SizedBox(height: 4), - Text( - '${list['carType']}', - style: AppStyle.title - .copyWith(color: AppColor.greenColor), - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - Text('📈 ${list['passengerRate']}', - style: AppStyle.title), - MyElevatedButton( - title: 'Accept'.tr, - onPressed: () async { - box.write( - BoxName.statusDriverLocation, 'on'); + ), + ], + ), + const SizedBox(height: 4), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Text('${'Price: '.tr}${list['price']} \$'), + const SizedBox(height: 4), + Text( + '${list['carType']}', + style: AppStyle.title + .copyWith(color: AppColor.greenColor), + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Text('📈 ${list['passengerRate']}', + style: AppStyle.title), + MyElevatedButton( + title: 'Accept'.tr, + onPressed: () async { + box.write( + BoxName.statusDriverLocation, 'on'); - var res = await CRUD().post( - link: AppLink.updateStausFromSpeed, + var res = await CRUD().post( + link: AppLink.updateStausFromSpeed, + payload: { + 'id': list['id'], + 'rideTimeStart': + DateTime.now().toString(), + 'status': 'Apply', + 'driver_id': + box.read(BoxName.driverID), + }); + // .then((value) { + // var json = jsonDecode(res); + if (res == "failure") { + Get.defaultDialog( + title: + "This ride is already taken by another driver." + .tr, + middleText: '', + titleStyle: AppStyle.title, + middleTextStyle: AppStyle.title, + confirm: MyElevatedButton( + title: 'Ok'.tr, + onPressed: () { + Get.back(); + // Get.back(); + // Get.back(); + })); + } else if (jsonDecode(res)['status'] == + "success") { + List bodyToPassenger = [ + box.read(BoxName.driverID).toString(), + box + .read(BoxName.nameDriver) + .toString(), + box + .read(BoxName.tokenDriver) + .toString(), + ]; + await CRUD().postFromDialogue( + link: AppLink.addDriverOrder, payload: { - 'id': list['id'], - 'rideTimeStart': - DateTime.now().toString(), - 'status': 'Apply', 'driver_id': box.read(BoxName.driverID), + // box.read(BoxName.driverID).toString(), + 'order_id': list['id'], + 'status': 'Apply' + }); + await CRUD().post( + link: AppLink.updateRides, + payload: { + 'id': list['id'], + 'DriverIsGoingToPassenger': + DateTime.now().toString(), + 'status': 'Applied' + }); + await CRUD().post( + link: AppLink.updateWaitingRide, + payload: { + 'id': list['id'], + 'status': 'Applied' }); - // .then((value) { - // var json = jsonDecode(res); - if (res == "failure") { - Get.defaultDialog( - title: - "This ride is already taken by another driver." - .tr, - middleText: '', - titleStyle: AppStyle.title, - middleTextStyle: AppStyle.title, - confirm: MyElevatedButton( - title: 'Ok'.tr, - onPressed: () { - Get.back(); - Get.back(); - Get.back(); - })); - } else if (jsonDecode(res)['status'] == - "success") { - List bodyToPassenger = [ - box - .read(BoxName.driverID) - .toString(), - box - .read(BoxName.nameDriver) - .toString(), - box - .read(BoxName.tokenDriver) - .toString(), - ]; - await CRUD().postFromDialogue( - link: AppLink.addDriverOrder, - payload: { - 'driver_id': - box.read(BoxName.driverID), - // box.read(BoxName.driverID).toString(), - 'order_id': list['id'], - 'status': 'Apply' - }); - await CRUD().post( - link: AppLink.updateRides, - payload: { - 'id': list['id'], - 'DriverIsGoingToPassenger': - DateTime.now().toString(), - 'status': 'Applied' - }); - FirebaseMessagesController() - .sendNotificationToPassengerToken( - 'Apply Ride', - 'your ride is applied'.tr, - // arguments['DriverList'][9].toString(), - list['passengerToken'].toString(), - // box.read(BoxName.tokenDriver).toString(), - bodyToPassenger, - ); - Get.back(); - Get.to( - () => PassengerLocationMapPage(), - arguments: { - 'passengerLocation': - list['start_location'] - .toString(), - 'passengerDestination': - list['end_location'] - .toString(), - 'Duration': - list['duration'].toString(), - 'totalCost': - list['price'].toString(), - 'Distance': - list['distance'].toString(), - 'name': list['first_name'] + FirebaseMessagesController() + .sendNotificationToPassengerToken( + 'Apply Ride', + 'your ride is applied'.tr, + // arguments['DriverList'][9].toString(), + list['passengerToken'] .toString(), - 'phone': - list['phone'].toString(), - 'email': - list['email'].toString(), - 'WalletChecked': - list['payment_method'] - .toString(), - 'tokenPassenger': - list['passengerToken'] - .toString(), - 'direction': - 'https://www.google.com/maps/dir/${list['start_location']}/${list['end_location']}/', - 'DurationToPassenger': - list['duration'].toString(), - 'rideId': list['id'].toString(), - 'passengerId': - list['passenger_id'] - .toString(), - 'driverId': box - .read(BoxName.driverID) - .toString(), - 'durationOfRideValue': - list['duration'].toString(), - 'paymentAmount': - list['price'].toString(), - 'paymentMethod': - 'cash'.toString() == //todo fix payment method - 'true' - ? 'visa' - : 'cash', - 'isHaveSteps': - 'startEnd'.toString(), - 'step0': ''.toString(), - 'step1': ''.toString(), - 'step2': ''.toString(), - 'step3': ''.toString(), - 'step4': ''.toString(), - 'passengerWalletBurc': - list['bruc'].toString(), - 'timeOfOrder': - DateTime.now().toString(), - 'totalPassenger': - list['price'].toString(), - 'carType': - list['carType'].toString(), - 'kazan': Get.find< - HomeCaptainController>() - .kazan - .toString(), - }); - } - }, - kolor: AppColor.greenColor, - ), - Text( - '📍 ${list['distance']} ${'KM'.tr}', - style: AppStyle.title - .copyWith(color: AppColor.greenColor), - ), - ], - ) - ], - ), - ); - }), - ) + // box.read(BoxName.tokenDriver).toString(), + bodyToPassenger, + 'start.wav'); + Get.back(); + Get.to(() => PassengerLocationMapPage(), + arguments: { + 'passengerLocation': + list['start_location'] + .toString(), + 'passengerDestination': + list['end_location'] + .toString(), + 'Duration': + list['duration'].toString(), + 'totalCost': + list['price'].toString(), + 'Distance': + list['distance'].toString(), + 'name': + list['first_name'].toString(), + 'phone': list['phone'].toString(), + 'email': list['email'].toString(), + 'WalletChecked': + list['payment_method'] + .toString(), + 'tokenPassenger': + list['passengerToken'] + .toString(), + 'direction': + 'https://www.google.com/maps/dir/${list['start_location']}/${list['end_location']}/', + 'DurationToPassenger': + list['duration'].toString(), + 'rideId': list['id'].toString(), + 'passengerId': + list['passenger_id'] + .toString(), + 'driverId': box + .read(BoxName.driverID) + .toString(), + 'durationOfRideValue': + list['duration'].toString(), + 'paymentAmount': + list['price'].toString(), + 'paymentMethod': + 'cash'.toString() == //todo fix payment method + 'true' + ? 'visa' + : 'cash', + 'isHaveSteps': + 'startEnd'.toString(), + 'step0': ''.toString(), + 'step1': ''.toString(), + 'step2': ''.toString(), + 'step3': ''.toString(), + 'step4': ''.toString(), + 'passengerWalletBurc': + list['bruc'].toString(), + 'timeOfOrder': + DateTime.now().toString(), + 'totalPassenger': + list['price'].toString(), + 'carType': + list['carType'].toString(), + 'kazan': Get.find< + HomeCaptainController>() + .kazan + .toString(), + }); + } + }, + kolor: AppColor.greenColor, + ), + Text( + '📍 ${list['distance']} ${'KM'.tr}', + style: AppStyle.title + .copyWith(color: AppColor.greenColor), + ), + ], + ) + ], + ), + ), + ); + }) ], isleading: true); });