diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a04f9b4..2f6b853 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -81,6 +81,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 232344b..66ce2fd 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -3005,6 +3005,16 @@ class MapPassengerController extends GetxController { 'longitude': double.parse(matchSearch.group(2)!), }; } + + // النمط الرابع: place/lat,lng (غالباً متواجد في الروابط المشتركة من خرائط جوجل) + RegExp regexPlace = RegExp(r'place/(-?\d+\.\d+),(-?\d+\.\d+)'); + var matchPlace = regexPlace.firstMatch(finalUrl); + if (matchPlace != null) { + return { + 'latitude': double.parse(matchPlace.group(1)!), + 'longitude': double.parse(matchPlace.group(2)!), + }; + } } catch (e) { Log.print('Error parsing location link: $e'); } @@ -8184,8 +8194,10 @@ Intaleq Team'''; Log.print( '🚀 Drawing route from Deep Link: $originStr to $destStr'); - // 3. مسح أي مسارات سابقة + // 3. مسح أي مسارات ونقاط توقف سابقة clearPolyline(); + waypoints.clear(); + clearAllMenuWaypoints(); // 4. استدعاء دالة رسم المسار وحساب التكلفة التي برمجتها await getDirectionMap(originStr, destStr); @@ -8210,6 +8222,43 @@ Intaleq Team'''; _deepLinkController.rawDeepLink.value = null; } }); + + // معالجة الرابط إذا كان موجوداً مسبقاً (Cold Start) قبل تفعيل المستمع + if (_deepLinkController.rawDeepLink.value != null && _deepLinkController.rawDeepLink.value!.isNotEmpty) { + String link = _deepLinkController.rawDeepLink.value!; + _deepLinkController.rawDeepLink.value = null; + + // نؤجل التنفيذ قليلاً لضمان تحميل الخريطة + Future.delayed(const Duration(milliseconds: 500), () async { + Log.print('📍 MapPassengerController processing link (Cold Start): $link'); + + Map? coordinates = await extractCoordinatesFromLinkAsync(link); + + if (coordinates != null) { + double destLat = coordinates['latitude']!; + double destLng = coordinates['longitude']!; + myDestination = LatLng(destLat, destLng); + + if (passengerLocation == null || (passengerLocation.latitude == 0 && passengerLocation.longitude == 0)) { + await getLocation(); + } + + if (passengerLocation != null) { + String originStr = '${passengerLocation.latitude},${passengerLocation.longitude}'; + String destStr = '$destLat,$destLng'; + + clearPolyline(); + waypoints.clear(); + clearAllMenuWaypoints(); + await getDirectionMap(originStr, destStr); + + isBottomSheetShown = true; + heightBottomSheetShown = 250; + update(); + } + } + }); + } } @override diff --git a/test_intent.xml b/test_intent.xml new file mode 100644 index 0000000..18817a9 --- /dev/null +++ b/test_intent.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + +