Files
tripz-llc/apps/rider-archive-cubit/lib/features/trip/bloc/trip_state.dart
T
Hamza-AyedandClaude Opus 5 9909d9b4c1 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>
2026-07-27 05:12:04 +03:00

112 lines
3.1 KiB
Dart

import 'package:equatable/equatable.dart';
import '../data/models/trip_model.dart';
/// هل هذه الحالة نهائية (لا انتقالات منها)?
bool isTerminalStatus(String status) {
return status == 'cancelled' || status == 'no_drivers' || status == 'expired' || status == 'paid';
}
/// حالة TripBloc الموحدة.
class TripState extends Equatable {
final TripRequestStatus requestStatus;
final TripModel? trip;
final String? driverName;
final String? vehicleMake;
final String? vehicleModel;
final String? vehiclePlate;
final String? vehicleColor;
final double? driverLat;
final double? driverLng;
final double? driverHeading;
final String? error;
final bool rated;
const TripState({
this.requestStatus = TripRequestStatus.idle,
this.trip,
this.driverName,
this.vehicleMake,
this.vehicleModel,
this.vehiclePlate,
this.vehicleColor,
this.driverLat,
this.driverLng,
this.driverHeading,
this.error,
this.rated = false,
});
TripState copyWith({
TripRequestStatus? requestStatus,
TripModel? trip,
String? driverName,
String? vehicleMake,
String? vehicleModel,
String? vehiclePlate,
String? vehicleColor,
double? driverLat,
double? driverLng,
double? driverHeading,
String? error,
bool? rated,
bool clearError = false,
bool clearDriver = false,
}) {
return TripState(
requestStatus: requestStatus ?? this.requestStatus,
trip: trip ?? this.trip,
driverName: clearDriver ? null : (driverName ?? this.driverName),
vehicleMake: clearDriver ? null : (vehicleMake ?? this.vehicleMake),
vehicleModel: clearDriver ? null : (vehicleModel ?? this.vehicleModel),
vehiclePlate: clearDriver ? null : (vehiclePlate ?? this.vehiclePlate),
vehicleColor: clearDriver ? null : (vehicleColor ?? this.vehicleColor),
driverLat: driverLat ?? this.driverLat,
driverLng: driverLng ?? this.driverLng,
driverHeading: driverHeading ?? this.driverHeading,
error: clearError ? null : (error ?? this.error),
rated: rated ?? this.rated,
);
}
/// هل هناك رحلة نشطة (ليست idle ولا terminal)?
bool get hasActiveTrip =>
trip != null &&
requestStatus != TripRequestStatus.idle &&
!isTerminalStatus(trip!.status);
/// هل يمكن إلغاء الرحلة حالياً?
bool get canCancel {
if (trip == null) return false;
return ['searching', 'assigned', 'driver_arriving', 'driver_arrived']
.contains(trip!.status);
}
/// هل يمكن للمستخدم ركوب الرحلة (اكتملت)?
bool get isCompleted => trip?.status == 'completed' || trip?.status == 'paid';
@override
List<Object?> get props => [
requestStatus,
trip,
driverName,
vehicleMake,
vehicleModel,
vehiclePlate,
vehicleColor,
driverLat,
driverLng,
driverHeading,
error,
rated,
];
}
enum TripRequestStatus {
idle,
loading,
searching,
active, // assigned → in_progress
completed,
error,
}