From c853d8903762f98935584ebf4d88535e3bd64b08 Mon Sep 17 00:00:00 2001 From: Hamza Aleghwairyeen Date: Sat, 30 Mar 2024 01:08:06 +0300 Subject: [PATCH] 3/30/1 --- lib/constant/links.dart | 2 +- .../orderCaptin/order_request_page.dart | 700 ++++++++---------- .../orderCaptin/order_speed_request.dart | 691 ++++++++++------- 3 files changed, 732 insertions(+), 661 deletions(-) diff --git a/lib/constant/links.dart b/lib/constant/links.dart index df7a88c..f8f166b 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -53,6 +53,7 @@ class AppLink { static String getRideStatusFromStartApp = "$ride/rides/getRideStatusFromStartApp.php"; static String updateRides = "$ride/rides/update.php"; + static String updateStausFromSpeed = "$ride/rides/updateStausFromSpeed.php"; static String deleteRides = "$ride/rides/delete.php"; //-----------------DriverPayment------------------ @@ -63,7 +64,6 @@ class AppLink { static String getKazanPercent = "$ride/kazan/get.php"; static String addKazanPercent = "$ride/kazan/add.php"; - ////-----------------DriverPayment------------------ static String addDriverpayment = "$ride/payment/add.php"; static String addDriverPaymentPoints = "$ride/driverPayment/add.php"; diff --git a/lib/views/home/Captin/orderCaptin/order_request_page.dart b/lib/views/home/Captin/orderCaptin/order_request_page.dart index 23e8ec4..4063ef7 100644 --- a/lib/views/home/Captin/orderCaptin/order_request_page.dart +++ b/lib/views/home/Captin/orderCaptin/order_request_page.dart @@ -83,388 +83,336 @@ class OrderRequestPage extends StatelessWidget { return MyScafolld( title: 'Order Details'.tr, body: [ - ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // SizedBox(height: 200, child: Text(pointsList.toString())), - // Text(message.notification!.body.toString()), - SizedBox( - height: Get.height * .2, - child: GoogleMap( - initialCameraPosition: CameraPosition( - zoom: 12, - target: Get.find().myLocation), - cameraTargetBounds: CameraTargetBounds(bounds), - myLocationButtonEnabled: true, - trafficEnabled: true, - buildingsEnabled: true, - mapToolbarEnabled: true, - myLocationEnabled: true, - markers: { - Marker( - markerId: MarkerId('MyLocation'.tr), - position: - LatLng(latPassengerLocation, lngPassengerLocation), - draggable: true, - icon: startIcon), - Marker( - markerId: MarkerId('Destination'.tr), - position: LatLng( - latPassengerDestination, lngPassengerDestination), - draggable: true, - icon: endIcon), - }, - polylines: { - Polyline( - zIndex: 1, - consumeTapEvents: true, - geodesic: true, - endCap: Cap.buttCap, - startCap: Cap.buttCap, - visible: true, - polylineId: const PolylineId('routeOrder'), - points: pointsDirection, - color: AppColor.primaryColor, - width: 2, - ), - }, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // SizedBox(height: 200, child: Text(pointsList.toString())), + // Text(message.notification!.body.toString()), + SizedBox( + height: Get.height * .2, + child: GoogleMap( + initialCameraPosition: CameraPosition( + zoom: 12, + target: Get.find().myLocation), + cameraTargetBounds: CameraTargetBounds(bounds), + myLocationButtonEnabled: true, + trafficEnabled: true, + buildingsEnabled: true, + mapToolbarEnabled: true, + myLocationEnabled: true, + markers: { + Marker( + markerId: MarkerId('MyLocation'.tr), + position: LatLng( + latPassengerLocation, lngPassengerLocation), + draggable: true, + icon: startIcon), + Marker( + markerId: MarkerId('Destination'.tr), + position: LatLng( + latPassengerDestination, lngPassengerDestination), + draggable: true, + icon: endIcon), + }, + polylines: { + Polyline( + zIndex: 1, + consumeTapEvents: true, + geodesic: true, + endCap: Cap.buttCap, + startCap: Cap.buttCap, + visible: true, + polylineId: const PolylineId('routeOrder'), + points: pointsDirection, + color: AppColor.primaryColor, + width: 2, + ), + }, + ), ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Card( - elevation: 3, - color: myList[20].toString() == 'haveSteps' - ? AppColor.greenColor - : AppColor.secondaryColor, + Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + elevation: 3, + color: myList[20].toString() == 'haveSteps' + ? AppColor.greenColor + : AppColor.secondaryColor, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + TextButton.icon( + onPressed: () { + String mapUrl = + 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/'; + print(mapUrl); + showInBrowser(mapUrl); + }, + icon: const Icon(Icons.map), + label: myList[20].toString() == 'haveSteps' + ? Text( + 'Trip has Steps'.tr, + style: AppStyle.title, + ) + : Text('Rouats of Trip'.tr, + style: AppStyle.title)), + Container( + color: myList[13].toString() == 'true' + ? AppColor.deepPurpleAccent + : AppColor.greenColor, + child: myList[13].toString() == + 'true' //Visa or Cash Method from notify to driver + ? Text( + 'Visa', + style: AppStyle.title, + ) + : Text('Cash', style: AppStyle.title), + ) + ], + ), + ), + ), + + Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + double.parse(myList[2]).toStringAsFixed(2), + style: AppStyle.headTitle2, + ) + // RichText( + // text: TextSpan( + // text: 'Total From Passenger is '.tr, + // style: AppStyle.title, + // children: [ + // TextSpan( + // text: double.parse(myList[2]).toStringAsFixed(2), + // style: AppStyle.headTitle2), + // ], + // ), + // ), + ), + ), + Container( + height: Get.height * .15, + width: Get.width * .9, + decoration: AppStyle.boxDecoration1, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Icon( + Icons.arrow_circle_up, + color: AppColor.greenColor, + ), + Text( + myList[12] + ' ' + ' (${myList[11]}) ', + style: AppStyle.title, + ), + ], + ), + Text( + myList[29], + style: AppStyle.title, + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Icon( + Icons.arrow_circle_up, + color: AppColor.greenColor, + ), + Text( + myList[5] + ' ' + ' (${myList[4]}) ', + style: AppStyle.title, + ), + ], + ), + Text( + myList[30], + style: AppStyle.title, + ), + ], + ), + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: RichText( + text: TextSpan( + text: 'Passenger Name is '.tr, + style: AppStyle.subtitle, + children: [ + TextSpan(text: myList[8], style: AppStyle.title), + ], + ), + ), + ), + Padding( + padding: const EdgeInsets.all(4), + child: Container( + color: AppColor.deepPurpleAccent, + child: RichText( + text: TextSpan( + text: 'Cost Of Trip IS '.tr, + style: AppStyle.title, + children: [ + TextSpan( + text: double.parse(myList[26]).toStringAsFixed(2), + style: AppStyle.headTitle2), + ], + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - TextButton.icon( - onPressed: () { - String mapUrl = - 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/'; - print(mapUrl); - showInBrowser(mapUrl); - }, - icon: const Icon(Icons.map), - label: myList[20].toString() == 'haveSteps' - ? Text( - 'Trip has Steps'.tr, - style: AppStyle.title, - ) - : Text('Rouats of Trip'.tr, - style: AppStyle.title)), - Container( - color: myList[13].toString() == 'true' - ? AppColor.deepPurpleAccent - : AppColor.greenColor, - child: myList[13].toString() == - 'true' //Visa or Cash Method from notify to driver - ? Text( - 'Visa', - style: AppStyle.title, - ) - : Text('Cash', style: AppStyle.title), - ) + MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Accept Order'.tr, + onPressed: () async { + box.write(BoxName.statusDriverLocation, 'on'); + + orderRequestController.changeApplied(); + await CRUD().postFromDialogue( + link: AppLink.addDriverOrder, + payload: { + 'driver_id': myList[6].toString(), + // box.read(BoxName.driverID).toString(), + 'order_id': body.toString(), + 'status': 'Apply' + }); + await CRUD() + .post(link: AppLink.updateRides, payload: { + 'id': myList[16], + 'rideTimeStart': DateTime.now().toString(), + 'status': 'Apply', + 'driver_id': box.read(BoxName.driverID), + }); + // Get.back(); + List bodyToPassenger = [ + box.read(BoxName.driverID).toString(), + box.read(BoxName.nameDriver).toString(), + box.read(BoxName.tokenDriver).toString(), + ]; + // print(bodyToPassenger); + FirebaseMessagesController() + .sendNotificationToPassengerToken( + 'Apply Ride', 'your ride is applied'.tr, + // arguments['DriverList'][9].toString(), + arguments['DriverList'][9].toString(), + // box.read(BoxName.tokenDriver).toString(), + bodyToPassenger, + ); + Get.back(); + Get.to(() => PassengerLocationMapPage(), arguments: { + '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(), + }); + }, + ), + GetBuilder( + builder: (timerController) { + final isNearEnd = timerController.remainingTime <= + 5; // Define a threshold for "near end" + + return Stack( + alignment: Alignment.center, + children: [ + CircularProgressIndicator( + value: timerController.progress, + // Set the color based on the "isNearEnd" condition + color: isNearEnd ? Colors.red : Colors.blue, + ), + Text( + '${timerController.remainingTime}', + style: AppStyle.number, + ), + ], + ); + }, + ), + MyElevatedButton( + title: 'Refuse Order'.tr, + onPressed: () async { + List bodyToPassenger = [ + box.read(BoxName.driverID).toString(), + box.read(BoxName.nameDriver).toString(), + box.read(BoxName.tokenDriver).toString(), + ]; + + FirebaseMessagesController() + .sendNotificationToPassengerToken( + 'Refused Ride', + '${box.read(BoxName.nameDriver)} ${'rejct your order.'.tr}', + arguments['DriverList'][9].toString(), + // box.read(BoxName.tokenDriver).toString(), + bodyToPassenger, + ); + orderRequestController.refuseOrder( + myList[16].toString(), + ); + }, + kolor: AppColor.redColor, + ), ], ), - ), - ), - - Container( - decoration: AppStyle.boxDecoration1, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - double.parse(myList[2]).toStringAsFixed(2), - style: AppStyle.headTitle2, - ) - // RichText( - // text: TextSpan( - // text: 'Total From Passenger is '.tr, - // style: AppStyle.title, - // children: [ - // TextSpan( - // text: double.parse(myList[2]).toStringAsFixed(2), - // style: AppStyle.headTitle2), - // ], - // ), - // ), - ), - ), - Container( - height: Get.height * .15, - width: Get.width * .9, - decoration: AppStyle.boxDecoration1, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const Icon( - Icons.arrow_circle_up, - color: AppColor.greenColor, - ), - Text( - myList[12] + ' ' + ' (${myList[11]}) ', - style: AppStyle.title, - ), - ], - ), - Text( - myList[29], - style: AppStyle.title, - ), - ], - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const Icon( - Icons.arrow_circle_up, - color: AppColor.greenColor, - ), - Text( - myList[5] + ' ' + ' (${myList[4]}) ', - style: AppStyle.title, - ), - ], - ), - Text( - myList[30], - style: AppStyle.title, - ), - ], - ), - ], - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: RichText( - text: TextSpan( - text: 'Passenger Name is '.tr, - style: AppStyle.subtitle, - children: [ - TextSpan(text: myList[8], style: AppStyle.title), - ], - ), - ), - ), - // 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( - color: AppColor.deepPurpleAccent, - child: RichText( - text: TextSpan( - text: 'Cost Of Trip IS '.tr, - style: AppStyle.title, - children: [ - TextSpan( - text: double.parse(myList[26]).toStringAsFixed(2), - style: AppStyle.headTitle2), - ], - ), - ), - ), - ), - // 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( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - MyElevatedButton( - kolor: AppColor.greenColor, - title: 'Accept Order'.tr, - onPressed: () async { - box.write(BoxName.statusDriverLocation, 'on'); - - orderRequestController.changeApplied(); - await CRUD().postFromDialogue( - link: AppLink.addDriverOrder, - payload: { - 'driver_id': myList[6].toString(), - // box.read(BoxName.driverID).toString(), - 'order_id': body.toString(), - 'status': 'Apply' - }); - await CRUD().post(link: AppLink.updateRides, payload: { - 'id': myList[16], - 'rideTimeStart': DateTime.now().toString(), - 'status': 'Apply', - 'driver_id': box.read(BoxName.driverID), - }); - // Get.back(); - List bodyToPassenger = [ - box.read(BoxName.driverID).toString(), - box.read(BoxName.nameDriver).toString(), - box.read(BoxName.tokenDriver).toString(), - ]; - // print(bodyToPassenger); - FirebaseMessagesController() - .sendNotificationToPassengerToken( - 'Apply Ride', 'your ride is applied'.tr, - // arguments['DriverList'][9].toString(), - arguments['DriverList'][9].toString(), - // box.read(BoxName.tokenDriver).toString(), - bodyToPassenger, - ); - Get.back(); - Get.to(() => PassengerLocationMapPage(), arguments: { - '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(), - }); - }, - ), - GetBuilder( - builder: (timerController) { - final isNearEnd = timerController.remainingTime <= - 5; // Define a threshold for "near end" - - return Stack( - alignment: Alignment.center, - children: [ - CircularProgressIndicator( - value: timerController.progress, - // Set the color based on the "isNearEnd" condition - color: isNearEnd ? Colors.red : Colors.blue, - ), - Text( - '${timerController.remainingTime}', - style: AppStyle.number, - ), - ], - ); - }, - ), - MyElevatedButton( - title: 'Refuse Order'.tr, - onPressed: () async { - List bodyToPassenger = [ - box.read(BoxName.driverID).toString(), - box.read(BoxName.nameDriver).toString(), - box.read(BoxName.tokenDriver).toString(), - ]; - - FirebaseMessagesController() - .sendNotificationToPassengerToken( - 'Refused Ride', - '${box.read(BoxName.nameDriver)} ${'rejct your order.'.tr}', - arguments['DriverList'][9].toString(), - // box.read(BoxName.tokenDriver).toString(), - bodyToPassenger, - ); - orderRequestController.refuseOrder( - myList[16].toString(), - ); - }, - kolor: AppColor.redColor, - ), - ], - ), - ) - ], + ) + ], + ), ) ], isleading: true); diff --git a/lib/views/home/Captin/orderCaptin/order_speed_request.dart b/lib/views/home/Captin/orderCaptin/order_speed_request.dart index 9117016..dbad7b0 100644 --- a/lib/views/home/Captin/orderCaptin/order_speed_request.dart +++ b/lib/views/home/Captin/orderCaptin/order_speed_request.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:SEFER/controller/home/captin/home_captain_controller.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -33,6 +35,8 @@ class OrderSpeedRequest extends StatelessWidget { orderRequestController.startTimer(myList[6].toString(), body.toString()); var coords = myList[0].split(','); var coordDestination = myList[1].split(','); + BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker; + BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker; // Parse to double double latPassengerLocation = double.parse(coords[0]); @@ -58,307 +62,426 @@ class OrderSpeedRequest extends StatelessWidget { southwest: LatLng(minLatitude, minLongitude), northeast: LatLng(maxLatitude, maxLongitude), ); + // void addCustomStartIcon() async { +// Create the marker with the resized image + + ImageConfiguration config = ImageConfiguration( + size: const Size(25, 25), devicePixelRatio: Get.pixelRatio); + BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png', + mipmaps: false) + .then((value) { + startIcon = value; + }); + ImageConfiguration config1 = ImageConfiguration( + size: const Size(25, 25), devicePixelRatio: Get.pixelRatio); + BitmapDescriptor.fromAssetImage(config1, 'assets/images/b.png', + mipmaps: false) + .then((value) { + endIcon = value; + }); + // } + return MyScafolld( - title: 'Order Details Speed'.tr, + title: 'Order Details'.tr, body: [ - Container( - color: AppColor.accentColor, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // SizedBox(height: 200, child: Text(pointsList.toString())), - // Text(message.notification!.body.toString()), - SizedBox( - height: 200, - child: GoogleMap( - initialCameraPosition: CameraPosition( - zoom: 12, - target: Get.find().myLocation), - cameraTargetBounds: CameraTargetBounds(bounds), - myLocationButtonEnabled: true, - trafficEnabled: true, - buildingsEnabled: true, - mapToolbarEnabled: true, - myLocationEnabled: true, - markers: { - Marker( + ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // SizedBox(height: 200, child: Text(pointsList.toString())), + // Text(message.notification!.body.toString()), + SizedBox( + height: Get.height * .2, + child: GoogleMap( + initialCameraPosition: CameraPosition( + zoom: 12, + target: Get.find().myLocation), + cameraTargetBounds: CameraTargetBounds(bounds), + myLocationButtonEnabled: true, + trafficEnabled: true, + buildingsEnabled: true, + mapToolbarEnabled: true, + myLocationEnabled: true, + markers: { + Marker( markerId: MarkerId('MyLocation'.tr), position: LatLng(latPassengerLocation, lngPassengerLocation), draggable: true, - icon: BitmapDescriptor.defaultMarkerWithHue( - BitmapDescriptor.hueGreen), - ), - Marker( + icon: startIcon), + Marker( markerId: MarkerId('Destination'.tr), position: LatLng( latPassengerDestination, lngPassengerDestination), draggable: true, - icon: BitmapDescriptor.defaultMarkerWithHue( - BitmapDescriptor.hueBlue), - ), - }, - polylines: { - Polyline( - zIndex: 1, - consumeTapEvents: true, - geodesic: true, - endCap: Cap.buttCap, - startCap: Cap.buttCap, - visible: true, - polylineId: const PolylineId('routeOrder'), - points: pointsDirection, - color: AppColor.primaryColor, - width: 2, - ), - }, - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Card( - elevation: 3, - color: myList[20].toString() == 'haveSteps' - ? AppColor.greenColor - : AppColor.secondaryColor, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - TextButton.icon( - onPressed: () { - String mapUrl = - 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/'; - print(mapUrl); - showInBrowser(mapUrl); - }, - icon: const Icon(Icons.map), - label: myList[20].toString() == 'haveSteps' - ? Text( - 'Trip has Steps'.tr, - style: AppStyle.title, - ) - : Text('Rouats of Trip'.tr, - style: AppStyle.title)), - Container( - color: myList[13].toString() == 'true' - ? AppColor.deepPurpleAccent - : AppColor.greenColor, - child: myList[13].toString() == - 'true' //Visa or Cash Method from notify to driver - ? Text( - 'Visa', - style: AppStyle.title, - ) - : Text('Cash', style: AppStyle.title), - ) - ], + icon: endIcon), + }, + polylines: { + Polyline( + zIndex: 1, + consumeTapEvents: true, + geodesic: true, + endCap: Cap.buttCap, + startCap: Cap.buttCap, + visible: true, + polylineId: const PolylineId('routeOrder'), + points: pointsDirection, + color: AppColor.primaryColor, + width: 2, ), - ), + }, ), - - Padding( - padding: const EdgeInsets.all(8.0), - child: RichText( - text: TextSpan( - text: 'Passenger Name is '.tr, - style: AppStyle.title, - children: [ - TextSpan(text: myList[8], style: AppStyle.headTitle2), - ], - ), - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: RichText( - text: TextSpan( - text: 'Total From Passenger is '.tr, - style: AppStyle.title, - children: [ - TextSpan( - text: double.parse(myList[2]).toStringAsFixed(2), - style: AppStyle.headTitle2), - ], - ), - ), - ), - 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(8.0), - child: Container( - color: AppColor.deepPurpleAccent, - child: RichText( - text: TextSpan( - text: 'Cost Of Trip IS '.tr, - style: AppStyle.title, - children: [ - TextSpan( - text: double.parse(myList[26]).toStringAsFixed(2), - style: AppStyle.headTitle2), - ], - ), - ), - ), - ), - 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), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + elevation: 3, + color: myList[20].toString() == 'haveSteps' + ? AppColor.greenColor + : AppColor.secondaryColor, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - MyElevatedButton( - kolor: AppColor.greenColor, - title: 'Accept Order'.tr, - onPressed: () async { - box.write(BoxName.statusDriverLocation, 'on'); - - orderRequestController.changeApplied(); - await CRUD().postFromDialogue( - link: AppLink.addDriverOrder, - payload: { - 'driver_id': box.read( - BoxName.driverID), //myList[6].toString(), - // box.read(BoxName.driverID).toString(), - 'order_id': - myList[16].toString(), //body.toString(), - 'status': 'Apply' - }); - await CRUD() - .post(link: AppLink.updateRides, payload: { - 'id': myList[16], - 'rideTimeStart': DateTime.now().toString(), - 'status': 'Apply', - 'driver_id': box.read(BoxName.driverID), - }); - // Get.back(); - List bodyToPassenger = [ - box.read(BoxName.driverID).toString(), - box.read(BoxName.nameDriver).toString(), - box.read(BoxName.tokenDriver).toString(), - ]; - // print(bodyToPassenger); - FirebaseMessagesController() - .sendNotificationToPassengerToken( - 'Apply Ride', - 'The ${box.read(BoxName.nameDriver)} ${'accepted your order'.tr}', - arguments['DriverList'][9].toString(), - // box.read(BoxName.tokenDriver).toString(), - bodyToPassenger, - ); - Get.back(); - Get.to(() => PassengerLocationMapPage(), arguments: { - '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(), - }); - }, - ), - GetBuilder( - builder: (timerController) { - return Stack( - alignment: Alignment.center, - children: [ - CircularProgressIndicator( - value: timerController.progressSpeed, - // Set the color based on the "isNearEnd" condition - color: Colors.blue, - ), - Text( - '${timerController.remainingTimeSpeed}', - style: AppStyle.number, - ), - ], - ); - }, - ), + TextButton.icon( + onPressed: () { + String mapUrl = + 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/'; + print(mapUrl); + showInBrowser(mapUrl); + }, + icon: const Icon(Icons.map), + label: myList[20].toString() == 'haveSteps' + ? Text( + 'Trip has Steps'.tr, + style: AppStyle.title, + ) + : Text('Rouats of Trip'.tr, + style: AppStyle.title)), + Container( + color: myList[13].toString() == 'true' + ? AppColor.deepPurpleAccent + : AppColor.greenColor, + child: myList[13].toString() == + 'true' //Visa or Cash Method from notify to driver + ? Text( + 'Visa', + style: AppStyle.title, + ) + : Text('Cash', style: AppStyle.title), + ) ], ), - ) - ], - ), + ), + ), + + Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + double.parse(myList[2]).toStringAsFixed(2), + style: AppStyle.headTitle2, + ) + // RichText( + // text: TextSpan( + // text: 'Total From Passenger is '.tr, + // style: AppStyle.title, + // children: [ + // TextSpan( + // text: double.parse(myList[2]).toStringAsFixed(2), + // style: AppStyle.headTitle2), + // ], + // ), + // ), + ), + ), + Container( + height: Get.height * .15, + width: Get.width * .9, + decoration: AppStyle.boxDecoration1, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Icon( + Icons.arrow_circle_up, + color: AppColor.greenColor, + ), + Text( + myList[12] + ' ' + ' (${myList[11]}) ', + style: AppStyle.title, + ), + ], + ), + Text( + myList[29], + style: AppStyle.title, + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Icon( + Icons.arrow_circle_up, + color: AppColor.greenColor, + ), + Text( + myList[5] + ' ' + ' (${myList[4]}) ', + style: AppStyle.title, + ), + ], + ), + Text( + myList[30], + style: AppStyle.title, + ), + ], + ), + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: RichText( + text: TextSpan( + text: 'Passenger Name is '.tr, + style: AppStyle.subtitle, + children: [ + TextSpan(text: myList[8], style: AppStyle.title), + ], + ), + ), + ), + // 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( + color: AppColor.deepPurpleAccent, + child: RichText( + text: TextSpan( + text: 'Cost Of Trip IS '.tr, + style: AppStyle.title, + children: [ + TextSpan( + text: double.parse(myList[26]).toStringAsFixed(2), + style: AppStyle.headTitle2), + ], + ), + ), + ), + ), + // 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( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Accept Order'.tr, + onPressed: () async { + box.write(BoxName.statusDriverLocation, 'on'); + + orderRequestController.changeApplied(); + await CRUD().postFromDialogue( + link: AppLink.addDriverOrder, + payload: { + 'driver_id': myList[6].toString(), + // box.read(BoxName.driverID).toString(), + 'order_id': body.toString(), + 'status': 'Apply' + }); + await CRUD() + .post(link: AppLink.updateStausFromSpeed, payload: { + 'id': myList[16], + 'rideTimeStart': DateTime.now().toString(), + 'status': 'Apply', + 'driver_id': box.read(BoxName.driverID), + }).then((value) { + var json = jsonDecode(value); + if (json['message'] == + "This ride is already taken by another driver.") { + 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())); + } else if (json['message'] == + "Ride data updated successfully") { + List bodyToPassenger = [ + box.read(BoxName.driverID).toString(), + box.read(BoxName.nameDriver).toString(), + box.read(BoxName.tokenDriver).toString(), + ]; + // print(bodyToPassenger); + FirebaseMessagesController() + .sendNotificationToPassengerToken( + 'Apply Ride', 'your ride is applied'.tr, + // arguments['DriverList'][9].toString(), + arguments['DriverList'][9].toString(), + // box.read(BoxName.tokenDriver).toString(), + bodyToPassenger, + ); + Get.back(); + Get.to(() => PassengerLocationMapPage(), + arguments: { + '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(), + }); + } + }); + // Get.back(); + }, + ), + GetBuilder( + builder: (timerController) { + final isNearEnd = timerController.remainingTime <= + 5; // Define a threshold for "near end" + + return Stack( + alignment: Alignment.center, + children: [ + CircularProgressIndicator( + value: timerController.progress, + // Set the color based on the "isNearEnd" condition + color: isNearEnd ? Colors.red : Colors.blue, + ), + Text( + '${timerController.remainingTime}', + style: AppStyle.number, + ), + ], + ); + }, + ), + MyElevatedButton( + title: 'Refuse Order'.tr, + onPressed: () async { + Get.defaultDialog( + title: 'Reject Order'.tr, + titleStyle: AppStyle.title, + middleText: + 'You can decline a request without any cost'.tr, + middleTextStyle: AppStyle.title, + confirm: MyElevatedButton( + title: 'Ok'.tr, + onPressed: () { + Get.back(); + })); + }, + kolor: AppColor.redColor, + ), + ], + ), + ) + ], ) ], isleading: true);