chore: أرشفة تطبيقات ولوحات تريبز التي سيحلّ محلها كود سيرو
استكمال قرار 2026-07-27 (كوميت fff76c9 أرشف الباك إند):
apps/rider → apps/rider-archive-cubit
apps/driver → apps/driver-archive-cubit
dashboards/admin-web → dashboards/admin-web-archive
dashboards/service-web → dashboards/service-web-archive
إعادة تسمية بلا تعديل محتوى. rider/driver كانا إعادة بناء Cubit مبنية على
عقد NestJS المؤرشف. admin-web و service-web نموذجان بملف HTML واحد (164 و
128 سطراً) — يحلّ محلهما siro_admin و siro_service المكتملان.
يُحمل من المؤرشف ولا يُعاد اكتشافه: عقد map-saas المثبَّت بالتجربة في
apps/rider-archive-cubit/lib/core/api/ (x-api-key ترويسة، reverse مصفوفة،
route في points) ودرس مسار FCM.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
fff76c949f
commit
9909d9b4c1
@@ -0,0 +1,92 @@
|
||||
import 'dart:async';
|
||||
import '../../home/data/models/trip_offer_model.dart';
|
||||
|
||||
/// تحديث حالة رحلة من WebSocket (للسائق).
|
||||
class DriverTripUpdate {
|
||||
final String tripId;
|
||||
final String status;
|
||||
final Map<String, dynamic> extra;
|
||||
|
||||
const DriverTripUpdate({
|
||||
required this.tripId,
|
||||
required this.status,
|
||||
this.extra = const {},
|
||||
});
|
||||
}
|
||||
|
||||
/// محول أحداث WebSocket للسائق — يدعم:
|
||||
/// - عروض الرحلات (`trip:offer`)
|
||||
/// - إلغاء العروض (`trip:offer_taken`)
|
||||
/// - تحديثات الحالة (`trip:update`)
|
||||
/// - رحلات جديدة (`trip:new`)
|
||||
///
|
||||
/// التصفية الصامتة تتم بترتيب الحالات (docs/23 §15).
|
||||
int _statusOrder(String s) {
|
||||
switch (s) {
|
||||
case 'assigned':
|
||||
return 0;
|
||||
case 'driver_arriving':
|
||||
return 1;
|
||||
case 'driver_arrived':
|
||||
return 2;
|
||||
case 'in_progress':
|
||||
return 3;
|
||||
case 'completed':
|
||||
return 4;
|
||||
case 'paid':
|
||||
return 5;
|
||||
default:
|
||||
return -1; // cancelled, expired
|
||||
}
|
||||
}
|
||||
|
||||
class DriverTripEventMerger {
|
||||
final _offerController = StreamController<TripOfferModel>.broadcast();
|
||||
final _offerTakenController = StreamController<String>.broadcast();
|
||||
final _updateController = StreamController<DriverTripUpdate>.broadcast();
|
||||
final _newTripController = StreamController<String>.broadcast();
|
||||
|
||||
/// الحالة المعروضة حالياً لكل رحلة.
|
||||
final Map<String, int> _currentOrder = {};
|
||||
|
||||
Stream<TripOfferModel> get offerStream => _offerController.stream;
|
||||
Stream<String> get offerTakenStream => _offerTakenController.stream;
|
||||
Stream<DriverTripUpdate> get updateStream => _updateController.stream;
|
||||
Stream<String> get newTripStream => _newTripController.stream;
|
||||
|
||||
/// استقبال عرض رحلة وارد.
|
||||
void addOffer(TripOfferModel offer) {
|
||||
_offerController.add(offer);
|
||||
}
|
||||
|
||||
/// العرض تم قبوله من سائق آخر.
|
||||
void addOfferTaken(String tripId) {
|
||||
_offerTakenController.add(tripId);
|
||||
}
|
||||
|
||||
/// تحديث حالة رحلة نشطة.
|
||||
void addUpdate(DriverTripUpdate update) {
|
||||
final newOrder = _statusOrder(update.status);
|
||||
final currentOrder = _currentOrder[update.tripId] ?? -1;
|
||||
|
||||
if (newOrder >= 0 && newOrder <= currentOrder) return;
|
||||
|
||||
if (newOrder >= 0) {
|
||||
_currentOrder[update.tripId] = newOrder;
|
||||
}
|
||||
|
||||
_updateController.add(update);
|
||||
}
|
||||
|
||||
/// إشعار برحلة جديدة متاحة.
|
||||
void addNewTrip(String tripId) {
|
||||
_newTripController.add(tripId);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_offerController.close();
|
||||
_offerTakenController.close();
|
||||
_updateController.close();
|
||||
_newTripController.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user