9/11/1
This commit is contained in:
@@ -126,12 +126,12 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
changeConfirmRide() async {
|
||||
rideConfirm = true;
|
||||
print('rideConfirm= $rideConfirm');
|
||||
|
||||
// rideConfirm = true;
|
||||
// update();
|
||||
// print('rideConfirm= $rideConfirm');
|
||||
await getCarsLocationByPassenger();
|
||||
await CRUD().post(link: AppLink.addRides, 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']}',
|
||||
@@ -147,6 +147,7 @@ class MapController extends GetxController {
|
||||
"distance": distance.toString()
|
||||
}).then((value) {
|
||||
// print(jsonDecode(value)['message']);
|
||||
// List<String> body = [
|
||||
List<String> body = [
|
||||
// '${data[0]['start_address']}',
|
||||
// '${data[0]['end_address']}',
|
||||
@@ -157,21 +158,37 @@ class MapController extends GetxController {
|
||||
duration.toString(),
|
||||
distance.toString(),
|
||||
dataCarsLocationByPassenger['message'][0]['id'].toString(),
|
||||
box.read(BoxName.pasengerID).toString()
|
||||
box.read(BoxName.pasengerID).toString(),
|
||||
box.read(BoxName.name).toString(),
|
||||
box.read(BoxName.tokenFCM).toString(),
|
||||
box.read(BoxName.phone).toString(),
|
||||
duratioByPassenger.toString(),
|
||||
distanceByPassenger.toString(),
|
||||
];
|
||||
FirebasMessagesController().sendNotificationDriverId(
|
||||
FirebasMessagesController().sendNotificationToDriverMAP(
|
||||
'Order',
|
||||
jsonDecode(value)['message'].toString(),
|
||||
body[0],
|
||||
body[1],
|
||||
body[2],
|
||||
body[3],
|
||||
body[4],
|
||||
body[5],
|
||||
body[6],
|
||||
body[7],
|
||||
box.read(BoxName.tokenFCM).toString(), //TODO change to Driver
|
||||
dataCarsLocationByPassenger['message'][0]['token'].toString(),
|
||||
body,
|
||||
);
|
||||
// FirebasMessagesController().sendNotificationToDriverId(
|
||||
// 'Order',
|
||||
// jsonDecode(value)['message'].toString(),
|
||||
// body[0],
|
||||
// body[1],
|
||||
// body[2],
|
||||
// body[3],
|
||||
// body[4],
|
||||
// body[5],
|
||||
// body[6],
|
||||
// body[7],
|
||||
// body[8],
|
||||
// body[9],
|
||||
// body[10],
|
||||
// dataCarsLocationByPassenger['message'][0]['token'].toString(),
|
||||
// );
|
||||
print(dataCarsLocationByPassenger);
|
||||
print(dataCarsLocationByPassenger['message'][0]['token'].toString());
|
||||
});
|
||||
|
||||
update();
|
||||
@@ -372,7 +389,7 @@ class MapController extends GetxController {
|
||||
|
||||
LatLngBounds calculateBounds(
|
||||
double centerLat, double centerLng, double radius) {
|
||||
double radius = 2000; // 10 km in meters
|
||||
double radius = 4000; // 10 km in meters
|
||||
|
||||
southwest = LatLng(
|
||||
centerLat - (radius / 111000),
|
||||
@@ -449,6 +466,7 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
String duratioByPassenger = '';
|
||||
String distanceByPassenger = '';
|
||||
void getNearestDriverByPassengerLocation() async {
|
||||
if (polylines.isEmpty || data.isEmpty) {
|
||||
double nearestDistance = double.infinity;
|
||||
@@ -471,7 +489,7 @@ class MapController extends GetxController {
|
||||
// longitude: double.parse(carLocation['longitude']),
|
||||
// );
|
||||
// }
|
||||
isloading = true;
|
||||
// isloading = true;
|
||||
update();
|
||||
// Make API request to get exact distance and duration
|
||||
String apiUrl =
|
||||
@@ -481,6 +499,8 @@ class MapController extends GetxController {
|
||||
var data = response;
|
||||
// Extract distance and duration from the response and handle accordingly
|
||||
int distance1 = data['rows'][0]['elements'][0]['distance']['value'];
|
||||
distanceByPassenger =
|
||||
data['rows'][0]['elements'][0]['distance']['text'];
|
||||
duration1 = data['rows'][0]['elements'][0]['duration']['value'];
|
||||
duratioByPassenger =
|
||||
data['rows'][0]['elements'][0]['duration']['text'];
|
||||
@@ -495,7 +515,7 @@ class MapController extends GetxController {
|
||||
latitude: double.parse(carLocation['latitude']),
|
||||
longitude: double.parse(carLocation['longitude']),
|
||||
);
|
||||
isloading = false;
|
||||
// isloading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user