8/17/1
This commit is contained in:
@@ -218,7 +218,7 @@ class MapPassengerController extends GetxController {
|
||||
bool currentLocationToFormPlaces3 = false;
|
||||
bool currentLocationToFormPlaces4 = false;
|
||||
List currentLocationToFormPlacesAll = [];
|
||||
late String driverToken;
|
||||
late String driverToken = '';
|
||||
int carsOrder = 0;
|
||||
int wayPointIndex = 0;
|
||||
late double kazan;
|
||||
@@ -559,7 +559,7 @@ class MapPassengerController extends GetxController {
|
||||
remainingTimeToPassengerFromDriverAfterApplied =
|
||||
timeToPassengerFromDriverAfterApplied - secondsElapsed;
|
||||
|
||||
if (remainingTimeToPassengerFromDriverAfterApplied < 69) {
|
||||
if (remainingTimeToPassengerFromDriverAfterApplied < 59) {
|
||||
if (rideTimerBegin == false) {
|
||||
rideTimerBegin = true;
|
||||
}
|
||||
@@ -1016,11 +1016,13 @@ class MapPassengerController extends GetxController {
|
||||
late String make = '';
|
||||
late String licensePlate = '';
|
||||
confirmRideForFirstDriver() async {
|
||||
startCarLocationSearch(box.read(BoxName.carType));
|
||||
// await getCarsLocationByPassengerAndReloadMarker();
|
||||
// startCarLocationSearch(box.read(BoxName.carType));
|
||||
await getCarsLocationByPassengerAndReloadMarker(
|
||||
box.read(BoxName.carType), 7000);
|
||||
await getNearestDriverByPassengerLocationAPIGOOGLE();
|
||||
|
||||
if (dataCarsLocationByPassenger != 'failure') {
|
||||
if (dataCarsLocationByPassenger != 'failure' ||
|
||||
dataCarsLocationByPassenger != null) {
|
||||
driverToken =
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['token'].toString();
|
||||
driverPhone =
|
||||
@@ -1050,7 +1052,6 @@ class MapPassengerController extends GetxController {
|
||||
isDriversTokensSend = false;
|
||||
|
||||
update();
|
||||
|
||||
await CRUD().post(link: AppLink.addRides, payload: {
|
||||
"start_location": //'${data[0]['start_address']}',
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
@@ -1131,6 +1132,51 @@ class MapPassengerController extends GetxController {
|
||||
Log.print(
|
||||
'body: ${dataCarsLocationByPassenger['message'][carsOrder]['token']}');
|
||||
});
|
||||
CRUD().post(
|
||||
link: '${AppLink.seferAlexandriaServer}/ride/rides/add.php',
|
||||
payload: {
|
||||
"start_location": //'${data[0]['start_address']}',
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"end_location": //'${data[0]['end_address']}',
|
||||
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
|
||||
"date": DateTime.now().toString(),
|
||||
"time": DateTime.now().toString(),
|
||||
"endtime": durationToAdd.toString(),
|
||||
"price": totalPassenger.toStringAsFixed(2),
|
||||
"passenger_id": box.read(BoxName.passengerID).toString(),
|
||||
"driver_id": dataCarsLocationByPassenger['message'][carsOrder]
|
||||
['driver_id']
|
||||
.toString(),
|
||||
"status": "waiting",
|
||||
'carType': box.read(BoxName.carType),
|
||||
"price_for_driver": totalPassenger.toString(),
|
||||
"price_for_passenger": totalME.toString(),
|
||||
"distance": distance.toString(),
|
||||
"paymentMethod": paymentController.isWalletChecked.toString(),
|
||||
});
|
||||
CRUD().post(
|
||||
link: '${AppLink.seferGizaServer}/ride/rides/add.php',
|
||||
payload: {
|
||||
"start_location": //'${data[0]['start_address']}',
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"end_location": //'${data[0]['end_address']}',
|
||||
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
|
||||
"date": DateTime.now().toString(),
|
||||
"time": DateTime.now().toString(),
|
||||
"endtime": durationToAdd.toString(),
|
||||
"price": totalPassenger.toStringAsFixed(2),
|
||||
"passenger_id": box.read(BoxName.passengerID).toString(),
|
||||
"driver_id": dataCarsLocationByPassenger['message'][carsOrder]
|
||||
['driver_id']
|
||||
.toString(),
|
||||
"status": "waiting",
|
||||
'carType': box.read(BoxName.carType),
|
||||
"price_for_driver": totalPassenger.toString(),
|
||||
"price_for_passenger": totalME.toString(),
|
||||
"distance": distance.toString(),
|
||||
"paymentMethod": paymentController.isWalletChecked.toString(),
|
||||
});
|
||||
|
||||
delayAndFetchRideStatus(rideId);
|
||||
if (shouldFetch == false) {
|
||||
startTimer();
|
||||
@@ -1156,8 +1202,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
bool isDriversTokensSend = false;
|
||||
confirmRideForAllDriverAvailable() async {
|
||||
// isDriversTokensSend = true;
|
||||
|
||||
driversToken.remove(driverToken);
|
||||
PaymentController paymentController = Get.find<PaymentController>();
|
||||
rideConfirm = true;
|
||||
@@ -1206,6 +1250,7 @@ class MapPassengerController extends GetxController {
|
||||
kazan.toStringAsFixed(0),
|
||||
passengerRate.toStringAsFixed(2),
|
||||
];
|
||||
Log.print('body: ${body}');
|
||||
for (var i = 1; i < driversToken.length; i++) {
|
||||
FirebaseMessagesController().sendNotificationToDriverMapPolyline(
|
||||
'OrderSpeed',
|
||||
@@ -1255,8 +1300,8 @@ class MapPassengerController extends GetxController {
|
||||
// }
|
||||
tick++;
|
||||
} else {
|
||||
timer
|
||||
.cancel(); // Stop the timer if remainingTimeToPassengerFromDriverAfterApplied <= 0
|
||||
timer.cancel();
|
||||
// Stop the timer if remainingTimeToPassengerFromDriverAfterApplied <= 0
|
||||
}
|
||||
} else {
|
||||
timer.cancel(); // Stop the timer if shouldFetch is false
|
||||
@@ -1269,124 +1314,132 @@ class MapPassengerController extends GetxController {
|
||||
"No Captain Accepted Your Order".tr,
|
||||
"We are looking for a captain but the price may increase to let a captain accept"
|
||||
.tr,
|
||||
backgroundColor: AppColor.bronze,
|
||||
backgroundColor: AppColor.yellowColor,
|
||||
);
|
||||
}
|
||||
|
||||
void delayAndFetchRideStatusForAllDriverAvailable(String rideId) async {
|
||||
startCarLocationSearch(box.read(BoxName.carType));
|
||||
int attemptCounter = 0;
|
||||
const int maxAttempts = 15;
|
||||
int attemptCounter = 0;
|
||||
bool isApplied = false;
|
||||
tick = 0;
|
||||
Log.print('tick delayAndFetchRideStatusForAllDriverAvailable: ${tick}');
|
||||
|
||||
void fetchRideStatus() async {
|
||||
if (shouldFetch && attemptCounter < maxAttempts) {
|
||||
if (attemptCounter < maxAttempts && !isApplied) {
|
||||
attemptCounter++;
|
||||
tick++;
|
||||
var res = await getRideStatus(rideId);
|
||||
|
||||
if (res.toString() == 'Apply') {
|
||||
getUpdatedRideForDriverApply(rideId);
|
||||
|
||||
shouldFetch = false; // Stop further fetches
|
||||
isApplied = true;
|
||||
shouldFetch = false;
|
||||
statusRide = 'Apply';
|
||||
rideConfirm = false;
|
||||
isSearchingWindow = false;
|
||||
update();
|
||||
startTimerFromDriverToPassengerAfterApplied();
|
||||
} else {
|
||||
Timer(const Duration(seconds: 2),
|
||||
fetchRideStatus); // Continue fetching for other statuses
|
||||
}
|
||||
} else {
|
||||
// Stop fetching after maxAttempts or if shouldFetch is false
|
||||
shouldFetch = false;
|
||||
MyDialog().getDialog('upgrade price'.tr,
|
||||
'You can upgrade price to may driver accept your order'.tr, () {
|
||||
Get.back();
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: "Increase Your Trip Fee (Optional)".tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
children: [
|
||||
Text(
|
||||
"We haven't found any drivers yet. Consider increasing your trip fee to make your offer more attractive to drivers."
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
increasFeeFromPassenger.text =
|
||||
(totalPassenger + 6).toStringAsFixed(1);
|
||||
// mapPassengerController.increasFeeFromPassenger.text =
|
||||
// mapPassengerController.totalPassenger
|
||||
// .toStringAsFixed(1);
|
||||
update();
|
||||
},
|
||||
icon: Column(
|
||||
children: [
|
||||
Text(
|
||||
'6',
|
||||
style: AppStyle.number,
|
||||
),
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: AppColor.greenColor),
|
||||
child: const Icon(
|
||||
Icons.arrow_circle_up,
|
||||
size: 30,
|
||||
color: AppColor.secondaryColor,
|
||||
} else if (attemptCounter >= maxAttempts) {
|
||||
shouldFetch = false;
|
||||
// If the status is still not "Apply" after 15 attempts
|
||||
MyDialog().getDialog('upgrade price'.tr,
|
||||
'You can upgrade price to may driver accept your order'.tr, () {
|
||||
Get.back();
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: "Increase Your Trip Fee (Optional)".tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
children: [
|
||||
Text(
|
||||
"We haven't found any drivers yet. Consider increasing your trip fee to make your offer more attractive to drivers."
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
increasFeeFromPassenger.text =
|
||||
(totalPassenger + 6).toStringAsFixed(1);
|
||||
update();
|
||||
},
|
||||
icon: Column(
|
||||
children: [
|
||||
Text(
|
||||
'6',
|
||||
style: AppStyle.number,
|
||||
),
|
||||
),
|
||||
],
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: AppColor.greenColor),
|
||||
child: const Icon(
|
||||
Icons.arrow_circle_up,
|
||||
size: 30,
|
||||
color: AppColor.secondaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: Form(
|
||||
key: increaseFeeFormKey,
|
||||
child: MyTextForm(
|
||||
controller: increasFeeFromPassenger,
|
||||
label: totalPassenger.toStringAsFixed(2),
|
||||
hint: totalPassenger.toStringAsFixed(2),
|
||||
type: TextInputType.number),
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: Form(
|
||||
key: increaseFeeFormKey,
|
||||
child: MyTextForm(
|
||||
controller: increasFeeFromPassenger,
|
||||
label: totalPassenger.toStringAsFixed(2),
|
||||
hint: totalPassenger.toStringAsFixed(2),
|
||||
type: TextInputType.number),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
MyElevatedButton(
|
||||
title: "No, thanks",
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
cancelRide();
|
||||
}),
|
||||
MyElevatedButton(
|
||||
title: "Increase Fee".tr,
|
||||
kolor: AppColor.greenColor,
|
||||
onPressed: () {
|
||||
increaseFeeByPassengerAndReOrder();
|
||||
})
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
MyElevatedButton(
|
||||
title: "No, thanks",
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
cancelRide();
|
||||
}),
|
||||
MyElevatedButton(
|
||||
title: "Increase Fee".tr,
|
||||
kolor: AppColor.greenColor,
|
||||
onPressed: () {
|
||||
increaseFeeByPassengerAndReOrder();
|
||||
})
|
||||
],
|
||||
);
|
||||
});
|
||||
update();
|
||||
print('Stopped fetching ride status after 30 seconds.');
|
||||
);
|
||||
});
|
||||
update();
|
||||
print('Stopped fetching ride status after 15 attempts.');
|
||||
} else {
|
||||
Timer(const Duration(seconds: 2), fetchRideStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fetchRideStatus(); // Initial call to start the process
|
||||
}
|
||||
|
||||
reSearchAfterCanceledFromDriver() async {
|
||||
await getCarsLocationByPassengerAndReloadMarker(
|
||||
box.read(BoxName.carType), 7000);
|
||||
|
||||
confirmRideForAllDriverAvailable();
|
||||
shouldFetch = true; // Stop further fetches
|
||||
statusRide = 'wait';
|
||||
rideConfirm = true;
|
||||
isSearchingWindow = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void start15SecondTimer(String rideId) {
|
||||
Timer(const Duration(seconds: 15), () {
|
||||
delayAndFetchRideStatusForAllDriverAvailable(rideId);
|
||||
@@ -1581,7 +1634,7 @@ class MapPassengerController extends GetxController {
|
||||
Log.print('searchInterval: ${searchInterval}');
|
||||
int boundIncreaseStep = 2500; // Initial bounds in meters
|
||||
Log.print('boundIncreaseStep: ${boundIncreaseStep}');
|
||||
int maxAttempts = 6; // Maximum attempts to increase bounds
|
||||
int maxAttempts = 3; // Maximum attempts to increase bounds
|
||||
int maxBoundIncreaseStep = 6000; // Maximum bounds increase step
|
||||
int attempt = 0; // Current attempt
|
||||
Log.print('initial attempt: ${attempt}');
|
||||
@@ -1598,7 +1651,8 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
} else if (reloadStartApp == true) {
|
||||
Log.print('reloadStartApp: ${reloadStartApp}');
|
||||
foundCars = await getCarsLocationByPassengerAndReloadMarker(
|
||||
carType, boundIncreaseStep);
|
||||
Log.print('foundCars: ${foundCars}');
|
||||
@@ -1624,6 +1678,36 @@ class MapPassengerController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
String getLocationArea(double latitude, double longitude) {
|
||||
// Giza Boundary Check
|
||||
if (latitude >= 29.904975 &&
|
||||
latitude <= 30.143372 &&
|
||||
longitude >= 30.787030 &&
|
||||
longitude <= 31.238843) {
|
||||
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
|
||||
return 'Giza';
|
||||
}
|
||||
// Cairo Boundary Check
|
||||
else if (latitude >= 29.918901 &&
|
||||
latitude <= 30.198857 &&
|
||||
longitude >= 31.215009 &&
|
||||
longitude <= 31.532186) {
|
||||
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
|
||||
return 'Cairo';
|
||||
}
|
||||
// Alexandria Boundary Check
|
||||
else if (latitude >= 30.396286 &&
|
||||
latitude <= 31.654458 &&
|
||||
longitude >= 29.041139 &&
|
||||
longitude <= 32.626259) {
|
||||
box.write(BoxName.serverChosen, AppLink.seferAlexandriaServer);
|
||||
return 'Alexandria';
|
||||
}
|
||||
|
||||
// Return 'Unknown' if outside defined areas
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
Future<bool> getCarsLocationByPassengerAndReloadMarker(
|
||||
String carType, int boundIncreaseStep) async {
|
||||
if (statusRide == 'wait') {
|
||||
@@ -1631,6 +1715,7 @@ class MapPassengerController extends GetxController {
|
||||
LatLngBounds bounds = calculateBounds(passengerLocation.latitude,
|
||||
passengerLocation.longitude, boundIncreaseStep.toDouble());
|
||||
var res;
|
||||
// await getLocation();
|
||||
|
||||
switch (carType) {
|
||||
case 'Lady':
|
||||
@@ -1680,6 +1765,9 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
if (res == 'failure') {
|
||||
noCarString = true;
|
||||
dataCarsLocationByPassenger = 'failure';
|
||||
update();
|
||||
return false;
|
||||
} else {
|
||||
noCarString = false;
|
||||
@@ -1930,6 +2018,8 @@ class MapPassengerController extends GetxController {
|
||||
}));
|
||||
} else if (res1['status'] == 'success') {
|
||||
var tokenParent = res1['data'][0]['token'];
|
||||
Get.snackbar("The invitation was sent successfully".tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
"Trip Monitoring".tr,
|
||||
"Trip Monitoring".tr,
|
||||
@@ -2029,9 +2119,14 @@ class MapPassengerController extends GetxController {
|
||||
.toString());
|
||||
|
||||
BitmapDescriptor icon =
|
||||
datadriverCarsLocationToPassengerAfterApplied['message'][0]['model']
|
||||
.toString()
|
||||
.contains('دراجة')
|
||||
datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['model']
|
||||
.toString()
|
||||
.contains('دراجة') ||
|
||||
datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['make']
|
||||
.toString()
|
||||
.contains('دراجة')
|
||||
? motoIcon
|
||||
: datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['gender'] ==
|
||||
@@ -2155,14 +2250,14 @@ class MapPassengerController extends GetxController {
|
||||
clearPlacesDestination();
|
||||
clearPolyline();
|
||||
data = [];
|
||||
await CRUD().post(link: AppLink.updateDriverOrder, payload: {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
// await CRUD().post(link: AppLink.updateDriverOrder, payload: {
|
||||
// "order_id": rideId.toString(), // Convert to String
|
||||
// "status": 'Cancel'
|
||||
// });
|
||||
// await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
// "id": rideId.toString(), // Convert to String
|
||||
// "status": 'Cancel'
|
||||
// });
|
||||
Get.offAll(const MapPagePassenger());
|
||||
}
|
||||
}
|
||||
@@ -2516,6 +2611,7 @@ class MapPassengerController extends GetxController {
|
||||
(_locationData.latitude != null && _locationData.longitude != null
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
getLocationArea(passengerLocation.latitude, passengerLocation.longitude);
|
||||
newStartPointLocation = passengerLocation;
|
||||
speed = _locationData.speed!;
|
||||
// //print location details
|
||||
@@ -2563,30 +2659,34 @@ class MapPassengerController extends GetxController {
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
bool reloadStartApp = false;
|
||||
|
||||
startMarkerReloading() async {
|
||||
Log.print('AppLink.endPoint: ${AppLink.endPoint}');
|
||||
int reloadCount = 0;
|
||||
if (reloadStartApp == false) {
|
||||
Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
reloadCount++;
|
||||
Log.print('reloadCount: ${reloadCount}');
|
||||
|
||||
Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
reloadCount++;
|
||||
Log.print('reloadCount: ${reloadCount}');
|
||||
if (!rideConfirm) {
|
||||
clearMarkersExceptStartEnd();
|
||||
// _smoothlyUpdateMarker();
|
||||
// startCarLocationSearch(box.read(BoxName.carType));
|
||||
await getCarsLocationByPassengerAndReloadMarker(
|
||||
box.read(BoxName.carType), 6000);
|
||||
await getNearestDriverByPassengerLocation();
|
||||
Log.print('reloadMarkers: from startMarkerReloading');
|
||||
} else {
|
||||
// runWhenRideIsBegin();
|
||||
}
|
||||
|
||||
if (!rideConfirm) {
|
||||
clearMarkersExceptStartEnd();
|
||||
// _smoothlyUpdateMarker();
|
||||
// startCarLocationSearch(box.read(BoxName.carType));
|
||||
await getCarsLocationByPassengerAndReloadMarker(
|
||||
box.read(BoxName.carType), 6000);
|
||||
await getNearestDriverByPassengerLocation();
|
||||
Log.print('reloadMarkers: from startMarkerReloadin');
|
||||
} else {
|
||||
// runWhenRideIsBegin();
|
||||
}
|
||||
|
||||
if (reloadCount >= 10) {
|
||||
timer.cancel(); // Stop the timer after 5 reloads
|
||||
}
|
||||
});
|
||||
if (reloadCount >= 6) {
|
||||
reloadStartApp = true;
|
||||
timer.cancel(); // Stop the timer after 5 reloads
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String durationByPassenger = '';
|
||||
@@ -2602,39 +2702,41 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
if (!rideConfirm) {
|
||||
if (dataCarsLocationByPassenger != 'failure') {
|
||||
if (dataCarsLocationByPassenger['message'].length > 0) {
|
||||
for (var i = 0;
|
||||
i < dataCarsLocationByPassenger['message'].length;
|
||||
i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
if (dataCarsLocationByPassenger != null) {
|
||||
if (dataCarsLocationByPassenger['message'].length > 0) {
|
||||
for (var i = 0;
|
||||
i < dataCarsLocationByPassenger['message'].length;
|
||||
i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
|
||||
// Calculate the distance between the passenger's location and the current driver's location
|
||||
final distance = Geolocator.distanceBetween(
|
||||
passengerLocation.latitude,
|
||||
passengerLocation.longitude,
|
||||
double.parse(carLocation['latitude']),
|
||||
double.parse(carLocation['longitude']),
|
||||
);
|
||||
durationToPassenger = (distance * 25 * (1000 / 3600))
|
||||
.round(); //////35 is avg of speed in city
|
||||
// Update the UI with the distance and duration
|
||||
update();
|
||||
|
||||
// If the distance is less than the nearest distance, update the nearest driver
|
||||
if (distance < nearestDistance) {
|
||||
nearestDistance = distance;
|
||||
|
||||
nearestCar = CarLocation(
|
||||
distance: distance,
|
||||
duration:
|
||||
0, // We don't have duration information from Geolocator
|
||||
id: carLocation['driver_id'],
|
||||
latitude: double.parse(carLocation['latitude']),
|
||||
longitude: double.parse(carLocation['longitude']),
|
||||
// Calculate the distance between the passenger's location and the current driver's location
|
||||
final distance = Geolocator.distanceBetween(
|
||||
passengerLocation.latitude,
|
||||
passengerLocation.longitude,
|
||||
double.parse(carLocation['latitude']),
|
||||
double.parse(carLocation['longitude']),
|
||||
);
|
||||
|
||||
// Update the UI with the nearest driver
|
||||
durationToPassenger = (distance * 25 * (1000 / 3600))
|
||||
.round(); //////35 is avg of speed in city
|
||||
// Update the UI with the distance and duration
|
||||
update();
|
||||
|
||||
// If the distance is less than the nearest distance, update the nearest driver
|
||||
if (distance < nearestDistance) {
|
||||
nearestDistance = distance;
|
||||
|
||||
nearestCar = CarLocation(
|
||||
distance: distance,
|
||||
duration:
|
||||
0, // We don't have duration information from Geolocator
|
||||
id: carLocation['driver_id'],
|
||||
latitude: double.parse(carLocation['latitude']),
|
||||
longitude: double.parse(carLocation['longitude']),
|
||||
);
|
||||
|
||||
// Update the UI with the nearest driver
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2665,7 +2767,7 @@ class MapPassengerController extends GetxController {
|
||||
String apiUrl =
|
||||
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${passengerLocation.latitude},${passengerLocation.longitude}&units=metric&key=${AK.mapAPIKEY}';
|
||||
var response = await CRUD().getGoogleApi(link: apiUrl, payload: {});
|
||||
if (response['status'] == "OK") {
|
||||
if (response != null && response['status'] == "OK") {
|
||||
var data = response;
|
||||
// Extract distance and duration from the response and handle accordingly
|
||||
int distance1 =
|
||||
@@ -2701,6 +2803,7 @@ class MapPassengerController extends GetxController {
|
||||
// Handle the distance and duration as needed
|
||||
else {
|
||||
// 'Failed to retrieve distance and duration: ${response['status']}');
|
||||
Log.print('${response['status']}: ${response['status']}}');
|
||||
// Handle the failure case
|
||||
}
|
||||
}
|
||||
@@ -2788,7 +2891,8 @@ class MapPassengerController extends GetxController {
|
||||
isLoading = true;
|
||||
update();
|
||||
remainingTime = 25; //to make cancel every call
|
||||
startCarLocationSearch(box.read(BoxName.carType));
|
||||
// startCarLocationSearch(box.read(BoxName.carType));
|
||||
getCarsLocationByPassengerAndReloadMarker(box.read(BoxName.carType), 7000);
|
||||
// await getCarsLocationByPassengerAndReloadMarker();
|
||||
var coordDestination = destination.split(',');
|
||||
double latPassengerDestination = double.parse(coordDestination[0]);
|
||||
@@ -2992,7 +3096,9 @@ class MapPassengerController extends GetxController {
|
||||
getMapPoints(String originSteps, String destinationSteps, int index) async {
|
||||
isWayPointStopsSheetUtilGetMap = false;
|
||||
// haveSteps = true;
|
||||
startCarLocationSearch(box.read(BoxName.carType));
|
||||
// startCarLocationSearch(box.read(BoxName.carType));
|
||||
await getCarsLocationByPassengerAndReloadMarker(
|
||||
box.read(BoxName.carType), 7000);
|
||||
// await getCarsLocationByPassengerAndReloadMarker();
|
||||
// isLoading = true;
|
||||
update();
|
||||
@@ -3439,6 +3545,12 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void startFetchingData() {
|
||||
Timer.periodic(Duration(milliseconds: 50), (Timer timer) async {
|
||||
await getKazanPercent();
|
||||
});
|
||||
}
|
||||
|
||||
getPassengerRate() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getPassengerRate,
|
||||
@@ -3467,10 +3579,12 @@ class MapPassengerController extends GetxController {
|
||||
addCustomStartIcon();
|
||||
addCustomEndIcon();
|
||||
await getLocation();
|
||||
|
||||
// await addToken();
|
||||
await getKazanPercent();
|
||||
await getPassengerRate();
|
||||
await getRideStatusFromStartApp();
|
||||
getKazanPercent();
|
||||
getPassengerRate();
|
||||
getRideStatusFromStartApp();
|
||||
reloadStartApp = false;
|
||||
startMarkerReloading();
|
||||
Get.put(TextToSpeechController());
|
||||
box.write(BoxName.carType, 'yet');
|
||||
|
||||
@@ -22,8 +22,8 @@ class ComplaintController extends GetxController {
|
||||
'passengerId': box.read(BoxName.passengerID).toString(),
|
||||
'feedBack': complaintController.text
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
if (d['status'].toString() == 'success') {
|
||||
// var d = jsonDecode(res);
|
||||
if (res != 'failure') {
|
||||
Get.defaultDialog(
|
||||
title: 'Success'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
|
||||
Reference in New Issue
Block a user