passnger/5/3/4
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/widget/call_page.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/functions/toast.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/api_key.dart';
|
||||
@@ -17,15 +14,9 @@ import '../../constant/colors.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/Rate/rate_captain.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_speed_request.dart';
|
||||
import '../../views/home/map_page_passenger.dart';
|
||||
import '../../views/home/map_widget.dart/call_passenger_page.dart';
|
||||
import '../../views/home/profile/promos_passenger_page.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../home/map_passenger_controller.dart';
|
||||
import '../payment/payment_controller.dart';
|
||||
import 'local_notification.dart';
|
||||
|
||||
class FirebaseMessagesController extends GetxController {
|
||||
@@ -140,73 +131,22 @@ class FirebaseMessagesController extends GetxController {
|
||||
// 'PolylineJson': myPoints,
|
||||
'body': message.notification!.body
|
||||
});
|
||||
} else if (message.notification!.title! == 'Apply Ride') {
|
||||
var passengerList = message.data['passengerList'];
|
||||
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
driverID = myList[2].toString();
|
||||
|
||||
NotificationController().showNotification(
|
||||
'Apply Order'.tr, 'Driver Applied the Ride for You'.tr, 'order1');
|
||||
// driverAppliedTripSnakBar();
|
||||
} else if (message.notification!.title! == 'Promo') {
|
||||
NotificationController()
|
||||
.showNotification('Promo', 'Show latest promo'.tr, 'promo');
|
||||
Get.to(const PromosPassengerPage());
|
||||
} else if (message.notification!.title == 'Cancel Trip') {
|
||||
NotificationController().showNotification(
|
||||
'Cancel Trip'.tr, 'Passenger Cancel Trip'.tr, 'cancel');
|
||||
cancelTripDialog();
|
||||
} else if (message.notification!.title! == 'DriverIsGoingToPassenger') {
|
||||
Get.find<MapPassengerController>().isDriverInPassengerWay = true;
|
||||
Get.find<MapPassengerController>().update();
|
||||
NotificationController().showNotification('Driver is Going To You'.tr,
|
||||
'Please stay on the picked point.'.tr, 'tone1');
|
||||
// Get.snackbar('Driver is Going To Passenger', '',
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
} else if (message.notification!.title! == 'message From passenger') {
|
||||
NotificationController()
|
||||
.showNotification('message From passenger'.tr, ''.tr, 'tone2');
|
||||
passengerDialog(message.notification!.body!);
|
||||
|
||||
update();
|
||||
} else if (message.notification!.title! == 'RideIsBegin') {
|
||||
Get.find<MapPassengerController>().getBeginRideFromDriver();
|
||||
// Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor);
|
||||
box.write(BoxName.passengerWalletTotal, '0');
|
||||
NotificationController()
|
||||
.showNotification('Trip is Begin'.tr, ''.tr, 'start');
|
||||
update();
|
||||
} else if (message.notification!.title! == 'Hi ,I will go now') {
|
||||
// Get.snackbar('Hi ,I will go now', '',
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
NotificationController().showNotification(
|
||||
'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'tone2');
|
||||
update();
|
||||
} else if (message.notification!.title! == 'Hi ,I Arrive your site') {
|
||||
NotificationController()
|
||||
.showNotification('Hi ,I Arrive your site'.tr, ''.tr, 'tone2');
|
||||
driverArrivePassengerDialoge();
|
||||
|
||||
update();
|
||||
} else if (message.notification!.title! == 'Driver Finish Trip') {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
NotificationController().showNotification(
|
||||
'Driver Finish Trip'.tr,
|
||||
'you will pay to Driver'.tr + ' ${driverList[3].toString()} \$'.tr,
|
||||
'tone1');
|
||||
Get.find<MapPassengerController>().tripFinishedFromDriver();
|
||||
// if (Get.find<PaymentController>().isCashChecked == false &&
|
||||
// Get.find<PaymentController>().isWalletChecked == true) {
|
||||
// // driverFinishTripDialoge(driverList);
|
||||
// } else {
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
'price': driverList[3].toString()
|
||||
});
|
||||
// }
|
||||
} else if (message.notification!.title! == 'Call Income') {
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
@@ -219,11 +159,11 @@ class FirebaseMessagesController extends GetxController {
|
||||
);
|
||||
// }
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
Get.to(() => PassengerCallPage(
|
||||
channelName: driverList[1].toString(),
|
||||
token: driverList[0].toString(),
|
||||
remoteID: driverList[2].toString(),
|
||||
));
|
||||
// Get.to(() => PassengerCallPage(
|
||||
// channelName: driverList[1].toString(),
|
||||
// token: driverList[0].toString(),
|
||||
// remoteID: driverList[2].toString(),
|
||||
// ));
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
@@ -263,22 +203,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} else if (message.notification!.title! == 'Driver Cancel Your Trip') {
|
||||
// Get.snackbar(
|
||||
// 'You will be pay the cost to driver or we will get it from you on next trip'
|
||||
// .tr,
|
||||
// 'message',
|
||||
// backgroundColor: AppColor.redColor);
|
||||
if (Platform.isAndroid) {
|
||||
NotificationController().showNotification(
|
||||
'Driver Cancel Your Trip'.tr,
|
||||
'you will pay to Driver you will be pay the cost of driver time look to your SEFER Wallet'
|
||||
.tr,
|
||||
'cancel');
|
||||
}
|
||||
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(const MapPagePassenger());
|
||||
} else if (message.notification!.title! == 'Order Applied') {
|
||||
Get.snackbar(
|
||||
"The order has been accepted by another driver."
|
||||
@@ -346,24 +270,24 @@ class FirebaseMessagesController extends GetxController {
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> driverArrivePassengerDialoge() {
|
||||
return 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.find<MapPassengerController>()
|
||||
.startTimerDriverWaitPassenger5Minute();
|
||||
// Future<dynamic> driverArrivePassengerDialoge() {
|
||||
// return 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<MapDriverController>().driverToken, []);
|
||||
// Get.find<MapPassengerController>()
|
||||
// .startTimerDriverWaitPassenger5Minute();
|
||||
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
// Get.back();
|
||||
// }));
|
||||
// }
|
||||
|
||||
Future<dynamic> passengerDialog(String message) {
|
||||
return Get.defaultDialog(
|
||||
@@ -386,60 +310,60 @@ class FirebaseMessagesController extends GetxController {
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> driverFinishTripDialoge(List<dynamic> driverList) {
|
||||
return Get.defaultDialog(
|
||||
title: 'Driver Finish Trip'.tr,
|
||||
content: const 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()
|
||||
});
|
||||
// Future<dynamic> driverFinishTripDialoge(List<dynamic> driverList) {
|
||||
// return Get.defaultDialog(
|
||||
// title: 'Driver Finish Trip'.tr,
|
||||
// content: const 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.addDriversWalletPoints, 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'.tr}'} ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
driverList[2].toString(),
|
||||
);
|
||||
}
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
'price': driverList[3].toString()
|
||||
});
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No,I want'.tr,
|
||||
onPressed: () {
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
'price': driverList[3].toString()
|
||||
});
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
}
|
||||
// if (res != 'failure') {
|
||||
// FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
// 'You Have Tips',
|
||||
// '${'${tip.toString()}\$${' tips\nTotal is'.tr}'} ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
// driverList[2].toString(),
|
||||
// );
|
||||
// }
|
||||
// Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
// 'driverId': driverList[0].toString(),
|
||||
// 'rideId': driverList[1].toString(),
|
||||
// 'price': driverList[3].toString()
|
||||
// });
|
||||
// },
|
||||
// kolor: AppColor.greenColor,
|
||||
// ),
|
||||
// cancel: MyElevatedButton(
|
||||
// title: 'No,I want'.tr,
|
||||
// onPressed: () {
|
||||
// Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
// 'driverId': driverList[0].toString(),
|
||||
// 'rideId': driverList[1].toString(),
|
||||
// 'price': driverList[3].toString()
|
||||
// });
|
||||
// },
|
||||
// kolor: AppColor.redColor,
|
||||
// ));
|
||||
// }
|
||||
|
||||
void sendNotificationAll(String title, body) async {
|
||||
// Get the token you want to subtract.
|
||||
@@ -661,130 +585,3 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DriverTipWidget extends StatelessWidget {
|
||||
const DriverTipWidget({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<MapPassengerController>(builder: (controller) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
// Text(
|
||||
// '${'Your fee is '.tr}${Get.find<MapPassengerController>().totalPassenger.toStringAsFixed(2)}'),
|
||||
Text(
|
||||
'Do you want to pay Tips for this Driver'.tr,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipPercentage, '0.05');
|
||||
|
||||
Toast.show(
|
||||
context,
|
||||
'${'Tip is '.tr}${(controller.totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
controller.update();
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Center(
|
||||
child: Text('5%'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipPercentage, '0.10');
|
||||
Toast.show(
|
||||
context,
|
||||
'${'Tip is'.tr} ${(controller.totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
controller.update();
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Text('10%'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipPercentage, '0.15');
|
||||
Toast.show(
|
||||
context,
|
||||
'${'Tip is'.tr} ${(controller.totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
controller.update();
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Text('15%'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
box.write(BoxName.tipPercentage, '0.20');
|
||||
Toast.show(
|
||||
context,
|
||||
'${'Tip is'.tr} ${(controller.totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
|
||||
AppColor.blueColor);
|
||||
controller.update();
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Text('20%'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
MyElevatedButton(
|
||||
kolor: AppColor.redColor,
|
||||
title: 'No i want'.tr,
|
||||
onPressed: () {
|
||||
box.write(BoxName.tipPercentage, '0');
|
||||
controller.update();
|
||||
}),
|
||||
Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Text(
|
||||
'${(controller.totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))} ${box.read(BoxName.countryCode) == 'Egypt' ? 'LE'.tr : 'JOD'.tr}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user