4/6/1
This commit is contained in:
@@ -443,7 +443,9 @@ class MapDriverController extends GetxController {
|
||||
isRideFinished = true;
|
||||
isRideStarted = false;
|
||||
isPriceWindow = false;
|
||||
totalCost = price.toStringAsFixed(2);
|
||||
totalCost = carType == 'Comfort' || carType == 'Free Ride'
|
||||
? price.toStringAsFixed(1)
|
||||
: totalPassenger;
|
||||
paymentAmount = totalCost;
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
// changeRideToBeginToPassenger();
|
||||
@@ -470,7 +472,9 @@ class MapDriverController extends GetxController {
|
||||
Future.delayed(const Duration(milliseconds: 300));
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Driver Finish Trip',
|
||||
'you will pay to Driver'.tr + ' $price \$'.tr,
|
||||
'you will pay to Driver'.tr +
|
||||
' ${carType == 'Comfort' || carType == 'Free Ride' ? price.toStringAsFixed(1) : totalPassenger} \$'
|
||||
.tr,
|
||||
tokenPassenger,
|
||||
[
|
||||
box.read(BoxName.driverID),
|
||||
|
||||
@@ -587,7 +587,61 @@ class MapPassengerController extends GetxController {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressTimerRideBegin = i / durationToRide;
|
||||
remainingTimeTimerRideBegin = durationToRide - i;
|
||||
bool sendSOS = false;
|
||||
if (speed > 100 && sendSOS == false) {
|
||||
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 any additional information you want to include (optional)
|
||||
// - Example: current location (using GetX LocationController)
|
||||
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 with the constructed message
|
||||
launchCommunication(
|
||||
'whatsapp', box.read(BoxName.sosPhonePassenger), message);
|
||||
sendSOS = true;
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: "Cancel".tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
int minutes = (remainingTimeTimerRideBegin / 60).floor();
|
||||
int seconds = remainingTimeTimerRideBegin % 60;
|
||||
stringRemainingTimeRideBegin =
|
||||
@@ -636,7 +690,7 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void getRideStatusFromStartApp() async {
|
||||
getRideStatusFromStartApp() async {
|
||||
try {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getRideStatusFromStartApp,
|
||||
@@ -648,15 +702,36 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
if (decode['data']['status'] == 'Begin') {
|
||||
//todo from sql or get storage
|
||||
getMap(
|
||||
decode['data']['start_location'], decode['data']['end_location']);
|
||||
// timeToPassengerFromDriverAfterApplied = 0;
|
||||
// remainingTime = 0;
|
||||
// remainingTimeToPassengerFromDriverAfterApplied = 0;
|
||||
// // isCancelRidePageShown = true;
|
||||
// rideIsBeginPassengerTimer();
|
||||
// // //print('rideTimerBegin: $rideTimerBegin');
|
||||
// rideTimerBegin = true;
|
||||
List<dynamic> pol = box.read(BoxName.tripData);
|
||||
Map<String, dynamic> tripData =
|
||||
box.read(BoxName.tripData) as Map<String, dynamic>;
|
||||
final points = decodePolyline(
|
||||
tripData["routes"][0]["overview_polyline"]["points"]);
|
||||
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinates.add(LatLng(lat, lng));
|
||||
}
|
||||
var polyline = Polyline(
|
||||
polylineId: const PolylineId('begin trip'),
|
||||
points: polylineCoordinates,
|
||||
width: 10,
|
||||
color: Colors.blue,
|
||||
);
|
||||
|
||||
polyLines.add(polyline);
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
remainingTime = 0;
|
||||
remainingTimeToPassengerFromDriverAfterApplied = 0;
|
||||
remainingTimeDriverWaitPassenger5Minute = 0;
|
||||
rideTimerBegin = true;
|
||||
isDriverInPassengerWay = false;
|
||||
isDriverArrivePassenger = false;
|
||||
update();
|
||||
// isCancelRidePageShown = true;
|
||||
rideIsBeginPassengerTimer();
|
||||
runWhenRideIsBegin();
|
||||
update();
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -1578,6 +1653,7 @@ class MapPassengerController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
double speed = 0;
|
||||
Future<void> getLocation() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
@@ -1614,6 +1690,7 @@ class MapPassengerController extends GetxController {
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
newStartPointLocation = passengerLocation;
|
||||
speed = _locationData.speed!;
|
||||
// //print location details
|
||||
// //print('Accuracy: ${_locationData.accuracy}');
|
||||
// //print('Latitude: ${_locationData.latitude}');
|
||||
@@ -1886,6 +1963,7 @@ class MapPassengerController extends GetxController {
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
// //print(data);
|
||||
box.write(BoxName.tripData, response);
|
||||
startNameAddress = data[0]['start_address'];
|
||||
endNameAddress = data[0]['end_address'];
|
||||
isLoading = false;
|
||||
@@ -2367,8 +2445,9 @@ class MapPassengerController extends GetxController {
|
||||
await addToken();
|
||||
await getKazanPercent();
|
||||
await getPassengerRate();
|
||||
await getRideStatusFromStartApp();
|
||||
startMarkerReloading();
|
||||
// await getCarsLocationByPassenger();
|
||||
|
||||
// await getNearestDriverByPassengerLocation();
|
||||
|
||||
initilizeGetStorage();
|
||||
|
||||
Reference in New Issue
Block a user