Update: 2026-06-10 18:11:50
This commit is contained in:
@@ -2570,27 +2570,19 @@ class MapDriverController extends GetxController
|
||||
}
|
||||
|
||||
void _startLocationListening() {
|
||||
_locationSubscription?.cancel();
|
||||
_locationSubscription = geo.Geolocator.getPositionStream(
|
||||
locationSettings: const geo.LocationSettings(
|
||||
accuracy: geo.LocationAccuracy.bestForNavigation,
|
||||
distanceFilter: 2,
|
||||
),
|
||||
).listen((geo.Position pos) {
|
||||
_handleLocationUpdate(pos);
|
||||
});
|
||||
// Location stream is now centralized in LocationController to prevent device hanging.
|
||||
// LocationController will call handleLocationUpdateFromCentral directly.
|
||||
}
|
||||
|
||||
/// [Fix C-4] تحديث myLocation في المستمع الأساسي
|
||||
void _handleLocationUpdate(geo.Position pos) {
|
||||
final newLoc = LatLng(pos.latitude, pos.longitude);
|
||||
void handleLocationUpdateFromCentral(LatLng newLoc, double posSpeed, double posHeading) {
|
||||
myLocation = newLoc; // ← [Fix C-4] تحديث الموقع الفوري
|
||||
_oldLoc = smoothedLocation ?? newLoc;
|
||||
_targetLoc = newLoc;
|
||||
|
||||
_oldHeading = smoothedHeading;
|
||||
if (pos.speed > 0.5) {
|
||||
_targetHeading = pos.heading;
|
||||
if (posSpeed > 0.5) {
|
||||
_targetHeading = posHeading;
|
||||
} else {
|
||||
_targetHeading = _oldHeading;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class OrderRequestController extends GetxController
|
||||
|
||||
// --- الخريطة ---
|
||||
Set<Polyline> polylines = {};
|
||||
bool _hasCalculatedFullJourney = false;
|
||||
|
||||
// حالة التطبيق والصوت
|
||||
bool isInBackground = false;
|
||||
@@ -219,6 +220,11 @@ class OrderRequestController extends GetxController
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Future<void> _calculateFullJourney() async {
|
||||
if (_hasCalculatedFullJourney) {
|
||||
if (mapController != null) zoomToFitRide();
|
||||
return;
|
||||
}
|
||||
_hasCalculatedFullJourney = true;
|
||||
// Don't block on mapController being null - we'll draw routes
|
||||
// and markers first, then zoom when controller is ready
|
||||
bool canZoom = mapController != null;
|
||||
@@ -281,7 +287,7 @@ class OrderRequestController extends GetxController
|
||||
totalTripDistance = tripResult['distance_text'];
|
||||
totalTripDuration = tripResult['duration_text'];
|
||||
polylines.add(tripResult['polyline']);
|
||||
|
||||
|
||||
// 🔥 تخزين استجابة السيرفر كاملة (بما فيها الـ points والـ instructions)
|
||||
if (tripResult['raw_response'] != null) {
|
||||
box.write('cached_trip_route', tripResult['raw_response']);
|
||||
|
||||
Reference in New Issue
Block a user