feat(apps): تسجيل السائق والدردشة والكوبون — إكمال التغطية

فحص آليّ لنقاط docs/38 مقابل الكود كشف ثغرات لم تظهر بالقراءة.

## تسجيل السائق — أخطر ثغرة
لم يكن موجوداً أصلاً: سائق جديد يسجّل دخوله ثم يقف. بُنيت features/onboarding
كاملة — تقديم ← ملف ← مركبة ← وثائق ← انتظار الاعتماد.
- الخطوة تُشتقّ من حالة الخادم لا من تقدّم محلّي: سائق يعيد تثبيت التطبيق
  يعود إلى حيث وقف لا إلى البداية
- الاعتماد يقع على الخادم تلقائياً حين تكتمل الوثائق؛ التطبيق لا يعتمد أحداً
- عند الاعتماد خروج إجباري: الدور يتغيّر على الخادم والتوكن القديم يحمل
  القديم، فتفشل نقاط السائق بـ403 (مصيدة docs/38 §5)
- بوابة توجيه: مستخدم دوره ليس driver يُحجز في /onboarding
- الوثائق تُصوَّر بالكاميرا لا من المعرض: أصعب تزويراً

## الدردشة والكوبون
- Features.chat كان مفعّلاً بلا ميزة. features/chat باستطلاع كل خمس ثوان —
  قائمة أحداث الخادم لا تتضمّن الرسائل (docs/38 §9)، فالاستطلاع قيد خادم لا
  اختيار تصميمي
- الكوبون: حقل في ورقة التأكيد خلف طبقتَي الميزات، يُقيَّم على الخادم

## Features.calls أُطفئ صراحةً
الخادم يدعم WebRTC والتطبيق لا. عَلَم مفعّل بلا ميزة كذبٌ على القارئ التالي.

## بنية
- ApiClient.upload للرفع متعدّد الأجزاء
- AuthFailure → ApiFailure في core/api: يخدم المصادقة والملف والتسجيل
- tool/sync_from_rider.sh: المزامنة اليدوية بين التوأمين انكسرت أربع مرات،
  فصارت سكربتاً واحداً يعرّف ما يملكه كل تطبيق

flutter analyze نظيف · الراكب 101 ملف/7,809 سطر · السائق 110 ملف/8,116 سطر.
فحوص آلية: صفر استيراد بين ميزتين · صفر عَلَم مفعّل بلا ميزة · كل نقاط العقد
المخصّصة للتطبيقين مستهلكة.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hamza-Ayed
2026-08-05 00:04:28 +03:00
co-authored by Claude Opus 5
parent 096acae74e
commit bb2c0de478
56 changed files with 1936 additions and 68 deletions
@@ -109,6 +109,8 @@ class RideCubit extends Cubit<RideState> {
// ── التخطيط ────────────────────────────────────────────────────────────
void couponChanged(String code) => emit(state.copyWith(couponCode: code));
void openPlanner() => emit(state.copyWith(phase: RidePhase.planning));
void collapsePlanner() => emit(state.copyWith(phase: RidePhase.idle));
@@ -253,6 +255,9 @@ class RideCubit extends Cubit<RideState> {
destination: to,
serviceClass: type.code,
stops: state.stops,
couponCode: state.couponCode.trim().isEmpty
? null
: state.couponCode.trim(),
);
if (isClosed) return;
@@ -59,6 +59,7 @@ class RideState extends Equatable {
this.error = RideError.none,
this.pickTarget = PickTarget.destination,
this.cameraTarget,
this.couponCode = '',
});
final RidePhase phase;
@@ -92,6 +93,9 @@ class RideState extends Equatable {
/// وجهة الكاميرا حين يقودها المنطق لا المستخدم.
final GeoPoint? cameraTarget;
/// كود الخصم — يُقيَّم على الخادم عند الطلب لا في التطبيق.
final String couponCode;
bool get canConfirm =>
origin != null &&
destination != null &&
@@ -117,6 +121,7 @@ class RideState extends Equatable {
RideError? error,
PickTarget? pickTarget,
GeoPoint? cameraTarget,
String? couponCode,
bool clearDestination = false,
bool clearRoute = false,
bool clearTrip = false,
@@ -143,6 +148,7 @@ class RideState extends Equatable {
error: error ?? this.error,
pickTarget: pickTarget ?? this.pickTarget,
cameraTarget: clearCamera ? null : (cameraTarget ?? this.cameraTarget),
couponCode: couponCode ?? this.couponCode,
);
}
@@ -166,5 +172,6 @@ class RideState extends Equatable {
error,
pickTarget,
cameraTarget,
couponCode,
];
}
@@ -1,12 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import '../../../../core/design/tokens.dart';
import '../../../../core/design/tripz_colors.dart';
import '../../../../core/build_config.dart';
import '../../../../core/l10n/l10n.dart';
import '../../../../core/router.dart';
import '../../../../core/tenant/feature_gate.dart';
import '../../../../core/ui/tripz_button.dart';
@@ -41,6 +45,15 @@ class ActiveTripSheet extends StatelessWidget {
Text(_statusText(context), style: context.texts.titleMedium),
const SizedBox(height: Space.md),
DriverBadge(trip: trip),
if (Features.chat && context.tenantHas('chat')) ...[
const SizedBox(height: Space.sm),
TripzButton.secondary(
label: l10n.chatTitle,
icon: Icons.forum_outlined,
expanded: true,
onPressed: () => context.push('${Routes.chat}?trip=\${trip.id}'),
),
],
if (trip.priceForPassenger != null) ...[
const SizedBox(height: Space.md),
FareSummary(trip: trip),
@@ -12,7 +12,10 @@ import '../../../../core/l10n/l10n.dart';
import '../../../../core/ui/status_banner.dart';
import '../../../../core/build_config.dart';
import '../../../../core/tenant/feature_gate.dart';
import '../../../../core/ui/tripz_button.dart';
import '../../../../core/ui/tripz_text_field.dart';
import '../../cubit/ride_cubit.dart';
@@ -92,6 +95,15 @@ class ConfirmSheet extends StatelessWidget {
const SizedBox(height: Space.sm),
StatusBanner(message: l10n.rideNoDrivers, tone: BannerTone.warning),
],
// الكوبون خلف طبقتَي الميزات: مبنيّ في الـbinary ومشترى للمستأجر.
if (Features.coupons && context.tenantHas('coupons')) ...[
const SizedBox(height: Space.md),
TripzTextField(
hint: l10n.rideCoupon,
prefixIcon: Icons.local_offer_outlined,
onChanged: cubit.couponChanged,
),
],
const SizedBox(height: Space.md),
TripzButton.primary(
label: l10n.rideConfirmTrip,