This commit is contained in:
Hamza Aleghwairyeen
2024-04-06 12:50:44 +03:00
parent 03c2289653
commit c7595de6c3
11 changed files with 149 additions and 44 deletions

View File

@@ -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();