import 'package:equatable/equatable.dart'; import '../data/models/geo_point.dart'; import '../data/models/trip.dart'; /// حالة السائق. الفرق الجوهري عن الراكب: السائق **يستقبل** عملاً بدل أن /// يطلبه، فالمحور هنا الاتصال والعرض لا التخطيط. enum DutyPhase { /// غير متصل — لا يصله شيء. offline, /// متصل بانتظار عرض. waiting, /// عرض معروض بمؤقّت. offered, /// رحلة مقبولة جارية. active, } enum DutyError { none, goOnlineFailed, acceptFailed, offerTaken, statusFailed } class DutyState extends Equatable { const DutyState({ this.phase = DutyPhase.offline, this.myLocation, this.offer, this.trip, this.busy = false, this.error = DutyError.none, this.creditBalance, this.creditBlocked = false, }); final DutyPhase phase; final GeoPoint? myLocation; /// العرض المعروض حالياً — يختفي إن سبق إليه سائق آخر. final Trip? offer; final Trip? trip; final bool busy; final DutyError error; /// الرصيد التشغيلي: العمولة تُخصم منه عند الإنهاء (docs/38 §5). final String? creditBalance; /// محجوب لنفاد الرصيد — لا يصله عمل، ولا بد أن يعرف السبب صراحةً. final bool creditBlocked; bool get isOnline => phase != DutyPhase.offline; DutyState copyWith({ DutyPhase? phase, GeoPoint? myLocation, Trip? offer, Trip? trip, bool? busy, DutyError? error, String? creditBalance, bool? creditBlocked, bool clearOffer = false, bool clearTrip = false, }) { return DutyState( phase: phase ?? this.phase, myLocation: myLocation ?? this.myLocation, offer: clearOffer ? null : (offer ?? this.offer), trip: clearTrip ? null : (trip ?? this.trip), busy: busy ?? this.busy, error: error ?? this.error, creditBalance: creditBalance ?? this.creditBalance, creditBlocked: creditBlocked ?? this.creditBlocked, ); } @override List get props => [ phase, myLocation, offer, trip, busy, error, creditBalance, creditBlocked, ]; }