2/6/5
This commit is contained in:
@@ -5,6 +5,7 @@ import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
@@ -861,14 +862,12 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
Future runEvery30SecondsUntilConditionMet() async {
|
||||
// Calculate the duration of the trip in minutes.
|
||||
double tripDurationInMinutes = duration1 / 20;
|
||||
double tripDurationInMinutes = duration1 / 4;
|
||||
int loopCount = tripDurationInMinutes.ceil();
|
||||
// If the trip duration is less than or equal to 50 minutes, then break the loop.
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(
|
||||
seconds:
|
||||
31)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
await Future.delayed(const Duration(seconds: 4));
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
@@ -940,49 +939,48 @@ class MapPassengerController extends GetxController {
|
||||
// clearPolylineAll();
|
||||
data = [];
|
||||
changeCancelRidePageShow();
|
||||
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isCashConfirmPageShown = false;
|
||||
isPassengerChosen = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
isPickerShown = false;
|
||||
isMarkersShown = false;
|
||||
haveSteps = false;
|
||||
isMarkersShown = false;
|
||||
// totalStepDurations = 0;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
if (rideId != 'yet') {
|
||||
if (rideId != '') {
|
||||
await CRUD().post(link: AppLink.updateDriverOrder, payload: {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
}
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isCashConfirmPageShown = false;
|
||||
isPassengerChosen = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
isPickerShown = false;
|
||||
isMarkersShown = false;
|
||||
haveSteps = false;
|
||||
isMarkersShown = false;
|
||||
// totalStepDurations = 0;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
remainingTime = 0;
|
||||
update();
|
||||
} else {
|
||||
clearPlacesDestination();
|
||||
clearPolyline();
|
||||
data = [];
|
||||
isPickerShown = false;
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isPassengerChosen = false;
|
||||
haveSteps = false;
|
||||
isMarkersShown = false;
|
||||
isCashConfirmPageShown = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
// totalStepDurations = 0;
|
||||
changeCancelRidePageShow();
|
||||
clearPolyline();
|
||||
remainingTime = 0;
|
||||
await CRUD().post(link: AppLink.updateDriverOrder, payload: {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Cancel Trip', 'Trip Cancelled'.tr, driverToken, []);
|
||||
|
||||
isPickerShown = false;
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isCashConfirmPageShown = false;
|
||||
isPassengerChosen = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
haveSteps = false;
|
||||
isMarkersShown = false;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
changeCancelRidePageShow();
|
||||
clearPolyline();
|
||||
remainingTime = 0;
|
||||
durationTimer = 0;
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -1015,7 +1013,7 @@ class MapPassengerController extends GetxController {
|
||||
if (heightMenuBool == true) {
|
||||
getDrawerMenu();
|
||||
}
|
||||
|
||||
initilizeGetStorage();
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -1389,21 +1387,6 @@ class MapPassengerController extends GetxController {
|
||||
i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
|
||||
// double distance1 = Geolocator.distanceBetween(
|
||||
// mylocation.latitude,
|
||||
// mylocation.longitude,
|
||||
// double.parse(carLocation['latitude']),
|
||||
// double.parse(carLocation['longitude']),
|
||||
// );
|
||||
// if (distance1 < nearestDistance) {
|
||||
// nearestDistance = distance1;
|
||||
// // nearestCarLocation = carLocation;
|
||||
// nearestCar = CarLocation(
|
||||
// distance: distance1,
|
||||
// id: carLocation['driver_id'],
|
||||
// latitude: double.parse(carLocation['latitude']),
|
||||
// longitude: double.parse(carLocation['longitude']),
|
||||
// );
|
||||
// }
|
||||
// isloading = true;
|
||||
update();
|
||||
@@ -1462,6 +1445,33 @@ class MapPassengerController extends GetxController {
|
||||
//print(nearestCar!.id);
|
||||
}
|
||||
|
||||
calculateDistanceBetweenPassengerAndDriverBeforecancelRide() async {
|
||||
// await getDriverCarsLocationToPassengerAfterApplied();
|
||||
double distance = Geolocator.distanceBetween(
|
||||
passengerLocation.latitude,
|
||||
passengerLocation.longitude,
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message']
|
||||
[carsOrder]['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message']
|
||||
[carsOrder]['longitude']));
|
||||
if (distance > 500) {
|
||||
cancelRide();
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
title: 'The Driver Will be in your location soon .'.tr,
|
||||
middleText: 'The distance less than 500 meter.'.tr,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
);
|
||||
// cancel: MyElevatedButton(
|
||||
// title: 'No.Iwant Cancel Trip.'.tr, onPressed: () {}));
|
||||
}
|
||||
}
|
||||
|
||||
List<double> headingAngles = [];
|
||||
|
||||
late LatLngBounds boundsData;
|
||||
@@ -1881,7 +1891,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
// mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
readyWayPoints();
|
||||
await getLocation();
|
||||
await addToken();
|
||||
|
||||
Reference in New Issue
Block a user