Update: 2026-07-12 05:40:28
This commit is contained in:
@@ -32,6 +32,7 @@ import '../../../../constant/colors.dart';
|
||||
import '../About Us/video_page.dart';
|
||||
import '../assurance_health_page.dart';
|
||||
import '../maintain_center_page.dart';
|
||||
import '../../../transit/transit_driver_home_page.dart';
|
||||
|
||||
// 1. إنشاء Class لتعريف بيانات كل عنصر في القائمة
|
||||
class DrawerItem {
|
||||
@@ -55,6 +56,11 @@ class AppDrawer extends StatelessWidget {
|
||||
|
||||
// 2. تعريف بيانات القائمة بشكل مركزي ومنظم
|
||||
final List<DrawerItem> drawerItems = [
|
||||
DrawerItem(
|
||||
title: 'Mawasalati'.tr,
|
||||
icon: Icons.directions_bus_filled_rounded,
|
||||
color: Colors.teal,
|
||||
onTap: () => Get.to(() => const TransitDriverHomePage())),
|
||||
DrawerItem(
|
||||
title: 'Balance'.tr,
|
||||
icon: Icons.account_balance_wallet,
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
// transit_driver_home_page.dart — رحلات اليوم لسائق الباص (مواصلاتي)
|
||||
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 '../../controller/transit/transit_driver_models.dart';
|
||||
import '../widgets/elevated_btn.dart';
|
||||
import '../widgets/my_scafold.dart';
|
||||
|
||||
class TransitDriverHomePage extends StatelessWidget {
|
||||
const TransitDriverHomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(TransitDriverController());
|
||||
|
||||
return GetBuilder<TransitDriverController>(
|
||||
builder: (c) {
|
||||
if (c.isCheckingBusDriver) {
|
||||
return MyScafolld(
|
||||
title: 'Mawasalati'.tr,
|
||||
isleading: true,
|
||||
body: const [Expanded(child: Center(child: CircularProgressIndicator()))],
|
||||
);
|
||||
}
|
||||
|
||||
if (!c.isBusDriver) {
|
||||
return MyScafolld(
|
||||
title: 'Mawasalati'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
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 MyScafolld(
|
||||
title: c.orgName,
|
||||
isleading: true,
|
||||
body: [
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: c.fetchTodayTrips,
|
||||
child: c.isLoadingTrips
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: c.todayTrips.isEmpty
|
||||
? ListView(
|
||||
children: [
|
||||
const SizedBox(height: 80),
|
||||
Center(
|
||||
child: Text('No trips today'.tr, style: AppStyle.title),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: c.todayTrips.length,
|
||||
itemBuilder: (_, i) => _tripCard(c, c.todayTrips[i]),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tripCard(TransitDriverController c, TransitDriverTrip trip) {
|
||||
final isStarted = trip.status == 'started';
|
||||
final isCompleted = trip.status == 'completed';
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 14),
|
||||
color: AppColor.cardColor,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: BorderSide(color: isStarted ? AppColor.greenColor : AppColor.borderColor,
|
||||
width: isStarted ? 1.5 : 1),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.directions_bus, color: AppColor.accentColor),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(trip.routeName,
|
||||
style: AppStyle.title.copyWith(fontWeight: FontWeight.bold)),
|
||||
),
|
||||
if (trip.departureTime != null)
|
||||
Text(trip.departureTime!, style: AppStyle.subtitle),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text('${trip.stops.length} ${'Stops'.tr}', style: AppStyle.subtitle),
|
||||
if (trip.delayMinutes > 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text('${'Delayed by'.tr} ${trip.delayMinutes} ${'min'.tr}',
|
||||
style: AppStyle.subtitle.copyWith(color: AppColor.yellowColor)),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
if (!isCompleted)
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: MyElevatedButton(
|
||||
title: isStarted ? 'End Trip'.tr : 'Start Trip'.tr,
|
||||
kolor: isStarted ? AppColor.redColor : AppColor.greenColor,
|
||||
onPressed: c.isActionInProgress
|
||||
? () {}
|
||||
: () => isStarted ? c.endTrip(trip) : c.startTrip(trip),
|
||||
),
|
||||
),
|
||||
if (isStarted) ...[
|
||||
const SizedBox(width: 8),
|
||||
IconButton(
|
||||
icon: Icon(Icons.report_gmailerrorred, color: AppColor.yellowColor),
|
||||
onPressed: () => _showDelayDialog(c, trip),
|
||||
),
|
||||
],
|
||||
],
|
||||
)
|
||||
else
|
||||
Text('Trip completed'.tr,
|
||||
style: AppStyle.subtitle.copyWith(color: AppColor.greenColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDelayDialog(TransitDriverController c, TransitDriverTrip trip) {
|
||||
final ctrl = TextEditingController(text: '5');
|
||||
Get.defaultDialog(
|
||||
title: 'Report Delay'.tr,
|
||||
content: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: ctrl,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(labelText: 'Number of minutes'.tr),
|
||||
),
|
||||
],
|
||||
),
|
||||
textConfirm: 'Send'.tr,
|
||||
textCancel: 'Cancel'.tr,
|
||||
onConfirm: () {
|
||||
final minutes = int.tryParse(ctrl.text.trim()) ?? 5;
|
||||
c.reportDelay(trip, minutes);
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user