Files
tripz-llc/apps/rider_new/lib/features/trip/cubit/ride_state.dart
T
Hamza-AyedandClaude Opus 5 096acae74e feat(apps): الدراور وطبقتا الميزات والإشعارات — المرحلة 6
## طبقتا الميزات مُطبَّقتان معاً
AppDrawer يفحص: Features.wallet && context.tenantHas('wallet')
- Features.x ثابت const: يقرّر ما يُبنى في الـbinary. إطفاؤه يحذف الكود
  فلا يُستخرج (docs/23 §5)
- tenantHas من GET /tenant/config/:slug: يقرّر ما يُعرض ممّا بُني حسب اشتراك
  المستأجر (docs/38 §10)
هذا هو ربط lite/pro/max عملياً. TenantCubit يعرض النسخة المخزّنة فوراً ثم
يحدّثها: إقلاع بلا إنترنت يعرض الميزات المعروفة آخر مرة لا شاشة فارغة.

## الشاشات
الدراور · تعديل الحساب · سجلّ الرحلات · الإعدادات (مظهر + لغة) · المساعدة.
الرقم في تعديل الحساب معطّل مع سبب معروض لا مخفي: هو هوية الحساب على الخادم
وتغييره يعني حساباً آخر (docs/38 §1).

## الإشعارات
PushService معزول — الملف الوحيد الذي يعرف Firebase. التسجيل بعد إثبات
الجلسة عبر خطّاف في SessionCubit، ومع اشتراك onTokenRefresh: بدونه تتوقّف
الإشعارات بصمت بعد أسابيع. الإعداد الأصلي كان جاهزاً مسبقاً.

## تصحيحات بنيوية كشفها فحص آلي
docs/23 §1 يمنع أن تستورد ميزة من أخرى — وكانت خمس مخالفات:
1. features/history أُدمجت في features/trip — السجلّ جزء من ميزة الرحلة
2. AppDrawer صعد إلى core/ui — هيكل تطبيق لا ميزة
3. AuthFailure → core/api/api_failure.dart، ومترجمه → core/ui/failure_text.dart
4. AuthHeader → core/ui/form_header.dart
5. ProfileRepository مستقلّ عن AuthRepository: تعديل الملف ليس مصادقة

flutter analyze نظيف · الراكب 98 ملف/7,497 سطر · السائق 95 ملف/6,931 سطر.
فحوص آلية نظيفة: صفر استيراد بين ميزتين · core يستورد features من di و
router وحدهما · Firebase و intaleq_maps و geolocator و socket_io كلٌّ معزول.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 23:52:27 +03:00

171 lines
4.6 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,
];
}