## حسم تعارض الخرائط (docs/38 §7) لصالح القرار الأحدث 2026-07-20: كل الخرائط — البلاطات والبحث والعكسي والمسار — مباشرة إلى map-saas بترويسة x-api-key، بلا مرور بباك إند تريبز. نقاط /maps/* في الباك إند لا تُستعمل، وإحداها (geocode) معطوبة على المنشور. العقد تُحقّق حيّاً بـcurl قبل كتابة سطر. ## النواة المشتركة - core/api/antlaq_api.dart: عميل منفصل بلا AuthInterceptor — توكن تريبز لا شأن لخادم الخرائط به، وإرساله إليه تسريب بلا مقابل - core/realtime: Socket.IO واحد (trip:update · driver:location · trip:offer · trip:offer_taken) - core/location: نقطة الموقع الوحيدة بمرشّح 25 متراً - features/trip/data: سبعة نماذج + MapsRepository + TripRepository متطابق حرفياً بين التوأمين ## الراكب RideCubit بستّ مراحل + RidePage وثمانية ويدجت: الخريطة · دبّوس المنتصف · المخطّط · الخط الزمني · اختيار النوع · التأكيد · البحث عن سائق · الرحلة. ## السائق DutyCubit بأربع مراحل + DutyPage: مفتاح الاتصال · العرض بمؤقّت · الرحلة. ## قرارات تحمي الأداء والصحّة - GeoPoint مستقلّ عن حزمة الخريطة؛ intaleq_maps مستوردة في ملف واحد فقط لكل تطبيق. تبديل محرّك الخريطة لا يلمس منطقاً - الخريطة خارج BlocBuilder الورقة ولها BlocSelector خاص: نبضة موقع كل 25م لا تعيد بناء الشاشة - مهلة بحث محليّة 90ث + استطلاع كل 5ث: الخادم قد لا يُطلق expired/no_drivers أبداً (ثغرة R1)، وانتظار حدث قد لا يصل = شاشة بحث أبدية - offeredDrivers == 0 جواب نهائي فوري بلا انتظار المهلة - الأجرة لا تُعرض إلا إن كانت صالحة: /tariff/quote يرجّع 200 بقيم null صامتة - موقع السائق بمسارين عمداً: REST لمطابقة Redis والسوكت لخريطة الراكب flutter analyze نظيف · الراكب 70 ملف/5,294 سطر · السائق 67 ملف/4,771 سطر. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
166 lines
4.5 KiB
Dart
166 lines
4.5 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
import '../data/models/fare_quote.dart';
|
|
import '../data/models/geo_point.dart';
|
|
import '../data/models/place.dart';
|
|
import '../data/models/ride_type.dart';
|
|
import '../data/models/route_info.dart';
|
|
import '../data/models/trip.dart';
|
|
|
|
/// مراحل شاشة الراكب. المرحلة تحدّد ما يُعرض على الخريطة وما في الورقة
|
|
/// السفلية — «الشاشة مهمة واحدة» (docs/26 §8.1).
|
|
enum RidePhase {
|
|
/// الخريطة والبطاقة المطوية «إلى أين؟».
|
|
idle,
|
|
|
|
/// المخطّط الموسّع: المصدر والوجهة والمحطات.
|
|
planning,
|
|
|
|
/// المستخدم يحرّك الخريطة والدبّوس ثابت في المنتصف.
|
|
pickingOnMap,
|
|
|
|
/// المسار والتسعيرة معروضان بانتظار التأكيد.
|
|
confirming,
|
|
|
|
/// البحث عن سائق.
|
|
searching,
|
|
|
|
/// رحلة جارية.
|
|
active,
|
|
}
|
|
|
|
/// أيّ حقلٍ يلتقط اختيار الخريطة.
|
|
enum PickTarget { origin, destination }
|
|
|
|
enum RideError { none, noDrivers, quoteFailed, routeFailed, requestFailed }
|
|
|
|
class RideState extends Equatable {
|
|
const RideState({
|
|
this.phase = RidePhase.idle,
|
|
this.origin,
|
|
this.destination,
|
|
this.originLabel = '',
|
|
this.destinationLabel = '',
|
|
this.stops = const [],
|
|
this.rideTypes = const [],
|
|
this.selectedRideType,
|
|
this.route,
|
|
this.quote,
|
|
this.trip,
|
|
this.driverLocation,
|
|
this.searchResults = const [],
|
|
this.searching = false,
|
|
this.busy = false,
|
|
this.error = RideError.none,
|
|
this.pickTarget = PickTarget.destination,
|
|
this.cameraTarget,
|
|
});
|
|
|
|
final RidePhase phase;
|
|
|
|
final GeoPoint? origin;
|
|
final GeoPoint? destination;
|
|
final String originLabel;
|
|
final String destinationLabel;
|
|
final List<GeoPoint> stops;
|
|
|
|
final List<RideType> rideTypes;
|
|
final RideType? selectedRideType;
|
|
|
|
final RouteInfo? route;
|
|
final FareQuote? quote;
|
|
|
|
final Trip? trip;
|
|
|
|
/// موقع السائق الحيّ من `driver:location`.
|
|
final GeoPoint? driverLocation;
|
|
|
|
final List<Place> searchResults;
|
|
|
|
/// بحث نصّي جارٍ — منفصل عن [busy] كي لا يقفل مؤشّرُ البحثِ الشاشةَ كلها.
|
|
final bool searching;
|
|
final bool busy;
|
|
|
|
final RideError error;
|
|
final PickTarget pickTarget;
|
|
|
|
/// وجهة الكاميرا حين يقودها المنطق لا المستخدم.
|
|
final GeoPoint? cameraTarget;
|
|
|
|
bool get canConfirm =>
|
|
origin != null &&
|
|
destination != null &&
|
|
selectedRideType != null &&
|
|
quote?.isUsable == true;
|
|
|
|
RideState copyWith({
|
|
RidePhase? phase,
|
|
GeoPoint? origin,
|
|
GeoPoint? destination,
|
|
String? originLabel,
|
|
String? destinationLabel,
|
|
List<GeoPoint>? stops,
|
|
List<RideType>? rideTypes,
|
|
RideType? selectedRideType,
|
|
RouteInfo? route,
|
|
FareQuote? quote,
|
|
Trip? trip,
|
|
GeoPoint? driverLocation,
|
|
List<Place>? searchResults,
|
|
bool? searching,
|
|
bool? busy,
|
|
RideError? error,
|
|
PickTarget? pickTarget,
|
|
GeoPoint? cameraTarget,
|
|
bool clearDestination = false,
|
|
bool clearRoute = false,
|
|
bool clearTrip = false,
|
|
bool clearCamera = false,
|
|
}) {
|
|
return RideState(
|
|
phase: phase ?? this.phase,
|
|
origin: origin ?? this.origin,
|
|
destination: clearDestination ? null : (destination ?? this.destination),
|
|
originLabel: originLabel ?? this.originLabel,
|
|
destinationLabel: clearDestination
|
|
? ''
|
|
: (destinationLabel ?? this.destinationLabel),
|
|
stops: stops ?? this.stops,
|
|
rideTypes: rideTypes ?? this.rideTypes,
|
|
selectedRideType: selectedRideType ?? this.selectedRideType,
|
|
route: clearRoute ? null : (route ?? this.route),
|
|
quote: clearRoute ? null : (quote ?? this.quote),
|
|
trip: clearTrip ? null : (trip ?? this.trip),
|
|
driverLocation: driverLocation ?? this.driverLocation,
|
|
searchResults: searchResults ?? this.searchResults,
|
|
searching: searching ?? this.searching,
|
|
busy: busy ?? this.busy,
|
|
error: error ?? this.error,
|
|
pickTarget: pickTarget ?? this.pickTarget,
|
|
cameraTarget: clearCamera ? null : (cameraTarget ?? this.cameraTarget),
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
phase,
|
|
origin,
|
|
destination,
|
|
originLabel,
|
|
destinationLabel,
|
|
stops,
|
|
rideTypes,
|
|
selectedRideType,
|
|
route,
|
|
quote,
|
|
trip,
|
|
driverLocation,
|
|
searchResults,
|
|
searching,
|
|
busy,
|
|
error,
|
|
pickTarget,
|
|
cameraTarget,
|
|
];
|
|
}
|