2/9/3
This commit is contained in:
@@ -21,6 +21,7 @@ import '../../views/home/profile/promos_passenger_page.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../home/map_passenger_controller.dart';
|
||||
import '../home/payment/captain_wallet_controller.dart';
|
||||
import '../payment/payment_controller.dart';
|
||||
|
||||
class FirebaseMessagesController extends GetxController {
|
||||
final fcmToken = FirebaseMessaging.instance;
|
||||
@@ -204,56 +205,66 @@ class FirebaseMessagesController extends GetxController {
|
||||
} else if (message.notification!.title!.contains('Driver Finish Trip')) {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.defaultDialog(
|
||||
title: 'Driver Finish Trip'.tr,
|
||||
content: DriverTipWidget(),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Yes'.tr,
|
||||
onPressed: () async {
|
||||
var tip = (Get.find<MapPassengerController>().totalPassenger) *
|
||||
(double.parse(box.read(BoxName.tipAmount.toString())));
|
||||
var res = await CRUD().post(link: AppLink.addTips, payload: {
|
||||
'passengerID': box.read(BoxName.passengerID),
|
||||
'driverID': driverList[0].toString(),
|
||||
'rideID': driverList[1].toString(),
|
||||
'tipAmount': tip.toString(),
|
||||
});
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': ((-1) * tip).toString()
|
||||
});
|
||||
if (Get.find<PaymentController>().isCashChecked == false &&
|
||||
Get.find<PaymentController>().isWalletChecked == true) {
|
||||
Get.defaultDialog(
|
||||
title: 'Driver Finish Trip'.tr,
|
||||
content: DriverTipWidget(),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Yes'.tr,
|
||||
onPressed: () async {
|
||||
var tip = (Get.find<MapPassengerController>().totalPassenger) *
|
||||
(double.parse(box.read(BoxName.tipPercentage.toString())));
|
||||
var res = await CRUD().post(link: AppLink.addTips, payload: {
|
||||
'passengerID': box.read(BoxName.passengerID),
|
||||
'driverID': driverList[0].toString(),
|
||||
'rideID': driverList[1].toString(),
|
||||
'tipAmount': tip.toString(),
|
||||
});
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': ((-1) * tip).toString()
|
||||
});
|
||||
|
||||
await CRUD().post(link: AppLink.addDriversWallet, payload: {
|
||||
'driverID': driverList[0].toString(),
|
||||
'paymentID': '${Get.find<MapPassengerController>().rideId}tip',
|
||||
'amount': (tip * 100).toString(),
|
||||
'paymentMethod': 'visa-tip',
|
||||
});
|
||||
await CRUD()
|
||||
.post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': driverList[0].toString(),
|
||||
'paymentID':
|
||||
'${Get.find<MapPassengerController>().rideId}tip',
|
||||
'amount': (tip * 100).toString(),
|
||||
'paymentMethod': 'visa-tip',
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'You Have Tips',
|
||||
'${tip.toString()}\$ tips\nTotal is ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
driverList[2].toString(),
|
||||
);
|
||||
}
|
||||
Get.to(() => RateCaptainFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No,I want'.tr,
|
||||
onPressed: () {
|
||||
Get.to(() => RateCaptainFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
if (res != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'You Have Tips',
|
||||
'${tip.toString()}\$ tips\nTotal is ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
driverList[2].toString(),
|
||||
);
|
||||
}
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No,I want'.tr,
|
||||
onPressed: () {
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
} else {
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,10 +468,10 @@ class DriverTipWidget extends StatelessWidget {
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipAmount, '0.05');
|
||||
box.write(BoxName.tipPercentage, '0.05');
|
||||
Toast.show(
|
||||
context,
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
},
|
||||
child: Container(
|
||||
@@ -475,10 +486,10 @@ class DriverTipWidget extends StatelessWidget {
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipAmount, '0.10');
|
||||
box.write(BoxName.tipPercentage, '0.10');
|
||||
Toast.show(
|
||||
context,
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
},
|
||||
child: Container(
|
||||
@@ -493,10 +504,10 @@ class DriverTipWidget extends StatelessWidget {
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipAmount, '0.15');
|
||||
box.write(BoxName.tipPercentage, '0.15');
|
||||
Toast.show(
|
||||
context,
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
},
|
||||
child: Container(
|
||||
@@ -511,10 +522,10 @@ class DriverTipWidget extends StatelessWidget {
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipAmount, '0.20');
|
||||
box.write(BoxName.tipPercentage, '0.20');
|
||||
Toast.show(
|
||||
context,
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
|
||||
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
},
|
||||
child: Container(
|
||||
|
||||
Reference in New Issue
Block a user