Update: 2026-07-13 18:23:52
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:get/get.dart';
|
||||
import 'package:intaleq_maps/intaleq_maps.dart' show LatLng;
|
||||
|
||||
import '../functions/location_controller.dart';
|
||||
import '../widgets/error_snakbar.dart';
|
||||
import 'transit_driver_models.dart';
|
||||
import 'transit_driver_service.dart';
|
||||
|
||||
@@ -117,7 +118,7 @@ class TransitDriverController extends GetxController {
|
||||
}
|
||||
await fetchTodayTrips();
|
||||
} else {
|
||||
Get.snackbar('مواصلاتي', res.message);
|
||||
mySnackbarError(res.message);
|
||||
}
|
||||
|
||||
isActionInProgress = false;
|
||||
@@ -139,7 +140,7 @@ class TransitDriverController extends GetxController {
|
||||
}
|
||||
await fetchTodayTrips();
|
||||
} else {
|
||||
Get.snackbar('مواصلاتي', res.message);
|
||||
mySnackbarError(res.message);
|
||||
}
|
||||
|
||||
isActionInProgress = false;
|
||||
@@ -154,10 +155,23 @@ class TransitDriverController extends GetxController {
|
||||
delayMinutes: minutes,
|
||||
reason: reason,
|
||||
);
|
||||
if (!res.success) Get.snackbar('مواصلاتي', res.message);
|
||||
if (!res.success) mySnackbarError(res.message);
|
||||
return res.success;
|
||||
}
|
||||
|
||||
Future<bool> boardPassenger(int stopId, String passengerId) async {
|
||||
final res = await TransitDriverService.boardPassenger(stopId, passengerId);
|
||||
return res.success;
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getStopPassengers(int stopId) async {
|
||||
final res = await TransitDriverService.getStopPassengers(stopId);
|
||||
if (res.success && res.data != null) {
|
||||
return res.data!;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// ── كشف الوصول للمحطات (جيوفينس) ────────────────────────────
|
||||
// تُستدعى من LocationController عند كل تحديث للموقع أثناء وضع الباص
|
||||
void onLocationUpdate(LatLng pos) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// transit_driver_models.dart — نماذج بيانات مواصلاتي (جهة سائق الباص)
|
||||
|
||||
class TransitStopInfo {
|
||||
final int id;
|
||||
final int sequence;
|
||||
final String nameAr;
|
||||
final double latitude;
|
||||
@@ -9,6 +10,7 @@ class TransitStopInfo {
|
||||
final int? etaOffsetMin;
|
||||
|
||||
TransitStopInfo({
|
||||
required this.id,
|
||||
required this.sequence,
|
||||
required this.nameAr,
|
||||
required this.latitude,
|
||||
@@ -18,6 +20,7 @@ class TransitStopInfo {
|
||||
});
|
||||
|
||||
factory TransitStopInfo.fromJson(Map<String, dynamic> j) => TransitStopInfo(
|
||||
id: int.tryParse(j['id']?.toString() ?? '0') ?? 0,
|
||||
sequence: int.tryParse(j['sequence'].toString()) ?? 0,
|
||||
nameAr: j['name_ar']?.toString() ?? '',
|
||||
latitude: double.tryParse(j['latitude']?.toString() ?? '0') ?? 0,
|
||||
|
||||
@@ -108,4 +108,32 @@ class TransitDriverService {
|
||||
}
|
||||
return TransitApiResult(false, null, _errMsg(res));
|
||||
}
|
||||
|
||||
static Future<TransitApiResult<bool>> boardPassenger(int stopId, String passengerId) async {
|
||||
final res = await CRUD().post(
|
||||
link: '$_base/trip/board_passenger.php',
|
||||
payload: {
|
||||
'stop_id': stopId.toString(),
|
||||
'passenger_id': passengerId,
|
||||
},
|
||||
);
|
||||
if (res is Map && res['status'] == 'success') {
|
||||
return TransitApiResult(true, true, 'ok');
|
||||
}
|
||||
return TransitApiResult(false, false, _errMsg(res));
|
||||
}
|
||||
|
||||
static Future<TransitApiResult<List<Map<String, dynamic>>>> getStopPassengers(int stopId) async {
|
||||
final res = await CRUD().post(
|
||||
link: '$_base/trip/stop_passengers.php',
|
||||
payload: {
|
||||
'stop_id': stopId.toString(),
|
||||
},
|
||||
);
|
||||
if (res is Map && res['status'] == 'success' && res['message'] is List) {
|
||||
final list = (res['message'] as List).map((e) => Map<String, dynamic>.from(e)).toList();
|
||||
return TransitApiResult(true, list, 'ok');
|
||||
}
|
||||
return TransitApiResult(false, [], _errMsg(res));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user