Update: 2026-07-12 18:53:59

This commit is contained in:
Hamza-Ayed
2026-07-12 18:53:59 +03:00
parent 8cd4a4b57e
commit 653d73422f
54 changed files with 2078 additions and 436 deletions
@@ -22,6 +22,7 @@ import '../home/payment/captain_wallet_controller.dart';
import '../home/navigation/navigation_controller.dart';
import 'background_service.dart';
import 'crud.dart';
import '../transit/transit_driver_controller.dart';
class LocationController extends GetxController with WidgetsBindingObserver {
// ===================================================================
@@ -56,6 +57,10 @@ class LocationController extends GetxController with WidgetsBindingObserver {
isBusMode = enabled;
activeBusTripId = enabled ? tripId : null;
activeBusRouteId = enabled ? routeId : null;
// نحفظ الحالة في GetStorage ليقرأها background_service في الـ isolate المستقل
box.write(BoxName.isBusMode, enabled);
box.write(BoxName.busModeTripId, enabled ? tripId : null);
box.write(BoxName.busModeRouteId, enabled ? routeId : null);
Log.print('🚌 Bus mode ${enabled ? "enabled" : "disabled"} (trip: $tripId, route: $routeId)');
}
@@ -572,6 +577,10 @@ class LocationController extends GetxController with WidgetsBindingObserver {
// 🚌 وضع الباص: بثّ موقع الباص فقط — لا يدخل حوض الرحلات العادي
if (isBusMode) {
emitBusLocationToSocket(pos, heading, speed);
// كشف الوصول للمحطات (جيوفينس)
if (Get.isRegistered<TransitDriverController>()) {
Get.find<TransitDriverController>().onLocationUpdate(pos);
}
await _saveBehaviorIfMoved(pos, now, currentSpeed: speed);
return;
}