This commit is contained in:
Hamza-Ayed
2024-02-07 21:21:32 +03:00
parent 42c7463181
commit 57d0560a8c
13 changed files with 339 additions and 55 deletions

View File

@@ -6,6 +6,7 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:ride/controller/functions/crud.dart';
import 'package:ride/controller/functions/toast.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import '../../constant/api_key.dart';
@@ -183,33 +184,56 @@ class FirebaseMessagesController extends GetxController {
// MapPassengerController mapController = Get.put(MapPassengerController());
Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor);
// mapController.driverArrivePassenger();
update();
} else if (message.notification!.title!.contains('Hi ,I will go now')) {
// MapPassengerController mapController = Get.put(MapPassengerController());
Get.snackbar('Hi ,I will go now', '',
backgroundColor: AppColor.greenColor);
// mapController.driverArrivePassenger();
update();
} else if (message.notification!.title!
.contains('Hi ,I Arrive your site')) {
// MapPassengerController mapController = Get.put(MapPassengerController());
Get.defaultDialog(
barrierDismissible: false,
title: 'Hi ,I Arrive your site'.tr,
middleText: 'Please go to Car Driver'.tr,
confirm: MyElevatedButton(
title: 'Ok I will go now.'.tr,
onPressed: () {
FirebaseMessagesController().sendNotificationToPassengerToken(
'Hi ,I will go now'.tr,
'I will go now'.tr,
Get.find<MapPassengerController>().driverToken, []);
Get.back();
}));
update();
} 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: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Your fee is ${Get.find<MapPassengerController>().totalPassenger.toStringAsFixed(2)}'),
Text('Do you want to pay Tips for this Driver'.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': '1',
'tipAmount': tip.toString(),
});
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': ((-1) * tip).toString()
});
if (res != 'failure') {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'You Have Tips',
'1\$ tips',
'${tip.toString()}\$ tips\nTotal is ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
driverList[2].toString(),
);
}
@@ -223,7 +247,8 @@ class FirebaseMessagesController extends GetxController {
cancel: MyElevatedButton(
title: 'No,I want'.tr,
onPressed: () {
Get.offAll(() => RateCaptainFromPassenger());
Get.back();
Get.off(() => RateCaptainFromPassenger());
},
kolor: AppColor.redColor,
));
@@ -411,3 +436,98 @@ class FirebaseMessagesController extends GetxController {
}
}
}
class DriverTipWidget extends StatelessWidget {
const DriverTipWidget({
super.key,
});
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Your fee is ${Get.find<MapPassengerController>().totalPassenger.toStringAsFixed(2)}'),
Text('Do you want to pay Tips for this Driver'.tr),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.05');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
AppColor.blueColor);
},
child: Container(
decoration: BoxDecoration(border: Border.all()),
child: const Padding(
padding: EdgeInsets.all(4),
child: Center(
child: Text('5%'),
),
),
),
),
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.10');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
AppColor.blueColor);
},
child: Container(
decoration: BoxDecoration(border: Border.all()),
child: const Center(
child: Padding(
padding: EdgeInsets.all(5),
child: Text('10%'),
),
),
),
),
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.15');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
AppColor.blueColor);
},
child: Container(
decoration: BoxDecoration(border: Border.all()),
child: const Center(
child: Padding(
padding: EdgeInsets.all(5),
child: Text('15%'),
),
),
),
),
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.20');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
AppColor.blueColor);
},
child: Container(
decoration: BoxDecoration(border: Border.all()),
child: const Center(
child: Padding(
padding: EdgeInsets.all(5),
child: Text('20%'),
),
),
),
),
],
)
],
);
}
}