1/27/1
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math' show cos;
|
||||
import 'package:flutter/material.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/views/home/map_page_passenger.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/box_name.dart';
|
||||
import '../../constant/info.dart';
|
||||
@@ -25,7 +23,6 @@ import '../../views/widgets/elevated_btn.dart';
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import '../functions/crud.dart';
|
||||
import '../functions/launch.dart';
|
||||
import '../functions/location_controller.dart';
|
||||
import '../functions/secure_storage.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 newPointLocation3 = 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> polylineCoordinates0 = [];
|
||||
List<LatLng> polylineCoordinates1 = [];
|
||||
@@ -216,6 +213,7 @@ class MapPassengerController extends GetxController {
|
||||
void getMapPointsForAllMethods() async {
|
||||
print(placesCoordinate.toString());
|
||||
clearPolyline();
|
||||
isMarkersShown = false;
|
||||
isWayPointStopsSheetUtilGetMap = false;
|
||||
durationToRide = 0;
|
||||
distanceOfDestnation = 0;
|
||||
@@ -229,8 +227,16 @@ class MapPassengerController extends GetxController {
|
||||
);
|
||||
}
|
||||
}
|
||||
updateCameraForDistanceAfterGetMap();
|
||||
// isWayPointStopsSheet = false;
|
||||
|
||||
if (haveSteps) {
|
||||
String latestWaypoint =
|
||||
placesCoordinate.lastWhere((coord) => coord.isNotEmpty);
|
||||
latestPosition = LatLng(
|
||||
double.parse(latestWaypoint.split(',')[0]),
|
||||
double.parse(latestWaypoint.split(',')[1]),
|
||||
);
|
||||
}
|
||||
changeWayPointStopsSheet();
|
||||
bottomSheet();
|
||||
showBottomSheet1();
|
||||
@@ -474,8 +480,8 @@ class MapPassengerController extends GetxController {
|
||||
rideTimerBegin = false;
|
||||
isRideFinished = true;
|
||||
update();
|
||||
print('rideTimerBegin: $rideTimerBegin');
|
||||
print('isRideFinished: $isRideFinished');
|
||||
//print('rideTimerBegin: $rideTimerBegin');
|
||||
//print('isRideFinished: $isRideFinished');
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': ((-1) * totalPassenger).toString()
|
||||
@@ -491,7 +497,7 @@ class MapPassengerController extends GetxController {
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId});
|
||||
if (res == 'failure') {
|
||||
print(res);
|
||||
//print(res);
|
||||
}
|
||||
var decode = jsonDecode(res);
|
||||
|
||||
@@ -501,12 +507,12 @@ class MapPassengerController extends GetxController {
|
||||
remainingTimeToPassengerFromDriverAfterApplied = 0;
|
||||
// isCancelRidePageShown = true;
|
||||
rideIsBeginPassengerTimer();
|
||||
// print('rideTimerBegin: $rideTimerBegin');
|
||||
// //print('rideTimerBegin: $rideTimerBegin');
|
||||
rideTimerBegin = true;
|
||||
update();
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error: $e');
|
||||
//print('Error: $e');
|
||||
// Handle the error or perform any necessary actions
|
||||
}
|
||||
}
|
||||
@@ -584,7 +590,7 @@ class MapPassengerController extends GetxController {
|
||||
timeToPassengerFromDriverAfterApplied = 60;
|
||||
|
||||
update();
|
||||
// print('rideConfirm= $rideConfirm');
|
||||
// //print('rideConfirm= $rideConfirm');
|
||||
|
||||
await getCarsLocationByPassenger();
|
||||
await CRUD().post(link: AppLink.addRides, payload: {
|
||||
@@ -605,7 +611,7 @@ class MapPassengerController extends GetxController {
|
||||
"price_for_passenger": totalME.toString(),
|
||||
"distance": distance.toString()
|
||||
}).then((value) {
|
||||
// print(jsonDecode(value)['message']);
|
||||
// //print(jsonDecode(value)['message']);
|
||||
// List<String> body = [
|
||||
rideId = jsonDecode(value)['message'];
|
||||
List<String> body = [
|
||||
@@ -646,8 +652,8 @@ class MapPassengerController extends GetxController {
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['token'].toString(),
|
||||
body,
|
||||
);
|
||||
// print(dataCarsLocationByPassenger);
|
||||
// print(dataCarsLocationByPassenger['message'][0]['token'].toString());
|
||||
// //print(dataCarsLocationByPassenger);
|
||||
// //print(dataCarsLocationByPassenger['message'][0]['token'].toString());
|
||||
});
|
||||
delayAndFetchRideStatus(rideId);
|
||||
if (shouldFetch == false) {
|
||||
@@ -669,12 +675,12 @@ class MapPassengerController extends GetxController {
|
||||
void delayAndFetchRideStatus(String rideId) {
|
||||
Timer(const Duration(milliseconds: 200), () async {
|
||||
if (shouldFetch) {
|
||||
// print('shouldFetch is =$shouldFetch');
|
||||
// //print('shouldFetch is =$shouldFetch');
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getRideStatus, payload: {'order_id': rideId});
|
||||
var decod = jsonDecode(res);
|
||||
print(' 0000000000000000000000000000000000000000000000000');
|
||||
print(decod['data']);
|
||||
//print(' 0000000000000000000000000000000000000000000000000');
|
||||
//print(decod['data']);
|
||||
if (decod['data'].toString() == 'Apply') {
|
||||
shouldFetch = false; // Stop further fetches
|
||||
rideConfirm = false;
|
||||
@@ -683,12 +689,12 @@ class MapPassengerController extends GetxController {
|
||||
} else if (decod['data'].toString() == 'Refused') {
|
||||
carsOrder = carsOrder + 1;
|
||||
update();
|
||||
print(dataCarsLocationByPassenger['message'].length);
|
||||
print(dataCarsLocationByPassenger['message']);
|
||||
print(carsOrder);
|
||||
//print(dataCarsLocationByPassenger['message'].length);
|
||||
//print(dataCarsLocationByPassenger['message']);
|
||||
//print(carsOrder);
|
||||
|
||||
if (carsOrder < dataCarsLocationByPassenger['message'].length) {
|
||||
print('55555555555555555555');
|
||||
//print('55555555555555555555');
|
||||
changeConfirmRide();
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
@@ -718,11 +724,11 @@ class MapPassengerController extends GetxController {
|
||||
if (remainingTime == 0) {
|
||||
rideConfirm = false;
|
||||
|
||||
// print(timeToPassengerFromDriverAfterApplied);
|
||||
// //print(timeToPassengerFromDriverAfterApplied);
|
||||
timeToPassengerFromDriverAfterApplied += duration1;
|
||||
// print(duration1);
|
||||
// //print(duration1);
|
||||
|
||||
// print('timeToPassengerFromDriverAfterApplied====' +
|
||||
// //print('timeToPassengerFromDriverAfterApplied====' +
|
||||
// timeToPassengerFromDriverAfterApplied.toString());
|
||||
startTimerToPassengerFromDriverAfterApplied();
|
||||
update();
|
||||
@@ -733,7 +739,7 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
void timerEnded() async {
|
||||
print('Timer ended');
|
||||
//print('Timer ended');
|
||||
|
||||
runEvery30SecondsUntilConditionMet();
|
||||
isCancelRidePageShown = false;
|
||||
@@ -751,11 +757,11 @@ class MapPassengerController extends GetxController {
|
||||
// if (rideConfirm == false) {
|
||||
carsLocationByPassenger = [];
|
||||
LatLngBounds bounds = calculateBounds(
|
||||
passengerLocation.latitude, passengerLocation.longitude, 8000);
|
||||
print(
|
||||
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
||||
print(
|
||||
'Northeast: ${bounds.northeast.latitude}, ${bounds.northeast.longitude}');
|
||||
passengerLocation.latitude, passengerLocation.longitude, 4000);
|
||||
//print(
|
||||
// 'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
||||
//print(
|
||||
// 'Northeast: ${bounds.northeast.latitude}, ${bounds.northeast.longitude}');
|
||||
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
|
||||
@@ -771,13 +777,13 @@ class MapPassengerController extends GetxController {
|
||||
} else {
|
||||
noCarString = false;
|
||||
dataCarsLocationByPassenger = jsonDecode(res);
|
||||
print(dataCarsLocationByPassenger);
|
||||
//print(dataCarsLocationByPassenger);
|
||||
// if (dataCarsLocationByPassenger.length > carsOrder) {
|
||||
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
|
||||
.toString();
|
||||
// }
|
||||
|
||||
// print('driverId==============$driverId');
|
||||
// //print('driverId==============$driverId');
|
||||
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
|
||||
carsLocationByPassenger.add(LatLng(
|
||||
double.parse(dataCarsLocationByPassenger['message'][i]['latitude']),
|
||||
@@ -885,7 +891,7 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
Future cancelRide() async {
|
||||
print("rideConfirm=$rideConfirm");
|
||||
//print("rideConfirm=$rideConfirm");
|
||||
|
||||
if (rideConfirm == false) {
|
||||
clearPlacesDestination();
|
||||
@@ -906,6 +912,7 @@ class MapPassengerController extends GetxController {
|
||||
isPassengerChosen = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
isPickerShown = false;
|
||||
isMarkersShown = false;
|
||||
haveSteps = false;
|
||||
isMarkersShown = false;
|
||||
// totalStepDurations = 0;
|
||||
@@ -957,17 +964,29 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
void changeMainBottomMenuMap() {
|
||||
// else {
|
||||
isMainBottomMenuMap = !isMainBottomMenuMap;
|
||||
mainBottomMenuMapHeight =
|
||||
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7;
|
||||
isWayPointSheet = false;
|
||||
if (heightMenuBool == true) {
|
||||
getDrawerMenu();
|
||||
}
|
||||
if (isWayPointStopsSheetUtilGetMap == true) {
|
||||
changeWayPointSheet();
|
||||
} else {
|
||||
isMainBottomMenuMap = !isMainBottomMenuMap;
|
||||
mainBottomMenuMapHeight =
|
||||
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .6;
|
||||
isWayPointSheet = false;
|
||||
if (heightMenuBool == true) {
|
||||
getDrawerMenu();
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void downPoints() {
|
||||
if (Get.find<WayPointController>().wayPoints.length < 2) {
|
||||
isWayPointStopsSheetUtilGetMap = false;
|
||||
changeWayPointStopsSheet();
|
||||
update();
|
||||
}
|
||||
changeWayPointStopsSheet();
|
||||
update();
|
||||
// }
|
||||
}
|
||||
|
||||
void changeWayPointSheet() {
|
||||
@@ -982,7 +1001,7 @@ class MapPassengerController extends GetxController {
|
||||
void changeWayPointStopsSheet() {
|
||||
// int waypointsLength = Get.find<WayPointController>().wayPoints.length;
|
||||
|
||||
print('isWayPointStopsSheet $wayPointIndex');
|
||||
//print('isWayPointStopsSheet $wayPointIndex');
|
||||
if (wayPointIndex > -1) {
|
||||
isWayPointStopsSheet = true;
|
||||
isWayPointStopsSheetUtilGetMap = true;
|
||||
@@ -1072,7 +1091,7 @@ class MapPassengerController extends GetxController {
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
placesDestination = response['results'];
|
||||
print(placesDestination);
|
||||
//print(placesDestination);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1084,7 +1103,7 @@ class MapPassengerController extends GetxController {
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
placesStart = response['results'];
|
||||
print(placesStart);
|
||||
//print(placesStart);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1096,7 +1115,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
wayPoint0 = response['results'];
|
||||
placeListResponseAll[index] = response['results'];
|
||||
print(wayPoint0);
|
||||
//print(wayPoint0);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1208,11 +1227,11 @@ class MapPassengerController extends GetxController {
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
|
||||
// Print location details
|
||||
// print('Accuracy: ${_locationData.accuracy}');
|
||||
// print('Latitude: ${_locationData.latitude}');
|
||||
// print('Longitude: ${_locationData.longitude}');
|
||||
// print('Time: ${_locationData.time}');
|
||||
// //print location details
|
||||
// //print('Accuracy: ${_locationData.accuracy}');
|
||||
// //print('Latitude: ${_locationData.latitude}');
|
||||
// //print('Longitude: ${_locationData.longitude}');
|
||||
// //print('Time: ${_locationData.time}');
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
@@ -1249,7 +1268,7 @@ class MapPassengerController extends GetxController {
|
||||
// void startMarkerReloading() {
|
||||
// int count = 0;
|
||||
// markerReloadingTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
|
||||
// print('timer==============================');
|
||||
// //print('timer==============================');
|
||||
// reloadMarkers();
|
||||
//
|
||||
// count++;
|
||||
@@ -1263,20 +1282,18 @@ class MapPassengerController extends GetxController {
|
||||
late Timer markerReloadingTimer1;
|
||||
late int duration1;
|
||||
void startMarkerReloading() {
|
||||
// Schedule timer 1 to reload markers at a specific time
|
||||
DateTime scheduledTime1 = DateTime.now().add(const Duration(seconds: 20));
|
||||
markerReloadingTimer1 =
|
||||
Timer(scheduledTime1.difference(DateTime.now()), () {
|
||||
print('timer 1 ==============================');
|
||||
reloadMarkers();
|
||||
});
|
||||
int reloadCount = 0;
|
||||
|
||||
// Schedule timer 2 to reload markers at a specific time
|
||||
DateTime scheduledTime2 = DateTime.now().add(const Duration(seconds: 40));
|
||||
markerReloadingTimer2 =
|
||||
Timer(scheduledTime2.difference(DateTime.now()), () {
|
||||
print('timer 2 ==============================');
|
||||
Timer.periodic(const Duration(seconds: 12), (timer) {
|
||||
reloadCount++;
|
||||
|
||||
//print('Reloading markers ($reloadCount)');
|
||||
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
|
||||
mapController?.animateCamera(CameraUpdate.newLatLng(
|
||||
LatLng(passengerLocation.latitude, passengerLocation.longitude)));
|
||||
// mapController?.animateCamera(CameraUpdate.newLatLng(
|
||||
// LatLng(passengerLocation.latitude, passengerLocation.longitude)));
|
||||
}
|
||||
|
||||
String durationByPassenger = '';
|
||||
@@ -1381,8 +1398,8 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// Handle the distance and duration as needed
|
||||
else {
|
||||
print(
|
||||
'Failed to retrieve distance and duration: ${response['status']}');
|
||||
//print(
|
||||
// 'Failed to retrieve distance and duration: ${response['status']}');
|
||||
// Handle the failure case
|
||||
}
|
||||
}
|
||||
@@ -1390,17 +1407,17 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
}
|
||||
print(nearestCar!.distance);
|
||||
print(nearestCar!.duration);
|
||||
print(nearestCar!.latitude);
|
||||
print(nearestCar!.longitude);
|
||||
print(nearestCar!.id);
|
||||
//print(nearestCar!.distance);
|
||||
//print(nearestCar!.duration);
|
||||
//print(nearestCar!.latitude);
|
||||
//print(nearestCar!.longitude);
|
||||
//print(nearestCar!.id);
|
||||
}
|
||||
|
||||
late LatLngBounds boundsData;
|
||||
getMap(String origin, destination) async {
|
||||
await getCarsLocationByPassenger();
|
||||
// print(carsLocationByPassenger);
|
||||
// //print(carsLocationByPassenger);
|
||||
var coordDestination = destination.split(',');
|
||||
double latPassengerDestination = double.parse(coordDestination[0]);
|
||||
double lngPassengerDestination = double.parse(coordDestination[1]);
|
||||
@@ -1413,7 +1430,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
// print(data);
|
||||
// //print(data);
|
||||
isLoading = false;
|
||||
update();
|
||||
durationToRide = data[0]['duration']['value'];
|
||||
@@ -1440,27 +1457,8 @@ class MapPassengerController extends GetxController {
|
||||
// getDistanceFromText(data[0]['distance']['text']);
|
||||
double distanceOfTrip = (data[0]['distance']['value']) / 1000;
|
||||
distance = distanceOfTrip;
|
||||
print('distance is $distanceOfTrip');
|
||||
// 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));
|
||||
}
|
||||
updateCameraForDistanceAfterGetMap();
|
||||
|
||||
if (polyLines.isNotEmpty) {
|
||||
clearPolyline();
|
||||
} else {
|
||||
@@ -1480,6 +1478,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
double distanceOfDestnation = 0;
|
||||
bool haveSteps = false;
|
||||
late LatLng latestPosition;
|
||||
getMapPoints(String originSteps, String destinationSteps, int index) async {
|
||||
isWayPointStopsSheetUtilGetMap = false;
|
||||
haveSteps = true;
|
||||
@@ -1488,20 +1487,15 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
var url =
|
||||
('${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: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
// print(data);
|
||||
// //print(data);
|
||||
// isLoading = false;
|
||||
|
||||
int durationToRide0 = data[0]['duration']['value'];
|
||||
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;
|
||||
|
||||
print('totalStepdistance is $distanceOfDestnation');
|
||||
update();
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
@@ -1521,31 +1515,6 @@ class MapPassengerController extends GetxController {
|
||||
// Create the LatLngBounds object
|
||||
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) {
|
||||
// clearPolyline();
|
||||
} 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 {
|
||||
bottomSheet();
|
||||
isBottomSheetShown = true;
|
||||
@@ -1593,13 +1585,13 @@ class MapPassengerController extends GetxController {
|
||||
var decode = jsonDecode(value);
|
||||
|
||||
if (decode["status"] == "success") {
|
||||
print(totalPassenger);
|
||||
//print(totalPassenger);
|
||||
var firstElement = decode["message"][0];
|
||||
totalPassenger = totalPassenger -
|
||||
(totalPassenger * int.parse(firstElement['amount']) / 100);
|
||||
promoTaken = true;
|
||||
update();
|
||||
print(totalPassenger);
|
||||
//print(totalPassenger);
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
@@ -1618,7 +1610,7 @@ class MapPassengerController extends GetxController {
|
||||
Future bottomSheet() async {
|
||||
if (data.isNotEmpty) {
|
||||
durationToAdd = Duration(seconds: durationToRide);
|
||||
print('durationToRide----- $durationToRide');
|
||||
//print('durationToRide----- $durationToRide');
|
||||
hours = durationToAdd.inHours;
|
||||
minutes = (durationToAdd.inMinutes % 60).round();
|
||||
DateTime currentTime = DateTime.now();
|
||||
@@ -1649,7 +1641,7 @@ class MapPassengerController extends GetxController {
|
||||
cost = distance * 0.21;
|
||||
update();
|
||||
}
|
||||
print('cost $cost');
|
||||
//print('cost $cost');
|
||||
if (totalPassenger < 1) {
|
||||
totalPassenger = 1;
|
||||
totalDriver = 1;
|
||||
|
||||
@@ -9,8 +9,8 @@ ThemeData themeEnglish = ThemeData(
|
||||
displaySmall: AppStyle.title,
|
||||
displayLarge: AppStyle.title,
|
||||
displayMedium: AppStyle.title,
|
||||
bodyLarge: AppStyle.headTitle,
|
||||
bodyMedium: AppStyle.headTitle2),
|
||||
bodyLarge: AppStyle.title,
|
||||
bodyMedium: AppStyle.title),
|
||||
primarySwatch: Colors.blue,
|
||||
dialogTheme: DialogTheme(
|
||||
backgroundColor: AppColor.secondaryColor,
|
||||
|
||||
@@ -14,59 +14,76 @@ GetBuilder<MapPassengerController> formSearchPlaces() {
|
||||
builder: (controller) => Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Container(
|
||||
decoration:
|
||||
const BoxDecoration(color: AppColor.secondaryColor),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.only(),
|
||||
gapPadding: 4,
|
||||
borderSide: BorderSide(
|
||||
color: AppColor.redColor,
|
||||
width: 2,
|
||||
)),
|
||||
suffixIcon: const Icon(Icons.search),
|
||||
hintText: controller.hintTextDestinationPoint,
|
||||
hintStyle: AppStyle.title,
|
||||
hintMaxLines: 1,
|
||||
prefixIcon: IconButton(
|
||||
onPressed: () {
|
||||
controller.placeDestinationController.clear();
|
||||
controller.clearPlacesDestination();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.red[300],
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width * .8,
|
||||
decoration:
|
||||
const BoxDecoration(color: AppColor.secondaryColor),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.only(),
|
||||
gapPadding: 4,
|
||||
borderSide: BorderSide(
|
||||
color: AppColor.redColor,
|
||||
width: 2,
|
||||
)),
|
||||
suffixIcon: const Icon(Icons.search),
|
||||
hintText: controller.hintTextDestinationPoint,
|
||||
hintStyle: AppStyle.title,
|
||||
hintMaxLines: 1,
|
||||
prefixIcon: IconButton(
|
||||
onPressed: () {
|
||||
controller.placeDestinationController.clear();
|
||||
controller.clearPlacesDestination();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.red[300],
|
||||
),
|
||||
),
|
||||
),
|
||||
controller: controller.placeDestinationController,
|
||||
onChanged: (value) {
|
||||
if (controller
|
||||
.placeDestinationController.text.length >
|
||||
5) {
|
||||
controller.getPlaces();
|
||||
controller.changeHeightPlaces();
|
||||
}
|
||||
},
|
||||
// onEditingComplete: () => controller.changeHeight(),
|
||||
),
|
||||
),
|
||||
controller: controller.placeDestinationController,
|
||||
onChanged: (value) {
|
||||
if (controller.placeDestinationController.text.length >
|
||||
5) {
|
||||
controller.getPlaces();
|
||||
controller.changeHeightPlaces();
|
||||
}
|
||||
},
|
||||
// onEditingComplete: () => controller.changeHeight(),
|
||||
),
|
||||
),
|
||||
),
|
||||
controller.placesDestination.isEmpty
|
||||
? InkWell(
|
||||
onTap: () {
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
controller.changeMainBottomMenuMap();
|
||||
controller.changePickerShown();
|
||||
},
|
||||
child: Text(
|
||||
'Choose from Map'.tr,
|
||||
style:
|
||||
AppStyle.title.copyWith(color: AppColor.blueColor),
|
||||
icon: const Icon(
|
||||
Icons.map_outlined,
|
||||
color: AppColor.greenColor,
|
||||
),
|
||||
)
|
||||
: 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(
|
||||
height: controller.placesDestination.isNotEmpty
|
||||
? controller.height
|
||||
|
||||
@@ -15,59 +15,76 @@ GetBuilder<MapPassengerController> formSearchPlacesStart() {
|
||||
builder: (controller) => Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Container(
|
||||
decoration:
|
||||
const BoxDecoration(color: AppColor.secondaryColor),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.only(),
|
||||
gapPadding: 4,
|
||||
borderSide: BorderSide(
|
||||
color: AppColor.redColor,
|
||||
width: 2,
|
||||
)),
|
||||
suffixIcon: const Icon(Icons.search),
|
||||
hintText: controller.hintTextStartPoint,
|
||||
hintStyle: AppStyle.title,
|
||||
hintMaxLines: 1,
|
||||
prefixIcon: IconButton(
|
||||
onPressed: () {
|
||||
controller.placeStartController.clear();
|
||||
controller.clearPlacesStart();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.red[300],
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width * .8,
|
||||
decoration:
|
||||
const BoxDecoration(color: AppColor.secondaryColor),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.only(),
|
||||
gapPadding: 4,
|
||||
borderSide: BorderSide(
|
||||
color: AppColor.redColor,
|
||||
width: 2,
|
||||
)),
|
||||
suffixIcon: const Icon(Icons.search),
|
||||
hintText: controller.hintTextStartPoint,
|
||||
hintStyle: AppStyle.title,
|
||||
hintMaxLines: 1,
|
||||
prefixIcon: IconButton(
|
||||
onPressed: () {
|
||||
controller.placeStartController.clear();
|
||||
controller.clearPlacesStart();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.red[300],
|
||||
),
|
||||
),
|
||||
),
|
||||
controller: controller.placeStartController,
|
||||
onChanged: (value) {
|
||||
if (controller.placeStartController.text.length > 5) {
|
||||
controller.getPlacesStart();
|
||||
controller.changeHeightStartPlaces();
|
||||
}
|
||||
},
|
||||
// onEditingComplete: () => controller.changeHeight(),
|
||||
),
|
||||
),
|
||||
controller: controller.placeStartController,
|
||||
onChanged: (value) {
|
||||
if (controller.placeStartController.text.length > 5) {
|
||||
controller.getPlacesStart();
|
||||
controller.changeHeightStartPlaces();
|
||||
}
|
||||
},
|
||||
// onEditingComplete: () => controller.changeHeight(),
|
||||
),
|
||||
),
|
||||
),
|
||||
controller.placesDestination.isEmpty
|
||||
? InkWell(
|
||||
onTap: () {
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
controller.startLocationFromMap = true;
|
||||
controller.changeMainBottomMenuMap();
|
||||
controller.changePickerShown();
|
||||
},
|
||||
child: Text(
|
||||
'Choose from Map'.tr,
|
||||
style:
|
||||
AppStyle.title.copyWith(color: AppColor.blueColor),
|
||||
icon: const Icon(
|
||||
Icons.map_outlined,
|
||||
color: AppColor.yellowColor,
|
||||
),
|
||||
)
|
||||
: 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(
|
||||
height:
|
||||
controller.placesStart.isNotEmpty ? controller.height : 0,
|
||||
|
||||
@@ -176,19 +176,7 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
||||
if (controller.haveSteps)
|
||||
Marker(
|
||||
markerId: MarkerId('EndSteps'.tr),
|
||||
position: controller.newPointLocation4 == ''
|
||||
? 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,
|
||||
position: controller.latestPosition,
|
||||
draggable: true,
|
||||
icon: controller.endIcon,
|
||||
),
|
||||
|
||||
@@ -83,10 +83,6 @@ class MainBottomMenuMap extends StatelessWidget {
|
||||
// print(controller.newMyLocation);
|
||||
}
|
||||
|
||||
// await controller.getMap(
|
||||
// '${controller.myLocation.latitude},${controller.myLocation.longitude}',
|
||||
// '${controller.newMyLocation.latitude},${controller.newMyLocation.longitude}',
|
||||
// );
|
||||
controller.placesDestination = [];
|
||||
controller
|
||||
.placeDestinationController
|
||||
@@ -245,7 +241,7 @@ class MainBottomMenuMap extends StatelessWidget {
|
||||
height: 30,
|
||||
),
|
||||
MyElevatedButton(
|
||||
title: 'Go to Ride',
|
||||
title: 'Get Direction of Trip'.tr,
|
||||
onPressed: () async {
|
||||
controller.changeMainBottomMenuMap();
|
||||
|
||||
@@ -273,20 +269,20 @@ class MainBottomMenuMap extends StatelessWidget {
|
||||
style: AppStyle.title,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToAnyWithoutData(
|
||||
'title',
|
||||
'body',
|
||||
// 'e5IXztYGS1W9zFvv-gmMRL:APA91bF7-fFzksCRXIk0Fm7IfQuhHL0df-vnDW8DNNKa3sWea649j3Obc8PhyJo9UOxKBtrvoJxYcbjclFKpvycAuhG0lv_e4hkavy-LZ6SsAu5J5bYrPz6-0BbyLdLUHoBuOFlNMvmN');
|
||||
'eoV61-RSFUxLrCa88xaSG2:APA91bFmgGVTVH0mhjGhFqrB2_rMf0l0udBUzEUW-V2XlxtnYeDTnpESYRRCI_tMQnbDqQ3PK7pFMzW0-CZolS-pURSkwbwvnbVtV9VHB2UuOrKG3MYpGFsWfmjUdyRIOe30nx-eVkOu');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
color: AppColor.blueColor,
|
||||
),
|
||||
),
|
||||
// IconButton(
|
||||
// onPressed: () {
|
||||
// FirebaseMessagesController()
|
||||
// .sendNotificationToAnyWithoutData(
|
||||
// 'title',
|
||||
// 'body',
|
||||
// // 'e5IXztYGS1W9zFvv-gmMRL:APA91bF7-fFzksCRXIk0Fm7IfQuhHL0df-vnDW8DNNKa3sWea649j3Obc8PhyJo9UOxKBtrvoJxYcbjclFKpvycAuhG0lv_e4hkavy-LZ6SsAu5J5bYrPz6-0BbyLdLUHoBuOFlNMvmN');
|
||||
// 'eoV61-RSFUxLrCa88xaSG2:APA91bFmgGVTVH0mhjGhFqrB2_rMf0l0udBUzEUW-V2XlxtnYeDTnpESYRRCI_tMQnbDqQ3PK7pFMzW0-CZolS-pURSkwbwvnbVtV9VHB2UuOrKG3MYpGFsWfmjUdyRIOe30nx-eVkOu');
|
||||
// },
|
||||
// icon: const Icon(
|
||||
// Icons.add,
|
||||
// color: AppColor.blueColor,
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
||||
@@ -35,12 +35,13 @@ class PointsPageForRider extends StatelessWidget {
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
mapPassengerController.changeWayPointStopsSheet();
|
||||
mapPassengerController.downPoints();
|
||||
},
|
||||
icon: const Icon(Icons.arrow_drop_down_circle_outlined),
|
||||
),
|
||||
GetBuilder<WayPointController>(builder: (wayPointController) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
@@ -55,7 +56,7 @@ class PointsPageForRider extends StatelessWidget {
|
||||
mapPassengerController
|
||||
.getMapPointsForAllMethods();
|
||||
},
|
||||
child: const Text('Get Map'),
|
||||
child: const Text('Get Direction'),
|
||||
)
|
||||
: const SizedBox()
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user