feat: implement core architecture, design system, localization, and trip features for both driver and rider apps.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import '../../../core/api/api_client.dart';
|
||||
import 'models/driver_profile_model.dart';
|
||||
|
||||
/// مستودع بيانات السائق — يُستخدم من DriverCubit.
|
||||
class DriverRepository {
|
||||
final ApiClient _api;
|
||||
DriverRepository(this._api);
|
||||
|
||||
/// `GET /drivers/me` — جلب ملف السائق.
|
||||
Future<DriverProfileModel?> getProfile() async {
|
||||
try {
|
||||
final r = await _api.dio.get('/drivers/me');
|
||||
return DriverProfileModel.fromJson(r.data as Map<String, dynamic>);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// `PATCH /drivers/status` — تبديل الحالة (مُتصل/مُنقطع).
|
||||
Future<bool> setOnline(bool online) async {
|
||||
try {
|
||||
final r = await _api.dio.patch('/drivers/status', data: {'online': online});
|
||||
return r.data['online'] as bool? ?? online;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// `POST /drivers/location` — إرسال الموقع الحالي.
|
||||
///
|
||||
/// يُعيد `true` إذا كان الموقع "مُهماً" (تغيير كبير حسب السيرفر).
|
||||
Future<bool> sendLocation({
|
||||
required double lat,
|
||||
required double lng,
|
||||
double? heading,
|
||||
double? speed,
|
||||
}) async {
|
||||
try {
|
||||
final r = await _api.dio.post('/drivers/location', data: {
|
||||
'lat': lat,
|
||||
'lng': lng,
|
||||
if (heading != null) 'heading': heading,
|
||||
if (speed != null) 'speed': speed,
|
||||
});
|
||||
return r.data['significant'] as bool? ?? false;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user