إصلاح أخطاء شاشة الكباتن من تحديث الذكاء الاصطناعي

This commit is contained in:
Hamza-Ayed
2026-07-26 13:15:45 +03:00
parent 4b5235c35c
commit 330dfc6dba
9 changed files with 1025 additions and 61 deletions
@@ -40,15 +40,14 @@ class RideAdminController extends GetxController {
}
Future getRidesDetails() async {
// isLoading = true;
// update();
isLoading = true;
update();
var res = await CRUD().get(link: AppLink.getRidesDetails, payload: {});
var d = jsonDecode(res);
ridesDetails = d['message'];
// isLoading = false;
// update();
isLoading = false;
update();
}
@override
@@ -176,19 +176,21 @@ class WalletAdminController extends GetxController {
return token;
}
Future getWalletForEachDriverToPay() async {
Future getWalletForEachDriverToPay() async {
isLoading = true;
update();
var res = await CRUD()
.postWallet(link: AppLink.getVisaForEachDriver, payload: {});
var d = (res);
if (d != 'failure') {
driversWalletPoints = d['message'];
driversWalletPoints = d['message'] ?? [];
isLoading = false;
update();
} else {
driversWalletPoints = [];
isLoading = false;
update();
}
driversWalletPoints = [];
isLoading = false;
update();
}
}
}
@@ -5,22 +5,29 @@ import '../../views/widgets/snackbar.dart';
import '../functions/crud.dart';
class DriverController extends GetxController {
bool isLoading = false;
List drivers = [];
Map driverDetails = {};
// جلب السائقين pending
getDriversPending() async {
isLoading = true;
update();
var res = await CRUD().post(
link: AppLink.getDriversPending, // رابط drivers_pending_list.php
link: AppLink.getDriversPending,
payload: {},
);
if (res != 'failure') {
drivers = (res)['message'];
update(['drivers']); // تحديث الـ UI
isLoading = false;
update(['drivers']);
} else {
mySnackbarError('Failed to load drivers');
isLoading = false;
update();
}
}
}
// جلب تفاصيل سائق واحد
getDriverDetails(String driverId) async {
@@ -23,13 +23,16 @@ class DriversPendingPage extends StatelessWidget {
body: Column(
children: [
_buildAppBar(context, cs),
Expanded(
Expanded(
child: GetBuilder<DriverController>(
id: 'drivers',
builder: (c) { if (c.drivers.isEmpty) {
builder: (c) {
if (c.isLoading) {
return _buildLoadingState(cs);
}
if (c.drivers.isEmpty) {
return _buildEmptyState(cs);
}
return RefreshIndicator(
onRefresh: () => controller.getDriversPending(),
color: cs.primary,
@@ -147,13 +147,16 @@ class BlacklistPage extends StatelessWidget {
itemCount: controller.driversBlacklist.length,
itemBuilder: (context, index) {
var driver = controller.driversBlacklist[index];
final String phone = (driver['phone'] ?? driver['phone_normalized'] ?? driver['mobile'] ?? driver['number'] ?? '').toString();
final String reason = (driver['reason'] ?? driver['block_reason'] ?? driver['note'] ?? 'غير محدد').toString();
final String date = (driver['created_at'] ?? driver['createdAt'] ?? driver['date'] ?? driver['blocked_at'] ?? '').toString();
return _buildBlacklistItem(
phone: driver['phone'],
reason: driver['reason'] ?? 'غير محدد',
date: driver['created_at'],
phone: phone,
reason: reason,
date: date,
type: 'سائق',
icon: Icons.drive_eta_rounded,
onUnblock: () => controller.unblockDriver(driver['phone'].toString()),
onUnblock: () => controller.unblockDriver(phone),
cs: cs,
);
},
@@ -170,14 +173,17 @@ class BlacklistPage extends StatelessWidget {
itemCount: controller.passengersBlacklist.length,
itemBuilder: (context, index) {
var passenger = controller.passengersBlacklist[index];
final String phone = (passenger['phone'] ?? passenger['phone_normalized'] ?? passenger['mobile'] ?? passenger['number'] ?? '').toString();
final String reason = (passenger['reason'] ?? passenger['block_reason'] ?? passenger['note'] ?? 'غير محدد').toString();
final String date = (passenger['created_at'] ?? passenger['createdAt'] ?? passenger['date'] ?? passenger['blocked_at'] ?? '').toString();
final String phoneForUnblock = (passenger['phone_normalized'] ?? passenger['phone'] ?? passenger['mobile'] ?? passenger['number'] ?? '').toString();
return _buildBlacklistItem(
phone: passenger['phone'] ?? passenger['phone_normalized'],
reason: passenger['reason'] ?? 'غير محدد',
date: passenger['created_at'],
phone: phone,
reason: reason,
date: date,
type: 'راكب',
icon: Icons.person_rounded,
onUnblock: () => controller.unblockPassenger(
passenger['phone_normalized'].toString()),
onUnblock: () => controller.unblockPassenger(phoneForUnblock),
cs: cs,
);
},
@@ -204,11 +204,6 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
late final RidesListController controller;
late TabController _tabController;
// 🎨 الألوان العصرية
final Color bgColor = const Color(0xFFF4F7FE);
final Color primaryColor = const Color(0xFF4318FF);
final Color textPrimary = const Color(0xFF2B3674);
@override
void initState() {
super.initState();
@@ -232,10 +227,11 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: bgColor,
backgroundColor: cs.surface,
body: SafeArea(
top: false, // نسمح للـ AppBar بالتمدد لأعلى الشاشة
top: false,
child: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
@@ -243,16 +239,16 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
SliverAppBar(
pinned: true,
floating: false,
expandedHeight: 310.0, // ارتفاع الجزء العلوي بالكامل
backgroundColor: primaryColor,
expandedHeight: 310.0,
backgroundColor: cs.primary,
elevation: 4,
shadowColor: primaryColor.withOpacity(0.4),
iconTheme: const IconThemeData(color: Colors.white),
shadowColor: cs.primary.withValues(alpha: 0.4),
iconTheme: IconThemeData(color: cs.onPrimary),
centerTitle: true,
title: const Text(
title: Text(
'إدارة الرحلات',
style: TextStyle(
color: Colors.white,
color: cs.onPrimary,
fontWeight: FontWeight.bold,
fontSize: 20,
),
@@ -263,16 +259,16 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
padding: const EdgeInsets.symmetric(horizontal: 14),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
color: cs.onPrimary.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(12),
),
alignment: Alignment.center,
child: const Text(
child: Text(
'اليوم',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.white,
color: cs.onPrimary,
),
),
),
@@ -281,7 +277,10 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
background: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [primaryColor, primaryColor.withOpacity(0.8)],
colors: [
cs.primary,
cs.primary.withValues(alpha: 0.8),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
@@ -290,12 +289,12 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
mainAxisAlignment: MainAxisAlignment.end,
children: [
// الإحصائيات تختفي عند التمرير لأعلى
_buildStatisticsSection(),
_buildStatisticsSection(cs),
const SizedBox(height: 12),
// شريط البحث يختفي عند التمرير لأعلى
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: _buildSearchBar(),
child: _buildSearchBar(cs),
),
const SizedBox(height: 60), // مساحة للـ TabBar بالأسفل
],
@@ -306,18 +305,17 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
bottom: PreferredSize(
preferredSize: const Size.fromHeight(54),
child: Container(
decoration: const BoxDecoration(
color:
Color(0xFFF4F7FE), // لون خلفية التطبيق ليظهر بشكل مدمج
decoration: BoxDecoration(
color: cs.surface,
borderRadius:
BorderRadius.vertical(top: Radius.circular(24)),
const BorderRadius.vertical(top: Radius.circular(24)),
),
child: TabBar(
controller: _tabController,
isScrollable: true,
labelColor: primaryColor,
unselectedLabelColor: Colors.grey,
indicatorColor: primaryColor,
labelColor: cs.primary,
unselectedLabelColor: cs.onSurfaceVariant,
indicatorColor: cs.primary,
indicatorWeight: 3,
labelStyle: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 14),
@@ -359,13 +357,13 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.inbox_rounded,
size: 80, color: Colors.grey[400]),
size: 80, color: cs.onSurfaceVariant),
const SizedBox(height: 16),
Text(
'لا توجد رحلات في هذا القسم',
style: TextStyle(
fontSize: 16,
color: Colors.grey[600],
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
@@ -380,7 +378,7 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
(context, index) {
final ride = controller.displayedRides[index];
return _buildRideCardCompact(
ride, controller.isSuperAdmin);
ride, controller.isSuperAdmin, cs);
},
childCount: controller.displayedRides.length,
),
@@ -395,7 +393,7 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
// --- Components ---
Widget _buildStatisticsSection() {
Widget _buildStatisticsSection(ColorScheme cs) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -446,17 +444,17 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
}
Widget _buildStatCard(
String label, String value, IconData icon, Color iconColor) {
String label, String value, IconData icon, Color iconColor, ColorScheme cs) {
return Container(
width: 105,
margin: const EdgeInsets.only(left: 10),
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
decoration: BoxDecoration(
color: Colors.white,
color: cs.surface,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
color: cs.shadow.withValues(alpha: 0.1),
blurRadius: 10,
offset: const Offset(0, 4),
)
@@ -470,7 +468,7 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
Text(
value,
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold, color: textPrimary),
fontSize: 18, fontWeight: FontWeight.bold, color: cs.onSurface),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@@ -479,7 +477,7 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
label,
style: TextStyle(
fontSize: 11,
color: Colors.grey[600],
color: cs.onSurfaceVariant,
fontWeight: FontWeight.bold),
),
],
@@ -487,7 +485,7 @@ class _RidesDashboardScreenState extends State<RidesDashboardScreen>
);
}
Widget _buildSearchBar() {
Widget _buildSearchBar(ColorScheme cs) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
@@ -0,0 +1,483 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class UnifiedAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final Widget? leading;
final List<Widget>? actions;
final Color? backgroundColor;
final Color? foregroundColor;
final double elevation;
final bool centerTitle;
final PreferredSizeWidget? bottom;
final double toolbarHeight;
const UnifiedAppBar({
super.key,
required this.title,
this.leading,
this.actions,
this.backgroundColor,
this.foregroundColor,
this.elevation = 0,
this.centerTitle = false,
this.bottom,
this.toolbarHeight = kToolbarHeight + 34,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final bgColor = backgroundColor ?? cs.surface;
return Container(
height: toolbarHeight,
padding: const EdgeInsets.fromLTRB(16, 50, 16, 16),
decoration: BoxDecoration(
color: bgColor,
border: Border(bottom: BorderSide(color: cs.outline, width: 0.5)),
),
child: SafeArea(
bottom: false,
child: Row(
children: [
leading ??
GestureDetector(
onTap: () => Get.back(),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: cs.outline),
),
child: Icon(
Icons.arrow_back_ios_new_rounded,
color: cs.onSurfaceVariant,
size: 16,
),
),
),
const SizedBox(width: 12),
Expanded(
child: Text(
title,
style: TextStyle(
color: foregroundColor ?? cs.onSurface,
fontSize: 18,
fontWeight: FontWeight.w700,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (actions != null) ...actions!,
],
),
),
);
}
@override
Size get preferredSize => Size.fromHeight(toolbarHeight);
}
class UnifiedAppBarWithTabs extends StatelessWidget implements PreferredSizeWidget {
final String title;
final List<Widget> tabs;
final TabController? tabController;
final Widget? leading;
final List<Widget>? actions;
final Color? backgroundColor;
final Color? foregroundColor;
final double elevation;
final EdgeInsetsGeometry? tabPadding;
const UnifiedAppBarWithTabs({
super.key,
required this.title,
required this.tabs,
this.tabController,
this.leading,
this.actions,
this.backgroundColor,
this.foregroundColor,
this.elevation = 0,
this.tabPadding,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final bgColor = backgroundColor ?? cs.surface;
return Container(
height: kToolbarHeight + 34 + 48,
padding: const EdgeInsets.fromLTRB(16, 50, 16, 16),
decoration: BoxDecoration(
color: bgColor,
border: Border(bottom: BorderSide(color: cs.outline, width: 0.5)),
),
child: SafeArea(
bottom: false,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
leading ??
GestureDetector(
onTap: () => Get.back(),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: cs.outline),
),
child: Icon(
Icons.arrow_back_ios_new_rounded,
color: cs.onSurfaceVariant,
size: 16,
),
),
),
const SizedBox(width: 12),
Expanded(
child: Text(
title,
style: TextStyle(
color: foregroundColor ?? cs.onSurface,
fontSize: 18,
fontWeight: FontWeight.w700,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (actions != null) ...actions!,
],
),
const SizedBox(height: 8),
Container(
padding: tabPadding ?? const EdgeInsets.all(4),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: cs.outline),
),
child: TabBar(
controller: tabController,
isScrollable: true,
indicator: BoxDecoration(
color: cs.primary.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: cs.primary.withValues(alpha: 0.3)),
),
indicatorSize: TabBarIndicatorSize.tab,
dividerColor: Colors.transparent,
labelColor: cs.primary,
unselectedLabelColor: cs.onSurfaceVariant,
labelStyle: const TextStyle(fontWeight: FontWeight.w700, fontSize: 13),
unselectedLabelStyle: const TextStyle(fontWeight: FontWeight.w500, fontSize: 13),
tabs: tabs,
),
),
],
),
),
);
}
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight + 34 + 48);
}
class UnifiedScaffold extends StatelessWidget {
final String title;
final Widget body;
final List<Widget>? actions;
final Widget? leading;
final Color? backgroundColor;
final bool extendBody;
final FloatingActionButton? floatingActionButton;
final FloatingActionButtonLocation? floatingActionButtonLocation;
final PreferredSizeWidget? bottomNavigationBar;
const UnifiedScaffold({
super.key,
required this.title,
required this.body,
this.actions,
this.leading,
this.backgroundColor,
this.extendBody = false,
this.floatingActionButton,
this.floatingActionButtonLocation,
this.bottomNavigationBar,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: backgroundColor ?? cs.surface,
extendBody: extendBody,
floatingActionButton: floatingActionButton,
floatingActionButtonLocation: floatingActionButtonLocation,
bottomNavigationBar: bottomNavigationBar,
appBar: UnifiedAppBar(
title: title,
actions: actions,
leading: leading,
backgroundColor: backgroundColor,
),
body: body,
);
}
}
class UnifiedLoadingState extends StatelessWidget {
final String? message;
final Color? color;
const UnifiedLoadingState({super.key, this.message, this.color});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 40,
height: 40,
child: CircularProgressIndicator(
color: color ?? cs.primary,
strokeWidth: 2,
backgroundColor: (color ?? cs.primary).withValues(alpha: 0.1),
),
),
const SizedBox(height: 16),
Text(
message ?? 'جاري التحميل...',
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 13),
),
],
),
);
}
}
class UnifiedEmptyState extends StatelessWidget {
final IconData icon;
final String title;
final String? subtitle;
final Widget? action;
const UnifiedEmptyState({
super.key,
required this.icon,
required this.title,
this.subtitle,
this.action,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
shape: BoxShape.circle,
),
child: Icon(icon, size: 48, color: cs.onSurfaceVariant),
),
const SizedBox(height: 16),
Text(
title,
style: TextStyle(color: cs.onSurface, fontSize: 16, fontWeight: FontWeight.w600),
textAlign: TextAlign.center,
),
if (subtitle != null) ...[
const SizedBox(height: 8),
Text(
subtitle!,
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 13),
textAlign: TextAlign.center,
),
],
if (action != null) ...[
const SizedBox(height: 20),
action!,
],
],
),
),
);
}
}
class UnifiedStatCard extends StatelessWidget {
final String label;
final String value;
final IconData icon;
final Color color;
final VoidCallback? onTap;
final String? subtitle;
const UnifiedStatCard({
super.key,
required this.label,
required this.value,
required this.icon,
required this.color,
this.onTap,
this.subtitle,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(16),
splashColor: color.withValues(alpha: 0.1),
highlightColor: color.withValues(alpha: 0.05),
child: Container(
width: 155,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: cs.outline),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: const EdgeInsets.all(7),
decoration: BoxDecoration(
color: color.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(9),
),
child: Icon(icon, color: color, size: 16),
),
Container(
width: 6,
height: 6,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: color.withValues(alpha: 0.6),
),
),
],
),
const Spacer(),
Text(
value,
style: TextStyle(
color: cs.onSurface,
fontSize: 20,
fontWeight: FontWeight.w700,
height: 1.1,
),
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 3),
Text(
label,
style: TextStyle(
color: cs.onSurfaceVariant,
fontSize: 10,
fontWeight: FontWeight.w500,
),
overflow: TextOverflow.ellipsis,
),
if (subtitle != null) ...[
const SizedBox(height: 2),
Text(
subtitle!,
style: TextStyle(
color: cs.onSurfaceVariant,
fontSize: 9,
fontWeight: FontWeight.w400,
),
overflow: TextOverflow.ellipsis,
),
],
],
),
),
),
);
}
}
class UnifiedSectionHeader extends StatelessWidget {
final String title;
final IconData? icon;
final Color? iconColor;
final Widget? trailing;
const UnifiedSectionHeader({
super.key,
required this.title,
this.icon,
this.iconColor,
this.trailing,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 10),
child: Row(
children: [
Container(
width: 3,
height: 14,
decoration: BoxDecoration(
color: iconColor ?? cs.primary,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(width: 8),
if (icon != null) ...[
Icon(icon!, size: 16, color: iconColor ?? cs.primary),
const SizedBox(width: 6),
],
Text(
title,
style: TextStyle(
color: cs.onSurfaceVariant,
fontSize: 11,
fontWeight: FontWeight.w600,
letterSpacing: 1.2,
),
),
if (trailing != null) ...[
const Spacer(),
trailing!,
],
],
),
);
}
}