This commit is contained in:
Hamza-Ayed
2024-01-13 17:10:24 +03:00
parent c73c01aa81
commit dfbe9ba1b6
10 changed files with 154 additions and 381 deletions

View File

@@ -108,6 +108,8 @@ class MapPassengerController extends GetxController {
bool rideConfirm = false;
bool isMainBottomMenuMap = true;
bool isWayPointSheet = false;
bool isWayPointStopsSheet = false;
bool isWayPointStopsSheetUtilGetMap = false;
double heightBottomSheetShown = 0;
double cashConfirmPageShown = 250;
late String driverId;
@@ -125,7 +127,7 @@ class MapPassengerController extends GetxController {
double progress = 0;
double progressTimerToPassengerFromDriverAfterApplied = 0;
int durationTimer = 25;
late int durationToRide;
int durationToRide = 0;
int remainingTime = 25;
int remainingTimeToPassengerFromDriverAfterApplied = 60;
int timeToPassengerFromDriverAfterApplied = 0;
@@ -804,6 +806,7 @@ class MapPassengerController extends GetxController {
shouldFetch = false;
isPassengerChosen = false;
isCashConfirmPageShown = false;
totalStepDurations = 0;
isCashSelectedBeforeConfirmRide = false;
timeToPassengerFromDriverAfterApplied = 0;
changeCancelRidePageShow();
@@ -826,6 +829,7 @@ class MapPassengerController extends GetxController {
isPassengerChosen = false;
isCashSelectedBeforeConfirmRide = false;
isPickerShown = false;
totalStepDurations = 0;
timeToPassengerFromDriverAfterApplied = 0;
update();
} else {
@@ -843,6 +847,7 @@ class MapPassengerController extends GetxController {
isCashConfirmPageShown = false;
isCashSelectedBeforeConfirmRide = false;
timeToPassengerFromDriverAfterApplied = 0;
totalStepDurations = 0;
changeCancelRidePageShow();
remainingTime = 0;
@@ -862,16 +867,28 @@ class MapPassengerController extends GetxController {
update();
}
void changeMainBottomMenuMap() {
isMainBottomMenuMap = !isMainBottomMenuMap;
mainBottomMenuMapHeight =
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7;
if (heightMenuBool == true) {
getDrawerMenu();
}
getCoordinateFromMapWayPoints(int index) {
placesCoordinate[index] = newStartPointLocation.toString();
update();
}
void changeMainBottomMenuMap() {
print(isWayPointStopsSheetUtilGetMap);
if (isWayPointStopsSheetUtilGetMap == true) {
isWayPointSheet = true;
wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .4;
update();
} else {
isMainBottomMenuMap = !isMainBottomMenuMap;
mainBottomMenuMapHeight =
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7;
if (heightMenuBool == true) {
getDrawerMenu();
}
update();
}
}
void changeWayPointSheet() {
isWayPointSheet = !isWayPointSheet;
wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .4;
@@ -881,6 +898,16 @@ class MapPassengerController extends GetxController {
update();
}
void changeWayPointStopsSheet() {
isWayPointStopsSheetUtilGetMap = true;
isWayPointStopsSheet = !isWayPointStopsSheet;
wayPointSheetHeight = isWayPointStopsSheet == false ? 0 : Get.height * .4;
// if (heightMenuBool == true) {
// getDrawerMenu();
// }
update();
}
changeHeightPlaces() {
if (placesDestination.isEmpty) {
height = 0;
@@ -986,49 +1013,49 @@ class MapPassengerController extends GetxController {
update();
}
Future getPlacesListsWayPoint1() async {
var url =
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint1Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
// Future getPlacesListsWayPoint1() async {
// var url =
// '${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint1Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
var response = await CRUD().getGoogleApi(link: url, payload: {});
// var response = await CRUD().getGoogleApi(link: url, payload: {});
wayPoint1 = response['results'];
print(wayPoint1);
update();
}
// wayPoint1 = response['results'];
// print(wayPoint1);
// update();
// }
Future getPlacesListsWayPoint2() async {
var url =
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint2Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
// Future getPlacesListsWayPoint2() async {
// var url =
// '${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint2Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
var response = await CRUD().getGoogleApi(link: url, payload: {});
// var response = await CRUD().getGoogleApi(link: url, payload: {});
wayPoint2 = response['results'];
print(wayPoint2);
update();
}
// wayPoint2 = response['results'];
// print(wayPoint2);
// update();
// }
Future getPlacesListsWayPoint3() async {
var url =
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint3Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
// Future getPlacesListsWayPoint3() async {
// var url =
// '${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint3Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
var response = await CRUD().getGoogleApi(link: url, payload: {});
// var response = await CRUD().getGoogleApi(link: url, payload: {});
wayPoint3 = response['results'];
print(wayPoint3);
update();
}
// wayPoint3 = response['results'];
// print(wayPoint3);
// update();
// }
Future getPlacesListsWayPoint4() async {
var url =
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint4Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
// Future getPlacesListsWayPoint4() async {
// var url =
// '${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint4Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
var response = await CRUD().getGoogleApi(link: url, payload: {});
// var response = await CRUD().getGoogleApi(link: url, payload: {});
wayPoint4 = response['results'];
print(wayPoint4);
update();
}
// wayPoint4 = response['results'];
// print(wayPoint4);
// update();
// }
LatLng fromString(String location) {
List<String> parts = location.split(',');
@@ -1367,7 +1394,9 @@ class MapPassengerController extends GetxController {
}
}
int totalStepDurations = 0;
getMapPoints(String origin, destination, int index) async {
isWayPointStopsSheetUtilGetMap = false;
await getCarsLocationByPassenger();
isLoading = false;
update();
@@ -1379,7 +1408,8 @@ class MapPassengerController extends GetxController {
// print(data);
isLoading = false;
update();
durationToRide = data[0]['duration']['value'];
durationToRide = durationToRide + int.parse(data[0]['duration']['value']);
// totalStepDurations = totalStepDurations + durationToRide;
final points =
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
for (int i = 0; i < points.length; i++) {