Update: 2026-07-12 18:53:59

This commit is contained in:
Hamza-Ayed
2026-07-12 18:53:59 +03:00
parent 8cd4a4b57e
commit 653d73422f
54 changed files with 2078 additions and 436 deletions
@@ -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),
),
],
),
);
}
}