Update codebase

This commit is contained in:
Hamza-Ayed
2026-08-09 16:56:13 +03:00
parent 95e2e4f35d
commit b64debaa88
1058 changed files with 164327 additions and 113928 deletions
@@ -10,7 +10,7 @@ import '../print.dart';
/// هذه الخدمة مشابهة لـ [IosLiveActivityService] ولكن لمنصة Android
class AndroidLiveUpdateService {
static const MethodChannel _channel =
MethodChannel('tripz/android_live_update');
MethodChannel('siro/android_live_update');
static bool _isSupported = false;
static bool _isActive = false;
@@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart';
import 'package:native_geofence/native_geofence.dart';
import 'package:http/http.dart' as http;
import 'package:get_storage/get_storage.dart';
import 'package:tripz_rider/constant/links.dart';
import 'package:siro_rider/constant/links.dart';
// Top-level function for background execution
@pragma('vm:entry-point')
@@ -33,7 +33,7 @@ Future<void> geofenceBackgroundCallback(GeofenceCallbackParams params) async {
}
}
class TripzGeofencingService {
class SiroGeofencingService {
static final _storage = GetStorage();
static Future<void> initAndStart() async {
@@ -113,8 +113,7 @@ class OfflineMapService {
for (var region in regions) {
await deleteOfflineRegion(region.id);
}
Log.print(
"✅ Map cache cleared successfully. ${regions.length} regions removed.");
Log.print("✅ Map cache cleared successfully. ${regions.length} regions removed.");
} catch (e) {
Log.print("⚠️ Failed to clear map cache: $e");
}
+1 -1
View File
@@ -6,7 +6,7 @@ import '../print.dart';
/// خدمة التحكم بوضع النافذة العائمة (Picture-in-Picture) على أندرويد.
/// تُستدعى عند بدء الرحلة لتفعيل PiP تلقائياً عند خروج المستخدم من التطبيق.
class PipService {
static const MethodChannel _channel = MethodChannel('tripz/pip');
static const MethodChannel _channel = MethodChannel('siro/pip');
/// هل وضع PiP مدعوم على هذا الجهاز؟
static Future<bool> isPipSupported() async {
@@ -22,7 +22,7 @@ class RideLiveNotification {
final android = AndroidNotificationDetails(
'live_ride_tracking', // channel id
'Ride Tracking', // channel name
channelDescription: 'Live updates for the current Tripz ride',
channelDescription: 'Live updates for the current Siro ride',
importance: Importance.max,
priority: Priority.high,
ongoing: true, // إشعار ثابت
@@ -2,7 +2,7 @@ import 'dart:io';
import 'package:flutter/services.dart';
class RideTrackingNative {
static const MethodChannel _channel = MethodChannel('tripz/ride_tracking');
static const MethodChannel _channel = MethodChannel('siro/ride_tracking');
static Future<void> updateRideTracking({
required String driverName,
@@ -1,11 +1,11 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:tripz_rider/print.dart';
import 'package:siro_rider/print.dart';
class SignalingService {
WebSocket? _socket;
final String _url = "wss://calls.tripzapp.com/ws";
final String _url = "wss://calls.intaleqapp.com/ws";
// Callbacks
Function(List<dynamic> iceServers)? onConnected;
@@ -0,0 +1,79 @@
// turn_credentials_service.dart — جلب بيانات اعتماد TURN المؤقتة وتخزينها
//
// خادم الإشارات (Node) يُعيد STUN فقط، وSTUN وحده لا يكفي حين يكون الطرفان
// خلف CGNAT — وهي الحالة الغالبة لسائق وزبون على بيانات الجوال. نجلب TURN
// من الباك إند ونضمّه إلى قائمة ICE قبل إنشاء الاتصال.
//
// البيانات مؤقتة (HMAC بمهلة) لا كلمة مرور ثابتة داخل التطبيق، ونُخزّنها
// محلياً حتى قرب انتهائها فلا نُثقل بنداء شبكة قبل كل مكالمة.
import 'dart:convert';
import '../constant/box_name.dart';
import '../constant/links.dart';
import '../controller/functions/crud.dart';
import '../main.dart';
import '../print.dart';
class TurnCredentialsService {
static const String _cacheKey = BoxName.turnIceCache;
/// خوادم ICE جاهزة لتمريرها إلى createPeerConnection.
/// تعيد قائمة فارغة عند أي فشل — والمُنادي يكمل بـ STUN كما كان سابقاً.
static Future<List<Map<String, dynamic>>> getIceServers() async {
final cached = _readCache();
if (cached != null) return cached;
try {
final res = await CRUD().post(
link: '${AppLink.server}/ride/call/turn_credentials.php',
);
if (res is! Map || res['status'] != 'success') return [];
// غلاف jsonSuccess يضع الحمولة في message
final payload = res['message'];
if (payload is! Map || payload['ice_servers'] is! List) return [];
final servers = (payload['ice_servers'] as List)
.whereType<Map>()
.map((s) => Map<String, dynamic>.from(s))
.toList();
final ttl = int.tryParse(payload['ttl']?.toString() ?? '0') ?? 0;
if (ttl > 0 && servers.isNotEmpty) {
// ننتهي قبل الخادم بخمس دقائق تفادياً لسباق انتهاء الصلاحية أثناء مكالمة
final expiresAt = DateTime.now().add(Duration(seconds: ttl - 300));
box.write(_cacheKey, jsonEncode({
'expires_at': expiresAt.toIso8601String(),
'servers': servers,
}));
}
return servers;
} catch (e) {
Log.print('⚠️ [TURN] تعذّر جلب بيانات الاعتماد: $e');
return [];
}
}
static List<Map<String, dynamic>>? _readCache() {
try {
final raw = box.read(_cacheKey);
if (raw == null) return null;
final data = jsonDecode(raw.toString());
final expiresAt = DateTime.tryParse(data['expires_at']?.toString() ?? '');
if (expiresAt == null || DateTime.now().isAfter(expiresAt)) return null;
final servers = (data['servers'] as List)
.whereType<Map>()
.map((s) => Map<String, dynamic>.from(s))
.toList();
return servers.isEmpty ? null : servers;
} catch (_) {
return null;
}
}
static void clearCache() => box.remove(_cacheKey);
}