Update: 2026-07-12 18:53:59
This commit is contained in:
@@ -123,4 +123,10 @@ class BoxName {
|
||||
static const String registrationDate = "registrationDate";
|
||||
static const String recentLocations = 'recentLocations';
|
||||
static const String tripData = 'tripData';
|
||||
|
||||
// 🚌 مواصلاتي — وضع الباص (يُكتب من LocationController.setBusMode)
|
||||
// تقرأه background_service لتمييز أحداث السوكيت في الخلفية
|
||||
static const String isBusMode = 'isBusMode';
|
||||
static const String busModeTripId = 'busModeTripId';
|
||||
static const String busModeRouteId = 'busModeRouteId';
|
||||
}
|
||||
|
||||
@@ -78,6 +78,14 @@ Future<bool> onStart(ServiceInstance service) async {
|
||||
// 🔥 قراءة حالة التطبيق مباشرة قبل العرض
|
||||
await GetStorage.init(); // تأكد من تحديث البيانات
|
||||
final box = GetStorage();
|
||||
|
||||
// 🚌 في وضع الباص لا نعرض طلبات الرحلات — السائق في مهمة باص نشطة
|
||||
final bool inBusMode = box.read(BoxName.isBusMode) ?? false;
|
||||
if (inBusMode) {
|
||||
print("🚌 Bus mode active — ignoring new_ride_request in background.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool isAppInForeground = box.read(BoxName.isAppInForeground) ?? false;
|
||||
|
||||
// 🔥 Check إضافي: هل الـ Overlay مفتوح بالفعل؟ (للأندرويد فقط)
|
||||
|
||||
@@ -22,6 +22,7 @@ import '../home/payment/captain_wallet_controller.dart';
|
||||
import '../home/navigation/navigation_controller.dart';
|
||||
import 'background_service.dart';
|
||||
import 'crud.dart';
|
||||
import '../transit/transit_driver_controller.dart';
|
||||
|
||||
class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
// ===================================================================
|
||||
@@ -56,6 +57,10 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
isBusMode = enabled;
|
||||
activeBusTripId = enabled ? tripId : null;
|
||||
activeBusRouteId = enabled ? routeId : null;
|
||||
// نحفظ الحالة في GetStorage ليقرأها background_service في الـ isolate المستقل
|
||||
box.write(BoxName.isBusMode, enabled);
|
||||
box.write(BoxName.busModeTripId, enabled ? tripId : null);
|
||||
box.write(BoxName.busModeRouteId, enabled ? routeId : null);
|
||||
Log.print('🚌 Bus mode ${enabled ? "enabled" : "disabled"} (trip: $tripId, route: $routeId)');
|
||||
}
|
||||
|
||||
@@ -572,6 +577,10 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
// 🚌 وضع الباص: بثّ موقع الباص فقط — لا يدخل حوض الرحلات العادي
|
||||
if (isBusMode) {
|
||||
emitBusLocationToSocket(pos, heading, speed);
|
||||
// كشف الوصول للمحطات (جيوفينس)
|
||||
if (Get.isRegistered<TransitDriverController>()) {
|
||||
Get.find<TransitDriverController>().onLocationUpdate(pos);
|
||||
}
|
||||
await _saveBehaviorIfMoved(pos, now, currentSpeed: speed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -741,32 +741,19 @@ class HomeCaptainController extends GetxController {
|
||||
"📍 [HomeCaptain] Location updated: ${myLocation.latitude}, ${myLocation.longitude}");
|
||||
|
||||
if (!CountryPolygons.isServiceSupported(myLocation)) {
|
||||
Get.bottomSheet(
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.location_off,
|
||||
size: 60, color: Colors.redAccent),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
'service_unavailable_area'.tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
isDismissible: false,
|
||||
enableDrag: false,
|
||||
);
|
||||
if (!Get.isSnackbarOpen) {
|
||||
Get.snackbar(
|
||||
'Alert'.tr,
|
||||
'service_unavailable_area'.tr,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.redAccent,
|
||||
colorText: Colors.white,
|
||||
icon: const Icon(Icons.location_off, color: Colors.white),
|
||||
margin: const EdgeInsets.all(15),
|
||||
duration: const Duration(seconds: 5),
|
||||
isDismissible: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print(
|
||||
|
||||
@@ -10,6 +10,11 @@ final Map<String, String> ar_eg = {
|
||||
"Report Delay": "الإبلاغ عن تأخير",
|
||||
"Number of minutes": "عدد الدقائق",
|
||||
"Send": "إرسال",
|
||||
"Activate Bus Driver Account": "تفعيل حساب سائق الباص",
|
||||
"Invite Token": "رمز الدعوة",
|
||||
"Paste the token from the WhatsApp message": "الصق الرمز من رسالة الواتساب",
|
||||
"Activate": "تفعيل",
|
||||
"Now at": "الآن في",
|
||||
" \${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}": " \${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}",
|
||||
" \\\${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}": " \\\${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}",
|
||||
" and acknowledge our Privacy Policy.": "وأوافق على سياسة الخصوصية.",
|
||||
|
||||
@@ -10,6 +10,11 @@ final Map<String, String> ar_jo = {
|
||||
"Report Delay": "الإبلاغ عن تأخير",
|
||||
"Number of minutes": "عدد الدقائق",
|
||||
"Send": "إرسال",
|
||||
"Activate Bus Driver Account": "تفعيل حساب سائق الباص",
|
||||
"Invite Token": "رمز الدعوة",
|
||||
"Paste the token from the WhatsApp message": "الصق الرمز من رسالة الواتساب",
|
||||
"Activate": "تفعيل",
|
||||
"Now at": "الآن في",
|
||||
" \${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}": " \${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}",
|
||||
" \\\${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}": " \\\${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}",
|
||||
" and acknowledge our Privacy Policy.": "وأوافق على سياسة الخصوصية الخاصة بنا.",
|
||||
|
||||
@@ -10,6 +10,11 @@ final Map<String, String> ar_sy = {
|
||||
"Report Delay": "الإبلاغ عن تأخير",
|
||||
"Number of minutes": "عدد الدقائق",
|
||||
"Send": "إرسال",
|
||||
"Activate Bus Driver Account": "تفعيل حساب سائق الباص",
|
||||
"Invite Token": "رمز الدعوة",
|
||||
"Paste the token from the WhatsApp message": "الصق الرمز من رسالة الواتساب",
|
||||
"Activate": "تفعيل",
|
||||
"Now at": "الآن في",
|
||||
" \${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}": " \${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}",
|
||||
" \\\${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}": " \\\${durationController.jsonData1['message'][0]['day'].toString().split('-')[1]}",
|
||||
" and acknowledge our Privacy Policy.": "وبوافق على سياسة الخصوصية.",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// transit_driver_controller.dart — تحكم وضع الباص (جهة السائق)
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intaleq_maps/intaleq_maps.dart' show LatLng;
|
||||
|
||||
@@ -18,6 +19,13 @@ class TransitDriverController extends GetxController {
|
||||
TransitDriverTrip? activeTrip;
|
||||
bool isActionInProgress = false;
|
||||
|
||||
// ── حالة التفعيل ──────────────────────────────────────────────
|
||||
bool isActivating = false;
|
||||
String activationError = '';
|
||||
|
||||
// ── جيوفينس المحطات — آخر محطة تم الإعلان عنها ──────────────
|
||||
int _lastAnnouncedStopSeq = 0;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -41,18 +49,35 @@ class TransitDriverController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
/// تفعيل الحساب بتوكن الدعوة
|
||||
Future<void> activateWithToken(String token) async {
|
||||
if (token.trim().isEmpty) return;
|
||||
isActivating = true;
|
||||
activationError = '';
|
||||
update();
|
||||
|
||||
final res = await TransitDriverService.activateByInviteToken(token.trim());
|
||||
if (res.success) {
|
||||
// أعد فحص الحالة بعد التفعيل
|
||||
await checkBusDriverStatus();
|
||||
} else {
|
||||
activationError = res.message;
|
||||
}
|
||||
isActivating = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future<void> fetchTodayTrips() async {
|
||||
if (driverTransitId == null) return;
|
||||
isLoadingTrips = true;
|
||||
update();
|
||||
|
||||
final res = await TransitDriverService.getTodayTrips(driverTransitId!);
|
||||
final res = await TransitDriverService.getTodayTrips();
|
||||
if (res.success) {
|
||||
todayTrips = res.data ?? [];
|
||||
final started = todayTrips.where((t) => t.status == 'started');
|
||||
activeTrip = started.isNotEmpty ? started.first : null;
|
||||
|
||||
// إن كانت هناك رحلة قيد التشغيل بالفعل (مثلاً بعد إعادة فتح التطبيق)، فعّل وضع الباص
|
||||
// إن كانت هناك رحلة قيد التشغيل بالفعل (إعادة فتح التطبيق)
|
||||
if (activeTrip != null && Get.isRegistered<LocationController>()) {
|
||||
Get.find<LocationController>().setBusMode(
|
||||
enabled: true,
|
||||
@@ -66,7 +91,7 @@ class TransitDriverController extends GetxController {
|
||||
}
|
||||
|
||||
Future<bool> startTrip(TransitDriverTrip trip) async {
|
||||
if (driverTransitId == null || isActionInProgress) return false;
|
||||
if (isActionInProgress) return false;
|
||||
isActionInProgress = true;
|
||||
update();
|
||||
|
||||
@@ -77,12 +102,12 @@ class TransitDriverController extends GetxController {
|
||||
|
||||
final res = await TransitDriverService.startTrip(
|
||||
tripId: trip.id,
|
||||
driverTransitId: driverTransitId!,
|
||||
lat: pos.latitude,
|
||||
lng: pos.longitude,
|
||||
);
|
||||
|
||||
if (res.success) {
|
||||
_lastAnnouncedStopSeq = 0;
|
||||
if (Get.isRegistered<LocationController>()) {
|
||||
Get.find<LocationController>().setBusMode(
|
||||
enabled: true,
|
||||
@@ -101,16 +126,14 @@ class TransitDriverController extends GetxController {
|
||||
}
|
||||
|
||||
Future<bool> endTrip(TransitDriverTrip trip) async {
|
||||
if (driverTransitId == null || isActionInProgress) return false;
|
||||
if (isActionInProgress) return false;
|
||||
isActionInProgress = true;
|
||||
update();
|
||||
|
||||
final res = await TransitDriverService.endTrip(
|
||||
tripId: trip.id,
|
||||
driverTransitId: driverTransitId!,
|
||||
);
|
||||
final res = await TransitDriverService.endTrip(tripId: trip.id);
|
||||
|
||||
if (res.success) {
|
||||
_lastAnnouncedStopSeq = 0;
|
||||
if (Get.isRegistered<LocationController>()) {
|
||||
Get.find<LocationController>().setBusMode(enabled: false);
|
||||
}
|
||||
@@ -124,15 +147,57 @@ class TransitDriverController extends GetxController {
|
||||
return res.success;
|
||||
}
|
||||
|
||||
Future<bool> reportDelay(TransitDriverTrip trip, int minutes, {String? reason}) async {
|
||||
if (driverTransitId == null) return false;
|
||||
Future<bool> reportDelay(TransitDriverTrip trip, int minutes,
|
||||
{String? reason}) async {
|
||||
final res = await TransitDriverService.reportDelay(
|
||||
tripId: trip.id,
|
||||
driverTransitId: driverTransitId!,
|
||||
delayMinutes: minutes,
|
||||
reason: reason,
|
||||
);
|
||||
if (!res.success) Get.snackbar('مواصلاتي', res.message);
|
||||
return res.success;
|
||||
}
|
||||
|
||||
// ── كشف الوصول للمحطات (جيوفينس) ────────────────────────────
|
||||
// تُستدعى من LocationController عند كل تحديث للموقع أثناء وضع الباص
|
||||
void onLocationUpdate(LatLng pos) {
|
||||
if (activeTrip == null || activeTrip!.stops.isEmpty) return;
|
||||
|
||||
final stops = activeTrip!.stops;
|
||||
int? nextSeq;
|
||||
|
||||
// الاتجاه للمحطة التالية بعد آخر معلنة
|
||||
for (final stop in stops) {
|
||||
if (stop.sequence <= _lastAnnouncedStopSeq) continue;
|
||||
final dist = Geolocator.distanceBetween(
|
||||
pos.latitude, pos.longitude,
|
||||
stop.latitude, stop.longitude,
|
||||
);
|
||||
if (dist <= stop.geofenceRadius) {
|
||||
nextSeq = stop.sequence;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextSeq != null && nextSeq > _lastAnnouncedStopSeq) {
|
||||
_lastAnnouncedStopSeq = nextSeq;
|
||||
// أرسل التسلسل الحالي عبر السوكيت
|
||||
if (Get.isRegistered<LocationController>()) {
|
||||
final lc = Get.find<LocationController>();
|
||||
lc.emitBusLocationToSocket(pos, 0, 0, currentStopSeq: nextSeq);
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
// عودة بالمحطة الحالية للعرض
|
||||
TransitStop? get currentStop {
|
||||
if (activeTrip == null || _lastAnnouncedStopSeq == 0) return null;
|
||||
try {
|
||||
return activeTrip!.stops
|
||||
.firstWhere((s) => s.sequence == _lastAnnouncedStopSeq);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,29 +3,35 @@
|
||||
class TransitStopInfo {
|
||||
final int sequence;
|
||||
final String nameAr;
|
||||
final double lat;
|
||||
final double lng;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final double geofenceRadius; // متر
|
||||
final int? etaOffsetMin;
|
||||
|
||||
TransitStopInfo({
|
||||
required this.sequence,
|
||||
required this.nameAr,
|
||||
required this.lat,
|
||||
required this.lng,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
this.geofenceRadius = 150,
|
||||
this.etaOffsetMin,
|
||||
});
|
||||
|
||||
factory TransitStopInfo.fromJson(Map<String, dynamic> j) => TransitStopInfo(
|
||||
sequence: int.tryParse(j['sequence'].toString()) ?? 0,
|
||||
nameAr: j['name_ar']?.toString() ?? '',
|
||||
lat: double.tryParse(j['latitude']?.toString() ?? '0') ?? 0,
|
||||
lng: double.tryParse(j['longitude']?.toString() ?? '0') ?? 0,
|
||||
latitude: double.tryParse(j['latitude']?.toString() ?? '0') ?? 0,
|
||||
longitude: double.tryParse(j['longitude']?.toString() ?? '0') ?? 0,
|
||||
geofenceRadius: double.tryParse(j['geofence_radius']?.toString() ?? '150') ?? 150,
|
||||
etaOffsetMin: j['eta_offset_min'] == null
|
||||
? null
|
||||
: int.tryParse(j['eta_offset_min'].toString()),
|
||||
);
|
||||
}
|
||||
|
||||
// alias للتوافق مع كود الجيوفينس
|
||||
typedef TransitStop = TransitStopInfo;
|
||||
|
||||
class TransitDriverTrip {
|
||||
final int id;
|
||||
final int routeId;
|
||||
|
||||
@@ -29,13 +29,23 @@ class TransitDriverService {
|
||||
return TransitApiResult(false, null, _errMsg(res));
|
||||
}
|
||||
|
||||
/// رحلات اليوم (تُنشأ تلقائياً من الجداول عند أول استدعاء)
|
||||
static Future<TransitApiResult<List<TransitDriverTrip>>> getTodayTrips(
|
||||
int driverTransitId) async {
|
||||
/// تفعيل حساب السائق بتوكن الدعوة (بعد IDOR fix لا نحتاج driver_transit_id)
|
||||
static Future<TransitApiResult<Map<String, dynamic>>> activateByInviteToken(
|
||||
String inviteToken) async {
|
||||
final res = await CRUD().post(
|
||||
link: '$_base/trip/today.php',
|
||||
payload: {'driver_transit_id': driverTransitId.toString()},
|
||||
link: '$_base/driver/activate_by_app.php',
|
||||
payload: {'invite_token': inviteToken},
|
||||
);
|
||||
if (res is Map && res['status'] == 'success' && res['message'] is Map) {
|
||||
return TransitApiResult(
|
||||
true, Map<String, dynamic>.from(res['message']), 'ok');
|
||||
}
|
||||
return TransitApiResult(false, null, _errMsg(res));
|
||||
}
|
||||
|
||||
/// رحلات اليوم — الخادم يجلب السائق من JWT، لا نمرر driver_transit_id
|
||||
static Future<TransitApiResult<List<TransitDriverTrip>>> getTodayTrips() async {
|
||||
final res = await CRUD().post(link: '$_base/trip/today.php');
|
||||
if (res is Map && res['status'] == 'success' && res['message'] is Map) {
|
||||
final msg = res['message'] as Map;
|
||||
final list = (msg['trips'] is List)
|
||||
@@ -50,7 +60,6 @@ class TransitDriverService {
|
||||
|
||||
static Future<TransitApiResult<Map<String, dynamic>>> startTrip({
|
||||
required int tripId,
|
||||
required int driverTransitId,
|
||||
required double lat,
|
||||
required double lng,
|
||||
}) async {
|
||||
@@ -58,7 +67,6 @@ class TransitDriverService {
|
||||
link: '$_base/trip/start.php',
|
||||
payload: {
|
||||
'trip_id': tripId.toString(),
|
||||
'driver_transit_id': driverTransitId.toString(),
|
||||
'lat': lat.toString(),
|
||||
'lng': lng.toString(),
|
||||
},
|
||||
@@ -71,14 +79,10 @@ class TransitDriverService {
|
||||
|
||||
static Future<TransitApiResult<Map<String, dynamic>>> endTrip({
|
||||
required int tripId,
|
||||
required int driverTransitId,
|
||||
}) async {
|
||||
final res = await CRUD().post(
|
||||
link: '$_base/trip/end.php',
|
||||
payload: {
|
||||
'trip_id': tripId.toString(),
|
||||
'driver_transit_id': driverTransitId.toString(),
|
||||
},
|
||||
payload: {'trip_id': tripId.toString()},
|
||||
);
|
||||
if (res is Map && res['status'] == 'success') {
|
||||
return TransitApiResult(true, Map<String, dynamic>.from(res['message'] ?? {}), 'ok');
|
||||
@@ -88,7 +92,6 @@ class TransitDriverService {
|
||||
|
||||
static Future<TransitApiResult<void>> reportDelay({
|
||||
required int tripId,
|
||||
required int driverTransitId,
|
||||
required int delayMinutes,
|
||||
String? reason,
|
||||
}) async {
|
||||
@@ -96,7 +99,6 @@ class TransitDriverService {
|
||||
link: '$_base/trip/delay.php',
|
||||
payload: {
|
||||
'trip_id': tripId.toString(),
|
||||
'driver_transit_id': driverTransitId.toString(),
|
||||
'delay_minutes': delayMinutes.toString(),
|
||||
if (reason != null) 'reason': reason,
|
||||
},
|
||||
|
||||
@@ -18,6 +18,7 @@ class TransitDriverHomePage extends StatelessWidget {
|
||||
|
||||
return GetBuilder<TransitDriverController>(
|
||||
builder: (c) {
|
||||
// ── حالة التحميل ─────────────────────────────────────────
|
||||
if (c.isCheckingBusDriver) {
|
||||
return MyScafolld(
|
||||
title: 'Mawasalati'.tr,
|
||||
@@ -26,37 +27,22 @@ class TransitDriverHomePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// ── حساب غير مفعّل — شاشة إدخال التوكن ─────────────────
|
||||
if (!c.isBusDriver) {
|
||||
return MyScafolld(
|
||||
title: 'Mawasalati'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Text(
|
||||
'This account is not registered as a bus driver in any institution'.tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
return _ActivationPage(controller: c);
|
||||
}
|
||||
|
||||
// ── رحلات اليوم ──────────────────────────────────────────
|
||||
return MyScafolld(
|
||||
title: c.orgName,
|
||||
isleading: true,
|
||||
body: [
|
||||
Column(
|
||||
children: [
|
||||
// بانر المحطة الحالية إن كانت هناك رحلة نشطة
|
||||
if (c.activeTrip != null && c.currentStop != null)
|
||||
_CurrentStopBanner(stop: c.currentStop!),
|
||||
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: c.fetchTodayTrips,
|
||||
@@ -96,7 +82,8 @@ class TransitDriverHomePage extends StatelessWidget {
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: BorderSide(color: isStarted ? AppColor.greenColor : AppColor.borderColor,
|
||||
side: BorderSide(
|
||||
color: isStarted ? AppColor.greenColor : AppColor.borderColor,
|
||||
width: isStarted ? 1.5 : 1),
|
||||
),
|
||||
child: Padding(
|
||||
@@ -121,7 +108,8 @@ class TransitDriverHomePage extends StatelessWidget {
|
||||
if (trip.delayMinutes > 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text('${'Delayed by'.tr} ${trip.delayMinutes} ${'min'.tr}',
|
||||
child: Text(
|
||||
'${'Delayed by'.tr} ${trip.delayMinutes} ${'min'.tr}',
|
||||
style: AppStyle.subtitle.copyWith(color: AppColor.yellowColor)),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
@@ -178,3 +166,136 @@ class TransitDriverHomePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ── شاشة التفعيل بتوكن الدعوة ──────────────────────────────────────────────
|
||||
|
||||
class _ActivationPage extends StatelessWidget {
|
||||
final TransitDriverController controller;
|
||||
const _ActivationPage({required this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tokenCtrl = TextEditingController();
|
||||
|
||||
return MyScafolld(
|
||||
title: 'Mawasalati'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 40),
|
||||
Container(
|
||||
width: 88,
|
||||
height: 88,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.accentColor.withOpacity(0.12),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(Icons.directions_bus_rounded,
|
||||
size: 46, color: AppColor.accentColor),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'This account is not registered as a bus driver in any institution'.tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Activate Bus Driver Account'.tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
TextField(
|
||||
controller: tokenCtrl,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Invite Token'.tr,
|
||||
hintText: 'Paste the token from the WhatsApp message'.tr,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 14),
|
||||
),
|
||||
),
|
||||
if (controller.activationError.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
controller.activationError,
|
||||
style: AppStyle.subtitle.copyWith(color: AppColor.redColor),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: controller.isActivating
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.accentColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
onPressed: () =>
|
||||
controller.activateWithToken(tokenCtrl.text),
|
||||
child: Text(
|
||||
'Activate'.tr,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextButton(
|
||||
onPressed: controller.checkBusDriverStatus,
|
||||
child: Text('Refresh'.tr,
|
||||
style: AppStyle.subtitle.copyWith(color: AppColor.accentColor)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ── بانر المحطة الحالية ──────────────────────────────────────────────────────
|
||||
|
||||
class _CurrentStopBanner extends StatelessWidget {
|
||||
final TransitStopInfo stop;
|
||||
const _CurrentStopBanner({required this.stop});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
color: AppColor.greenColor.withOpacity(0.12),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.location_on_rounded, color: AppColor.greenColor, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${'Now at'.tr}: ${stop.nameAr}',
|
||||
style: AppStyle.subtitle.copyWith(
|
||||
color: AppColor.greenColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user