1/27/2
This commit is contained in:
@@ -62,6 +62,7 @@ class MapDriverController extends GetxController {
|
||||
bool isRideFinished = false;
|
||||
bool isRideStarted = false;
|
||||
double passengerInfoWindow = Get.height * .35;
|
||||
double driverEndPage = 100;
|
||||
double progress = 0;
|
||||
double progressToPassenger = 0;
|
||||
bool isRideBegin = false;
|
||||
@@ -102,6 +103,11 @@ class MapDriverController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void changeDriverEndPage() {
|
||||
remainingTimeTimerRideBegin < 60 ? driverEndPage = 160 : 100;
|
||||
update();
|
||||
}
|
||||
|
||||
takeSnapMap() {
|
||||
mapController!.takeSnapshot();
|
||||
}
|
||||
@@ -226,7 +232,7 @@ class MapDriverController extends GetxController {
|
||||
});
|
||||
rideIsBeginPassengerTimer();
|
||||
double pointsSubstraction = 0;
|
||||
pointsSubstraction = double.parse(paymentAmount) * -1;
|
||||
pointsSubstraction = double.parse(paymentAmount) * -100;
|
||||
var res = await CRUD().post(link: AppLink.addDriversWallet, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'amount': (pointsSubstraction).toString(),
|
||||
@@ -309,6 +315,7 @@ class MapDriverController extends GetxController {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressTimerRideBegin = i / durationOfRide;
|
||||
remainingTimeTimerRideBegin = durationOfRide - i;
|
||||
remainingTimeTimerRideBegin < 60 ? driverEndPage = 160 : 100;
|
||||
|
||||
int minutes = (remainingTimeTimerRideBegin / 60).floor();
|
||||
int seconds = remainingTimeTimerRideBegin % 60;
|
||||
@@ -429,7 +436,12 @@ class MapDriverController extends GetxController {
|
||||
width: 10,
|
||||
color: AppColor.blueColor,
|
||||
);
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
||||
// final dataBounds = response["routes"][0]["bounds"];
|
||||
|
||||
// updateCameraFromBoundsAfterGetMap(dataBounds);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
|
||||
polyLines.add(polyline);
|
||||
// rideConfirm = false;
|
||||
update();
|
||||
@@ -468,13 +480,31 @@ class MapDriverController extends GetxController {
|
||||
width: 10,
|
||||
color: AppColor.redColor,
|
||||
);
|
||||
// final dataBounds = response["routes"][0]["bounds"];
|
||||
|
||||
polyLinesDestination.add(polyline);
|
||||
// updateCameraFromBoundsAfterGetMap(dataBounds);
|
||||
// polyLinesDestination.add(polyline);
|
||||
// rideConfirm = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void updateCameraFromBoundsAfterGetMap(dynamic response) {
|
||||
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
|
||||
LatLngBounds boundsData =
|
||||
LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 140);
|
||||
mapController!.animateCamera(cameraUpdate);
|
||||
}
|
||||
|
||||
void changePassengerInfoWindow() {
|
||||
isPassengerInfoWindow = !isPassengerInfoWindow;
|
||||
passengerInfoWindow = isPassengerInfoWindow == true ? 200 : 0;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user