diff --git a/assets/images/freeRide.png b/assets/images/freeRide.png new file mode 100644 index 0000000..0667d42 Binary files /dev/null and b/assets/images/freeRide.png differ diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 0000000..7e7e7f6 --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1 @@ +extensions: diff --git a/lib/controller/home/captin/order_request_controller.dart b/lib/controller/home/captin/order_request_controller.dart index 7e2e3d4..ddbf139 100644 --- a/lib/controller/home/captin/order_request_controller.dart +++ b/lib/controller/home/captin/order_request_controller.dart @@ -97,14 +97,14 @@ class OrderRequestController extends GetxController { update(); } - if (remainingTimeSpeed == 0) { - if (applied == false) { - print('applied========================='); - print(applied); - Get.back(); - // refuseOrder(box.read(BoxName.driverID), orderID); - } - } + // if (remainingTimeSpeed == 0) { + // if (applied == false) { + // print('applied========================='); + // print(applied); + // Get.back(); + // // refuseOrder(box.read(BoxName.driverID), orderID); + // } + // } } void refuseOrder(orderID) async { diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index e995a6e..8a23023 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -471,7 +471,7 @@ class MapPassengerController extends GetxController { // Format the message. String message = - '${'${'Hi! This is'.tr} ${box.read(BoxName.name)}.\n${' I am using'.tr}'} ${box.read(AppInformation.appName)}${' to ride with'.tr} $firstName${' as the driver.'.tr} $firstName \n${'is driving a '.tr}$model\n${' with license plate '.tr}$licensePlate.\n${' I am currently located at '.tr}$passengerLocation.\n${' If you need to reach me, please contact the driver directly at'.tr}\n\n $driverPhone.'; + '${'${'Hi! This is'.tr} ${box.read(BoxName.name)}.\n${' I am using'.tr}'} ${AppInformation.appName}${' to ride with'.tr} $firstName${' as the driver.'.tr} $firstName \n${'is driving a '.tr}$model\n${' with license plate '.tr}$licensePlate.\n${' I am currently located at '.tr} https://www.google.com/maps/place/${passengerLocation.latitude},${passengerLocation.longitude}.\n${' If you need to reach me, please contact the driver directly at'.tr}\n\n $driverPhone.'; // Launch the URL to send the SMS. launchCommunication('whatsapp', to, message); @@ -1199,18 +1199,16 @@ class MapPassengerController extends GetxController { } void reloadMarkerDriverCarsLocationToPassengerAfterApplied() { - // Clear existing markers - // markers.clear(); - // update(); clearMarkersExceptStartEnd(); // for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) { + LatLng driverPosition = LatLng( + double.parse( + datadriverCarsLocationToPassengerAfterApplied[0]['latitude']), + double.parse( + datadriverCarsLocationToPassengerAfterApplied[0]['longitude'])); final driverAcceptedMarker = Marker( markerId: const MarkerId('driverToPassengers'), - position: LatLng( - double.parse( - datadriverCarsLocationToPassengerAfterApplied[0]['latitude']), - double.parse( - datadriverCarsLocationToPassengerAfterApplied[0]['longitude'])), + position: driverPosition, rotation: double.parse( datadriverCarsLocationToPassengerAfterApplied['message'][0] ['heading']), @@ -1218,9 +1216,7 @@ class MapPassengerController extends GetxController { ); markers.add(driverAcceptedMarker); // update(); - mapController?.animateCamera(CameraUpdate.newLatLng(LatLng( - driverCarsLocationToPassengerAfterApplied[0].latitude, - driverCarsLocationToPassengerAfterApplied[0].longitude))); + mapController?.animateCamera(CameraUpdate.newLatLng(driverPosition)); update(); // } // Update the map with the new markers } diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 54695a7..b4d1561 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -458,7 +458,12 @@ class MyTranslation extends Translations { 'Are you sure to cancel?': "هل أنت متأكد من الإلغاء؟", 'Yes': 'نعم', 'Insert Emergincy Number': "أدخل رقم الطوارئ", - 'Insert': "إدراج",'You can decline a request without any cost':'‏يمكنك إلغاء الطلب بدون أي تكلفة', + 'Best choice for comfort car and flexible route and stops point': 'أفضل اختيار لسيارة مريحة ومسار مرن ونقاط توقف', + 'Insert': "إدراج",'This is for delivery or a motorcycle.':"هذا للتسليم أو الدراجة النارية", + 'This trip goes directly from your starting point to your destination for a fixed price. The driver must follow the planned route':'الرحلة دي من نقطة البداية لنقطة النهاية بسعر ثابت والسواق لازم يمشي بنفس الطريق.', + 'You can decline a request without any cost': + '‏يمكنك إلغاء الطلب بدون أي تكلفة', + 'Perfect for adventure seekers who want to experience something new and exciting':'خيار مثالي لللي عايزين يخرجوا من الروتين ويجربوا حاجات جديدة ومثيرة', " My current location is:": "موقعي الحالي هو:", " \nand I have a trip on": "\nولدي رحلة على", "App \nwith Passenger ": "التطبيق\nمع الراكب ", diff --git a/lib/views/home/Captin/orderCaptin/order_speed_request.dart b/lib/views/home/Captin/orderCaptin/order_speed_request.dart index d7463a1..87ef710 100644 --- a/lib/views/home/Captin/orderCaptin/order_speed_request.dart +++ b/lib/views/home/Captin/orderCaptin/order_speed_request.dart @@ -270,34 +270,6 @@ class OrderSpeedRequest extends StatelessWidget { ), ), ), - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: RichText( - // text: TextSpan( - // text: 'Duration To Passenger is '.tr, - // style: AppStyle.title, - // children: [ - // TextSpan( - // text: myList[11].toString(), - // style: AppStyle.headTitle2), - // ], - // ), - // ), - // ), - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: RichText( - // text: TextSpan( - // text: 'Distance To Passenger is '.tr, - // style: AppStyle.title, - // children: [ - // TextSpan( - // text: myList[12].toString(), - // style: AppStyle.headTitle2), - // ], - // ), - // ), - // ), Padding( padding: const EdgeInsets.all(4), child: Container( @@ -315,36 +287,6 @@ class OrderSpeedRequest extends StatelessWidget { ), ), ), - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: RichText( - // text: TextSpan( - // text: 'Distance from Passenger to destination is '.tr, - // style: AppStyle.title, - // children: [ - // TextSpan( - // text: myList[5].toString(), - // style: AppStyle.headTitle2), - // TextSpan(text: ' KM'.tr, style: AppStyle.title), - // ]), - // ), - // ), - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: RichText( - // text: TextSpan( - // text: 'Duration of Trip is '.tr, - // style: AppStyle.title, - // children: [ - // TextSpan( - // text: hours > 1 - // ? '${'Your Ride Duration is '.tr}$hours${' H and'.tr} $minutes m' - // : '${'Your Ride Duration is '.tr} $minutes m', - // style: AppStyle.title), - // TextSpan(text: ' Minutes'.tr, style: AppStyle.title), - // ]), - // ), - // ), Padding( padding: const EdgeInsets.all(8.0), child: Row( @@ -356,8 +298,6 @@ class OrderSpeedRequest extends StatelessWidget { onPressed: () async { box.write(BoxName.statusDriverLocation, 'on'); - // orderRequestController.changeApplied(); - var res = await CRUD() .post(link: AppLink.updateStausFromSpeed, payload: { 'id': myList[16], @@ -378,8 +318,7 @@ class OrderSpeedRequest extends StatelessWidget { middleTextStyle: AppStyle.title, confirm: MyElevatedButton( title: 'Ok'.tr, onPressed: () => Get.back())); - } else if (json['message'] == - "Ride data updated successfully") { + } else if (json['status'] == "success") { List bodyToPassenger = [ box.read(BoxName.driverID).toString(), box.read(BoxName.nameDriver).toString(), diff --git a/lib/views/home/map_page_passenger.dart b/lib/views/home/map_page_passenger.dart index df8c53c..6a6302a 100644 --- a/lib/views/home/map_page_passenger.dart +++ b/lib/views/home/map_page_passenger.dart @@ -44,7 +44,7 @@ class MapPagePassenger extends StatelessWidget { const MapMenuWidget(), const MenuIconMapPageWidget(), buttomSheetMapPage(), - const CarDetailsTypeToChoose(), + CarDetailsTypeToChoose(), const ApplyOrderWidget(), // hexagonClipper(), const CancelRidePageShow(), diff --git a/lib/views/home/map_widget.dart/car_details_widget_to_go.dart b/lib/views/home/map_widget.dart/car_details_widget_to_go.dart index 72579c4..0167c46 100644 --- a/lib/views/home/map_widget.dart/car_details_widget_to_go.dart +++ b/lib/views/home/map_widget.dart/car_details_widget_to_go.dart @@ -6,6 +6,7 @@ import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import '../../../controller/functions/tts.dart'; import '../../../controller/home/map_passenger_controller.dart'; class CarType { @@ -31,11 +32,15 @@ List carTypes = [ carType: 'Delivery'.tr, carDetail: 'Delivery service'.tr, image: 'assets/images/moto.png'), + CarType( + carType: 'Free Ride'.tr, + carDetail: 'free ride without end point'.tr, + image: 'assets/images/freeRide.png'), ]; class CarDetailsTypeToChoose extends StatelessWidget { - const CarDetailsTypeToChoose({super.key}); - + CarDetailsTypeToChoose({super.key}); + final textToSpeechController = Get.put(TextToSpeechController()); @override Widget build(BuildContext context) { return GetBuilder( @@ -59,7 +64,7 @@ class CarDetailsTypeToChoose extends StatelessWidget { child: Column( children: [ SizedBox( - height: Get.height * .3, + height: Get.height * .4, child: ListView.builder( itemCount: carTypes.length, itemBuilder: (context, index) { @@ -117,9 +122,11 @@ class CarDetailsTypeToChoose extends StatelessWidget { ? mapPassengerController .totalPassenger .toStringAsFixed(2) - : mapPassengerController - .totalPassengerMotoDelivery - .toStringAsFixed(2), + : carType.carType == 'Delivery' + ? mapPassengerController + .totalPassengerMotoDelivery + .toStringAsFixed(2) + : '50', style: AppStyle.title .copyWith(fontSize: 20), ), @@ -177,40 +184,184 @@ class CarDetailsTypeToChoose extends StatelessWidget { onTap: () { mapPassengerController.selectCarFromList(index); + + if (mapPassengerController.selectedIndex != -1) { + // Get.snackbar('You should select one'.tr, '', + // backgroundColor: AppColor.greenColor); + if (mapPassengerController.selectedIndex == 0) { + box.write(BoxName.carType, 'Comfort'); + mapPassengerController.totalPassenger = + mapPassengerController + .totalPassengerComfort; + Get.defaultDialog( + title: 'Comfort', + titleStyle: AppStyle.title, + content: CarDialogue( + textToSpeechController: + textToSpeechController, + image: 'assets/images/blob.png', + text: + 'Best choice for comfort car and flexible route and stops point' + .tr), + confirm: MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Next'.tr, + onPressed: () { + Get.back(); + mapPassengerController + .isBottomSheetShown = false; + mapPassengerController.update(); + mapPassengerController + .changeCashConfirmPageShown(); + }), + cancel: MyElevatedButton( + title: 'Cancel'.tr, + kolor: AppColor.redColor, + onPressed: () { + Get.back(); + })); + } else if (mapPassengerController + .selectedIndex == + 1) { + box.write(BoxName.carType, 'Speed'); + mapPassengerController.totalPassenger = + mapPassengerController.totalPassenger; + Get.defaultDialog( + title: 'Speed', + titleStyle: AppStyle.title, + content: CarDialogue( + textToSpeechController: + textToSpeechController, + image: 'assets/images/carspeed.png', + text: + 'This trip goes directly from your starting point to your destination for a fixed price. The driver must follow the planned route' + .tr), + confirm: MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Next'.tr, + onPressed: () { + Get.back(); + mapPassengerController + .isBottomSheetShown = false; + mapPassengerController.update(); + mapPassengerController + .changeCashConfirmPageShown(); + }), + cancel: MyElevatedButton( + title: 'Cancel'.tr, + kolor: AppColor.redColor, + onPressed: () { + Get.back(); + })); + } else if (mapPassengerController + .selectedIndex == + 2) { + box.write(BoxName.carType, 'Delivery'); + mapPassengerController.totalPassenger = + mapPassengerController + .totalPassengerMotoDelivery; + Get.defaultDialog( + title: 'Delivery', + titleStyle: AppStyle.title, + content: CarDialogue( + textToSpeechController: + textToSpeechController, + image: 'assets/images/moto.png', + text: + 'This is for delivery or a motorcycle.' + .tr), + confirm: MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Next'.tr, + onPressed: () { + Get.back(); + mapPassengerController + .isBottomSheetShown = false; + mapPassengerController.update(); + mapPassengerController + .changeCashConfirmPageShown(); + }), + cancel: MyElevatedButton( + title: 'Cancel'.tr, + kolor: AppColor.redColor, + onPressed: () { + Get.back(); + })); + } else if (mapPassengerController + .selectedIndex == + 3) { + box.write(BoxName.carType, 'FreeRide'); + mapPassengerController.totalPassenger = 50; + Get.defaultDialog( + title: 'FreeRide', + titleStyle: AppStyle.title, + content: CarDialogue( + textToSpeechController: + textToSpeechController, + image: 'assets/images/freeRide.png', + text: + 'Perfect for adventure seekers who want to experience something new and exciting' + .tr), + confirm: MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Next'.tr, + onPressed: () { + Get.back(); + mapPassengerController + .isBottomSheetShown = false; + mapPassengerController.update(); + mapPassengerController + .changeCashConfirmPageShown(); + }), + cancel: MyElevatedButton( + title: 'Cancel'.tr, + kolor: AppColor.redColor, + onPressed: () { + Get.back(); + })); + } + } else { + Get.snackbar('You should select one'.tr, '', + backgroundColor: AppColor.redColor); + } }, ); }, ), ), - MyElevatedButton( - title: 'Next'.tr, - onPressed: () { - if (mapPassengerController.selectedIndex != -1) { - // Get.snackbar('You should select one'.tr, '', - // backgroundColor: AppColor.greenColor); - if (mapPassengerController.selectedIndex == 0) { - box.write(BoxName.carType, 'Comfort'); - mapPassengerController.totalPassenger = - mapPassengerController.totalPassengerComfort; - } else if (mapPassengerController.selectedIndex == - 1) { - box.write(BoxName.carType, 'Speed'); - } else if (mapPassengerController.selectedIndex == - 2) { - box.write(BoxName.carType, 'Delivery'); - mapPassengerController.totalPassenger = - mapPassengerController - .totalPassengerMotoDelivery; - } - mapPassengerController.isBottomSheetShown = false; - mapPassengerController.update(); - mapPassengerController.changeCashConfirmPageShown(); - // mapPassengerController.confirmRideForFirstDriver(); - } else { - Get.snackbar('You should select one'.tr, '', - backgroundColor: AppColor.redColor); - } - }) + // MyElevatedButton( + // title: 'Next'.tr, + // onPressed: () { + // if (mapPassengerController.selectedIndex != -1) { + // // Get.snackbar('You should select one'.tr, '', + // // backgroundColor: AppColor.greenColor); + // if (mapPassengerController.selectedIndex == 0) { + // box.write(BoxName.carType, 'Comfort'); + // mapPassengerController.totalPassenger = + // mapPassengerController.totalPassengerComfort; + // } else if (mapPassengerController.selectedIndex == + // 1) { + // box.write(BoxName.carType, 'Speed'); + // } else if (mapPassengerController.selectedIndex == + // 2) { + // box.write(BoxName.carType, 'Delivery'); + // mapPassengerController.totalPassenger = + // mapPassengerController + // .totalPassengerMotoDelivery; + // } else if (mapPassengerController.selectedIndex == + // 3) { + // box.write(BoxName.carType, 'FreeRide'); + // mapPassengerController.totalPassenger = 50; + // } + // mapPassengerController.isBottomSheetShown = false; + // mapPassengerController.update(); + // mapPassengerController.changeCashConfirmPageShown(); + // // mapPassengerController.confirmRideForFirstDriver(); + // } else { + // Get.snackbar('You should select one'.tr, '', + // backgroundColor: AppColor.redColor); + // } + // }) ], ), ), @@ -220,3 +371,44 @@ class CarDetailsTypeToChoose extends StatelessWidget { }); } } + +class CarDialogue extends StatelessWidget { + const CarDialogue({ + super.key, + required this.textToSpeechController, + required this.image, + required this.text, + }); + + final TextToSpeechController textToSpeechController; + final String image, text; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + image, + width: 50, + ), + IconButton( + onPressed: () { + textToSpeechController.speakText( + text, + ); + }, + icon: const Icon(Icons.headphones)), + ], + ), + Text( + text.tr, + style: AppStyle.title, + textAlign: TextAlign.center, + ), + ], + ); + } +}