feat: implement core architecture, design system, localization, and trip features for both driver and rider apps.

This commit is contained in:
Hamza-Ayed
2026-07-19 16:21:58 +03:00
parent 959e2fa758
commit c4dfeb4c6f
207 changed files with 14017 additions and 5567 deletions
@@ -0,0 +1,33 @@
import 'package:equatable/equatable.dart';
/// نموذج رسالة الدردشة — من `GET /chat/:tripId/messages` و`POST /chat/:tripId/send`.
class ChatMessageModel extends Equatable {
final String id;
final String tripId;
final String senderId;
final String text;
final DateTime createdAt;
final bool isMe;
const ChatMessageModel({
required this.id,
required this.tripId,
required this.senderId,
required this.text,
required this.createdAt,
required this.isMe,
});
factory ChatMessageModel.fromJson(Map<String, dynamic> j, {String? currentUserId}) =>
ChatMessageModel(
id: j['id'] as String,
tripId: (j['tripId'] ?? '') as String,
senderId: j['senderId'] as String,
text: j['text'] as String,
createdAt: DateTime.parse(j['createdAt'] as String),
isMe: j['senderId'] == currentUserId,
);
@override
List<Object?> get props => [id, tripId, senderId, text, createdAt];
}
@@ -0,0 +1,93 @@
import 'package:equatable/equatable.dart';
/// نموذج الرحلة من وجهة نظر السائق — من `GET /trips/available` وتحديثات WebSocket.
class DriverTripModel extends Equatable {
final String id;
final String status;
final String? clientId;
final String? clientName;
final String? clientPhone;
final double pickupLat;
final double pickupLng;
final String? pickupAddress;
final double dropoffLat;
final double dropoffLng;
final String? dropoffAddress;
final String vehicleClass;
final num? fare;
final String? currency;
final String? paymentMethod;
final DateTime? createdAt;
final DateTime? updatedAt;
const DriverTripModel({
required this.id,
required this.status,
this.clientId,
this.clientName,
this.clientPhone,
required this.pickupLat,
required this.pickupLng,
this.pickupAddress,
required this.dropoffLat,
required this.dropoffLng,
this.dropoffAddress,
required this.vehicleClass,
this.fare,
this.currency,
this.paymentMethod,
this.createdAt,
this.updatedAt,
});
factory DriverTripModel.fromJson(Map<String, dynamic> j) => DriverTripModel(
id: j['id'] as String,
status: j['status'] as String,
clientId: j['clientId'] as String?,
clientName: j['clientName'] as String?,
clientPhone: j['clientPhone'] as String?,
pickupLat: (j['pickup']?['lat'] ?? j['pickupLat'] ?? 0).toDouble(),
pickupLng: (j['pickup']?['lng'] ?? j['pickupLng'] ?? 0).toDouble(),
pickupAddress: (j['pickup']?['address'] ?? j['pickupAddress']) as String?,
dropoffLat: (j['dropoff']?['lat'] ?? j['dropoffLat'] ?? 0).toDouble(),
dropoffLng: (j['dropoff']?['lng'] ?? j['dropoffLng'] ?? 0).toDouble(),
dropoffAddress: (j['dropoff']?['address'] ?? j['dropoffAddress']) as String?,
vehicleClass: (j['vehicleClass'] ?? '') as String,
fare: (j['fare'] as num?),
currency: j['currency'] as String?,
paymentMethod: j['paymentMethod'] as String?,
createdAt: j['createdAt'] != null ? DateTime.tryParse(j['createdAt'] as String) : null,
updatedAt: j['updatedAt'] != null ? DateTime.tryParse(j['updatedAt'] as String) : null,
);
DriverTripModel copyWith({
String? status,
String? clientName,
String? clientPhone,
num? fare,
String? currency,
}) {
return DriverTripModel(
id: id,
status: status ?? this.status,
clientId: clientId,
clientName: clientName ?? this.clientName,
clientPhone: clientPhone ?? this.clientPhone,
pickupLat: pickupLat,
pickupLng: pickupLng,
pickupAddress: pickupAddress,
dropoffLat: dropoffLat,
dropoffLng: dropoffLng,
dropoffAddress: dropoffAddress,
vehicleClass: vehicleClass,
fare: fare ?? this.fare,
currency: currency ?? this.currency,
paymentMethod: paymentMethod,
createdAt: createdAt,
updatedAt: DateTime.now(),
);
}
@override
List<Object?> get props => [id, status, clientId, vehicleClass, fare];
}