Update: 2026-07-13 18:23:52

This commit is contained in:
Hamza-Ayed
2026-07-13 18:23:52 +03:00
parent 7bf6dc1be7
commit fd3f4a365a
23 changed files with 802 additions and 31 deletions
@@ -2693,4 +2693,19 @@ final Map<String, String> ar_jo = {
"Destination cleared!": "تم مسح الوجهة الشخصية!",
"Move map to select destination": "حرك الخريطة لتحديد الوجهة الشخصية",
"service_unavailable_area": "هذه الخدمة غير متوفرة حالياً في منطقتك",
"بطاقة الصعود (Boarding Pass)": "بطاقة الصعود (Boarding Pass)",
"بطاقة الصعود": "بطاقة الصعود",
"يرجى إبراز هذا الرمز للسائق عند الصعود للحافلة": "يرجى إبراز هذا الرمز للسائق عند الصعود للحافلة",
"مسافر موثق": "مسافر موثق",
"Now at": "الآن في",
"Scan": "مسح",
"Scan Passengers": "مسح الركاب",
"Manual Passenger List": "القائمة اليدوية",
"Manual List": "القائمة اليدوية",
"تم صعود الراكب بنجاح ✅": "تم صعود الراكب بنجاح ✅",
"فشل التحقق ❌": "فشل التحقق ❌",
"تم تسجيل حضور الراكب": "تم تسجيل حضور الراكب",
"فشل تسجيل الحضور": "فشل تسجيل الحضور",
"لا يوجد ركاب مسجلين في هذه المحطة": "لا يوجد ركاب مسجلين في هذه المحطة",
"حاضر": "حاضر",
};
+16
View File
@@ -1603,6 +1603,22 @@ final Map<String, String> en = {
"Submit Your Complaint": "Submit Your Complaint",
"Submit Your Question": "Submit Your Question",
"Submit a Complaint": "Submit a Complaint",
"your current rating": "your current rating",
"بطاقة الصعود (Boarding Pass)": "Boarding Pass",
"بطاقة الصعود": "Boarding Pass",
"يرجى إبراز هذا الرمز للسائق عند الصعود للحافلة": "Please show this code to the driver when boarding the bus",
"مسافر موثق": "Verified Passenger",
"Now at": "Now at",
"Scan": "Scan",
"Scan Passengers": "Scan Passengers",
"Manual Passenger List": "Manual Passenger List",
"Manual List": "Manual List",
"تم صعود الراكب بنجاح ✅": "Passenger boarded successfully ✅",
"فشل التحقق ❌": "Verification failed ❌",
"تم تسجيل حضور الراكب": "Passenger attendance recorded",
"فشل تسجيل الحضور": "Failed to record attendance",
"لا يوجد ركاب مسجلين في هذه المحطة": "No passengers registered at this stop",
"حاضر": "Present",
"Submit rating": "Submit rating",
"Success": "Success",
"Suez Canal Bank": "Suez Canal Bank",
@@ -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));
}
}
@@ -0,0 +1,112 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
import '../../controller/transit/transit_driver_controller.dart';
import '../widgets/elevated_btn.dart';
import '../widgets/error_snakbar.dart';
class ManualBoardingPage extends StatefulWidget {
final int stopId;
final String stopName;
const ManualBoardingPage({super.key, required this.stopId, required this.stopName});
@override
State<ManualBoardingPage> createState() => _ManualBoardingPageState();
}
class _ManualBoardingPageState extends State<ManualBoardingPage> {
bool isLoading = true;
List<Map<String, dynamic>> passengers = [];
@override
void initState() {
super.initState();
_loadPassengers();
}
Future<void> _loadPassengers() async {
final c = Get.find<TransitDriverController>();
// For now, this is a placeholder. You'll need to add getStopPassengers in the controller.
final result = await c.getStopPassengers(widget.stopId);
if (mounted) {
setState(() {
passengers = result;
isLoading = false;
});
}
}
void _markBoarded(int index) async {
final c = Get.find<TransitDriverController>();
final pId = passengers[index]['passenger_id']?.toString() ?? '';
if (pId.isEmpty) return;
final success = await c.boardPassenger(widget.stopId, pId);
if (success && mounted) {
setState(() {
passengers[index]['is_boarded'] = true;
});
mySnackbarSuccess('تم تسجيل حضور الراكب'.tr);
} else {
mySnackbarError('فشل تسجيل الحضور'.tr);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.secondaryColor,
appBar: AppBar(
title: Text('${'Manual List'.tr} - ${widget.stopName}', style: AppStyle.headTitle2.copyWith(color: AppColor.writeColor)),
backgroundColor: AppColor.secondaryColor,
elevation: 0,
iconTheme: IconThemeData(color: AppColor.writeColor),
),
body: isLoading
? const Center(child: CircularProgressIndicator())
: passengers.isEmpty
? Center(child: Text('لا يوجد ركاب مسجلين في هذه المحطة'.tr))
: ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: passengers.length,
itemBuilder: (context, index) {
final p = passengers[index];
final isBoarded = p['is_boarded'] == true;
return Container(
margin: const EdgeInsets.only(bottom: 12),
decoration: BoxDecoration(
color: AppColor.cardColor,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 10, offset: const Offset(0, 2))
],
),
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
leading: CircleAvatar(
backgroundColor: isBoarded ? AppColor.greenColor.withOpacity(0.2) : AppColor.grayColor.withOpacity(0.2),
child: Icon(Icons.person, color: isBoarded ? AppColor.greenColor : AppColor.grayColor),
),
title: Text(p['name'] ?? 'Unknown', style: AppStyle.title.copyWith(fontWeight: FontWeight.bold)),
subtitle: Text('ID: ${p['student_id'] ?? p['passenger_id']}', style: AppStyle.subtitle.copyWith(color: AppColor.grayColor)),
trailing: isBoarded
? const Icon(Icons.check_circle, color: AppColor.greenColor, size: 28)
: SizedBox(
width: 80,
height: 35,
child: MyElevatedButton(
title: 'حاضر'.tr,
kolor: AppColor.accentColor,
onPressed: () => _markBoarded(index),
),
),
),
);
},
),
);
}
}
@@ -0,0 +1,159 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:audioplayers/audioplayers.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
import '../../controller/transit/transit_driver_controller.dart';
import '../widgets/elevated_btn.dart';
import 'manual_boarding_page.dart';
class QRScannerPage extends StatefulWidget {
final int stopId;
final String stopName;
const QRScannerPage({super.key, required this.stopId, required this.stopName});
@override
State<QRScannerPage> createState() => _QRScannerPageState();
}
class _QRScannerPageState extends State<QRScannerPage> {
final MobileScannerController _scannerController = MobileScannerController();
final AudioPlayer _audioPlayer = AudioPlayer();
bool _isProcessing = false;
String _successMessage = '';
@override
void dispose() {
_scannerController.dispose();
_audioPlayer.dispose();
super.dispose();
}
void _onDetect(BarcodeCapture capture) async {
if (_isProcessing) return;
final List<Barcode> barcodes = capture.barcodes;
if (barcodes.isEmpty) return;
final String? code = barcodes.first.rawValue;
if (code == null || !code.startsWith('transit_board:')) return;
setState(() {
_isProcessing = true;
});
final passengerId = code.replaceAll('transit_board:', '');
// Play beep sound
try {
// Assuming you might add a beep sound asset later, or just visual feedback for now.
// await _audioPlayer.play(AssetSource('sounds/beep.mp3'));
} catch (_) {}
// Send API Request
final c = Get.find<TransitDriverController>();
final success = await c.boardPassenger(widget.stopId, passengerId);
if (success) {
setState(() {
_successMessage = 'تم صعود الراكب بنجاح ✅'.tr;
});
// Clear message after 1.5s
Future.delayed(const Duration(milliseconds: 1500), () {
if (mounted) {
setState(() {
_successMessage = '';
_isProcessing = false;
});
}
});
} else {
setState(() {
_successMessage = 'فشل التحقق ❌'.tr;
});
Future.delayed(const Duration(milliseconds: 2000), () {
if (mounted) {
setState(() {
_successMessage = '';
_isProcessing = false;
});
}
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: Text('${'Scan Passengers'.tr} - ${widget.stopName}', style: AppStyle.headTitle2.copyWith(color: Colors.white)),
backgroundColor: Colors.transparent,
elevation: 0,
iconTheme: const IconThemeData(color: Colors.white),
),
body: Stack(
children: [
MobileScanner(
controller: _scannerController,
onDetect: _onDetect,
),
// Overlay for scanner target
Center(
child: Container(
width: 250,
height: 250,
decoration: BoxDecoration(
border: Border.all(color: AppColor.accentColor, width: 3),
borderRadius: BorderRadius.circular(20),
),
),
),
// Processing Overlay
if (_isProcessing && _successMessage.isEmpty)
Container(
color: Colors.black54,
child: const Center(
child: CircularProgressIndicator(color: AppColor.accentColor),
),
),
// Success / Error Message Overlay
if (_successMessage.isNotEmpty)
Container(
color: _successMessage.contains('✅') ? Colors.green.withValues(alpha: 0.8) : Colors.red.withValues(alpha: 0.8),
child: Center(
child: Text(
_successMessage,
style: AppStyle.headTitle2.copyWith(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
// Fallback manual list button
Positioned(
bottom: 40,
left: 20,
right: 20,
child: SizedBox(
height: 55,
child: MyElevatedButton(
onPressed: () {
Get.to(() => ManualBoardingPage(stopId: widget.stopId, stopName: widget.stopName));
},
kolor: AppColor.cardColor,
title: 'Manual Passenger List'.tr,
),
),
),
],
),
);
}
}
@@ -8,6 +8,7 @@ import '../../controller/transit/transit_driver_controller.dart';
import '../../controller/transit/transit_driver_models.dart';
import '../widgets/elevated_btn.dart';
import '../widgets/my_scafold.dart';
import 'qr_scanner_page.dart';
class TransitDriverHomePage extends StatelessWidget {
const TransitDriverHomePage({super.key});
@@ -194,7 +195,7 @@ class _ActivationPage extends StatelessWidget {
width: 88,
height: 88,
decoration: BoxDecoration(
color: AppColor.accentColor.withOpacity(0.12),
color: AppColor.accentColor.withValues(alpha: 0.12),
shape: BoxShape.circle,
),
child: Icon(Icons.directions_bus_rounded,
@@ -236,24 +237,14 @@ class _ActivationPage extends StatelessWidget {
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
height: 55,
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)),
),
: MyElevatedButton(
kolor: AppColor.accentColor,
onPressed: () =>
controller.activateWithToken(tokenCtrl.text),
child: Text(
'Activate'.tr,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold),
),
title: 'Activate'.tr,
),
),
const SizedBox(height: 16),
@@ -284,15 +275,28 @@ class _CurrentStopBanner extends StatelessWidget {
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
color: AppColor.greenColor.withOpacity(0.12),
color: AppColor.greenColor.withValues(alpha: 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),
Expanded(
child: Text(
'${'Now at'.tr}: ${stop.nameAr}',
style: AppStyle.subtitle.copyWith(
color: AppColor.greenColor, fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 35,
width: 80,
child: MyElevatedButton(
onPressed: () {
Get.to(() => QRScannerPage(stopId: stop.id, stopName: stop.nameAr));
},
kolor: AppColor.accentColor,
title: 'Scan'.tr,
),
),
],
),
@@ -6,6 +6,7 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_linux/audioplayers_linux_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
@@ -13,6 +14,9 @@
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin");
audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar);
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux
file_selector_linux
flutter_secure_storage_linux
flutter_webrtc
@@ -6,6 +6,7 @@ import FlutterMacOS
import Foundation
import audio_session
import audioplayers_darwin
import battery_plus
import connectivity_plus
import device_info_plus
@@ -24,6 +25,7 @@ import geolocator_apple
import just_audio
import local_auth_darwin
import location
import mobile_scanner
import package_info_plus
import record_macos
import share_plus
@@ -36,6 +38,7 @@ import webview_flutter_wkwebview
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
BatteryPlusMacosPlugin.register(with: registry.registrar(forPlugin: "BatteryPlusMacosPlugin"))
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
@@ -54,6 +57,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin"))
MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
RecordMacOsPlugin.register(with: registry.registrar(forPlugin: "RecordMacOsPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
+64
View File
@@ -73,6 +73,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.3"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
sha256: f16640453cc47487b7de72a2b28d37c7df1ac97999849f4a46d92b1d2b0f093d
url: "https://pub.dev"
source: hosted
version: "6.7.1"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
sha256: "60a6728277228413a85755bd3ffd6fab98f6555608923813ce383b190a360605"
url: "https://pub.dev"
source: hosted
version: "5.2.1"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
sha256: c994b3bb3a921e4904ac40e013fbc94488e824fd7c1de6326f549943b0b44a91
url: "https://pub.dev"
source: hosted
version: "6.4.0"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
sha256: f75bce1ce864170ef5e6a2c6a61cd3339e1a17ce11e99a25bae4474ea491d001
url: "https://pub.dev"
source: hosted
version: "4.2.1"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
sha256: "0e2f6a919ab56d0fec272e801abc07b26ae7f31980f912f24af4748763e5a656"
url: "https://pub.dev"
source: hosted
version: "7.1.1"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
sha256: "24a6f258062bd7da8cb2157e83fccb9816a08dd306cbaaa24f9813d071470545"
url: "https://pub.dev"
source: hosted
version: "5.2.1"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
sha256: "95f875a96c88c3dbbcb608d4f8288e300b0113d256a81d0b3197fcc18f0dc91a"
url: "https://pub.dev"
source: hosted
version: "4.3.1"
battery_plus:
dependency: "direct main"
description:
@@ -1492,6 +1548,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
mobile_scanner:
dependency: "direct main"
description:
name: mobile_scanner
sha256: "0b466a0a8a211b366c2e87f3345715faef9b6011c7147556ad22f37de6ba3173"
url: "https://pub.dev"
source: hosted
version: "6.0.11"
nested:
dependency: transitive
description:
+2
View File
@@ -58,6 +58,8 @@ dependencies:
flutter_tts: ^4.0.2
geolocator: ^14.0.2
image_cropper: ^12.1.1
mobile_scanner: ^6.0.4
audioplayers: ^6.0.0
image_picker: ^1.0.4
internet_connection_checker: ^3.0.1
jailbreak_root_detection: ^1.1.5
@@ -6,6 +6,7 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <battery_plus/battery_plus_windows_plugin.h>
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <file_selector_windows/file_selector_windows.h>
@@ -23,6 +24,8 @@
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
BatteryPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BatteryPlusWindowsPlugin"));
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows
battery_plus
connectivity_plus
file_selector_windows