110 lines
2.8 KiB
Dart
110 lines
2.8 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
/// أحداث TripBloc — المصادر الثلاث: المستخدم، WebSocket، FCM.
|
|
///
|
|
/// كل حدث يحمل `timestamp` لتمييز التسلسل عند الحاجة.
|
|
sealed class TripEvent extends Equatable {
|
|
const TripEvent();
|
|
|
|
@override
|
|
List<Object?> get props => [];
|
|
}
|
|
|
|
/// فحص رحلة نشطة عند بدء التشغيل أو العودة للخلفية.
|
|
class TripCheckActive extends TripEvent {
|
|
const TripCheckActive();
|
|
}
|
|
|
|
/// طلب رحلة جديدة (من شاشة تأكيد الاختيار).
|
|
class TripRequested extends TripEvent {
|
|
final double pickupLat;
|
|
final double pickupLng;
|
|
final String? pickupAddress;
|
|
final double dropoffLat;
|
|
final double dropoffLng;
|
|
final String? dropoffAddress;
|
|
final String vehicleClass;
|
|
final String paymentMethod;
|
|
final String? couponCode;
|
|
|
|
const TripRequested({
|
|
required this.pickupLat,
|
|
required this.pickupLng,
|
|
this.pickupAddress,
|
|
required this.dropoffLat,
|
|
required this.dropoffLng,
|
|
this.dropoffAddress,
|
|
required this.vehicleClass,
|
|
this.paymentMethod = 'cash',
|
|
this.couponCode,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [pickupLat, pickupLng, dropoffLat, dropoffLng, vehicleClass];
|
|
}
|
|
|
|
/// تحديث حالة الرحلة — ي הגיע عبر WebSocket أو FCM.
|
|
/// الترتيب: searching < assigned < driver_arriving < driver_arrived < in_progress < completed < paid
|
|
class TripUpdateReceived extends TripEvent {
|
|
final String tripId;
|
|
final String status;
|
|
final String? driverId;
|
|
final Map<String, dynamic> extra;
|
|
|
|
const TripUpdateReceived({
|
|
required this.tripId,
|
|
required this.status,
|
|
this.driverId,
|
|
this.extra = const {},
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [tripId, status, driverId];
|
|
}
|
|
|
|
/// موقع السائق الحي — من WebSocket.
|
|
class TripDriverLocation extends TripEvent {
|
|
final String tripId;
|
|
final double lat;
|
|
final double lng;
|
|
final double heading;
|
|
final double speed;
|
|
|
|
const TripDriverLocation({
|
|
required this.tripId,
|
|
required this.lat,
|
|
required this.lng,
|
|
this.heading = 0,
|
|
this.speed = 0,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [tripId, lat, lng];
|
|
}
|
|
|
|
/// إلغاء الرحلة من الراكب.
|
|
class TripCancelRequested extends TripEvent {
|
|
const TripCancelRequested();
|
|
}
|
|
|
|
/// إعادة المحاولة بعد خطأ.
|
|
class TripRetry extends TripEvent {
|
|
const TripRetry();
|
|
}
|
|
|
|
/// تقييم الرحلة المكتملة.
|
|
class TripRate extends TripEvent {
|
|
final int stars;
|
|
final String? comment;
|
|
|
|
const TripRate({required this.stars, this.comment});
|
|
|
|
@override
|
|
List<Object?> get props => [stars, comment];
|
|
}
|
|
|
|
/// مسح الرحلة من الذاكرة (بعد التقييم أو العودة للرئيسية).
|
|
class TripClear extends TripEvent {
|
|
const TripClear();
|
|
}
|