This commit is contained in:
Hamza Aleghwairyeen
2024-04-02 18:02:54 +03:00
parent 26d5beadc0
commit e822f8c552
2 changed files with 105 additions and 107 deletions

View File

@@ -438,93 +438,93 @@ class MapDriverController extends GetxController {
Get.find<LocationController>().myLocation.latitude,
Get.find<LocationController>().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<LocationController>();
myLocation = locationController.myLocation;
markers.add(
Marker(
markerId: MarkerId('MyLocation'.tr),

View File

@@ -129,26 +129,26 @@ GetBuilder<MapDriverController> driverEndRideBar() {
}
GetBuilder<MapDriverController> speedCircle() {
if (Get.find<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 GetBuilder<MapDriverController>(
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,