This commit is contained in:
Hamza-Ayed
2024-01-19 15:17:18 +03:00
parent 7af7e71b30
commit ec7f2de651
7 changed files with 84 additions and 116 deletions

View File

@@ -27,6 +27,7 @@ class HomeCaptainController extends GetxController {
String totalMoneyInSEFER = '0';
String totalDurationToday = '0';
Timer? timer;
late LatLng myLocation;
String totalPoints = '0';
String countRefuse = '0';
bool mapType = false;
@@ -146,7 +147,7 @@ class HomeCaptainController extends GetxController {
mapHomeCaptaiController = controller;
controller.getVisibleRegion();
controller.animateCamera(
CameraUpdate.newLatLng(locationController.myLocation),
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
);
update();
}
@@ -181,6 +182,8 @@ class HomeCaptainController extends GetxController {
@override
void onInit() async {
await addToken();
// await Get.find<LocationController>().getLocation();
onButtonSelected();
getPaymentToday();
getAllPayment();
@@ -188,6 +191,7 @@ class HomeCaptainController extends GetxController {
onMapCreated(mapHomeCaptaiController!);
getRefusedOrderByCaptain();
totalPoints = Get.find<CaptainWalletController>().totalPoints;
// LocationController().getLocation();
super.onInit();
}

View File

@@ -73,13 +73,13 @@ class MapDriverController extends GetxController {
String? mapAPIKEY;
final zones = <Zone>[];
void onMapCreated(GoogleMapController controller) {
LocationController locationController = Get.find<LocationController>();
myLocation = locationController.myLocation;
void onMapCreated(GoogleMapController controller) async {
myLocation = Get.find<LocationController>().location as LatLng;
myLocation = myLocation;
mapController = controller;
controller.getVisibleRegion();
controller.animateCamera(
CameraUpdate.newLatLngZoom(myLocation, 17),
CameraUpdate.newLatLng(myLocation),
);
update();
@@ -442,6 +442,7 @@ class MapDriverController extends GetxController {
rideId = Get.arguments['rideId'];
durationOfRideValue = Get.arguments['durationOfRideValue'];
paymentAmount = Get.arguments['paymentAmount'];
paymentMethod = Get.arguments['paymentMethod'];
isHaveSteps = Get.arguments['isHaveSteps'];
step0 = Get.arguments['step0'];
step1 = Get.arguments['step1'];

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:math' show cos;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
@@ -208,6 +209,29 @@ class MapPassengerController extends GetxController {
update();
}
void getMapPointsForAllMethods() async {
print(placesCoordinate.toString());
clearPolyline();
isWayPointStopsSheetUtilGetMap = false;
durationToRide = 0;
wayPointSheetHeight = 0;
for (var i = 0; i < Get.find<WayPointController>().wayPoints.length; i++) {
if (placesCoordinate[i + 1].toString() != '') {
await getMapPoints(
placesCoordinate[i].toString(),
placesCoordinate[i + 1].toString(),
i,
);
}
}
// isWayPointStopsSheet = false;
changeWayPointStopsSheet();
bottomSheet();
showBottomSheet1();
update();
}
void convertHintTextStartNewPlaces(int index) {
if (placesStart.isEmpty) {
hintTextStartPoint = 'Search for your Start point'.tr;
@@ -439,19 +463,27 @@ class MapPassengerController extends GetxController {
}
void getBeginRideFromDriver() async {
var res = await CRUD()
.get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId});
var decode = jsonDecode(res);
try {
var res = await CRUD()
.get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId});
if (res == 'failure') {
print(res);
}
var decode = jsonDecode(res);
if (decode['data']['status'] == 'Begin') {
timeToPassengerFromDriverAfterApplied = 0;
remainingTime = 0;
remainingTimeToPassengerFromDriverAfterApplied = 0;
// isCancelRidePageShown = true;
rideIsBeginPassengerTimer();
// print('rideTimerBegin: $rideTimerBegin');
rideTimerBegin = true;
update();
if (decode['data']['status'] == 'Begin') {
timeToPassengerFromDriverAfterApplied = 0;
remainingTime = 0;
remainingTimeToPassengerFromDriverAfterApplied = 0;
// isCancelRidePageShown = true;
rideIsBeginPassengerTimer();
// print('rideTimerBegin: $rideTimerBegin');
rideTimerBegin = true;
update();
}
} catch (e) {
print('Error: $e');
// Handle the error or perform any necessary actions
}
}
@@ -645,14 +677,6 @@ class MapPassengerController extends GetxController {
cancelRideAfterRejectFromAll();
}
} else if (decod['data'].toString() == 'Cancel') {
remainingTime = 0;
shouldFetch = false;
rideConfirm = false;
FirebaseMessagesController().sendNotificationToDriverMAP(
'Trip Canceled'.tr, '', driverToken, []);
update();
} else {
delayAndFetchRideStatus(
rideId); // Repeat the delay and fetch operation
@@ -824,7 +848,6 @@ class MapPassengerController extends GetxController {
"status": 'Cancel'
});
rideConfirm = false;
totalStepDurations = 0;
shouldFetch = false;
isPassengerChosen = false;
isCashConfirmPageShown = false;
@@ -853,7 +876,6 @@ class MapPassengerController extends GetxController {
isCashSelectedBeforeConfirmRide = false;
isPickerShown = false;
totalStepDurations = 0;
totalStepDurations = 0;
timeToPassengerFromDriverAfterApplied = 0;
update();
} else {
@@ -872,9 +894,8 @@ class MapPassengerController extends GetxController {
isCashSelectedBeforeConfirmRide = false;
timeToPassengerFromDriverAfterApplied = 0;
totalStepDurations = 0;
totalStepDurations = 0;
changeCancelRidePageShow();
// clearPolylineAll();
clearPolyline();
remainingTime = 0;
update();
@@ -922,9 +943,10 @@ class MapPassengerController extends GetxController {
}
void changeWayPointStopsSheet() {
int waypointsLength = Get.find<WayPointController>().wayPoints.length;
print('isWayPointStopsSheet $waypointsLength');
if (waypointsLength > 2) {
// int waypointsLength = Get.find<WayPointController>().wayPoints.length;
print('isWayPointStopsSheet $wayPointIndex');
if (wayPointIndex > 1) {
isWayPointStopsSheet = true;
isWayPointStopsSheetUtilGetMap = true;
}
@@ -1041,50 +1063,6 @@ 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()}';
// var response = await CRUD().getGoogleApi(link: url, payload: {});
// 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()}';
// var response = await CRUD().getGoogleApi(link: url, payload: {});
// 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()}';
// var response = await CRUD().getGoogleApi(link: url, payload: {});
// 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()}';
// var response = await CRUD().getGoogleApi(link: url, payload: {});
// wayPoint4 = response['results'];
// print(wayPoint4);
// update();
// }
LatLng fromString(String location) {
List<String> parts = location.split(',');
double lat = double.parse(parts[0]);
@@ -1128,11 +1106,14 @@ class MapPassengerController extends GetxController {
});
}
void addCustomStartIcon() {
ImageConfiguration config = ImageConfiguration(
size: Size(Get.width * .6, Get.height * .6),
void addCustomStartIcon() async {
// Create the marker with the resized image
ImageConfiguration config = const ImageConfiguration(
size: Size(20, 20),
);
BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png')
BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png',
mipmaps: false)
.then((value) {
startIcon = value;
update();