diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index dcc9db9..573f7bd 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -63,5 +63,6 @@ class BoxName { static const String color = "color"; static const String owner = "owner"; static const String registrationDate = "registrationDate"; - static const List recentLocations = []; + static const String recentLocations = 'recentLocations'; + static const String tripData = 'tripData'; } diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 1de5919..dea107a 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -203,7 +203,7 @@ class FirebaseMessagesController extends GetxController { var myListString = message.data['passengerList']; var driverList = jsonDecode(myListString) as List; NotificationController().showNotification( - 'Driver Finish Trip'.tr, + 'Call Income'.tr, message.notification!.body!, 'order', ); diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index 3b33f02..7db2763 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -104,8 +104,7 @@ class CRUD { ); var headers = { 'Content-Type': 'application/json', - 'Authorization': - 'Bearer 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' + 'Authorization': 'Bearer ${Env.chatGPTkeySeferNew}' }; var data = json.encode({ "model": "gpt-3.5-turbo", @@ -252,9 +251,9 @@ class CRUD { } Future sendVerificationRequest(String phoneNumber) async { - final accountSid = "ACb4ad857efe0903bfd6238a763a2ce4d1"; - final authToken = "14f39ef4628bb8a4f18469f462f8af75"; - final verifySid = "VAf6e6022a7e95186aa5b1da25411859bd"; + final accountSid = AK.accountSIDTwillo; + final authToken = AK.authTokenTwillo; + final verifySid = AK.twilloRecoveryCode; final Uri verificationUri = Uri.parse( 'https://verify.twilio.com/v2/Services/$verifySid/Verifications'); diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index fde9c38..b44a57e 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -443,7 +443,9 @@ class MapDriverController extends GetxController { isRideFinished = true; isRideStarted = false; isPriceWindow = false; - totalCost = price.toStringAsFixed(2); + totalCost = carType == 'Comfort' || carType == 'Free Ride' + ? price.toStringAsFixed(1) + : totalPassenger; paymentAmount = totalCost; box.write(BoxName.statusDriverLocation, 'off'); // changeRideToBeginToPassenger(); @@ -470,7 +472,9 @@ class MapDriverController extends GetxController { Future.delayed(const Duration(milliseconds: 300)); FirebaseMessagesController().sendNotificationToPassengerToken( 'Driver Finish Trip', - 'you will pay to Driver'.tr + ' $price \$'.tr, + 'you will pay to Driver'.tr + + ' ${carType == 'Comfort' || carType == 'Free Ride' ? price.toStringAsFixed(1) : totalPassenger} \$' + .tr, tokenPassenger, [ box.read(BoxName.driverID), diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 96d561b..f034e0f 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -587,7 +587,61 @@ class MapPassengerController extends GetxController { await Future.delayed(const Duration(seconds: 1)); progressTimerRideBegin = i / durationToRide; remainingTimeTimerRideBegin = durationToRide - i; + bool sendSOS = false; + if (speed > 100 && sendSOS == false) { + Get.defaultDialog( + barrierDismissible: false, + title: "Warning: Speeding detected!".tr, + titleStyle: AppStyle.title, + content: Text( + "We noticed the speed is exceeding 100 km/h. Please slow down for your safety. If you feel unsafe, you can share your trip details with a contact or call the police using the red SOS button." + .tr, + style: AppStyle.title, + ), + confirm: MyElevatedButton( + title: "Share Trip Details".tr, + onPressed: () { + Get.back(); + // Implement sharing trip details logic here + String message = "**Emergency SOS from Passenger:**\n"; +// Get trip details from GetX or relevant provider + String origin = passengerLocation.toString(); + String destination = myDestination.toString(); + String driverName = firstName; + String driverCarPlate = licensePlate; + +// Add trip details to the message + message += "* ${'Origin'.tr}: $origin\n"; + message += "* ${'Destination'.tr}: $destination\n"; + message += "* ${'Driver Name'.tr}: $driverName\n"; + message += "* ${'Driver Car Plate'.tr}: $driverCarPlate\n\n"; + message += "* ${'Driver phone'.tr}:$driverPhone\n\n"; + +// Add any additional information you want to include (optional) +// - Example: current location (using GetX LocationController) + message += + "${'Current Location'.tr}:https://www.google.com/maps/place/${passengerLocation.latitude},${passengerLocation.longitude} \n"; + +// Append a call to action + message += "Please help! Contact me as soon as possible.".tr; + +// Launch WhatsApp communication with the constructed message + launchCommunication( + 'whatsapp', box.read(BoxName.sosPhonePassenger), message); + sendSOS = true; + }, + kolor: AppColor.redColor, + ), + cancel: MyElevatedButton( + title: "Cancel".tr, + onPressed: () { + Get.back(); + }, + kolor: AppColor.greenColor, + ), + ); + } int minutes = (remainingTimeTimerRideBegin / 60).floor(); int seconds = remainingTimeTimerRideBegin % 60; stringRemainingTimeRideBegin = @@ -636,7 +690,7 @@ class MapPassengerController extends GetxController { } } - void getRideStatusFromStartApp() async { + getRideStatusFromStartApp() async { try { var res = await CRUD().get( link: AppLink.getRideStatusFromStartApp, @@ -648,15 +702,36 @@ class MapPassengerController extends GetxController { if (decode['data']['status'] == 'Begin') { //todo from sql or get storage - getMap( - decode['data']['start_location'], decode['data']['end_location']); - // timeToPassengerFromDriverAfterApplied = 0; - // remainingTime = 0; - // remainingTimeToPassengerFromDriverAfterApplied = 0; - // // isCancelRidePageShown = true; - // rideIsBeginPassengerTimer(); - // // //print('rideTimerBegin: $rideTimerBegin'); - // rideTimerBegin = true; + List pol = box.read(BoxName.tripData); + Map tripData = + box.read(BoxName.tripData) as Map; + final points = decodePolyline( + tripData["routes"][0]["overview_polyline"]["points"]); + + for (int i = 0; i < points.length; i++) { + double lat = points[i][0].toDouble(); + double lng = points[i][1].toDouble(); + polylineCoordinates.add(LatLng(lat, lng)); + } + var polyline = Polyline( + polylineId: const PolylineId('begin trip'), + points: polylineCoordinates, + width: 10, + color: Colors.blue, + ); + + polyLines.add(polyline); + timeToPassengerFromDriverAfterApplied = 0; + remainingTime = 0; + remainingTimeToPassengerFromDriverAfterApplied = 0; + remainingTimeDriverWaitPassenger5Minute = 0; + rideTimerBegin = true; + isDriverInPassengerWay = false; + isDriverArrivePassenger = false; + update(); + // isCancelRidePageShown = true; + rideIsBeginPassengerTimer(); + runWhenRideIsBegin(); update(); } } catch (e) { @@ -1578,6 +1653,7 @@ class MapPassengerController extends GetxController { }); } + double speed = 0; Future getLocation() async { isLoading = true; update(); @@ -1614,6 +1690,7 @@ class MapPassengerController extends GetxController { ? LatLng(_locationData.latitude!, _locationData.longitude!) : null)!; newStartPointLocation = passengerLocation; + speed = _locationData.speed!; // //print location details // //print('Accuracy: ${_locationData.accuracy}'); // //print('Latitude: ${_locationData.latitude}'); @@ -1886,6 +1963,7 @@ class MapPassengerController extends GetxController { var response = await CRUD().getGoogleApi(link: url, payload: {}); data = response['routes'][0]['legs']; // //print(data); + box.write(BoxName.tripData, response); startNameAddress = data[0]['start_address']; endNameAddress = data[0]['end_address']; isLoading = false; @@ -2367,8 +2445,9 @@ class MapPassengerController extends GetxController { await addToken(); await getKazanPercent(); await getPassengerRate(); + await getRideStatusFromStartApp(); startMarkerReloading(); - // await getCarsLocationByPassenger(); + // await getNearestDriverByPassengerLocation(); initilizeGetStorage(); diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 286f979..fe654fe 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -478,11 +478,22 @@ class MyTranslation extends Translations { 'Distance from Passenger to destination is ': "المسافة من الراكب إلى الوجهة هي ", 'Cost Of Trip IS ': "تكلفة الرحلة هي ", + "We noticed the speed is exceeding 100 km/h. Please slow down for your safety. If you feel unsafe, you can share your trip details with a contact or call the police using the red SOS button.": + "لقد لاحظنا أن السرعة تتجاوز ١٠٠ كم/ساعة. يرجى التباطؤ من أجل سلامتك. إذا كنت تشعر بعدم الأمان، يمكنك مشاركة تفاصيل رحلتك مع جهة اتصال أو الاتصال بالشرطة باستخدام زر SOS الأحمر.", + 'Warning: Speeding detected!': "تحذير: تم رصد السرعة الزائدة!", + "Please help! Contact me as soon as possible.": + "الرجاء المساعدة! اتصل بي في أقرب وقت ممكن.", + 'Share Trip Details': "مشاركة تفاصيل الرحلة", 'No ride found yet': '‏لا يوجد طلبات متوفرة حاليا', 'Accept Order': "‏اقبل الطلب", 'reject your order.': "رفض طلبك.", 'Bottom Bar Example': "مثال لشريط الأسفل", + 'Driver phone': '‏رقم السائق', 'Statistics': "الإحصائيات", + 'Origin': "نقطة الانطلاق", + 'Destination': 'الوجهة', + 'Driver Name': 'اسم السائق', + 'Driver Car Plate': 'لوحة السيارة', 'Available for rides': '‏مشاوير متاحة', 'Scan Id': "مسح الهوية", 'Camera not initilaized yet': "الكاميرا لم تُثبت بعد", diff --git a/lib/controller/notification/ride_available_controller.dart b/lib/controller/notification/ride_available_controller.dart index 42a1add..6d2494c 100644 --- a/lib/controller/notification/ride_available_controller.dart +++ b/lib/controller/notification/ride_available_controller.dart @@ -9,13 +9,13 @@ import '../functions/crud.dart'; class RideAvailableController extends GetxController { bool isLoading = false; - Map rideAvalibleMap = {}; - getRideAvalible() async { + Map rideAvailableMap = {}; + getRideAvailable() async { isLoading = true; var res = await CRUD().get(link: AppLink.getRideWaiting, payload: {}); if (res != 'failure') { - rideAvalibleMap = jsonDecode(res); - print(rideAvalibleMap); + rideAvailableMap = jsonDecode(res); + print(rideAvailableMap); isLoading = false; update(); } else { @@ -34,7 +34,7 @@ class RideAvailableController extends GetxController { @override void onInit() { - getRideAvalible(); + getRideAvailable(); super.onInit(); } } 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 3e552f6..037e426 100644 --- a/lib/views/home/Captin/home_captain/widget/call_page.dart +++ b/lib/views/home/Captin/home_captain/widget/call_page.dart @@ -37,18 +37,18 @@ GetBuilder callPage() { onTap: () async { // await callController.initAgoraFull(); // callController.join(); - FirebaseMessagesController().sendNotificationToPassengerToken( - 'Call Income', - 'You have call from driver ${box.read(BoxName.nameDriver)}', - Get.find().tokenPassenger, - [ - callController.token, - callController.channelName, - callController.uid.toString(), - callController.remoteUid.toString(), - ], - ); - callController.join(); + // FirebaseMessagesController().sendNotificationToPassengerToken( + // 'Call Income', + // 'You have call from driver ${box.read(BoxName.nameDriver)}', + // Get.find().tokenPassenger, + // [ + // callController.token, + // callController.channelName, + // callController.uid.toString(), + // callController.remoteUid.toString(), + // ], + // ); + // callController.join(); }, child: Container( width: 50, diff --git a/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart b/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart index 5406807..b976808 100644 --- a/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart +++ b/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart @@ -21,8 +21,8 @@ GetBuilder driverEndRideBar() { child: Container( decoration: AppStyle.boxDecoration, height: mapDriverController.remainingTimeTimerRideBegin < 60 - ? mapDriverController.driverEndPage = 160 - : 130, + ? mapDriverController.driverEndPage = 180 + : 150, width: 240, child: Column( children: [ diff --git a/lib/views/home/map_widget.dart/ride_begin_passenger.dart b/lib/views/home/map_widget.dart/ride_begin_passenger.dart index 53379f9..8ede3bd 100644 --- a/lib/views/home/map_widget.dart/ride_begin_passenger.dart +++ b/lib/views/home/map_widget.dart/ride_begin_passenger.dart @@ -170,7 +170,8 @@ class RideBeginPassenger extends StatelessWidget { phoneNumber = phoneNumber.replaceAll('0', ''); print(phoneNumber); // Output: 798583061 var phone = - '+${box.read(BoxName.countryCode)}${box.read(BoxName.sosPhonePassenger)}'; + // '+${box.read(BoxName.countryCode)}${box.read(BoxName.sosPhonePassenger)}'; + '+20${box.read(BoxName.sosPhonePassenger)}'; controller.sendWhatsapp(phone); } }, diff --git a/lib/views/notification/available_rides_page.dart b/lib/views/notification/available_rides_page.dart index 9481243..3954753 100644 --- a/lib/views/notification/available_rides_page.dart +++ b/lib/views/notification/available_rides_page.dart @@ -33,9 +33,9 @@ class AvailableRidesPage extends StatelessWidget { : Padding( padding: const EdgeInsets.all(8.0), child: rideAvailableController - .rideAvalibleMap['message'].length == + .rideAvailableMap['message'].length == 1 && - rideAvailableController.rideAvalibleMap['message'] + rideAvailableController.rideAvailableMap['message'] [0]['start_location'] == null ? Center( @@ -46,10 +46,10 @@ class AvailableRidesPage extends StatelessWidget { ) : ListView.builder( itemCount: rideAvailableController - .rideAvalibleMap['message'].length, + .rideAvailableMap['message'].length, itemBuilder: (BuildContext context, int index) { var list = rideAvailableController - .rideAvalibleMap['message'][index]; + .rideAvailableMap['message'][index]; return Container( width: Get.width * .9, decoration: AppStyle.boxDecoration1, @@ -146,6 +146,16 @@ class AvailableRidesPage extends StatelessWidget { 'order_id': list['id'], 'status': 'Apply' }); + await CRUD().post( + link: AppLink.updateRides, + payload: { + 'id': list['id'], + 'driverGoToPassengerTime': + DateTime.now() + .toString(), + 'status': 'Applied' + }); + // print(bodyToPassenger); FirebaseMessagesController() .sendNotificationToPassengerToken(