Update: 2026-06-21 02:07:00

This commit is contained in:
Hamza-Ayed
2026-06-21 02:07:00 +03:00
parent af3dcae5b7
commit b2fae9ec66
23 changed files with 1412 additions and 210 deletions

View File

@@ -44,6 +44,15 @@ class AppLink {
}
}
static String get locationSocketUrl {
switch (currentCountry) {
case 'Syria': return 'https://location-syria.siromove.com';
case 'Egypt': return 'https://location-egypt.siromove.com';
case 'Jordan':
default: return 'https://location-jordan.siromove.com'; // You can change the default to location.intaleq.xyz if needed
}
}
static String get mapSaasRoute {
switch (currentCountry) {
case 'Syria': return 'https://map-syria.siromove.com/api/maps/route';

View File

@@ -10,6 +10,7 @@ import 'package:socket_io_client/socket_io_client.dart' as IO;
import 'package:flutter_overlay_window/flutter_overlay_window.dart' as Overlay;
import 'package:get_storage/get_storage.dart';
import '../../constant/box_name.dart';
import '../../constant/links.dart';
import '../firebase/local_notification.dart';
const String notificationChannelId = 'driver_service_channel';
@@ -32,7 +33,7 @@ Future<bool> onStart(ServiceInstance service) async {
if (driverId.isNotEmpty) {
socket = IO.io(
'https://location.intaleq.xyz',
AppLink.locationSocketUrl,
IO.OptionBuilder()
.setTransports(['websocket'])
.disableAutoConnect()

View File

@@ -143,7 +143,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
// إيقاف خدمة الخلفية
BackgroundServiceHelper.stopService();
if (socket == null || (!socket!.connected && !_isInitializingSocket)) {
Log.print("🔄 Initializing Socket on resume...");
initSocket();
@@ -213,7 +213,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
try {
// العودة للـ Websocket حصراً لأنه الوحيد الذي ينجح في فتح القناة
socket = IO.io(
'https://location.intaleq.xyz',
AppLink.locationSocketUrl,
IO.OptionBuilder()
.setTransports(['websocket'])
.setQuery({'driver_id': driverId, 'token': token, 'EIO': '3'})
@@ -360,8 +360,9 @@ class LocationController extends GetxController with WidgetsBindingObserver {
var sortedKeys = rideData.keys
.where((e) => int.tryParse(e) != null)
.map((e) => int.parse(e))
.toList()..sort();
.toList()
..sort();
for (var key in sortedKeys) {
driverList.add(rideData[key.toString()]);
}
@@ -598,7 +599,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
_recordTimer =
Timer.periodic(recDur, (_) => _recordCurrentLocationToBuffer());
_uploadBatchTimer = Timer.periodic(upDur, (_) => _flushBufferToServer());
// محاولة إعادة الاتصال بالسوكيت إذا انقطع كل 3 ثواني
_socketWatchdogTimer = Timer.periodic(const Duration(seconds: 3), (_) {
if (!isSocketConnected && !_isInitializingSocket) {
@@ -636,10 +637,10 @@ class LocationController extends GetxController with WidgetsBindingObserver {
Future<void> _flushBufferToServer() async {
if (_trackBuffer.isEmpty) return;
int itemsToTake = _trackBuffer.length > 100 ? 100 : _trackBuffer.length;
List<Map<String, dynamic>> batch = _trackBuffer.sublist(0, itemsToTake);
final String driverId = (box.read(BoxName.driverID) ?? '').toString();
try {
var res = await CRUD().post(
@@ -686,7 +687,8 @@ class LocationController extends GetxController with WidgetsBindingObserver {
interval: interval,
distanceFilter: _isPowerSavingMode ? 20 : 10,
);
Log.print("🔋 Location settings updated. Power Save: $_isPowerSavingMode");
Log.print(
"🔋 Location settings updated. Power Save: $_isPowerSavingMode");
} catch (e) {
Log.print("❌ Failed to update location settings: $e");
}
@@ -697,7 +699,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
final dist =
(_lastSqlLoc == null) ? 999.0 : _calculateDistance(_lastSqlLoc!, pos);
if (dist < 15.0) return;
final accel = _calcAcceleration(currentSpeed, now) ?? 0.0;
_lastSqlLoc = pos;
@@ -719,7 +721,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
if (_behaviorBuffer.isEmpty) return;
List<Map<String, dynamic>> batch = List.from(_behaviorBuffer);
_behaviorBuffer.clear();
Future.microtask(() async {
try {
for (var data in batch) {
@@ -799,7 +801,9 @@ class LocationController extends GetxController with WidgetsBindingObserver {
try {
if (await _ensureServiceAndPermission()) {
final locData = await location.getLocation();
if (locData != null && locData.latitude != null && locData.longitude != null) {
if (locData != null &&
locData.latitude != null &&
locData.longitude != null) {
myLocation = LatLng(locData.latitude!, locData.longitude!);
heading = locData.heading ?? 0.0;
speed = locData.speed ?? 0.0;
@@ -814,7 +818,8 @@ class LocationController extends GetxController with WidgetsBindingObserver {
final homeCtrl = Get.find<HomeCaptainController>();
if (homeCtrl.mapHomeCaptainController != null &&
homeCtrl.isMapReadyForCommands) {
Log.print("📍 [LocationController] Animating camera to single location update");
Log.print(
"📍 [LocationController] Animating camera to single location update");
homeCtrl.mapHomeCaptainController?.animateCamera(
CameraUpdate.newLatLngZoom(myLocation, 17.5),
);

View File

@@ -97,8 +97,8 @@ class HomeCaptainController extends GetxController {
// دالة جلب البيانات ورسم الخريطة
Future<void> fetchAndDrawHeatmap() async {
print("🚀 [Heatmap] Fetching live data...");
// استخدم الرابط المباشر لملف JSON لسرعة قصوى
final String jsonUrl = "${AppLink.ride}/rides/heatmap_live.json";
// استخدم الرابط المباشر للملف الديناميكي الجديد
final String jsonUrl = "${AppLink.ride}/heatmap/heatmap_live.php";
try {
// نستخدم timestamp لمنع الكاش من الموبايل نفسه

View File

@@ -92,10 +92,20 @@ class OrderRequestController extends GetxController
_checkOverlay();
// 🔥 تهيئة البيانات هي الخطوة الأولى والأهم
_initializeData();
_parseExtraData();
// 🚫 Self-ride prevention: Check if passenger device fingerprint matches driver's fingerprint
final String passengerFp = _safeGet(6);
final String myFp = box.read(BoxName.deviceFingerprint)?.toString() ?? '';
if (passengerFp.isNotEmpty && passengerFp == myFp) {
print("🚫 Self-ride detected on same device. Auto-dismissing request.");
NotificationController().cancelOrderNotification();
_stopAudio();
Get.back();
return;
}
// 1. تجهيز أيقونة السائق
await _prepareDriverIcon();
@@ -641,13 +651,14 @@ class OrderRequestController extends GetxController
_stopAudio();
try {
// 1. إرسال الطلب
var res = await CRUD()
.post(link: "${AppLink.ride}/rides/acceptRide.php", payload: {
'id': _safeGet(16),
'rideTimeStart': DateTime.now().toString(),
'status': 'Apply',
'passengerToken': _safeGet(9),
'passengerFingerprint': _safeGet(6),
'passenger_id': _safeGet(7),
'driver_id': box.read(BoxName.driverID),
});

View File

@@ -588,6 +588,17 @@ class PassengerInfoWindow extends StatelessWidget {
'message_content': body,
},
);
// Log the chat message interaction under driver_ride_scam
CRUD().post(
link: AppLink.addDriverScam,
payload: {
'driverID': box.read(BoxName.driverID).toString(),
'passengerID': controller.passengerId.toString(),
'rideID': controller.rideId.toString(),
'isDriverCallPassenger': 'false',
},
);
} catch (e) {
// Ignore or log error
}