9/27/1
This commit is contained in:
@@ -17,17 +17,17 @@ import '../../main.dart';
|
||||
import '../../models/model/locations.dart';
|
||||
|
||||
class MapController extends GetxController {
|
||||
bool isloading = true;
|
||||
bool isLoading = true;
|
||||
TextEditingController placeController = TextEditingController();
|
||||
List data = [];
|
||||
List<LatLng> bounds = [];
|
||||
List places = [];
|
||||
LatLngBounds? boundsdata;
|
||||
List<Marker> markers = [];
|
||||
List<Polyline> polylines = [];
|
||||
late LatLng mylocation;
|
||||
late LatLng newMylocation = const LatLng(32.115295, 36.064773);
|
||||
LatLng mydestination = const LatLng(32.115295, 36.064773);
|
||||
List<Polyline> polyLines = [];
|
||||
late LatLng myLocation;
|
||||
late LatLng newMyLocation = const LatLng(32.115295, 36.064773);
|
||||
LatLng myDestination = const LatLng(32.115295, 36.064773);
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
List<LatLng> carsLocationByPassenger = [];
|
||||
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
|
||||
@@ -43,17 +43,17 @@ class MapController extends GetxController {
|
||||
double mainBottomMenuMap = Get.height * .2;
|
||||
bool heightMenuBool = false;
|
||||
bool isPickerShown = false;
|
||||
bool isButtomSheetShown = false;
|
||||
bool isBottomSheetShown = false;
|
||||
bool mapType = false;
|
||||
bool mapTraficON = false;
|
||||
bool mapTrafficON = false;
|
||||
bool isCancelRidePageShown = false;
|
||||
bool isCashConfirmPageShown = false;
|
||||
bool isPaymentMethodPageShown = false;
|
||||
bool rideConfirm = false;
|
||||
bool isMainBottomMenuMap = true;
|
||||
double heightButtomSheetShown = 0;
|
||||
double heightBottomSheetShown = 0;
|
||||
double cashConfirmPageShown = 250;
|
||||
double widthMapTypeAndTrafic = 50;
|
||||
double widthMapTypeAndTraffic = 50;
|
||||
double paymentPageShown = Get.height * .6;
|
||||
late LatLng southwest;
|
||||
late LatLng northeast;
|
||||
@@ -65,18 +65,21 @@ class MapController extends GetxController {
|
||||
bool shouldFetch = true; // Flag to determine if fetch should be executed
|
||||
int selectedPassengerCount = 1;
|
||||
double progress = 0;
|
||||
double progressTimerToPassengerFromDriverAfterApplied = 0;
|
||||
int durationTimer = 25;
|
||||
int remainingTime = 25;
|
||||
|
||||
int remainingTimeToPassengerFromDriverAfterApplied = 60;
|
||||
int timeToPassengerFromDriverAfterApplied = 0;
|
||||
Timer? timerToPassengerFromDriverAfterApplied;
|
||||
void onChangedPassengerCount(int newValue) {
|
||||
selectedPassengerCount = newValue;
|
||||
update();
|
||||
}
|
||||
|
||||
// final mainBottomMenuMap = GlobalKey<AnimatedContainer>();
|
||||
void changeButtomSheetShown() {
|
||||
isButtomSheetShown = !isButtomSheetShown;
|
||||
heightButtomSheetShown = isButtomSheetShown == true ? 250 : 0;
|
||||
void changeBottomSheetShown() {
|
||||
isBottomSheetShown = !isBottomSheetShown;
|
||||
heightBottomSheetShown = isBottomSheetShown == true ? 250 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -99,7 +102,7 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
void changeMapTraffic() {
|
||||
mapTraficON = !mapTraficON;
|
||||
mapTrafficON = !mapTrafficON;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -113,12 +116,35 @@ class MapController extends GetxController {
|
||||
|
||||
void getDrawerMenu() {
|
||||
heightMenuBool = !heightMenuBool;
|
||||
widthMapTypeAndTrafic = heightMenuBool == true ? 0 : 50;
|
||||
widthMapTypeAndTraffic = heightMenuBool == true ? 0 : 50;
|
||||
heightMenu = heightMenuBool == true ? 100 : 0;
|
||||
widthMenu = heightMenuBool == true ? 110 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void startTimerToPassengerFromDriverAfterApplied() async {
|
||||
for (int i = 0; i <= timeToPassengerFromDriverAfterApplied; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressTimerToPassengerFromDriverAfterApplied =
|
||||
i / timeToPassengerFromDriverAfterApplied;
|
||||
remainingTimeToPassengerFromDriverAfterApplied =
|
||||
timeToPassengerFromDriverAfterApplied - i;
|
||||
update();
|
||||
if (remainingTimeToPassengerFromDriverAfterApplied == 0) {
|
||||
driverArrivePassenger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void driverArrivePassenger() {
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void cancelTimerToPassengerFromDriverAfterApplied() {
|
||||
timerToPassengerFromDriverAfterApplied?.cancel();
|
||||
}
|
||||
|
||||
void clearPlaces() {
|
||||
places = [];
|
||||
update();
|
||||
@@ -133,18 +159,20 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
var rideId;
|
||||
int carsOrder = 0;
|
||||
changeConfirmRide() async {
|
||||
rideConfirm = true;
|
||||
shouldFetch = true;
|
||||
timeToPassengerFromDriverAfterApplied = 60;
|
||||
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']}',
|
||||
"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(),
|
||||
@@ -153,7 +181,7 @@ class MapController extends GetxController {
|
||||
"driver_id": dataCarsLocationByPassenger['message'][0]['id'].toString(),
|
||||
"status": "waiting",
|
||||
"price_for_driver": totalDriver.toString(),
|
||||
"price_for_passenger": totaME.toString(),
|
||||
"price_for_passenger": totalME.toString(),
|
||||
"distance": distance.toString()
|
||||
}).then((value) {
|
||||
// print(jsonDecode(value)['message']);
|
||||
@@ -168,18 +196,18 @@ class MapController extends GetxController {
|
||||
totalDriver.toString(),
|
||||
duration.toString(),
|
||||
distance.toString(),
|
||||
dataCarsLocationByPassenger['message'][0]['id'].toString(),
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['id'].toString(),
|
||||
box.read(BoxName.pasengerID).toString(),
|
||||
box.read(BoxName.name).toString(),
|
||||
box.read(BoxName.tokenFCM).toString(),
|
||||
box.read(BoxName.phone).toString(),
|
||||
duratioByPassenger.toString(),
|
||||
durationByPassenger.toString(),
|
||||
distanceByPassenger.toString(),
|
||||
];
|
||||
FirebasMessagesController().sendNotificationToDriverMAP(
|
||||
'Order',
|
||||
jsonDecode(value)['message'].toString(),
|
||||
dataCarsLocationByPassenger['message'][0]['token'].toString(),
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['token'].toString(),
|
||||
body,
|
||||
);
|
||||
// print(dataCarsLocationByPassenger);
|
||||
@@ -202,12 +230,15 @@ class MapController extends GetxController {
|
||||
var decod = jsonDecode(res);
|
||||
print(' 0000000000000000000000000000000000000000000000000');
|
||||
print(decod['data']);
|
||||
if (decod['data'].toString() == 'Apply' ||
|
||||
decod['data'].toString() == 'Refused') {
|
||||
if (decod['data'].toString() == 'Apply') {
|
||||
shouldFetch = false; // Stop further fetches
|
||||
rideConfirm = false;
|
||||
update();
|
||||
startTimer();
|
||||
} else if (decod['data'].toString() == 'Refused') {
|
||||
carsOrder++;
|
||||
update();
|
||||
changeConfirmRide();
|
||||
} else {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
@@ -224,6 +255,13 @@ class MapController extends GetxController {
|
||||
remainingTime = durationTimer - i;
|
||||
if (remainingTime == 0) {
|
||||
rideConfirm = false;
|
||||
// print(timeToPassengerFromDriverAfterApplied);
|
||||
timeToPassengerFromDriverAfterApplied += duration1;
|
||||
// print(duration1);
|
||||
|
||||
// print('timeToPassengerFromDriverAfterApplied====' +
|
||||
// timeToPassengerFromDriverAfterApplied.toString());
|
||||
startTimerToPassengerFromDriverAfterApplied();
|
||||
update();
|
||||
}
|
||||
update();
|
||||
@@ -234,7 +272,7 @@ class MapController extends GetxController {
|
||||
void timerEnded() async {
|
||||
print('Timer ended');
|
||||
|
||||
runEvery50SecondsUntilConditionMet();
|
||||
runEvery30SecondsUntilConditionMet();
|
||||
isCancelRidePageShown = false;
|
||||
update();
|
||||
}
|
||||
@@ -249,7 +287,7 @@ class MapController extends GetxController {
|
||||
Future getCarsLocationByPassenger() async {
|
||||
carsLocationByPassenger = [];
|
||||
LatLngBounds bounds =
|
||||
calculateBounds(mylocation.latitude, mylocation.longitude, 8000);
|
||||
calculateBounds(myLocation.latitude, myLocation.longitude, 8000);
|
||||
print(
|
||||
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
||||
print(
|
||||
@@ -293,21 +331,22 @@ class MapController extends GetxController {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverCarsLocationToPassengerAfterApplied,
|
||||
payload: {
|
||||
'driver_id': dataCarsLocationByPassenger['message'][0]['driver_id']
|
||||
'driver_id': dataCarsLocationByPassenger['message'][carsOrder]
|
||||
['driver_id']
|
||||
});
|
||||
|
||||
datadriverCarsLocationToPassengerAfterApplied = jsonDecode(res);
|
||||
|
||||
driverCarsLocationToPassengerAfterApplied.add(LatLng(
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['longitude'])));
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message']
|
||||
[carsOrder]['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message']
|
||||
[carsOrder]['longitude'])));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Future runEvery50SecondsUntilConditionMet() async {
|
||||
Future runEvery30SecondsUntilConditionMet() async {
|
||||
// Calculate the duration of the trip in minutes.
|
||||
double tripDurationInMinutes = duration1 / 60;
|
||||
int loopCount = tripDurationInMinutes.ceil();
|
||||
@@ -316,7 +355,7 @@ class MapController extends GetxController {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(
|
||||
seconds:
|
||||
50)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
30)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
@@ -353,7 +392,7 @@ class MapController extends GetxController {
|
||||
|
||||
if (rideConfirm == false) {
|
||||
clearPlaces();
|
||||
clearpolyline();
|
||||
clearPolyline();
|
||||
data = [];
|
||||
changeCancelRidePageShow();
|
||||
rideConfirm = false;
|
||||
@@ -361,7 +400,7 @@ class MapController extends GetxController {
|
||||
update();
|
||||
} else {
|
||||
clearPlaces();
|
||||
clearpolyline();
|
||||
clearPolyline();
|
||||
data = [];
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
@@ -417,7 +456,7 @@ class MapController extends GetxController {
|
||||
Future getPlaces() async {
|
||||
var url =
|
||||
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=${mylocation.latitude},${mylocation.longitude}&radius=50000&language=ar&key=${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=ar&key=${AppCredintials.mapAPIKEY}';
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
@@ -433,8 +472,8 @@ class MapController extends GetxController {
|
||||
return LatLng(lat, lng);
|
||||
}
|
||||
|
||||
void clearpolyline() {
|
||||
polylines = [];
|
||||
void clearPolyline() {
|
||||
polyLines = [];
|
||||
polylineCoordinates.clear();
|
||||
update();
|
||||
}
|
||||
@@ -452,8 +491,8 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = const ImageConfiguration(
|
||||
size: Size(50, 50),
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: Size(Get.width * .6, Get.height * .6),
|
||||
// scale: 1.0,
|
||||
);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
|
||||
@@ -464,7 +503,7 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getLocation() async {
|
||||
isloading = true;
|
||||
isLoading = true;
|
||||
update();
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
@@ -494,7 +533,7 @@ class MapController extends GetxController {
|
||||
|
||||
// Get the current location
|
||||
LocationData _locationData = await location.getLocation();
|
||||
mylocation =
|
||||
myLocation =
|
||||
(_locationData.latitude != null && _locationData.longitude != null
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
@@ -504,7 +543,7 @@ class MapController extends GetxController {
|
||||
print('Latitude: ${_locationData.latitude}');
|
||||
print('Longitude: ${_locationData.longitude}');
|
||||
print('Time: ${_locationData.time}');
|
||||
isloading = false;
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -530,15 +569,21 @@ class MapController extends GetxController {
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(mylocation),
|
||||
CameraUpdate.newLatLng(myLocation),
|
||||
);
|
||||
update();
|
||||
}
|
||||
|
||||
// void startMarkerReloading() {
|
||||
// int count = 0;
|
||||
// markerReloadingTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
|
||||
// print('timer==============================');
|
||||
// reloadMarkers();
|
||||
//
|
||||
// count++;
|
||||
// if (count == 10) {
|
||||
// timer.cancel();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@@ -547,7 +592,7 @@ class MapController extends GetxController {
|
||||
late int duration1;
|
||||
void startMarkerReloading() {
|
||||
// Schedule timer 1 to reload markers at a specific time
|
||||
DateTime scheduledTime1 = DateTime.now().add(const Duration(seconds: 30));
|
||||
DateTime scheduledTime1 = DateTime.now().add(const Duration(seconds: 20));
|
||||
markerReloadingTimer1 =
|
||||
Timer(scheduledTime1.difference(DateTime.now()), () {
|
||||
print('timer 1 ==============================');
|
||||
@@ -555,7 +600,7 @@ class MapController extends GetxController {
|
||||
});
|
||||
|
||||
// Schedule timer 2 to reload markers at a specific time
|
||||
DateTime scheduledTime2 = DateTime.now().add(const Duration(seconds: 60));
|
||||
DateTime scheduledTime2 = DateTime.now().add(const Duration(seconds: 40));
|
||||
markerReloadingTimer2 =
|
||||
Timer(scheduledTime2.difference(DateTime.now()), () {
|
||||
print('timer 2 ==============================');
|
||||
@@ -564,11 +609,15 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
void reloadMarkers() async {
|
||||
//TODO await getCarsLocationByPassenger();
|
||||
await getCarsLocationByPassenger();
|
||||
|
||||
// Clear existing markers
|
||||
// mapController!.showMarkerInfoWindow(MarkerId('g'));
|
||||
markers.clear();
|
||||
update();
|
||||
// if (rideConfirm) {
|
||||
getNearestDriverByPassengerLocation();
|
||||
// }
|
||||
// Add new markers
|
||||
// Example: Add a marker for each item in a list
|
||||
for (var item in carsLocationByPassenger) {
|
||||
@@ -583,16 +632,17 @@ class MapController extends GetxController {
|
||||
|
||||
// Update the map with the new markers
|
||||
mapController?.animateCamera(CameraUpdate.newLatLng(
|
||||
LatLng(mylocation.latitude, mylocation.longitude)));
|
||||
LatLng(myLocation.latitude, myLocation.longitude)));
|
||||
}
|
||||
|
||||
String duratioByPassenger = '';
|
||||
String durationByPassenger = '';
|
||||
late DateTime newTime1 = DateTime.now();
|
||||
late DateTime timeFromDriverToPassenger = DateTime.now();
|
||||
String distanceByPassenger = '';
|
||||
late Duration durationfromDriverToPassenger;
|
||||
late Duration durationFromDriverToPassenger;
|
||||
|
||||
void getNearestDriverByPassengerLocation() async {
|
||||
if (polylines.isEmpty || data.isEmpty) {
|
||||
if (polyLines.isEmpty || data.isEmpty) {
|
||||
double nearestDistance = double.infinity;
|
||||
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
@@ -617,7 +667,7 @@ class MapController extends GetxController {
|
||||
update();
|
||||
// Make API request to get exact distance and duration
|
||||
String apiUrl =
|
||||
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${mylocation.latitude},${mylocation.longitude}&units=metric&key=${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${myLocation.latitude},${myLocation.longitude}&units=metric&key=${AppCredintials.mapAPIKEY}';
|
||||
var response = await CRUD().getGoogleApi(link: apiUrl, payload: {});
|
||||
if (response['status'] == "OK") {
|
||||
var data = response;
|
||||
@@ -626,9 +676,11 @@ class MapController extends GetxController {
|
||||
distanceByPassenger =
|
||||
data['rows'][0]['elements'][0]['distance']['text'];
|
||||
duration1 = data['rows'][0]['elements'][0]['duration']['value'];
|
||||
durationfromDriverToPassenger = Duration(seconds: duration1.toInt());
|
||||
newTime1 = currentTime.add(durationfromDriverToPassenger);
|
||||
duratioByPassenger =
|
||||
durationFromDriverToPassenger = Duration(seconds: duration1.toInt());
|
||||
newTime1 = currentTime.add(durationFromDriverToPassenger);
|
||||
timeFromDriverToPassenger =
|
||||
newTime1.add(Duration(minutes: 2.toInt()));
|
||||
durationByPassenger =
|
||||
data['rows'][0]['elements'][0]['duration']['text'];
|
||||
update();
|
||||
if (distance1 < nearestDistance) {
|
||||
@@ -665,9 +717,9 @@ class MapController extends GetxController {
|
||||
getMap(String origin, destination) async {
|
||||
var origin1 = fromString(origin);
|
||||
var destination1 = fromString(destination);
|
||||
isloading = false;
|
||||
mydestination = destination1;
|
||||
mylocation = origin1;
|
||||
isLoading = false;
|
||||
myDestination = destination1;
|
||||
myLocation = origin1;
|
||||
update();
|
||||
await getCarsLocationByPassenger();
|
||||
// print(carsLocationByPassenger);
|
||||
@@ -703,20 +755,20 @@ class MapController extends GetxController {
|
||||
|
||||
// Animate the camera to the adjusted bounds
|
||||
if (distanceOfDestnation <= 5) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 14));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
||||
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 13));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
|
||||
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 12));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 12));
|
||||
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
|
||||
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10));
|
||||
} else if (distanceOfDestnation >= 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 7));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
|
||||
}
|
||||
if (polylines.isNotEmpty) {
|
||||
clearpolyline();
|
||||
if (polyLines.isNotEmpty) {
|
||||
clearPolyline();
|
||||
} else {
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
@@ -725,7 +777,7 @@ class MapController extends GetxController {
|
||||
color: Colors.blue,
|
||||
);
|
||||
|
||||
polylines.add(polyline);
|
||||
polyLines.add(polyline);
|
||||
rideConfirm = false;
|
||||
update();
|
||||
}
|
||||
@@ -733,15 +785,15 @@ class MapController extends GetxController {
|
||||
|
||||
showBottomSheet1() async {
|
||||
bottomSheet();
|
||||
isButtomSheetShown = true;
|
||||
heightButtomSheetShown = 250;
|
||||
isBottomSheetShown = true;
|
||||
heightBottomSheetShown = 250;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
final promo = TextEditingController();
|
||||
bool promoTaken = false;
|
||||
void applyPromoCodetoPassenger() async {
|
||||
void applyPromoCodeToPassenger() async {
|
||||
//TAWJIHI
|
||||
|
||||
CRUD().get(link: AppLink.getPassengersPromo, payload: {
|
||||
@@ -758,11 +810,11 @@ class MapController extends GetxController {
|
||||
},
|
||||
));
|
||||
}
|
||||
var decod = jsonDecode(value);
|
||||
var decode = jsonDecode(value);
|
||||
|
||||
if (decod["status"] == "success") {
|
||||
if (decode["status"] == "success") {
|
||||
print(totalPassenger);
|
||||
var firstElement = decod["message"][0];
|
||||
var firstElement = decode["message"][0];
|
||||
totalPassenger = totalPassenger -
|
||||
(totalPassenger * int.parse(firstElement['amount']) / 100);
|
||||
promoTaken = true;
|
||||
@@ -783,7 +835,7 @@ class MapController extends GetxController {
|
||||
return distance;
|
||||
}
|
||||
|
||||
late double totaME = 0;
|
||||
late double totalME = 0;
|
||||
late double tax = 0;
|
||||
late double totalPassenger = 0;
|
||||
late double totalDriver = 0;
|
||||
@@ -811,7 +863,7 @@ class MapController extends GetxController {
|
||||
totalDriver = cost + costDuration;
|
||||
totalPassenger = totalDriver + (totalDriver * .16);
|
||||
tax = totalPassenger * .04;
|
||||
totaME = totalPassenger - totalDriver - tax;
|
||||
totalME = totalPassenger - totalDriver - tax;
|
||||
update();
|
||||
if (currentTime.hour >= 21) {
|
||||
if (distanceText.contains('km')) {
|
||||
@@ -862,17 +914,17 @@ class MapController extends GetxController {
|
||||
update();
|
||||
if (totalDriver < .5) {
|
||||
totalDriver = .85;
|
||||
totaME = .11;
|
||||
totalME = .11;
|
||||
update();
|
||||
} else {
|
||||
totalDriver = .95;
|
||||
totaME = .05;
|
||||
totalME = .05;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
// buttomSheetMapPage();
|
||||
changeButtomSheetShown();
|
||||
changeBottomSheetShown();
|
||||
}
|
||||
|
||||
// Get.bottomSheet(
|
||||
|
||||
Reference in New Issue
Block a user