6/22/1
This commit is contained in:
@@ -254,7 +254,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
List<String> coordinatesWithoutEmpty = [];
|
||||
void getMapPointsForAllMethods() async {
|
||||
print(placesCoordinate.toString());
|
||||
clearPolyline();
|
||||
isMarkersShown = false;
|
||||
isWayPointStopsSheetUtilGetMap = false;
|
||||
@@ -271,7 +270,6 @@ class MapPassengerController extends GetxController {
|
||||
latestPosition = LatLng(
|
||||
double.parse(coordinatesWithoutEmpty.last.split(',')[0]),
|
||||
double.parse(coordinatesWithoutEmpty.last.split(',')[1]));
|
||||
// print(coordinatesWithoutEmpty);
|
||||
for (var i = 0; i < coordinatesWithoutEmpty.length; i++) {
|
||||
if ((i + 1) < coordinatesWithoutEmpty.length) {
|
||||
await getMapPoints(
|
||||
@@ -693,9 +691,7 @@ class MapPassengerController extends GetxController {
|
||||
try {
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId});
|
||||
if (res == 'failure') {
|
||||
// print(res);
|
||||
}
|
||||
if (res == 'failure') {}
|
||||
var decode = jsonDecode(res);
|
||||
|
||||
if (decode['data']['status'] == 'Begin') {
|
||||
@@ -711,10 +707,8 @@ class MapPassengerController extends GetxController {
|
||||
// isCancelRidePageShown = true;
|
||||
rideIsBeginPassengerTimer();
|
||||
runWhenRideIsBegin();
|
||||
// //print('rideTimerBegin: $rideTimerBegin');
|
||||
}
|
||||
} catch (e) {
|
||||
//print('Error: $e');
|
||||
// Handle the error or perform any necessary actions
|
||||
}
|
||||
}
|
||||
@@ -725,11 +719,8 @@ class MapPassengerController extends GetxController {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getRideStatusFromStartApp,
|
||||
payload: {'passenger_id': box.read(BoxName.passengerID)});
|
||||
if (res == 'failure') {
|
||||
//print(res);
|
||||
}
|
||||
if (res == 'failure') {}
|
||||
rideStatusFromStartApp = jsonDecode(res);
|
||||
print(rideStatusFromStartApp['data']['status']);
|
||||
if (rideStatusFromStartApp['data']['status'] == 'Begin') {
|
||||
statusRide = 'Begin';
|
||||
driverId = rideStatusFromStartApp['data']['driver_id'];
|
||||
@@ -751,7 +742,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
Map<String, dynamic> tripData =
|
||||
box.read(BoxName.tripData) as Map<String, dynamic>;
|
||||
print(tripData);
|
||||
final points = decodePolyline(
|
||||
tripData["routes"][0]["overview_polyline"]["points"]);
|
||||
|
||||
@@ -783,7 +773,6 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
}
|
||||
} catch (e) {
|
||||
//print('Error: $e');
|
||||
// Handle the error or perform any necessary actions
|
||||
}
|
||||
}
|
||||
@@ -893,8 +882,6 @@ class MapPassengerController extends GetxController {
|
||||
late String make = '';
|
||||
late String licensePlate = '';
|
||||
confirmRideForFirstDriver() async {
|
||||
print('confirmRideForFirstDriver');
|
||||
print('statusRide $statusRide');
|
||||
await getCarsLocationByPassengerAndReloadMarker();
|
||||
await getNearestDriverByPassengerLocationAPIGOOGLE();
|
||||
|
||||
@@ -928,7 +915,6 @@ class MapPassengerController extends GetxController {
|
||||
isDriversTokensSend = false;
|
||||
|
||||
update();
|
||||
// //print('rideConfirm= $rideConfirm');
|
||||
|
||||
await CRUD().post(link: AppLink.addRides, payload: {
|
||||
"start_location": //'${data[0]['start_address']}',
|
||||
@@ -949,7 +935,6 @@ class MapPassengerController extends GetxController {
|
||||
"price_for_passenger": totalME.toString(),
|
||||
"distance": distance.toString()
|
||||
}).then((value) {
|
||||
// //print(jsonDecode(value)['message']);
|
||||
// List<String> body = [
|
||||
rideId = jsonDecode(value)['message'];
|
||||
List<String> body = [
|
||||
@@ -995,7 +980,6 @@ class MapPassengerController extends GetxController {
|
||||
kazan.toStringAsFixed(0),
|
||||
passengerRate.toStringAsFixed(2),
|
||||
]; //
|
||||
print(body);
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Order',
|
||||
jsonDecode(value)['message'].toString(),
|
||||
@@ -1003,8 +987,6 @@ class MapPassengerController extends GetxController {
|
||||
body,
|
||||
// polylineCoordinates.toString()
|
||||
);
|
||||
print(dataCarsLocationByPassenger);
|
||||
// //print(dataCarsLocationByPassenger['message'][0]['token'].toString());
|
||||
});
|
||||
delayAndFetchRideStatus(rideId);
|
||||
if (shouldFetch == false) {
|
||||
@@ -1079,8 +1061,6 @@ class MapPassengerController extends GetxController {
|
||||
kazan.toStringAsFixed(0),
|
||||
passengerRate.toStringAsFixed(2),
|
||||
];
|
||||
print('driversToken');
|
||||
print(driversToken);
|
||||
for (var i = 1; i < driversToken.length; i++) {
|
||||
FirebaseMessagesController().sendNotificationToDriverMapPolyline(
|
||||
'OrderSpeed',
|
||||
@@ -1098,15 +1078,10 @@ class MapPassengerController extends GetxController {
|
||||
void delayAndFetchRideStatus(String rideId) {
|
||||
Timer(const Duration(milliseconds: 200), () async {
|
||||
if (shouldFetch) {
|
||||
// //print('shouldFetch is =$shouldFetch');
|
||||
if (remainingTimeToPassengerFromDriverAfterApplied > 0) {
|
||||
var res = await getRideStatus(rideId);
|
||||
|
||||
// print(res);
|
||||
// var decod = jsonDecode(res);
|
||||
print(
|
||||
' 000000000000000000delayAndFetchRideStatus0000000000000000000000000000000');
|
||||
print(res);
|
||||
if (res.toString() == 'Apply') {
|
||||
// getUpdatedRideForDriverApply(rideId);
|
||||
shouldFetch = false; // Stop further fetches
|
||||
@@ -1136,12 +1111,8 @@ class MapPassengerController extends GetxController {
|
||||
void delayAndFetchRideStatusForAllDriverAvailable(String rideId) {
|
||||
Timer(const Duration(milliseconds: 200), () async {
|
||||
if (shouldFetch) {
|
||||
// //print('shouldFetch is =$shouldFetch');
|
||||
var res = await getRideStatus(rideId);
|
||||
print(res);
|
||||
// var decod = jsonDecode(res);
|
||||
print('--------delayAndFetchRideStatusForAllDriverAvailable----');
|
||||
// print(decod['data']);
|
||||
if (res.toString() == 'Apply') {
|
||||
getUpdatedRideForDriverApply(rideId);
|
||||
|
||||
@@ -1166,11 +1137,8 @@ class MapPassengerController extends GetxController {
|
||||
if (remainingTime == 0) {
|
||||
rideConfirm = false;
|
||||
|
||||
// //print(timeToPassengerFromDriverAfterApplied);
|
||||
timeToPassengerFromDriverAfterApplied += durationToPassenger;
|
||||
// //print(duration1);
|
||||
|
||||
// //print('timeToPassengerFromDriverAfterApplied====' +
|
||||
// timeToPassengerFromDriverAfterApplied.toString());
|
||||
startTimerFromDriverToPassengerAfterApplied();
|
||||
update();
|
||||
@@ -1181,8 +1149,6 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
void timerEnded() async {
|
||||
//print('Timer ended');
|
||||
|
||||
runEvery30SecondsUntilConditionMet();
|
||||
isCancelRidePageShown = false;
|
||||
update();
|
||||
@@ -1202,16 +1168,6 @@ class MapPassengerController extends GetxController {
|
||||
await CRUD().get(link: AppLink.getRideOrderID, payload: {'id': rideId});
|
||||
if (res != 'failure') {
|
||||
var response = jsonDecode(res);
|
||||
print('driverId: ${response['data']['driver_id']}');
|
||||
print('driverPhone: ${response['data']['phone']}');
|
||||
print('driverCarMake: ${response['data']['make']}');
|
||||
print('model: ${response['data']['model']}');
|
||||
print('make: ${response['data']['make']}');
|
||||
print('licensePlate: ${response['data']['car_plate']}');
|
||||
print('firstName: ${response['data']['first_name']}');
|
||||
print('driverToken: ${response['data']['token']}');
|
||||
print('carYear: ${response['data']['year']}');
|
||||
print('driverRate: ${response['data']['ratingDriver']}');
|
||||
driverId = response['data']['driver_id'];
|
||||
driverPhone = response['data']['phone'];
|
||||
driverCarMake = response['data']['make'];
|
||||
@@ -1267,7 +1223,6 @@ class MapPassengerController extends GetxController {
|
||||
// Get.snackbar('no car', 'message');
|
||||
noCarString = false;
|
||||
dataCarsLocationByPassenger = jsonDecode(res);
|
||||
//print(dataCarsLocationByPassenger);
|
||||
// if (dataCarsLocationByPassenger.length > carsOrder) {
|
||||
driverId = dataCarsLocationByPassenger['message'][carsOrder]
|
||||
['driver_id']
|
||||
@@ -1276,8 +1231,6 @@ class MapPassengerController extends GetxController {
|
||||
.toString();
|
||||
// }
|
||||
|
||||
// //print('driverId==============$driverId');
|
||||
|
||||
carsLocationByPassenger.clear(); // Clear existing markers
|
||||
|
||||
// late LatLng lastDriverLocation; // Initialize a variable for last location
|
||||
@@ -1286,7 +1239,6 @@ class MapPassengerController extends GetxController {
|
||||
i < dataCarsLocationByPassenger['message'].length;
|
||||
i++) {
|
||||
var json = dataCarsLocationByPassenger['message'][i];
|
||||
print(json);
|
||||
CarLocationModel model = CarLocationModel.fromJson(json);
|
||||
if (carLocationsModels.length < i + 1) {
|
||||
carLocationsModels.add(model);
|
||||
@@ -1371,7 +1323,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
void handleResponse(Map<String, dynamic> res1) {
|
||||
if (res1['message'] == "No passenger found for the given phone number") {
|
||||
print(res1);
|
||||
Get.defaultDialog(
|
||||
title: "No user found for the given phone number".tr,
|
||||
titleStyle: AppStyle.title,
|
||||
@@ -1472,7 +1423,6 @@ class MapPassengerController extends GetxController {
|
||||
// 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.
|
||||
print('loop is $i from $loopCount');
|
||||
await Future.delayed(const Duration(seconds: 4));
|
||||
if (rideTimerBegin == true) {
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
@@ -1502,7 +1452,6 @@ class MapPassengerController extends GetxController {
|
||||
['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['longitude']));
|
||||
print('driver position $driverPosition');
|
||||
final driverAcceptedMarker = Marker(
|
||||
markerId: const MarkerId('driverToPassengers'),
|
||||
position: driverPosition,
|
||||
@@ -1552,13 +1501,10 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
Future cancelRide() async {
|
||||
//print("rideConfirm=$rideConfirm");
|
||||
|
||||
if (rideConfirm == false && statusRide == 'Apply') {
|
||||
clearPlacesDestination();
|
||||
clearPolyline();
|
||||
// clearPolylineAll();
|
||||
print('rideConfirm before is $rideConfirm');
|
||||
data = [];
|
||||
changeCancelRidePageShow();
|
||||
if (rideId != 'yet') {
|
||||
@@ -1593,7 +1539,6 @@ class MapPassengerController extends GetxController {
|
||||
} else {
|
||||
clearPlacesDestination();
|
||||
clearPolyline();
|
||||
print('rideConfirm is $rideConfirm');
|
||||
data = [];
|
||||
await CRUD().post(link: AppLink.updateDriverOrder, payload: {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
@@ -1682,7 +1627,6 @@ class MapPassengerController extends GetxController {
|
||||
void changeWayPointStopsSheet() {
|
||||
// int waypointsLength = Get.find<WayPointController>().wayPoints.length;
|
||||
|
||||
//print('isWayPointStopsSheet $wayPointIndex');
|
||||
if (wayPointIndex > -1) {
|
||||
isWayPointStopsSheet = true;
|
||||
isWayPointStopsSheetUtilGetMap = true;
|
||||
@@ -1772,7 +1716,6 @@ class MapPassengerController extends GetxController {
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
placesDestination = response['results'];
|
||||
//print(placesDestination);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1784,7 +1727,6 @@ class MapPassengerController extends GetxController {
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
placesStart = response['results'];
|
||||
//print(placesStart);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1796,7 +1738,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
wayPoint0 = response['results'];
|
||||
placeListResponseAll[index] = response['results'];
|
||||
//print(wayPoint0);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1944,10 +1885,6 @@ class MapPassengerController extends GetxController {
|
||||
newStartPointLocation = passengerLocation;
|
||||
speed = _locationData.speed!;
|
||||
// //print location details
|
||||
// //print('Accuracy: ${_locationData.accuracy}');
|
||||
// //print('Latitude: ${_locationData.latitude}');
|
||||
// //print('Longitude: ${_locationData.longitude}');
|
||||
// //print('Time: ${_locationData.time}');
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
@@ -1984,7 +1921,6 @@ class MapPassengerController extends GetxController {
|
||||
// void startMarkerReloading() {
|
||||
// int count = 0;
|
||||
// markerReloadingTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
|
||||
// //print('timer==============================');
|
||||
// reloadMarkers();
|
||||
//
|
||||
// count++;
|
||||
@@ -2000,7 +1936,6 @@ class MapPassengerController extends GetxController {
|
||||
Timer.periodic(const Duration(seconds: 2), (timer) {
|
||||
reloadCount++;
|
||||
|
||||
//print('Reloading markers ($reloadCount)');
|
||||
if (!rideConfirm) {
|
||||
reloadMarkers();
|
||||
} else {
|
||||
@@ -2009,7 +1944,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
if (reloadCount >= 35) {
|
||||
timer.cancel(); // Stop the timer after 5 reloads
|
||||
//print('Marker reloading completed.');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2063,7 +1997,6 @@ class MapPassengerController extends GetxController {
|
||||
latitude: double.parse(carLocation['latitude']),
|
||||
longitude: double.parse(carLocation['longitude']),
|
||||
);
|
||||
print('nearestCar ${nearestDistance.toStringAsFixed(0)}');
|
||||
|
||||
// Update the UI with the nearest driver
|
||||
update();
|
||||
@@ -2132,7 +2065,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// Handle the distance and duration as needed
|
||||
else {
|
||||
//print(
|
||||
// 'Failed to retrieve distance and duration: ${response['status']}');
|
||||
// Handle the failure case
|
||||
}
|
||||
@@ -2140,11 +2072,6 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
}
|
||||
//print(nearestCar!.distance);
|
||||
//print(nearestCar!.duration);
|
||||
//print(nearestCar!.latitude);
|
||||
//print(nearestCar!.longitude);
|
||||
//print(nearestCar!.id);
|
||||
}
|
||||
|
||||
calculateDistanceBetweenPassengerAndDriverBeforeCancelRide() async {
|
||||
@@ -2202,7 +2129,6 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
remainingTime = 25; //to make cancel every call
|
||||
await getCarsLocationByPassengerAndReloadMarker();
|
||||
// //print(carsLocationByPassenger);
|
||||
var coordDestination = destination.split(',');
|
||||
double latPassengerDestination = double.parse(coordDestination[0]);
|
||||
double lngPassengerDestination = double.parse(coordDestination[1]);
|
||||
@@ -2218,7 +2144,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
// //print(data);
|
||||
box.remove(BoxName.tripData);
|
||||
box.write(BoxName.tripData, response);
|
||||
startNameAddress = data[0]['start_address'];
|
||||
@@ -2314,12 +2239,9 @@ class MapPassengerController extends GetxController {
|
||||
// '&key=${AK.mapAPIKEY}';
|
||||
// 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(durationToRide0);
|
||||
// print('durationToRide = $durationToRide');
|
||||
// distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000;
|
||||
// update();
|
||||
// final points =
|
||||
@@ -2357,16 +2279,12 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destinationSteps&origin=$originSteps&key=${AK.mapAPIKEY}');
|
||||
// //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(durationToRide0);
|
||||
print('durationToRide = $durationToRide');
|
||||
distance = distanceOfDestination + (data[0]['distance']['value']) / 1000;
|
||||
|
||||
update();
|
||||
@@ -2422,10 +2340,6 @@ class MapPassengerController extends GetxController {
|
||||
LatLngBounds bounds =
|
||||
LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
|
||||
print('boundsbounds');
|
||||
print(bounds);
|
||||
print('boundsbounds');
|
||||
|
||||
// Fit the camera to the bounds
|
||||
var cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 180);
|
||||
mapController!.animateCamera(cameraUpdate);
|
||||
@@ -2471,7 +2385,6 @@ class MapPassengerController extends GetxController {
|
||||
var decode = jsonDecode(value);
|
||||
|
||||
if (decode["status"] == "success") {
|
||||
//print(totalPassenger);
|
||||
var firstElement = decode["message"][0];
|
||||
if (double.parse(box.read(BoxName.passengerWalletTotal)) < 0) {
|
||||
totalPassenger = totalCostPassenger -
|
||||
@@ -2487,7 +2400,6 @@ class MapPassengerController extends GetxController {
|
||||
(totalDriver * int.parse(firstElement['amount']) / 100);
|
||||
promoTaken = true;
|
||||
update();
|
||||
//print(totalPassenger);
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
@@ -2510,8 +2422,6 @@ class MapPassengerController extends GetxController {
|
||||
Future bottomSheet() async {
|
||||
if (data.isNotEmpty) {
|
||||
durationToAdd = Duration(seconds: durationToRide);
|
||||
print('durationToRide----- $durationToRide');
|
||||
print('durationToAdd----- $durationToAdd');
|
||||
hours = durationToAdd.inHours;
|
||||
minutes = (durationToAdd.inMinutes % 60).round();
|
||||
DateTime currentTime = DateTime.now();
|
||||
@@ -2519,11 +2429,7 @@ class MapPassengerController extends GetxController {
|
||||
averageDuration = (durationToRide / 60) / distance;
|
||||
// costDuration = (durationToRide / 60) * averageDuration * 0.016;
|
||||
costDuration = (durationToRide / 60).floorToDouble();
|
||||
print('costDuration----- $costDuration');
|
||||
print('costDistance----- $costDistance');
|
||||
print('Distance----- $distance');
|
||||
print(
|
||||
'passengerWalletTotal----- ${box.read(BoxName.passengerWalletTotal)}');
|
||||
'passengerWalletTotal----- ${box.read(BoxName.passengerWalletTotal)}';
|
||||
double costComfort, costSpeed, costDelivery, costLady, costRayehGai = 0;
|
||||
update();
|
||||
if (currentTime.hour >= 22 && currentTime.hour < 5) {
|
||||
@@ -2561,7 +2467,6 @@ class MapPassengerController extends GetxController {
|
||||
costDuration * 2;
|
||||
update();
|
||||
}
|
||||
//print('cost $cost');
|
||||
|
||||
var totalDriver1 = costDistance + costDuration;
|
||||
totalCostPassenger = totalDriver1 + (totalDriver1 * kazan / 100);
|
||||
@@ -2593,7 +2498,6 @@ class MapPassengerController extends GetxController {
|
||||
tax = totalCostPassenger * kazan / 100;
|
||||
totalME = totalCostPassenger - tax;
|
||||
costForDriver = fuelPrice * (20 / 210) * distance;
|
||||
print('cost for driver = $costForDriver');
|
||||
if (totalPassengerSpeed < 20) {
|
||||
// for eygpt 20 le open ride
|
||||
totalCostPassenger = 20;
|
||||
@@ -2620,9 +2524,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// buttomSheetMapPage();
|
||||
changeBottomSheetShown();
|
||||
} else {
|
||||
print('==========================');
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
|
||||
addToken() async {
|
||||
@@ -2720,7 +2622,6 @@ class MapPassengerController extends GetxController {
|
||||
payload: {'country': box.read(BoxName.countryCode).toString()},
|
||||
);
|
||||
if (res != 'failure') {
|
||||
print(jsonDecode(res));
|
||||
var json = jsonDecode(res);
|
||||
kazan = double.parse(json['message'][0]['kazan']);
|
||||
naturePrice = double.parse(json['message'][0]['naturePrice']);
|
||||
@@ -2739,7 +2640,6 @@ class MapPassengerController extends GetxController {
|
||||
link: AppLink.getPassengerRate,
|
||||
payload: {'passenger_id': box.read(BoxName.passengerID)});
|
||||
if (res != 'failure') {
|
||||
print(jsonDecode(res)['message']['rating']);
|
||||
if (jsonDecode(res)['message']['rating'] == null) {
|
||||
passengerRate = 5;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user