إضافة الهوية الجديدة Tripz
This commit is contained in:
@@ -9,7 +9,7 @@ import 'package:location/location.dart';
|
||||
import 'package:battery_plus/battery_plus.dart';
|
||||
import 'package:permission_handler/permission_handler.dart' as ph;
|
||||
import 'package:socket_io_client/socket_io_client.dart' as IO;
|
||||
import 'package:siro_driver/constant/table_names.dart';
|
||||
import 'package:tripz_driver/constant/table_names.dart';
|
||||
import 'package:trip_overlay_plugin/trip_overlay_plugin.dart';
|
||||
import '../../constant/country_polygons.dart';
|
||||
import '../../constant/box_name.dart';
|
||||
@@ -62,7 +62,8 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
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)');
|
||||
Log.print(
|
||||
'🚌 Bus mode ${enabled ? "enabled" : "disabled"} (trip: $tripId, route: $routeId)');
|
||||
}
|
||||
|
||||
StreamSubscription<LocationData>? _locSub;
|
||||
@@ -226,7 +227,8 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
socket = null;
|
||||
}
|
||||
|
||||
print("🟡 [LocationController] Initializing NEW Socket for Driver: $driverId");
|
||||
print(
|
||||
"🟡 [LocationController] Initializing NEW Socket for Driver: $driverId");
|
||||
|
||||
try {
|
||||
// العودة للـ Websocket حصراً لأنه الوحيد الذي ينجح في فتح القناة
|
||||
@@ -276,12 +278,12 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
|
||||
if (sid != null || eid != null) {
|
||||
isSocketConnected = true;
|
||||
|
||||
|
||||
if (myLocation.latitude != 0) {
|
||||
print("🚀 Sending initial location to socket after connect...");
|
||||
emitLocationToSocket(myLocation, heading, speed);
|
||||
}
|
||||
|
||||
|
||||
_startHeartbeat();
|
||||
|
||||
// 🆕 طلب أي رحلات انتظار فاتتنا أثناء انقطاع الاتصال
|
||||
@@ -460,7 +462,8 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
void _startHeartbeat() {
|
||||
_socketHeartbeat?.cancel();
|
||||
_socketHeartbeat = Timer.periodic(const Duration(seconds: 25), (timer) {
|
||||
if (socket == null || !isSocketConnected || myLocation.latitude == 0) return;
|
||||
if (socket == null || !isSocketConnected || myLocation.latitude == 0)
|
||||
return;
|
||||
|
||||
if (isBusMode) {
|
||||
emitBusLocationToSocket(myLocation, heading, speed);
|
||||
@@ -512,7 +515,8 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
// 🚌 مواصلاتي — بثّ موقع الباص (بديل عن update_location أثناء وضع الباص)
|
||||
void emitBusLocationToSocket(LatLng pos, double head, double spd, {int? currentStopSeq}) {
|
||||
void emitBusLocationToSocket(LatLng pos, double head, double spd,
|
||||
{int? currentStopSeq}) {
|
||||
if (activeBusTripId == null || activeBusRouteId == null) return;
|
||||
if (socket == null || !socket!.connected) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user