Update: 2026-07-10 03:04:06

This commit is contained in:
Hamza-Ayed
2026-07-10 03:04:06 +03:00
parent 2ff7450d0b
commit b18fd027b6
22 changed files with 2661 additions and 96 deletions
@@ -1889,7 +1889,7 @@ class RideLifecycleController extends GetxController {
var digest = md5.convert(bytes);
String token = digest.toString();
return "https://intaleqapp.com/track/index.php?id=$cleanRideId&token=$token";
return "https://siromove.com/track/index.php?id=$cleanRideId&token=$token";
}
calcualateDistsanceInMetet(LatLng prev, current) async {
@@ -2205,52 +2205,77 @@ class RideLifecycleController extends GetxController {
Future<void> calculateDriverToPassengerRoute(
LatLng driverPos, LatLng passengerPos,
{bool isBeginPhase = false}) async {
if (mapController == null) {
Log.print('⚠️ mapController is null, cannot calculate route via intaleq_maps');
Log.print(
'⚠️ mapController is null, cannot calculate route via intaleq_maps');
return;
}
Log.print('📍 Calculating Driver Route via IntaleqMapController...');
try {
final responseData = await mapController!.getDirections(driverPos, passengerPos);
final responseData =
await mapController!.getDirections(driverPos, passengerPos);
var routeData = responseData['routes'] != null
? responseData['routes'][0]
: responseData;
double durationSecondsRaw = (routeData['trafficAwareDuration'] ?? routeData['duration'] as num).toDouble();
int finalDurationSeconds =
(durationSecondsRaw * kDurationScalar).toInt();
double distanceMeters = (routeData['distance'] as num).toDouble();
double durationSecondsRaw =
(routeData['trafficAwareDuration'] ?? routeData['duration'] as num)
.toDouble();
int finalDurationSeconds = (durationSecondsRaw * kDurationScalar).toInt();
double distanceMeters = (routeData['distance'] as num).toDouble();
updateDriverRouteMetrics(
etaSeconds: finalDurationSeconds,
distanceMeters: distanceMeters,
);
_currentDriverRouteDistanceMeters = distanceMeters;
_currentDriverRouteDurationSeconds = finalDurationSeconds;
updateDriverRouteMetrics(
etaSeconds: finalDurationSeconds,
distanceMeters: distanceMeters,
);
_currentDriverRouteDistanceMeters = distanceMeters;
_currentDriverRouteDurationSeconds = finalDurationSeconds;
int minutes = (finalDurationSeconds / 60).floor();
int seconds = finalDurationSeconds % 60;
stringRemainingTimeToPassenger =
'$minutes:${seconds.toString().padLeft(2, '0')}';
int minutes = (finalDurationSeconds / 60).floor();
int seconds = finalDurationSeconds % 60;
stringRemainingTimeToPassenger =
'$minutes:${seconds.toString().padLeft(2, '0')}';
Log.print(
'✅ Driver Route Info: $minutes min, ${distanceMeters.toInt()} m');
Log.print(
'✅ Driver Route Info: $minutes min, ${distanceMeters.toInt()} m');
String pointsString =
routeData['points'] ?? routeData['geometry'] ?? "";
if (pointsString.isNotEmpty) {
List<LatLng> decodedPoints =
await compute(decodePolylineIsolate, pointsString);
_currentDriverRoutePoints = decodedPoints;
final double decodedDistance = _pathDistanceMeters(decodedPoints);
if (decodedDistance > 0) {
_currentDriverRouteDistanceMeters = decodedDistance;
}
// مسح كل السلمات السابقة (الخط المستمر والمتقطع على حد سواء)
String pointsString = routeData['points'] ?? routeData['geometry'] ?? "";
if (pointsString.isNotEmpty) {
List<LatLng> decodedPoints =
await compute(decodePolylineIsolate, pointsString);
_currentDriverRoutePoints = decodedPoints;
final double decodedDistance = _pathDistanceMeters(decodedPoints);
if (decodedDistance > 0) {
_currentDriverRouteDistanceMeters = decodedDistance;
}
// مسح كل السلمات السابقة (الخط المستمر والمتقطع على حد سواء)
polyLines = polyLines
.where((p) =>
!p.polylineId.value.startsWith('driver_route') &&
p.polylineId.value != 'main_route' &&
!p.polylineId.value.startsWith('route_primary') &&
p.polylineId.value != 'route_direct')
.toSet();
if (isBeginPhase) {
// حالة Begin: لا نرسم مسار السائق القديم إطلاقاً لأنه وصل والآن الرحلة ستبدأ
polyLines = polyLines
.where((p) => !p.polylineId.value.startsWith('driver_route'))
.toSet();
polyLines = {
...polyLines,
Polyline(
polylineId: const PolylineId('main_route'),
points: decodedPoints,
color: const Color(0xFF2196F3),
width: 6,
)
};
} else {
// مسح السلمات القديمة أولاً
polyLines = polyLines
.where((p) =>
!p.polylineId.value.startsWith('driver_route') &&
@@ -2258,46 +2283,22 @@ class RideLifecycleController extends GetxController {
!p.polylineId.value.startsWith('route_primary') &&
p.polylineId.value != 'route_direct')
.toSet();
if (isBeginPhase) {
// حالة Begin: لا نرسم مسار السائق القديم إطلاقاً لأنه وصل والآن الرحلة ستبدأ
polyLines = polyLines
.where((p) => !p.polylineId.value.startsWith('driver_route'))
.toSet();
polyLines = {
...polyLines,
Polyline(
polylineId: const PolylineId('main_route'),
points: decodedPoints,
color: const Color(0xFF2196F3),
width: 6,
)
};
} else {
// مسح السلمات القديمة أولاً
polyLines = polyLines
.where((p) =>
!p.polylineId.value.startsWith('driver_route') &&
p.polylineId.value != 'main_route' &&
!p.polylineId.value.startsWith('route_primary') &&
p.polylineId.value != 'route_direct')
.toSet();
// حالة Apply/Arrived: خط متصل صلب بدل المتقطع
polyLines = {
...polyLines,
Polyline(
polylineId: const PolylineId('driver_route_solid'),
points: decodedPoints,
color: Colors.amber, // مسار القدوم باللون الأصفر
width: 5,
)
};
}
// حالة Apply/Arrived: خط متصل صلب بدل المتقطع
polyLines = {
...polyLines,
Polyline(
polylineId: const PolylineId('driver_route_solid'),
points: decodedPoints,
color: Colors.amber, // مسار القدوم باللون الأصفر
width: 5,
)
};
}
}
mapEngine.fitCameraToPoints(driverPos, passengerPos);
_updatePassengerWalkLine();
update();
mapEngine.fitCameraToPoints(driverPos, passengerPos);
_updatePassengerWalkLine();
update();
} catch (e) {
Log.print('❌ Error calculating driver route: $e');
}
@@ -3521,8 +3522,9 @@ class RideLifecycleController extends GetxController {
// 🔥 [Fix Race] كل طلب جديد (attemptCount == 0) يفتح "جيلاً" جديداً؛
// إعادة المحاولات (retries) تتبع نفس الجيل. أي استجابة تصل بعد أن بدأ
// جيل أحدث (تبديل وجهة سريع) تُهمَل ولا تكتب فوق الحالة الحالية.
final int myGeneration =
attemptCount == 0 ? (++_routeRequestGeneration) : (gen ?? _routeRequestGeneration);
final int myGeneration = attemptCount == 0
? (++_routeRequestGeneration)
: (gen ?? _routeRequestGeneration);
if (attemptCount == 0) {
isDrawingRoute = true;
@@ -3616,8 +3618,8 @@ class RideLifecycleController extends GetxController {
if (attemptCount < 2) {
Log.print("🔄 Retrying request (Attempt ${attemptCount + 2})...");
await Future.delayed(const Duration(seconds: 1));
await getDirectionMap(origin, destination, waypoints,
attemptCount + 1, myGeneration);
await getDirectionMap(
origin, destination, waypoints, attemptCount + 1, myGeneration);
return;
} else {
Log.print("❌ All retries failed. Calculating Route is impossible.");
@@ -3798,8 +3800,9 @@ class RideLifecycleController extends GetxController {
}
}
Future<void> _retryProcess(String origin, String dest, List<String> waypoints,
int currentAttempt, [int? gen]) async {
Future<void> _retryProcess(
String origin, String dest, List<String> waypoints, int currentAttempt,
[int? gen]) async {
Log.print(
"🔄 Exception or Error caught. Retrying in 1s... (Attempt ${currentAttempt + 1})");
await Future.delayed(const Duration(seconds: 1));
@@ -4481,7 +4484,7 @@ class RideLifecycleController extends GetxController {
required double dashLengthMeters,
required double gapLengthMeters,
required Color color,
required int width,
required double width,
required String idPrefix,
}) {
final Set<Polyline> result = {};