11/21/1
This commit is contained in:
@@ -146,6 +146,7 @@ class MapPassengerController extends GetxController {
|
||||
double naturePrice = 0;
|
||||
bool heightMenuBool = false;
|
||||
String statusRide = 'wait';
|
||||
String statusRideVip = 'wait';
|
||||
bool statusRideFromStart = false;
|
||||
bool isPickerShown = false;
|
||||
bool isPointsPageForRider = false;
|
||||
@@ -747,9 +748,91 @@ class MapPassengerController extends GetxController {
|
||||
// update();
|
||||
}
|
||||
|
||||
int progressTimerRideBeginVip = 0;
|
||||
int elapsedTimeInSeconds = 0; // Timer starts from 0
|
||||
String stringElapsedTimeRideBegin = '0:00';
|
||||
String stringElapsedTimeRideBeginVip = '0:00';
|
||||
bool rideInProgress = true; // To control when to stop the timer
|
||||
|
||||
void rideIsBeginPassengerTimerVIP() async {
|
||||
rideInProgress = true; // Start the ride timer
|
||||
bool sendSOS = false;
|
||||
while (rideInProgress) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
// Increment elapsed time
|
||||
elapsedTimeInSeconds++;
|
||||
|
||||
// Update the time display
|
||||
int minutes = (elapsedTimeInSeconds / 60).floor();
|
||||
int seconds = elapsedTimeInSeconds % 60;
|
||||
stringElapsedTimeRideBeginVip =
|
||||
'$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
|
||||
// Check for speed and SOS conditions
|
||||
if (speed > 100 && !sendSOS) {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: "Warning: Speeding detected!".tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Text(
|
||||
"We noticed the speed is exceeding 100 km/h. Please slow down for your safety. If you feel unsafe, you can share your trip details with a contact or call the police using the red SOS button."
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: "Share Trip Details".tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
// Implement sharing trip details logic here
|
||||
String message = "**Emergency SOS from Passenger:**\n";
|
||||
|
||||
// Get trip details from GetX or relevant provider
|
||||
String origin = passengerLocation.toString();
|
||||
String destination = myDestination.toString();
|
||||
String driverName = firstName;
|
||||
String driverCarPlate = licensePlate;
|
||||
|
||||
// Add trip details to the message
|
||||
message += "* ${'Origin'.tr}: $origin\n";
|
||||
message += "* ${'Destination'.tr}: $destination\n";
|
||||
message += "* ${'Driver Name'.tr}: $driverName\n";
|
||||
message += "* ${'Driver Car Plate'.tr}: $driverCarPlate\n\n";
|
||||
message += "* ${'Driver Phone'.tr}: $driverPhone\n\n";
|
||||
|
||||
// Add current location
|
||||
message +=
|
||||
"${'Current Location'.tr}:https://www.google.com/maps/place/${passengerLocation.latitude},${passengerLocation.longitude} \n";
|
||||
|
||||
// Append a call to action
|
||||
message += "Please help! Contact me as soon as possible.".tr;
|
||||
|
||||
// Launch WhatsApp communication
|
||||
launchCommunication(
|
||||
'whatsapp', box.read(BoxName.sosPhonePassenger), message);
|
||||
sendSOS = true;
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: "Cancel".tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Update the UI
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void tripFinishedFromDriver() async {
|
||||
isRideFinished = true;
|
||||
rideTimerBegin = false;
|
||||
statusRideVip = 'Finished';
|
||||
box.write(BoxName.arrivalTime, '');
|
||||
remainingTimeTimerRideBegin = 0;
|
||||
box.write(BoxName.passengerWalletTotal, '0');
|
||||
@@ -795,6 +878,22 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
begiVIPTripFromPassenger() async {
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
remainingTime = 0;
|
||||
isBottomSheetShown = false;
|
||||
remainingTimeToPassengerFromDriverAfterApplied = 0;
|
||||
remainingTimeDriverWaitPassenger5Minute = 0;
|
||||
rideTimerBegin = true;
|
||||
statusRideVip = 'Begin';
|
||||
isDriverInPassengerWay = false;
|
||||
isDriverArrivePassenger = false;
|
||||
update();
|
||||
// isCancelRidePageShown = true;
|
||||
rideIsBeginPassengerTimerVIP();
|
||||
runWhenRideIsBegin();
|
||||
}
|
||||
|
||||
Map rideStatusFromStartApp = {};
|
||||
getRideStatusFromStartApp() async {
|
||||
try {
|
||||
@@ -1053,6 +1152,7 @@ class MapPassengerController extends GetxController {
|
||||
late String driverRate = '';
|
||||
late String firstName = '';
|
||||
late String carColor = '';
|
||||
late String colorHex = '';
|
||||
late String carYear = '';
|
||||
late String model = '';
|
||||
late String make = '';
|
||||
@@ -1099,6 +1199,8 @@ class MapPassengerController extends GetxController {
|
||||
.toString();
|
||||
carColor =
|
||||
dataCarsLocationByPassenger['data'][carsOrder]['color'].toString();
|
||||
colorHex = dataCarsLocationByPassenger['data'][carsOrder]['color_hex'] ??
|
||||
'#A52A2A';
|
||||
driverRate = dataCarsLocationByPassenger['data'][carsOrder]
|
||||
['ratingDriver']
|
||||
.toString();
|
||||
@@ -1971,7 +2073,10 @@ class MapPassengerController extends GetxController {
|
||||
return jsonDecode(response)['data'];
|
||||
}
|
||||
|
||||
late String driverCarModel, driverCarMake, driverLicensePlate, driverName;
|
||||
late String driverCarModel,
|
||||
driverCarMake,
|
||||
driverLicensePlate,
|
||||
driverName = '';
|
||||
getUpdatedRideForDriverApply(String rideId) async {
|
||||
// if (isDriversTokensSend) {
|
||||
final res = await CRUD().get(
|
||||
@@ -4597,12 +4702,13 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
Future mishwariOption() async {
|
||||
// isBottomSheetShown = false;
|
||||
isLoading = true;
|
||||
update();
|
||||
// add dialoug for select driver and car
|
||||
await selectDriverAndCarForMishwariTrip();
|
||||
Future.delayed(Duration.zero);
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
Get.to(() => CupertinoDriverListWidget());
|
||||
|
||||
// changeCashConfirmPageShown();
|
||||
@@ -4651,13 +4757,62 @@ class MapPassengerController extends GetxController {
|
||||
if (response != 'failure') {
|
||||
// Trip saved successfully
|
||||
// Get.snackbar('Success'.tr, 'Trip booked successfully'.tr);
|
||||
var id = response['message'].toString();
|
||||
var id = response['message']['id'].toString();
|
||||
await CRUD().post(
|
||||
link: '${AppLink.seferCairoServer}/ride/rides/add.php',
|
||||
payload: {
|
||||
"start_location":
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"end_location":
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"date": DateTime.now().toString(),
|
||||
"time": DateTime.now().toString(),
|
||||
"endtime":
|
||||
DateTime.now().add(const Duration(hours: 2)).toString(),
|
||||
"price": '50',
|
||||
"passenger_id": box.read(BoxName.passengerID).toString(),
|
||||
"driver_id": driver['driver_id'].toString(),
|
||||
"status": "waiting",
|
||||
'carType': 'vip',
|
||||
"price_for_driver": '50',
|
||||
"price_for_passenger": '50',
|
||||
"distance": '20',
|
||||
"paymentMethod": 'cash',
|
||||
}).then((value) {
|
||||
if (value is String) {
|
||||
final parsedValue = jsonDecode(value);
|
||||
rideId = parsedValue['message'];
|
||||
} else if (value is Map) {
|
||||
rideId = value['message'];
|
||||
} else {
|
||||
Log.print('Unexpected response type: ${value.runtimeType}');
|
||||
}
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
await CRUD().post(
|
||||
link: "${AppLink.endPoint}/ride/mishwari/add.php",
|
||||
payload: tripData);
|
||||
CRUD().post(link: '${AppLink.endPoint}/ride/rides/add.php', payload: {
|
||||
"start_location":
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"end_location":
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"date": DateTime.now().toString(),
|
||||
"time": DateTime.now().toString(),
|
||||
"endtime": DateTime.now().add(const Duration(hours: 2)).toString(),
|
||||
"price": '50',
|
||||
"passenger_id": box.read(BoxName.passengerID).toString(),
|
||||
"driver_id": driver['driver_id'].toString(),
|
||||
"status": "waiting",
|
||||
'carType': 'vip',
|
||||
"price_for_driver": '50',
|
||||
"price_for_passenger": '50',
|
||||
"distance": '20',
|
||||
"paymentMethod": 'cash',
|
||||
});
|
||||
}
|
||||
driverIdVip = driver['driver_id'];
|
||||
driverIdVip = driver['driver_id'].toString();
|
||||
driverId = driver['driver_id'].toString();
|
||||
|
||||
DateTime timeSelected = DateTime.parse(tripDateTime.toIso8601String());
|
||||
Get.find<NotificationController>().scheduleNotificationsForTimeSelected(
|
||||
@@ -4667,35 +4822,41 @@ class MapPassengerController extends GetxController {
|
||||
timeSelected);
|
||||
// Optionally, set up local notification or send a push notification
|
||||
|
||||
// await FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
// 'OrderVIP',
|
||||
// rideId.toString(),
|
||||
// driver['token'].toString(),
|
||||
// [
|
||||
// id,
|
||||
// driver['id'],
|
||||
// passengerLocation.latitude.toString(),
|
||||
// passengerLocation.longitude.toString(),
|
||||
// box.read(BoxName.name).toString(),
|
||||
// box.read(BoxName.passengerID).toString(),
|
||||
// box.read(BoxName.phone).toString(),
|
||||
// box.read(BoxName.email).toString(),
|
||||
// box.read(BoxName.passengerPhotoUrl).toString(),
|
||||
// box.read(BoxName.tokenFCM).toString(),
|
||||
// driver['token'].toString(),
|
||||
// ],
|
||||
// 'order.wav');
|
||||
await FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'OrderVIP',
|
||||
rideId.toString(),
|
||||
driver['token'].toString(),
|
||||
[
|
||||
id,
|
||||
driver['id'],
|
||||
passengerLocation.latitude.toString(),
|
||||
passengerLocation.longitude.toString(),
|
||||
box.read(BoxName.name).toString(),
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
box.read(BoxName.phone).toString(),
|
||||
box.read(BoxName.email).toString(),
|
||||
box.read(BoxName.passengerPhotoUrl).toString(),
|
||||
box.read(BoxName.tokenFCM).toString(),
|
||||
driver['token'].toString(),
|
||||
],
|
||||
'order.wav');
|
||||
if (response['message'] == "Trip updated successfully") {
|
||||
mySnackbarSuccess("Trip updated successfully".tr);
|
||||
// FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
// 'Order VIP Canceld'.tr,
|
||||
// 'Passenger cancel order'.tr,
|
||||
// token,
|
||||
// [],
|
||||
// 'cancel.wav',
|
||||
// );
|
||||
Log.print(
|
||||
'previous_driver_token: ${response['previous_driver_token']}');
|
||||
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Order VIP Canceld'.tr,
|
||||
'Passenger cancel order'.tr,
|
||||
response['previous_driver_token'].toString(),
|
||||
[],
|
||||
'cancel.wav',
|
||||
);
|
||||
}
|
||||
Get.to(() => const VipWaittingPage());
|
||||
// data = [];
|
||||
isBottomSheetShown = false;
|
||||
update();
|
||||
Get.to(() => VipWaittingPage());
|
||||
} else {
|
||||
throw Exception('Failed to save trip');
|
||||
}
|
||||
@@ -4723,6 +4884,16 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
sendToDriverAgain(String token) {
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Order VIP Canceld'.tr,
|
||||
'Passenger cancel order'.tr,
|
||||
token,
|
||||
[],
|
||||
'cancel.wav',
|
||||
);
|
||||
}
|
||||
|
||||
initilizeGetStorage() async {
|
||||
if (box.read(BoxName.addWork) == null) {
|
||||
box.write(BoxName.addWork, 'addWork');
|
||||
|
||||
Reference in New Issue
Block a user