This commit is contained in:
Hamza-Ayed
2024-01-30 16:58:23 +02:00
parent 18df215d0a
commit 87da645ae5
5 changed files with 448 additions and 51 deletions

View File

@@ -384,7 +384,7 @@ class MapPassengerController extends GetxController {
// Format the message.
String message =
'Hi! This is ${box.read(BoxName.name)}. I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} is driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()} with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}. I am currently located at $passengerLocation. If you need to reach me, please contact the driver directly at $driverPhone.';
'Hi! This is ${box.read(BoxName.name)}.\n I am using ${box.read(AppInformation.appName)} to ride with $firstName as the driver. $firstName \nis driving a $model\n with license plate $licensePlate.\n I am currently located at $passengerLocation.\n If you need to reach me, please contact the driver directly at\n\n $driverPhone.';
// Launch the URL to send the SMS.
launchCommunication('sms', to, message);
@@ -397,7 +397,7 @@ class MapPassengerController extends GetxController {
// Format the message.
String message =
'Hi! This is ${box.read(BoxName.name)}.\n I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} \nis driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()}\n with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}.\n I am currently located at $passengerLocation.\n If you need to reach me, please contact the driver directly at\n\n $driverPhone.';
'Hi! This is ${box.read(BoxName.name)}.\n I am using ${box.read(AppInformation.appName)} to ride with $firstName as the driver. $firstName \nis driving a $model\n with license plate $licensePlate.\n I am currently located at $passengerLocation.\n If you need to reach me, please contact the driver directly at\n\n $driverPhone.';
// Launch the URL to send the SMS.
launchCommunication('whatsapp', to, message);
@@ -579,10 +579,25 @@ class MapPassengerController extends GetxController {
update();
}
late String driverPhone;
late String firstName;
late String model;
late String licensePlate;
changeConfirmRide() async {
if (dataCarsLocationByPassenger != 'failure') {
driverToken =
dataCarsLocationByPassenger['message'][carsOrder]['token'].toString();
driverPhone =
dataCarsLocationByPassenger['message'][carsOrder]['phone'].toString();
firstName = dataCarsLocationByPassenger['message'][carsOrder]
['first_name']
.toString();
model =
dataCarsLocationByPassenger['message'][carsOrder]['model'].toString();
licensePlate = dataCarsLocationByPassenger['message'][carsOrder]
['license_plate']
.toString();
PaymentController paymentController = Get.find<PaymentController>();
rideConfirm = true;
shouldFetch = true;
@@ -601,7 +616,7 @@ class MapPassengerController extends GetxController {
"date": DateTime.now().toString(),
"time": DateTime.now().toString(),
"endtime": durationToAdd.toString(),
"price": totalPassenger.toString(),
"price": totalPassenger.toStringAsFixed(2),
"passenger_id": box.read(BoxName.passengerID).toString(),
"driver_id": dataCarsLocationByPassenger['message'][carsOrder]
['driver_id']
@@ -1442,23 +1457,28 @@ class MapPassengerController extends GetxController {
double lng = points[i][1].toDouble();
polylineCoordinates.add(LatLng(lat, lng));
}
// Define the northeast and southwest coordinates
newStartPointLocation = LatLng(
data[0]["start_location"]['lat'], data[0]["start_location"]['lng']);
// Define the northeast and southwest coordinates
final bounds = response["routes"][0]["bounds"];
LatLng northeast =
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
LatLng southwest =
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
// Create the LatLngBounds object
boundsData = LatLngBounds(northeast: northeast, southwest: southwest);
// Create the LatLngBounds object
LatLngBounds boundsData =
LatLngBounds(northeast: northeast, southwest: southwest);
// Calculate the zoom level based on the distance and screen size
// Fit the camera to the bounds
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 130);
mapController!.animateCamera(cameraUpdate);
// getDistanceFromText(data[0]['distance']['text']);
double distanceOfTrip = (data[0]['distance']['value']) / 1000;
distance = distanceOfTrip;
updateCameraForDistanceAfterGetMap();
// updateCameraForDistanceAfterGetMap();
if (polyLines.isNotEmpty) {
clearPolyline();
@@ -1506,15 +1526,6 @@ class MapPassengerController extends GetxController {
polylineCoordinatesPointsAll[index].add(LatLng(lat, lng));
}
// Define the northeast and southwest coordinates
final bounds = response["routes"][0]["bounds"];
LatLng northeast =
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
LatLng southwest =
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
// Create the LatLngBounds object
boundsData = LatLngBounds(northeast: northeast, southwest: southwest);
if (polyLines.isNotEmpty) {
// clearPolyline();
@@ -1533,26 +1544,24 @@ class MapPassengerController extends GetxController {
}
}
updateCameraForDistanceAfterGetMap() {
if (distance <= 5) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 14));
} else if (distance > 5 && distance <= 8) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 13));
} else if (distance > 8 && distance < 16) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 12));
} else if (distance >= 16 && distance < 30) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 8));
} else if (distance >= 30 && distance < 100) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 6));
} else if (distance >= 100) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 5));
}
void updateCameraForDistanceAfterGetMap() {
// Get the non-empty values from the data list
List<LatLng> nonEmptyValues = data
.where((element) => element != null && element.isNotEmpty)
.map((element) => LatLng(element['lat'], element['lng']))
.toList();
// Define the northeast and southwest coordinates
LatLng northeast = nonEmptyValues.first;
LatLng southwest = nonEmptyValues.last;
// Create the LatLngBounds object
LatLngBounds bounds =
LatLngBounds(northeast: northeast, southwest: southwest);
// Fit the camera to the bounds
var cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 130);
mapController!.animateCamera(cameraUpdate);
update();
}