diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index 1ec1ff7..aea2700 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -438,93 +438,93 @@ class MapDriverController extends GetxController { Get.find().myLocation.latitude, Get.find().myLocation.longitude, ); - if (carType != 'Comfort' || carType != 'Free Ride') { - if (distanceToDestination < 50) { - isRideFinished = true; - isRideStarted = false; - isPriceWindow = false; - - box.write(BoxName.statusDriverLocation, 'off'); - // changeRideToBeginToPassenger(); - await CRUD().post(link: AppLink.updateRides, payload: { - 'id': rideId, - 'rideTimeFinish': DateTime.now().toString(), - 'status': 'Finished' - }); - print('walletChecked is $walletChecked'); - if (walletChecked == 'true') { - await CRUD().post(link: AppLink.addPassengersWallet, payload: { - 'passenger_id': passengerId, - 'balance': ((-1) * double.parse(paymentAmount)).toString() - }); - } - print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}'); - if (double.parse(passengerWalletBurc) < 0) { - await CRUD().post(link: AppLink.addPassengersWallet, payload: { - 'passenger_id': passengerId, - 'balance': ((-1) * double.parse(passengerWalletBurc)).toString() - }); - print( - 'passengerWalletBurc aft ${double.parse(passengerWalletBurc)}'); - } - Future.delayed(const Duration(milliseconds: 300)); - FirebaseMessagesController().sendNotificationToPassengerToken( - 'Driver Finish Trip', - 'you will pay to Driver'.tr + ' $totalCost \$'.tr, - tokenPassenger, - [ - box.read(BoxName.driverID), - rideId, - box.read(BoxName.tokenDriver), - ], - ); - } else { - Get.defaultDialog( - title: 'You don\'t arrive destenation yet .'.tr, - middleText: '', - confirm: MyElevatedButton( - title: 'Ok'.tr, - onPressed: () { - Get.back(); - })); - } - } else { - totalCost = price.toStringAsFixed(2); - paymentAmount = totalCost; - box.write(BoxName.statusDriverLocation, 'off'); - // changeRideToBeginToPassenger(); - await CRUD().post(link: AppLink.updateRides, payload: { - 'id': rideId, - 'rideTimeFinish': DateTime.now().toString(), - 'status': 'Finished' + // if (carType != 'Comfort' || carType != 'Free Ride') { + // if (distanceToDestination < 50) { + isRideFinished = true; + isRideStarted = false; + isPriceWindow = false; + totalCost = price.toStringAsFixed(2); + paymentAmount = totalCost; + box.write(BoxName.statusDriverLocation, 'off'); + // changeRideToBeginToPassenger(); + await CRUD().post(link: AppLink.updateRides, payload: { + 'id': rideId, + 'rideTimeFinish': DateTime.now().toString(), + 'status': 'Finished' + }); + print('walletChecked is $walletChecked'); + if (walletChecked == 'true') { + await CRUD().post(link: AppLink.addPassengersWallet, payload: { + 'passenger_id': passengerId, + 'balance': ((-1) * double.parse(paymentAmount)).toString() }); - print('walletChecked is $walletChecked'); - if (walletChecked == 'true') { - await CRUD().post(link: AppLink.addPassengersWallet, payload: { - 'passenger_id': passengerId, - 'balance': ((-1) * double.parse(paymentAmount)).toString() - }); - } - print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}'); - if (double.parse(passengerWalletBurc) < 0) { - await CRUD().post(link: AppLink.addPassengersWallet, payload: { - 'passenger_id': passengerId, - 'balance': ((-1) * double.parse(passengerWalletBurc)).toString() - }); - print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}'); - } - Future.delayed(const Duration(milliseconds: 300)); - FirebaseMessagesController().sendNotificationToPassengerToken( - 'Driver Finish Trip', - 'you will pay to Driver'.tr + ' $totalCost \$'.tr, - tokenPassenger, - [ - box.read(BoxName.driverID), - rideId, - box.read(BoxName.tokenDriver), - ], - ); } + print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}'); + if (double.parse(passengerWalletBurc) < 0) { + await CRUD().post(link: AppLink.addPassengersWallet, payload: { + 'passenger_id': passengerId, + 'balance': ((-1) * double.parse(passengerWalletBurc)).toString() + }); + print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}'); + } + Future.delayed(const Duration(milliseconds: 300)); + FirebaseMessagesController().sendNotificationToPassengerToken( + 'Driver Finish Trip', + 'you will pay to Driver'.tr + ' $totalCost \$'.tr, + tokenPassenger, + [ + box.read(BoxName.driverID), + rideId, + box.read(BoxName.tokenDriver), + ], + ); + // } else { + // Get.defaultDialog( + // title: 'You don\'t arrive destenation yet .'.tr, + // middleText: '', + // confirm: MyElevatedButton( + // title: 'Ok'.tr, + // onPressed: () { + // Get.back(); + // })); + // } + // } else { + // totalCost = price.toStringAsFixed(2); + // paymentAmount = totalCost; + // box.write(BoxName.statusDriverLocation, 'off'); + // // changeRideToBeginToPassenger(); + // await CRUD().post(link: AppLink.updateRides, payload: { + // 'id': rideId, + // 'rideTimeFinish': DateTime.now().toString(), + // 'status': 'Finished' + // }); + // print('walletChecked is $walletChecked'); + // if (walletChecked == 'true') { + // await CRUD().post(link: AppLink.addPassengersWallet, payload: { + // 'passenger_id': passengerId, + // 'balance': ((-1) * double.parse(paymentAmount)).toString() + // }); + // } + // print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}'); + // if (double.parse(passengerWalletBurc) < 0) { + // await CRUD().post(link: AppLink.addPassengersWallet, payload: { + // 'passenger_id': passengerId, + // 'balance': ((-1) * double.parse(passengerWalletBurc)).toString() + // }); + // print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}'); + // } + // Future.delayed(const Duration(milliseconds: 300)); + // FirebaseMessagesController().sendNotificationToPassengerToken( + // 'Driver Finish Trip', + // 'you will pay to Driver'.tr + ' $totalCost \$'.tr, + // tokenPassenger, + // [ + // box.read(BoxName.driverID), + // rideId, + // box.read(BoxName.tokenDriver), + // ], + // ); + // } // add wallet from passenger from driver Get.to(() => RatePassenger(), arguments: { @@ -616,15 +616,13 @@ class MapDriverController extends GetxController { double recentAngelToMarker = 0; double speed = 0; void updateMarker() async { - // Remove the existing marker with the ID `MyLocation`. - markers.remove( MarkerId('MyLocation')); + markers.remove(MarkerId('MyLocation')); // Add a new marker with the ID `MyLocation` at the current location of the user. LocationController locationController = Get.find(); myLocation = locationController.myLocation; - - + markers.add( Marker( markerId: MarkerId('MyLocation'.tr), 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 3f72f0e..bb370c2 100644 --- a/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart +++ b/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart @@ -129,26 +129,26 @@ GetBuilder driverEndRideBar() { } GetBuilder speedCircle() { + if (Get.find().speed > 100) { + if (Platform.isIOS) { + HapticFeedback.selectionClick(); + } else { + Vibration.vibrate(duration: 1000); + } + Get.defaultDialog( + barrierDismissible: false, + titleStyle: AppStyle.title, + title: 'Speed Over'.tr, + middleText: 'Please slow down'.tr, + middleTextStyle: AppStyle.title, + confirm: MyElevatedButton( + title: 'I will slow down'.tr, + onPressed: () => Get.back(), + ), + ); + } return GetBuilder( builder: (mapDriverController) { - if (mapDriverController.speed > 100) { - if (Platform.isIOS) { - HapticFeedback.selectionClick(); - } else { - Vibration.vibrate(duration: 1000); - } - Get.defaultDialog( - barrierDismissible: false, - titleStyle: AppStyle.title, - title: 'Speed Over'.tr, - middleText: 'Please slow down'.tr, - middleTextStyle: AppStyle.title, - confirm: MyElevatedButton( - title: 'I will slow down'.tr, - onPressed: () => Get.back(), - ), - ); - } return mapDriverController.isRideStarted ? Positioned( bottom: 25,