1/18/1
This commit is contained in:
@@ -67,12 +67,12 @@ class MapPassengerController extends GetxController {
|
||||
late LatLng newPointLocation3 = const LatLng(32.115295, 36.064773);
|
||||
late LatLng newPointLocation4 = const LatLng(32.115295, 36.064773);
|
||||
LatLng myDestination = const LatLng(32.115295, 36.064773);
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
final List<LatLng> polylineCoordinates0 = [];
|
||||
final List<LatLng> polylineCoordinates1 = [];
|
||||
final List<LatLng> polylineCoordinates2 = [];
|
||||
final List<LatLng> polylineCoordinates3 = [];
|
||||
final List<LatLng> polylineCoordinates4 = [];
|
||||
List<LatLng> polylineCoordinates = [];
|
||||
List<LatLng> polylineCoordinates0 = [];
|
||||
List<LatLng> polylineCoordinates1 = [];
|
||||
List<LatLng> polylineCoordinates2 = [];
|
||||
List<LatLng> polylineCoordinates3 = [];
|
||||
List<LatLng> polylineCoordinates4 = [];
|
||||
List<List<LatLng>> polylineCoordinatesPointsAll = [];
|
||||
List<LatLng> carsLocationByPassenger = [];
|
||||
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
|
||||
@@ -187,7 +187,8 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
late Duration durationToAdd;
|
||||
late DateTime newTime = DateTime.now();
|
||||
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
void onChangedPassengerCount(int newValue) {
|
||||
selectedPassengerCount = newValue;
|
||||
update();
|
||||
@@ -573,7 +574,15 @@ class MapPassengerController extends GetxController {
|
||||
rideTimerBegin.toString(),
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
||||
.toString(),
|
||||
durationToRide.toString()
|
||||
durationToRide.toString(),
|
||||
Get.find<WayPointController>().wayPoints.length > 1
|
||||
? 'haveSteps'
|
||||
: 'startEnd',
|
||||
placesCoordinate[0],
|
||||
placesCoordinate[1],
|
||||
placesCoordinate[2],
|
||||
placesCoordinate[3],
|
||||
placesCoordinate[4],
|
||||
];
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Order',
|
||||
@@ -636,6 +645,14 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
cancelRideAfterRejectFromAll();
|
||||
}
|
||||
} else if (decod['data'].toString() == 'Cancel') {
|
||||
remainingTime = 0;
|
||||
shouldFetch = false;
|
||||
rideConfirm = false;
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Trip Canceled'.tr, '', driverToken, []);
|
||||
|
||||
update();
|
||||
} else {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
@@ -807,6 +824,7 @@ class MapPassengerController extends GetxController {
|
||||
"status": 'Cancel'
|
||||
});
|
||||
rideConfirm = false;
|
||||
totalStepDurations = 0;
|
||||
shouldFetch = false;
|
||||
isPassengerChosen = false;
|
||||
isCashConfirmPageShown = false;
|
||||
@@ -825,6 +843,7 @@ class MapPassengerController extends GetxController {
|
||||
if (rideConfirm == false) {
|
||||
clearPlacesDestination();
|
||||
clearPolyline();
|
||||
// clearPolylineAll();
|
||||
data = [];
|
||||
changeCancelRidePageShow();
|
||||
rideConfirm = false;
|
||||
@@ -834,6 +853,7 @@ class MapPassengerController extends GetxController {
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
isPickerShown = false;
|
||||
totalStepDurations = 0;
|
||||
totalStepDurations = 0;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
update();
|
||||
} else {
|
||||
@@ -852,7 +872,9 @@ class MapPassengerController extends GetxController {
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
totalStepDurations = 0;
|
||||
totalStepDurations = 0;
|
||||
changeCancelRidePageShow();
|
||||
// clearPolylineAll();
|
||||
remainingTime = 0;
|
||||
|
||||
update();
|
||||
@@ -1073,9 +1095,27 @@ class MapPassengerController extends GetxController {
|
||||
void clearPolyline() {
|
||||
polyLines = [];
|
||||
polylineCoordinates.clear();
|
||||
// polylineCoordinates = [];
|
||||
polylineCoordinatesPointsAll[0].clear();
|
||||
polylineCoordinatesPointsAll[1].clear();
|
||||
polylineCoordinatesPointsAll[2].clear();
|
||||
polylineCoordinatesPointsAll[3].clear();
|
||||
polylineCoordinatesPointsAll[4].clear();
|
||||
update();
|
||||
}
|
||||
|
||||
// void clearPolylineAll() {
|
||||
// polylineCoordinatesPointsAll[0].clear();
|
||||
// polylineCoordinatesPointsAll[1].clear();
|
||||
// polylineCoordinatesPointsAll[2].clear();
|
||||
// polylineCoordinatesPointsAll[3].clear();
|
||||
// polylineCoordinatesPointsAll[4].clear();
|
||||
|
||||
// polyLines = [];
|
||||
// polylineCoordinates.clear();
|
||||
// update();
|
||||
// }
|
||||
|
||||
void addCustomPicker() {
|
||||
ImageConfiguration config = const ImageConfiguration(
|
||||
size: Size(20, 20),
|
||||
@@ -1111,9 +1151,9 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: Size(Get.width * .6, Get.height * .6),
|
||||
// size: Size(20, 20),
|
||||
ImageConfiguration config = const ImageConfiguration(
|
||||
// size: Size(Get.width * .6, Get.height * .6),
|
||||
size: Size(20, 20),
|
||||
// scale: 1.0,
|
||||
);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
|
||||
@@ -1414,19 +1454,23 @@ class MapPassengerController extends GetxController {
|
||||
int totalStepDurations = 0;
|
||||
getMapPoints(String origin, String destination, int index) async {
|
||||
isWayPointStopsSheetUtilGetMap = false;
|
||||
|
||||
await getCarsLocationByPassenger();
|
||||
isLoading = false;
|
||||
update();
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
print(url);
|
||||
// print(url);
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
// print(data);
|
||||
isLoading = false;
|
||||
|
||||
int durationToRide0 = data[0]['duration']['value'];
|
||||
durationToRide = durationToRide + durationToRide0;
|
||||
print('durationToRide is ${data[0]['duration']['value']}');
|
||||
print('totalStepDurations is $durationToRide');
|
||||
update();
|
||||
durationToRide = durationToRide + int.parse(data[0]['duration']['value']);
|
||||
// totalStepDurations = totalStepDurations + durationToRide;
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
@@ -1452,20 +1496,20 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// Animate the camera to the adjusted bounds
|
||||
if (distanceOfDestnation <= 5) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 15));
|
||||
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
||||
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 12));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
|
||||
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
|
||||
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 9));
|
||||
} else if (distanceOfDestnation >= 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
|
||||
}
|
||||
if (polyLines.isNotEmpty) {
|
||||
clearPolyline();
|
||||
// clearPolyline();
|
||||
} else {
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
@@ -1540,18 +1584,21 @@ class MapPassengerController extends GetxController {
|
||||
print('=================================');
|
||||
distance = getDistanceFromText(distanceText);
|
||||
duration = getDistanceFromText(durationText);
|
||||
durationToAdd = Duration(minutes: duration.toInt());
|
||||
durationToAdd = Duration(seconds: durationToRide);
|
||||
print('durationToRide----- $durationToRide');
|
||||
hours = durationToAdd.inHours;
|
||||
minutes = (durationToAdd.inMinutes % 60).round();
|
||||
DateTime currentTime = DateTime.now();
|
||||
newTime = currentTime.add(durationToAdd);
|
||||
averageDuration = duration / distance;
|
||||
costDuration = duration * averageDuration * 0.016;
|
||||
averageDuration = (durationToRide / 60) / distance;
|
||||
costDuration = (durationToRide / 60) * averageDuration * 0.016;
|
||||
var totalDriver1 = cost + costDuration;
|
||||
totalPassenger = totalDriver1 + (totalDriver1 * .16);
|
||||
totalDriver = totalDriver1 + (totalDriver1 * .16);
|
||||
tax = totalPassenger * .04;
|
||||
totalME = totalPassenger - totalDriver - tax;
|
||||
tax = totalPassenger * .16;
|
||||
totalME = totalPassenger - tax;
|
||||
update();
|
||||
if (currentTime.hour >= 21) {
|
||||
if (currentTime.hour >= 22) {
|
||||
if (distanceText.contains('km')) {
|
||||
cost = distance * 0.23;
|
||||
update();
|
||||
@@ -1570,7 +1617,7 @@ class MapPassengerController extends GetxController {
|
||||
} else if (currentTime.hour >= 13 && currentTime.hour <= 16) {
|
||||
if (averageDuration > 2.5) {
|
||||
if (distanceText.contains('km')) {
|
||||
cost = distance * 0.23;
|
||||
cost = distance * 0.25;
|
||||
update();
|
||||
} else {
|
||||
cost = distance * 0.25 / 1000;
|
||||
@@ -1599,8 +1646,8 @@ class MapPassengerController extends GetxController {
|
||||
totalPassenger = 1;
|
||||
update();
|
||||
if (totalDriver < .5) {
|
||||
totalDriver = .80;
|
||||
totalME = .16;
|
||||
totalDriver = .75;
|
||||
totalME = .21;
|
||||
update();
|
||||
} else {
|
||||
totalDriver = .90;
|
||||
|
||||
Reference in New Issue
Block a user