This commit is contained in:
Hamza-Ayed
2024-01-27 00:53:44 +03:00
parent 91985fddf6
commit a63ebfe002
7 changed files with 270 additions and 259 deletions

View File

@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'dart:math' show cos; import 'dart:math' show cos;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -13,7 +12,6 @@ import 'package:ride/constant/style.dart';
import 'package:ride/controller/home/points_for_rider_controller.dart'; import 'package:ride/controller/home/points_for_rider_controller.dart';
import 'package:ride/views/home/map_page_passenger.dart'; import 'package:ride/views/home/map_page_passenger.dart';
import 'package:ride/views/home/map_widget.dart/form_serch_multiy_point.dart'; import 'package:ride/views/home/map_widget.dart/form_serch_multiy_point.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../constant/api_key.dart'; import '../../constant/api_key.dart';
import '../../constant/box_name.dart'; import '../../constant/box_name.dart';
import '../../constant/info.dart'; import '../../constant/info.dart';
@@ -25,7 +23,6 @@ import '../../views/widgets/elevated_btn.dart';
import '../firebase/firbase_messge.dart'; import '../firebase/firbase_messge.dart';
import '../functions/crud.dart'; import '../functions/crud.dart';
import '../functions/launch.dart'; import '../functions/launch.dart';
import '../functions/location_controller.dart';
import '../functions/secure_storage.dart'; import '../functions/secure_storage.dart';
import '../payment/payment_controller.dart'; import '../payment/payment_controller.dart';
@@ -70,7 +67,7 @@ class MapPassengerController extends GetxController {
late LatLng newPointLocation2 = const LatLng(32.115295, 36.064773); late LatLng newPointLocation2 = const LatLng(32.115295, 36.064773);
late LatLng newPointLocation3 = const LatLng(32.115295, 36.064773); late LatLng newPointLocation3 = const LatLng(32.115295, 36.064773);
late LatLng newPointLocation4 = const LatLng(32.115295, 36.064773); late LatLng newPointLocation4 = const LatLng(32.115295, 36.064773);
LatLng myDestination = const LatLng(32.115295, 36.064773); late LatLng myDestination;
List<LatLng> polylineCoordinates = []; List<LatLng> polylineCoordinates = [];
List<LatLng> polylineCoordinates0 = []; List<LatLng> polylineCoordinates0 = [];
List<LatLng> polylineCoordinates1 = []; List<LatLng> polylineCoordinates1 = [];
@@ -216,6 +213,7 @@ class MapPassengerController extends GetxController {
void getMapPointsForAllMethods() async { void getMapPointsForAllMethods() async {
print(placesCoordinate.toString()); print(placesCoordinate.toString());
clearPolyline(); clearPolyline();
isMarkersShown = false;
isWayPointStopsSheetUtilGetMap = false; isWayPointStopsSheetUtilGetMap = false;
durationToRide = 0; durationToRide = 0;
distanceOfDestnation = 0; distanceOfDestnation = 0;
@@ -229,8 +227,16 @@ class MapPassengerController extends GetxController {
); );
} }
} }
updateCameraForDistanceAfterGetMap();
// isWayPointStopsSheet = false; // isWayPointStopsSheet = false;
if (haveSteps) {
String latestWaypoint =
placesCoordinate.lastWhere((coord) => coord.isNotEmpty);
latestPosition = LatLng(
double.parse(latestWaypoint.split(',')[0]),
double.parse(latestWaypoint.split(',')[1]),
);
}
changeWayPointStopsSheet(); changeWayPointStopsSheet();
bottomSheet(); bottomSheet();
showBottomSheet1(); showBottomSheet1();
@@ -474,8 +480,8 @@ class MapPassengerController extends GetxController {
rideTimerBegin = false; rideTimerBegin = false;
isRideFinished = true; isRideFinished = true;
update(); update();
print('rideTimerBegin: $rideTimerBegin'); //print('rideTimerBegin: $rideTimerBegin');
print('isRideFinished: $isRideFinished'); //print('isRideFinished: $isRideFinished');
await CRUD().post(link: AppLink.addPassengersWallet, payload: { await CRUD().post(link: AppLink.addPassengersWallet, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(), 'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': ((-1) * totalPassenger).toString() 'balance': ((-1) * totalPassenger).toString()
@@ -491,7 +497,7 @@ class MapPassengerController extends GetxController {
var res = await CRUD() var res = await CRUD()
.get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId}); .get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId});
if (res == 'failure') { if (res == 'failure') {
print(res); //print(res);
} }
var decode = jsonDecode(res); var decode = jsonDecode(res);
@@ -501,12 +507,12 @@ class MapPassengerController extends GetxController {
remainingTimeToPassengerFromDriverAfterApplied = 0; remainingTimeToPassengerFromDriverAfterApplied = 0;
// isCancelRidePageShown = true; // isCancelRidePageShown = true;
rideIsBeginPassengerTimer(); rideIsBeginPassengerTimer();
// print('rideTimerBegin: $rideTimerBegin'); // //print('rideTimerBegin: $rideTimerBegin');
rideTimerBegin = true; rideTimerBegin = true;
update(); update();
} }
} catch (e) { } catch (e) {
print('Error: $e'); //print('Error: $e');
// Handle the error or perform any necessary actions // Handle the error or perform any necessary actions
} }
} }
@@ -584,7 +590,7 @@ class MapPassengerController extends GetxController {
timeToPassengerFromDriverAfterApplied = 60; timeToPassengerFromDriverAfterApplied = 60;
update(); update();
// print('rideConfirm= $rideConfirm'); // //print('rideConfirm= $rideConfirm');
await getCarsLocationByPassenger(); await getCarsLocationByPassenger();
await CRUD().post(link: AppLink.addRides, payload: { await CRUD().post(link: AppLink.addRides, payload: {
@@ -605,7 +611,7 @@ class MapPassengerController extends GetxController {
"price_for_passenger": totalME.toString(), "price_for_passenger": totalME.toString(),
"distance": distance.toString() "distance": distance.toString()
}).then((value) { }).then((value) {
// print(jsonDecode(value)['message']); // //print(jsonDecode(value)['message']);
// List<String> body = [ // List<String> body = [
rideId = jsonDecode(value)['message']; rideId = jsonDecode(value)['message'];
List<String> body = [ List<String> body = [
@@ -646,8 +652,8 @@ class MapPassengerController extends GetxController {
dataCarsLocationByPassenger['message'][carsOrder]['token'].toString(), dataCarsLocationByPassenger['message'][carsOrder]['token'].toString(),
body, body,
); );
// print(dataCarsLocationByPassenger); // //print(dataCarsLocationByPassenger);
// print(dataCarsLocationByPassenger['message'][0]['token'].toString()); // //print(dataCarsLocationByPassenger['message'][0]['token'].toString());
}); });
delayAndFetchRideStatus(rideId); delayAndFetchRideStatus(rideId);
if (shouldFetch == false) { if (shouldFetch == false) {
@@ -669,12 +675,12 @@ class MapPassengerController extends GetxController {
void delayAndFetchRideStatus(String rideId) { void delayAndFetchRideStatus(String rideId) {
Timer(const Duration(milliseconds: 200), () async { Timer(const Duration(milliseconds: 200), () async {
if (shouldFetch) { if (shouldFetch) {
// print('shouldFetch is =$shouldFetch'); // //print('shouldFetch is =$shouldFetch');
var res = await CRUD() var res = await CRUD()
.get(link: AppLink.getRideStatus, payload: {'order_id': rideId}); .get(link: AppLink.getRideStatus, payload: {'order_id': rideId});
var decod = jsonDecode(res); var decod = jsonDecode(res);
print(' 0000000000000000000000000000000000000000000000000'); //print(' 0000000000000000000000000000000000000000000000000');
print(decod['data']); //print(decod['data']);
if (decod['data'].toString() == 'Apply') { if (decod['data'].toString() == 'Apply') {
shouldFetch = false; // Stop further fetches shouldFetch = false; // Stop further fetches
rideConfirm = false; rideConfirm = false;
@@ -683,12 +689,12 @@ class MapPassengerController extends GetxController {
} else if (decod['data'].toString() == 'Refused') { } else if (decod['data'].toString() == 'Refused') {
carsOrder = carsOrder + 1; carsOrder = carsOrder + 1;
update(); update();
print(dataCarsLocationByPassenger['message'].length); //print(dataCarsLocationByPassenger['message'].length);
print(dataCarsLocationByPassenger['message']); //print(dataCarsLocationByPassenger['message']);
print(carsOrder); //print(carsOrder);
if (carsOrder < dataCarsLocationByPassenger['message'].length) { if (carsOrder < dataCarsLocationByPassenger['message'].length) {
print('55555555555555555555'); //print('55555555555555555555');
changeConfirmRide(); changeConfirmRide();
} else { } else {
Get.defaultDialog( Get.defaultDialog(
@@ -718,11 +724,11 @@ class MapPassengerController extends GetxController {
if (remainingTime == 0) { if (remainingTime == 0) {
rideConfirm = false; rideConfirm = false;
// print(timeToPassengerFromDriverAfterApplied); // //print(timeToPassengerFromDriverAfterApplied);
timeToPassengerFromDriverAfterApplied += duration1; timeToPassengerFromDriverAfterApplied += duration1;
// print(duration1); // //print(duration1);
// print('timeToPassengerFromDriverAfterApplied====' + // //print('timeToPassengerFromDriverAfterApplied====' +
// timeToPassengerFromDriverAfterApplied.toString()); // timeToPassengerFromDriverAfterApplied.toString());
startTimerToPassengerFromDriverAfterApplied(); startTimerToPassengerFromDriverAfterApplied();
update(); update();
@@ -733,7 +739,7 @@ class MapPassengerController extends GetxController {
} }
void timerEnded() async { void timerEnded() async {
print('Timer ended'); //print('Timer ended');
runEvery30SecondsUntilConditionMet(); runEvery30SecondsUntilConditionMet();
isCancelRidePageShown = false; isCancelRidePageShown = false;
@@ -751,11 +757,11 @@ class MapPassengerController extends GetxController {
// if (rideConfirm == false) { // if (rideConfirm == false) {
carsLocationByPassenger = []; carsLocationByPassenger = [];
LatLngBounds bounds = calculateBounds( LatLngBounds bounds = calculateBounds(
passengerLocation.latitude, passengerLocation.longitude, 8000); passengerLocation.latitude, passengerLocation.longitude, 4000);
print( //print(
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}'); // 'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
print( //print(
'Northeast: ${bounds.northeast.latitude}, ${bounds.northeast.longitude}'); // 'Northeast: ${bounds.northeast.latitude}, ${bounds.northeast.longitude}');
var res = var res =
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: { await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
@@ -771,13 +777,13 @@ class MapPassengerController extends GetxController {
} else { } else {
noCarString = false; noCarString = false;
dataCarsLocationByPassenger = jsonDecode(res); dataCarsLocationByPassenger = jsonDecode(res);
print(dataCarsLocationByPassenger); //print(dataCarsLocationByPassenger);
// if (dataCarsLocationByPassenger.length > carsOrder) { // if (dataCarsLocationByPassenger.length > carsOrder) {
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id'] driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
.toString(); .toString();
// } // }
// print('driverId==============$driverId'); // //print('driverId==============$driverId');
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) { for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
carsLocationByPassenger.add(LatLng( carsLocationByPassenger.add(LatLng(
double.parse(dataCarsLocationByPassenger['message'][i]['latitude']), double.parse(dataCarsLocationByPassenger['message'][i]['latitude']),
@@ -885,7 +891,7 @@ class MapPassengerController extends GetxController {
} }
Future cancelRide() async { Future cancelRide() async {
print("rideConfirm=$rideConfirm"); //print("rideConfirm=$rideConfirm");
if (rideConfirm == false) { if (rideConfirm == false) {
clearPlacesDestination(); clearPlacesDestination();
@@ -906,6 +912,7 @@ class MapPassengerController extends GetxController {
isPassengerChosen = false; isPassengerChosen = false;
isCashSelectedBeforeConfirmRide = false; isCashSelectedBeforeConfirmRide = false;
isPickerShown = false; isPickerShown = false;
isMarkersShown = false;
haveSteps = false; haveSteps = false;
isMarkersShown = false; isMarkersShown = false;
// totalStepDurations = 0; // totalStepDurations = 0;
@@ -957,17 +964,29 @@ class MapPassengerController extends GetxController {
} }
void changeMainBottomMenuMap() { void changeMainBottomMenuMap() {
// else { if (isWayPointStopsSheetUtilGetMap == true) {
changeWayPointSheet();
} else {
isMainBottomMenuMap = !isMainBottomMenuMap; isMainBottomMenuMap = !isMainBottomMenuMap;
mainBottomMenuMapHeight = mainBottomMenuMapHeight =
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7; isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .6;
isWayPointSheet = false; isWayPointSheet = false;
if (heightMenuBool == true) { if (heightMenuBool == true) {
getDrawerMenu(); getDrawerMenu();
} }
update(); update();
// } }
}
void downPoints() {
if (Get.find<WayPointController>().wayPoints.length < 2) {
isWayPointStopsSheetUtilGetMap = false;
changeWayPointStopsSheet();
update();
}
changeWayPointStopsSheet();
update();
} }
void changeWayPointSheet() { void changeWayPointSheet() {
@@ -982,7 +1001,7 @@ class MapPassengerController extends GetxController {
void changeWayPointStopsSheet() { void changeWayPointStopsSheet() {
// int waypointsLength = Get.find<WayPointController>().wayPoints.length; // int waypointsLength = Get.find<WayPointController>().wayPoints.length;
print('isWayPointStopsSheet $wayPointIndex'); //print('isWayPointStopsSheet $wayPointIndex');
if (wayPointIndex > -1) { if (wayPointIndex > -1) {
isWayPointStopsSheet = true; isWayPointStopsSheet = true;
isWayPointStopsSheetUtilGetMap = true; isWayPointStopsSheetUtilGetMap = true;
@@ -1072,7 +1091,7 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {}); var response = await CRUD().getGoogleApi(link: url, payload: {});
placesDestination = response['results']; placesDestination = response['results'];
print(placesDestination); //print(placesDestination);
update(); update();
} }
@@ -1084,7 +1103,7 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {}); var response = await CRUD().getGoogleApi(link: url, payload: {});
placesStart = response['results']; placesStart = response['results'];
print(placesStart); //print(placesStart);
update(); update();
} }
@@ -1096,7 +1115,7 @@ class MapPassengerController extends GetxController {
wayPoint0 = response['results']; wayPoint0 = response['results'];
placeListResponseAll[index] = response['results']; placeListResponseAll[index] = response['results'];
print(wayPoint0); //print(wayPoint0);
update(); update();
} }
@@ -1208,11 +1227,11 @@ class MapPassengerController extends GetxController {
? LatLng(_locationData.latitude!, _locationData.longitude!) ? LatLng(_locationData.latitude!, _locationData.longitude!)
: null)!; : null)!;
// Print location details // //print location details
// print('Accuracy: ${_locationData.accuracy}'); // //print('Accuracy: ${_locationData.accuracy}');
// print('Latitude: ${_locationData.latitude}'); // //print('Latitude: ${_locationData.latitude}');
// print('Longitude: ${_locationData.longitude}'); // //print('Longitude: ${_locationData.longitude}');
// print('Time: ${_locationData.time}'); // //print('Time: ${_locationData.time}');
isLoading = false; isLoading = false;
update(); update();
} }
@@ -1249,7 +1268,7 @@ class MapPassengerController extends GetxController {
// void startMarkerReloading() { // void startMarkerReloading() {
// int count = 0; // int count = 0;
// markerReloadingTimer = Timer.periodic(const Duration(seconds: 30), (timer) { // markerReloadingTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
// print('timer=============================='); // //print('timer==============================');
// reloadMarkers(); // reloadMarkers();
// //
// count++; // count++;
@@ -1263,20 +1282,18 @@ class MapPassengerController extends GetxController {
late Timer markerReloadingTimer1; late Timer markerReloadingTimer1;
late int duration1; late int duration1;
void startMarkerReloading() { void startMarkerReloading() {
// Schedule timer 1 to reload markers at a specific time int reloadCount = 0;
DateTime scheduledTime1 = DateTime.now().add(const Duration(seconds: 20));
markerReloadingTimer1 =
Timer(scheduledTime1.difference(DateTime.now()), () {
print('timer 1 ==============================');
reloadMarkers();
});
// Schedule timer 2 to reload markers at a specific time Timer.periodic(const Duration(seconds: 12), (timer) {
DateTime scheduledTime2 = DateTime.now().add(const Duration(seconds: 40)); reloadCount++;
markerReloadingTimer2 =
Timer(scheduledTime2.difference(DateTime.now()), () { //print('Reloading markers ($reloadCount)');
print('timer 2 ==============================');
reloadMarkers(); reloadMarkers();
if (reloadCount >= 6) {
timer.cancel(); // Stop the timer after 5 reloads
//print('Marker reloading completed.');
}
}); });
} }
@@ -1303,8 +1320,8 @@ class MapPassengerController extends GetxController {
} }
// Update the map with the new markers // Update the map with the new markers
mapController?.animateCamera(CameraUpdate.newLatLng( // mapController?.animateCamera(CameraUpdate.newLatLng(
LatLng(passengerLocation.latitude, passengerLocation.longitude))); // LatLng(passengerLocation.latitude, passengerLocation.longitude)));
} }
String durationByPassenger = ''; String durationByPassenger = '';
@@ -1381,8 +1398,8 @@ class MapPassengerController extends GetxController {
// Handle the distance and duration as needed // Handle the distance and duration as needed
else { else {
print( //print(
'Failed to retrieve distance and duration: ${response['status']}'); // 'Failed to retrieve distance and duration: ${response['status']}');
// Handle the failure case // Handle the failure case
} }
} }
@@ -1390,17 +1407,17 @@ class MapPassengerController extends GetxController {
} }
} }
} }
print(nearestCar!.distance); //print(nearestCar!.distance);
print(nearestCar!.duration); //print(nearestCar!.duration);
print(nearestCar!.latitude); //print(nearestCar!.latitude);
print(nearestCar!.longitude); //print(nearestCar!.longitude);
print(nearestCar!.id); //print(nearestCar!.id);
} }
late LatLngBounds boundsData; late LatLngBounds boundsData;
getMap(String origin, destination) async { getMap(String origin, destination) async {
await getCarsLocationByPassenger(); await getCarsLocationByPassenger();
// print(carsLocationByPassenger); // //print(carsLocationByPassenger);
var coordDestination = destination.split(','); var coordDestination = destination.split(',');
double latPassengerDestination = double.parse(coordDestination[0]); double latPassengerDestination = double.parse(coordDestination[0]);
double lngPassengerDestination = double.parse(coordDestination[1]); double lngPassengerDestination = double.parse(coordDestination[1]);
@@ -1413,7 +1430,7 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {}); var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs']; data = response['routes'][0]['legs'];
// print(data); // //print(data);
isLoading = false; isLoading = false;
update(); update();
durationToRide = data[0]['duration']['value']; durationToRide = data[0]['duration']['value'];
@@ -1440,27 +1457,8 @@ class MapPassengerController extends GetxController {
// getDistanceFromText(data[0]['distance']['text']); // getDistanceFromText(data[0]['distance']['text']);
double distanceOfTrip = (data[0]['distance']['value']) / 1000; double distanceOfTrip = (data[0]['distance']['value']) / 1000;
distance = distanceOfTrip; distance = distanceOfTrip;
print('distance is $distanceOfTrip'); updateCameraForDistanceAfterGetMap();
// Animate the camera to the adjusted bounds
if (distanceOfTrip <= 5) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 14));
} else if (distanceOfTrip > 5 && distanceOfTrip <= 8) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 16));
} else if (distanceOfTrip > 8 && distanceOfTrip < 16) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 12));
} else if (distanceOfTrip >= 16 && distanceOfTrip < 30) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 11));
} else if (distanceOfTrip >= 30 && distanceOfTrip < 100) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 10));
} else if (distanceOfTrip >= 100) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 7));
}
if (polyLines.isNotEmpty) { if (polyLines.isNotEmpty) {
clearPolyline(); clearPolyline();
} else { } else {
@@ -1480,6 +1478,7 @@ class MapPassengerController extends GetxController {
double distanceOfDestnation = 0; double distanceOfDestnation = 0;
bool haveSteps = false; bool haveSteps = false;
late LatLng latestPosition;
getMapPoints(String originSteps, String destinationSteps, int index) async { getMapPoints(String originSteps, String destinationSteps, int index) async {
isWayPointStopsSheetUtilGetMap = false; isWayPointStopsSheetUtilGetMap = false;
haveSteps = true; haveSteps = true;
@@ -1488,20 +1487,15 @@ class MapPassengerController extends GetxController {
update(); update();
var url = var url =
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destinationSteps&origin=$originSteps&key=${AK.mapAPIKEY}'); ('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destinationSteps&origin=$originSteps&key=${AK.mapAPIKEY}');
// print(url); // //print(url);
var response = await CRUD().getGoogleApi(link: url, payload: {}); var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs']; data = response['routes'][0]['legs'];
// print(data); // //print(data);
// isLoading = false; // isLoading = false;
int durationToRide0 = data[0]['duration']['value']; int durationToRide0 = data[0]['duration']['value'];
durationToRide = durationToRide + durationToRide0; durationToRide = durationToRide + durationToRide0;
print('durationToRide is ${data[0]['duration']['value']}');
print('totalStepDurations is $durationToRide');
print('distanceToRide is ${(data[0]['distance']['value']) / 1000}');
distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000; distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000;
print('totalStepdistance is $distanceOfDestnation');
update(); update();
final points = final points =
decodePolyline(response["routes"][0]["overview_polyline"]["points"]); decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
@@ -1521,31 +1515,6 @@ class MapPassengerController extends GetxController {
// Create the LatLngBounds object // Create the LatLngBounds object
boundsData = LatLngBounds(northeast: northeast, southwest: southwest); boundsData = LatLngBounds(northeast: northeast, southwest: southwest);
// Calculate the zoom level based on the distance and screen size
// double distanceOfDestnation =
// getDistanceFromText(data[0]['distance']['text']);
// Animate the camera to the adjusted bounds
if (distanceOfDestnation <= 5) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 14));
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 13));
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 12));
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 8));
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 6));
} else if (distanceOfDestnation >= 100) {
mapController!
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 5));
}
if (polyLines.isNotEmpty) { if (polyLines.isNotEmpty) {
// clearPolyline(); // clearPolyline();
} else { } else {
@@ -1563,6 +1532,29 @@ 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));
}
update();
}
showBottomSheet1() async { showBottomSheet1() async {
bottomSheet(); bottomSheet();
isBottomSheetShown = true; isBottomSheetShown = true;
@@ -1593,13 +1585,13 @@ class MapPassengerController extends GetxController {
var decode = jsonDecode(value); var decode = jsonDecode(value);
if (decode["status"] == "success") { if (decode["status"] == "success") {
print(totalPassenger); //print(totalPassenger);
var firstElement = decode["message"][0]; var firstElement = decode["message"][0];
totalPassenger = totalPassenger - totalPassenger = totalPassenger -
(totalPassenger * int.parse(firstElement['amount']) / 100); (totalPassenger * int.parse(firstElement['amount']) / 100);
promoTaken = true; promoTaken = true;
update(); update();
print(totalPassenger); //print(totalPassenger);
Get.back(); Get.back();
} }
}); });
@@ -1618,7 +1610,7 @@ class MapPassengerController extends GetxController {
Future bottomSheet() async { Future bottomSheet() async {
if (data.isNotEmpty) { if (data.isNotEmpty) {
durationToAdd = Duration(seconds: durationToRide); durationToAdd = Duration(seconds: durationToRide);
print('durationToRide----- $durationToRide'); //print('durationToRide----- $durationToRide');
hours = durationToAdd.inHours; hours = durationToAdd.inHours;
minutes = (durationToAdd.inMinutes % 60).round(); minutes = (durationToAdd.inMinutes % 60).round();
DateTime currentTime = DateTime.now(); DateTime currentTime = DateTime.now();
@@ -1649,7 +1641,7 @@ class MapPassengerController extends GetxController {
cost = distance * 0.21; cost = distance * 0.21;
update(); update();
} }
print('cost $cost'); //print('cost $cost');
if (totalPassenger < 1) { if (totalPassenger < 1) {
totalPassenger = 1; totalPassenger = 1;
totalDriver = 1; totalDriver = 1;

View File

@@ -9,8 +9,8 @@ ThemeData themeEnglish = ThemeData(
displaySmall: AppStyle.title, displaySmall: AppStyle.title,
displayLarge: AppStyle.title, displayLarge: AppStyle.title,
displayMedium: AppStyle.title, displayMedium: AppStyle.title,
bodyLarge: AppStyle.headTitle, bodyLarge: AppStyle.title,
bodyMedium: AppStyle.headTitle2), bodyMedium: AppStyle.title),
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
dialogTheme: DialogTheme( dialogTheme: DialogTheme(
backgroundColor: AppColor.secondaryColor, backgroundColor: AppColor.secondaryColor,

View File

@@ -14,8 +14,12 @@ GetBuilder<MapPassengerController> formSearchPlaces() {
builder: (controller) => Column( builder: (controller) => Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(12),
child: Container( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: Get.width * .8,
decoration: decoration:
const BoxDecoration(color: AppColor.secondaryColor), const BoxDecoration(color: AppColor.secondaryColor),
child: TextField( child: TextField(
@@ -44,7 +48,8 @@ GetBuilder<MapPassengerController> formSearchPlaces() {
), ),
controller: controller.placeDestinationController, controller: controller.placeDestinationController,
onChanged: (value) { onChanged: (value) {
if (controller.placeDestinationController.text.length > if (controller
.placeDestinationController.text.length >
5) { 5) {
controller.getPlaces(); controller.getPlaces();
controller.changeHeightPlaces(); controller.changeHeightPlaces();
@@ -53,20 +58,32 @@ GetBuilder<MapPassengerController> formSearchPlaces() {
// onEditingComplete: () => controller.changeHeight(), // onEditingComplete: () => controller.changeHeight(),
), ),
), ),
), IconButton(
controller.placesDestination.isEmpty onPressed: () {
? InkWell(
onTap: () {
controller.changeMainBottomMenuMap(); controller.changeMainBottomMenuMap();
controller.changePickerShown(); controller.changePickerShown();
}, },
child: Text( icon: const Icon(
'Choose from Map'.tr, Icons.map_outlined,
style: color: AppColor.greenColor,
AppStyle.title.copyWith(color: AppColor.blueColor),
), ),
) ),
: const SizedBox(), ],
),
),
// controller.placesDestination.isEmpty
// ? InkWell(
// onTap: () {
// controller.changeMainBottomMenuMap();
// controller.changePickerShown();
// },
// child: Text(
// 'Choose from Map'.tr,
// style:
// AppStyle.title.copyWith(color: AppColor.blueColor),
// ),
// )
// : const SizedBox(),
Container( Container(
height: controller.placesDestination.isNotEmpty height: controller.placesDestination.isNotEmpty
? controller.height ? controller.height

View File

@@ -15,8 +15,12 @@ GetBuilder<MapPassengerController> formSearchPlacesStart() {
builder: (controller) => Column( builder: (controller) => Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(12),
child: Container( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: Get.width * .8,
decoration: decoration:
const BoxDecoration(color: AppColor.secondaryColor), const BoxDecoration(color: AppColor.secondaryColor),
child: TextField( child: TextField(
@@ -53,21 +57,34 @@ GetBuilder<MapPassengerController> formSearchPlacesStart() {
// onEditingComplete: () => controller.changeHeight(), // onEditingComplete: () => controller.changeHeight(),
), ),
), ),
), IconButton(
controller.placesDestination.isEmpty onPressed: () {
? InkWell(
onTap: () {
controller.startLocationFromMap = true; controller.startLocationFromMap = true;
controller.changeMainBottomMenuMap(); controller.changeMainBottomMenuMap();
controller.changePickerShown(); controller.changePickerShown();
}, },
child: Text( icon: const Icon(
'Choose from Map'.tr, Icons.map_outlined,
style: color: AppColor.yellowColor,
AppStyle.title.copyWith(color: AppColor.blueColor),
), ),
) ),
: const SizedBox(), ],
),
),
// controller.placesDestination.isEmpty
// ? InkWell(
// onTap: () {
// controller.startLocationFromMap = true;
// controller.changeMainBottomMenuMap();
// controller.changePickerShown();
// },
// child: Text(
// 'Choose from Map Start Point'.tr,
// style:
// AppStyle.title.copyWith(color: AppColor.blueColor),
// ),
// )
// : const SizedBox(),
Container( Container(
height: height:
controller.placesStart.isNotEmpty ? controller.height : 0, controller.placesStart.isNotEmpty ? controller.height : 0,

View File

@@ -176,19 +176,7 @@ class GoogleMapPassengerWidget extends StatelessWidget {
if (controller.haveSteps) if (controller.haveSteps)
Marker( Marker(
markerId: MarkerId('EndSteps'.tr), markerId: MarkerId('EndSteps'.tr),
position: controller.newPointLocation4 == '' position: controller.latestPosition,
? LatLng(
double.parse(
controller.placesCoordinate[3].split(',')[0]),
double.parse(
controller.placesCoordinate[3].split(',')[1]))
: controller.newPointLocation3 == ''
? LatLng(
double.parse(controller.placesCoordinate[2]
.split(',')[0]),
double.parse(controller.placesCoordinate[2]
.split(',')[1]))
: controller.newPointLocation2,
draggable: true, draggable: true,
icon: controller.endIcon, icon: controller.endIcon,
), ),

View File

@@ -83,10 +83,6 @@ class MainBottomMenuMap extends StatelessWidget {
// print(controller.newMyLocation); // print(controller.newMyLocation);
} }
// await controller.getMap(
// '${controller.myLocation.latitude},${controller.myLocation.longitude}',
// '${controller.newMyLocation.latitude},${controller.newMyLocation.longitude}',
// );
controller.placesDestination = []; controller.placesDestination = [];
controller controller
.placeDestinationController .placeDestinationController
@@ -245,7 +241,7 @@ class MainBottomMenuMap extends StatelessWidget {
height: 30, height: 30,
), ),
MyElevatedButton( MyElevatedButton(
title: 'Go to Ride', title: 'Get Direction of Trip'.tr,
onPressed: () async { onPressed: () async {
controller.changeMainBottomMenuMap(); controller.changeMainBottomMenuMap();
@@ -273,20 +269,20 @@ class MainBottomMenuMap extends StatelessWidget {
style: AppStyle.title, style: AppStyle.title,
), ),
), ),
IconButton( // IconButton(
onPressed: () { // onPressed: () {
FirebaseMessagesController() // FirebaseMessagesController()
.sendNotificationToAnyWithoutData( // .sendNotificationToAnyWithoutData(
'title', // 'title',
'body', // 'body',
// 'e5IXztYGS1W9zFvv-gmMRL:APA91bF7-fFzksCRXIk0Fm7IfQuhHL0df-vnDW8DNNKa3sWea649j3Obc8PhyJo9UOxKBtrvoJxYcbjclFKpvycAuhG0lv_e4hkavy-LZ6SsAu5J5bYrPz6-0BbyLdLUHoBuOFlNMvmN'); // // 'e5IXztYGS1W9zFvv-gmMRL:APA91bF7-fFzksCRXIk0Fm7IfQuhHL0df-vnDW8DNNKa3sWea649j3Obc8PhyJo9UOxKBtrvoJxYcbjclFKpvycAuhG0lv_e4hkavy-LZ6SsAu5J5bYrPz6-0BbyLdLUHoBuOFlNMvmN');
'eoV61-RSFUxLrCa88xaSG2:APA91bFmgGVTVH0mhjGhFqrB2_rMf0l0udBUzEUW-V2XlxtnYeDTnpESYRRCI_tMQnbDqQ3PK7pFMzW0-CZolS-pURSkwbwvnbVtV9VHB2UuOrKG3MYpGFsWfmjUdyRIOe30nx-eVkOu'); // 'eoV61-RSFUxLrCa88xaSG2:APA91bFmgGVTVH0mhjGhFqrB2_rMf0l0udBUzEUW-V2XlxtnYeDTnpESYRRCI_tMQnbDqQ3PK7pFMzW0-CZolS-pURSkwbwvnbVtV9VHB2UuOrKG3MYpGFsWfmjUdyRIOe30nx-eVkOu');
}, // },
icon: const Icon( // icon: const Icon(
Icons.add, // Icons.add,
color: AppColor.blueColor, // color: AppColor.blueColor,
), // ),
), // ),
], ],
) )
], ],

View File

@@ -35,12 +35,13 @@ class PointsPageForRider extends StatelessWidget {
children: [ children: [
IconButton( IconButton(
onPressed: () { onPressed: () {
mapPassengerController.changeWayPointStopsSheet(); mapPassengerController.downPoints();
}, },
icon: const Icon(Icons.arrow_drop_down_circle_outlined), icon: const Icon(Icons.arrow_drop_down_circle_outlined),
), ),
GetBuilder<WayPointController>(builder: (wayPointController) { GetBuilder<WayPointController>(builder: (wayPointController) {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
@@ -55,7 +56,7 @@ class PointsPageForRider extends StatelessWidget {
mapPassengerController mapPassengerController
.getMapPointsForAllMethods(); .getMapPointsForAllMethods();
}, },
child: const Text('Get Map'), child: const Text('Get Direction'),
) )
: const SizedBox() : const SizedBox()
], ],