25-10-2/1

This commit is contained in:
Hamza-Ayed
2025-10-02 01:20:16 +03:00
parent 7595be8067
commit c48627a175
342 changed files with 15825 additions and 14862 deletions

View File

@@ -174,9 +174,9 @@ class MapPassengerController extends GetxController {
bool rideConfirm = false;
bool isMarkersShown = false;
bool isMainBottomMenuMap = true;
late Timer markerReloadingTimer2;
late Timer markerReloadingTimer1;
late int durationToPassenger = 0;
Timer? markerReloadingTimer2 = Timer(Duration.zero, () {});
Timer? markerReloadingTimer1 = Timer(Duration.zero, () {});
int durationToPassenger = 0;
bool isWayPointSheet = false;
bool isWayPointStopsSheet = false;
bool isWayPointStopsSheetUtilGetMap = false;
@@ -192,7 +192,7 @@ class MapPassengerController extends GetxController {
var dataCarsLocationByPassenger;
var datadriverCarsLocationToPassengerAfterApplied;
CarLocation? nearestCar;
late Timer markerReloadingTimer;
late Timer? markerReloadingTimer = Timer(Duration.zero, () {});
bool shouldFetch = true; // Flag to determine if fetch should be executed
int selectedPassengerCount = 1;
double progress = 0;
@@ -245,7 +245,7 @@ class MapPassengerController extends GetxController {
late String driverToken = '';
int carsOrder = 0;
int wayPointIndex = 0;
late double kazan;
late double kazan = 8;
String? mapAPIKEY;
late double totalME = 0;
late double tax = 0;
@@ -273,7 +273,10 @@ class MapPassengerController extends GetxController {
int minutes = 0;
// --- إضافة جديدة: للوصول إلى وحدة التحكم بالروابط ---
final DeepLinkController _deepLinkController = Get.find();
final DeepLinkController _deepLinkController =
Get.isRegistered<DeepLinkController>()
? Get.find<DeepLinkController>()
: Get.put(DeepLinkController());
// ------------------------------------------------
void onChangedPassengerCount(int newValue) {
@@ -2640,6 +2643,15 @@ class MapPassengerController extends GetxController {
'northeastLon': bounds.northeast.longitude.toString(),
});
break;
case 'Electric':
res = await CRUD()
.get(link: AppLink.getCarsLocationByPassengerElectric, payload: {
'southwestLat': bounds.southwest.latitude.toString(),
'southwestLon': bounds.southwest.longitude.toString(),
'northeastLat': bounds.northeast.latitude.toString(),
'northeastLon': bounds.northeast.longitude.toString(),
});
break;
case 'Pink Bike':
res = await CRUD()
.get(link: AppLink.getCarsLocationByPassengerPinkBike, payload: {
@@ -3198,9 +3210,9 @@ class MapPassengerController extends GetxController {
// 1. إلغاء المؤقتات الفردية
// Using ?.cancel() is safe even if the timer is null
markerReloadingTimer.cancel();
markerReloadingTimer1.cancel();
markerReloadingTimer2.cancel();
markerReloadingTimer!.cancel();
markerReloadingTimer1!.cancel();
markerReloadingTimer2!.cancel();
timerToPassengerFromDriverAfterApplied?.cancel();
_timer?.cancel();
@@ -3302,11 +3314,6 @@ class MapPassengerController extends GetxController {
}
Future cancelRide() async {
// if (rideConfirm == true ||
// statusRide == 'Apply' ||
// statusRide == 'Applied' ||
// statusRide == 'wait' ||
// statusRide == 'waiting') {
clearPlacesDestination();
clearPolyline();
// clearPolylineAll();
@@ -3315,7 +3322,7 @@ class MapPassengerController extends GetxController {
if (rideId != 'yet') {
Log.print('cancelRide: 1');
await firebaseMessagesController.sendNotificationToDriverMAP(
'Cancel Trip'.tr,
'Cancel Trip',
'Trip Cancelled'.tr,
driverToken.toString(),
[],
@@ -3336,31 +3343,8 @@ class MapPassengerController extends GetxController {
"status": 'Cancel'
}),
]);
if (AppLink.endPoint != AppLink.IntaleqCairoServer) {
CRUD().post(
link: "${AppLink.endPoint}/ride/driver_order/update.php",
payload: {
"order_id": rideId.toString(), // Convert to String
"status": 'Cancel'
});
CRUD()
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
"id": rideId.toString(), // Convert to String
"status": 'Cancel'
});
CRUD().post(
link:
"${AppLink.endPoint}/ride/notificationCaptain/updateWaitingTrip.php",
payload: {
"id": rideId.toString(), // Convert to String
"status": 'Cancel'
});
}
print('Cancel');
// }
}
Future.delayed(const Duration(seconds: 1));
// Future.delayed(const Duration(seconds: 1));
Get.offAll(() => const MapPagePassenger());
}
@@ -4560,6 +4544,7 @@ class MapPassengerController extends GetxController {
url += '&waypoints=$formattedWaypoints';
}
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
box.remove(BoxName.tripData);
box.write(BoxName.tripData, response);
@@ -4642,10 +4627,17 @@ class MapPassengerController extends GetxController {
if (polyLines.isNotEmpty) {
clearPolyline();
} else {
// الآن بإمكانك قراءة القيمة من الـBox في أي مكان:
bool lowEndMode = box.read(BoxName.lowEndMode) ?? true;
// الآن نقرأ القيمة ونحدد عدد النقاط بناءً عليها
bool lowEndMode = box.read(BoxName.lowEndMode) ??
false; // الأفضل أن يكون الافتراضي هو الجودة العالية
// نمرر عدد النقاط المناسب هنا
animatePolylineLayered(
polylineCoordinates,
maxPoints:
lowEndMode ? 30 : 150, // 30 نقطة لوضع الأداء، 150 للوضع العادي
);
animatePolylineLayered(polylineCoordinates);
rideConfirm = false;
isMarkersShown = true;
@@ -4680,12 +4672,13 @@ class MapPassengerController extends GetxController {
// 2) رسم متدرّج بطبقات متراكبة (بدون حذف)، برونزي ↔ أخضر، مع zIndex وعرض مختلف
Future<void> animatePolylineLayered(List<LatLng> coordinates,
{int layersCount = 8, int stepDelayMs = 10}) async {
{int layersCount = 1, int stepDelayMs = 10, int maxPoints = 150}) async {
// امسح أي طبقات قديمة فقط الخاصة بالطريق
polyLines.removeWhere((p) => p.polylineId.value.startsWith('route_layer_'));
update();
final List<LatLng> coords = _downsampleEven(coordinates, maxPoints: 20);
final List<LatLng> coords =
_downsampleEven(coordinates, maxPoints: maxPoints);
if (coords.length < 2) return;
// ألوان مع شفافية خفيفة للتمييز
@@ -4816,6 +4809,7 @@ class MapPassengerController extends GetxController {
var url =
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destinationSteps&origin=$originSteps&key=${AK.mapAPIKEY}');
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
// isLoading = false;
@@ -5300,30 +5294,23 @@ class MapPassengerController extends GetxController {
changeBottomSheetShown();
}
addToken() async {
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
// addToken() async {
// String fingerPrint = await DeviceHelper.getDeviceFingerprint();
await CRUD()
.post(link: "${AppLink.server}/ride/firebase/add.php", payload: {
'token': (box.read(BoxName.tokenFCM.toString())),
'passengerID': box.read(BoxName.passengerID).toString(),
"fingerPrint": fingerPrint
});
CRUD().postWallet(
link: "${AppLink.seferPaymentServer}/ride/firebase/add.php",
payload: {
'token': (box.read(BoxName.tokenFCM.toString())),
'passengerID': box.read(BoxName.passengerID).toString(),
"fingerPrint": fingerPrint
});
// CRUD().post(
// link: "${AppLink.IntaleqGizaServer}/ride/firebase/add.php",
// payload: {
// 'token': (box.read(BoxName.tokenFCM.toString())),
// 'passengerID': box.read(BoxName.passengerID).toString(),
// "fingerPrint": fingerPrint
// });
}
// await CRUD()
// .post(link: "${AppLink.server}/ride/firebase/add.php", payload: {
// 'token': (box.read(BoxName.tokenFCM.toString())),
// 'passengerID': box.read(BoxName.passengerID).toString(),
// "fingerPrint": fingerPrint
// });
// CRUD().postWallet(
// link: "${AppLink.seferPaymentServer}/ride/firebase/add.php",
// payload: {
// 'token': (box.read(BoxName.tokenFCM.toString())),
// 'passengerID': box.read(BoxName.passengerID).toString(),
// "fingerPrint": fingerPrint
// });
// }
List<LatLng> polylineCoordinate = [];
String? cardNumber;
@@ -5794,13 +5781,13 @@ class MapPassengerController extends GetxController {
void onInit() async {
super.onInit();
// // --- إضافة جديدة: تهيئة وحدة التحكم في الروابط العميقة ---
// Get.put(DeepLinkController(), permanent: true);
Get.put(DeepLinkController(), permanent: true);
// // ----------------------------------------------------
// مرحلة 0: الضروري جداً لعرض الخريطة سريعاً
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
// mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
await initilizeGetStorage(); // إعداد سريع
await _initMinimalIcons(); // start/end فقط
await addToken(); // لو لازم للمصادقة
// await addToken(); // لو لازم للمصادقة
_listenForDeepLink();
await getLocation(); // لتحديد الكاميرا
box.write(BoxName.carType, 'yet');