إصلاح توافق فلاتر مع Theme الجديد
This commit is contained in:
@@ -7,143 +7,324 @@ class BlacklistPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
Get.put(QualityController()).fetchBlacklist();
|
||||
|
||||
return DefaultTabController(
|
||||
length: 2,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('إدارة القائمة السوداء (Blacklist)',
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
backgroundColor: Colors.red[800],
|
||||
bottom: const TabBar(
|
||||
indicatorColor: Colors.white,
|
||||
tabs: [
|
||||
Tab(icon: Icon(Icons.drive_eta), text: 'السائقين المحظورين'),
|
||||
Tab(icon: Icon(Icons.person), text: 'الركاب المحظورين'),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: GetBuilder<QualityController>(
|
||||
builder: (controller) {
|
||||
if (controller.isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: cs.surface,
|
||||
body: Column(
|
||||
children: [
|
||||
_buildAppBar(context, cs),
|
||||
_buildTabBar(context, cs),
|
||||
Expanded(
|
||||
child: GetBuilder<QualityController>(
|
||||
builder: (controller) {
|
||||
if (controller.isLoading) {
|
||||
return _buildLoadingState(cs);
|
||||
}
|
||||
|
||||
return TabBarView(
|
||||
children: [
|
||||
_buildDriverList(controller),
|
||||
_buildPassengerList(controller),
|
||||
],
|
||||
);
|
||||
},
|
||||
return TabBarView(
|
||||
controller: DefaultTabController.of(context),
|
||||
children: [
|
||||
_buildDriverList(controller, cs),
|
||||
_buildPassengerList(controller, cs),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context, ColorScheme cs) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(16, 50, 16, 16),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surface,
|
||||
border: Border(bottom: BorderSide(color: cs.outline)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
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),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.error.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: cs.error.withValues(alpha: 0.25)),
|
||||
),
|
||||
child: Icon(Icons.block_rounded, color: cs.error, size: 18),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
'القائمة السوداء',
|
||||
style: TextStyle(
|
||||
color: cs.onSurface,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTabBar(BuildContext context, ColorScheme cs) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: TabBar(
|
||||
controller: DefaultTabController.of(context),
|
||||
indicator: BoxDecoration(
|
||||
color: cs.primary.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
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),
|
||||
padding: const EdgeInsets.all(4),
|
||||
labelPadding: EdgeInsets.zero,
|
||||
tabs: const [
|
||||
Tab(text: 'السائقين', icon: Icon(Icons.drive_eta_rounded, size: 16)),
|
||||
Tab(text: 'الركاب', icon: Icon(Icons.person_rounded, size: 16)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadingState(ColorScheme cs) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: CircularProgressIndicator(
|
||||
color: cs.primary,
|
||||
strokeWidth: 2,
|
||||
backgroundColor: cs.primary.withValues(alpha: 0.1),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('جاري التحميل...',
|
||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 13)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDriverList(QualityController controller, ColorScheme cs) {
|
||||
if (controller.driversBlacklist.isEmpty) {
|
||||
return _buildEmptyState('لا يوجد سائقين محظورين', cs);
|
||||
}
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 80),
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: controller.driversBlacklist.length,
|
||||
itemBuilder: (context, index) {
|
||||
var driver = controller.driversBlacklist[index];
|
||||
return _buildBlacklistItem(
|
||||
phone: driver['phone'],
|
||||
reason: driver['reason'] ?? 'غير محدد',
|
||||
date: driver['created_at'],
|
||||
type: 'سائق',
|
||||
icon: Icons.drive_eta_rounded,
|
||||
onUnblock: () => controller.unblockDriver(driver['phone'].toString()),
|
||||
cs: cs,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPassengerList(QualityController controller, ColorScheme cs) {
|
||||
if (controller.passengersBlacklist.isEmpty) {
|
||||
return _buildEmptyState('لا يوجد ركاب محظورين', cs);
|
||||
}
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 80),
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: controller.passengersBlacklist.length,
|
||||
itemBuilder: (context, index) {
|
||||
var passenger = controller.passengersBlacklist[index];
|
||||
return _buildBlacklistItem(
|
||||
phone: passenger['phone'] ?? passenger['phone_normalized'],
|
||||
reason: passenger['reason'] ?? 'غير محدد',
|
||||
date: passenger['created_at'],
|
||||
type: 'راكب',
|
||||
icon: Icons.person_rounded,
|
||||
onUnblock: () => controller.unblockPassenger(
|
||||
passenger['phone_normalized'].toString()),
|
||||
cs: cs,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyState(String message, ColorScheme cs) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(Icons.block_rounded, size: 48, color: cs.onSurfaceVariant),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(message,
|
||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBlacklistItem({
|
||||
required String phone,
|
||||
required String reason,
|
||||
required String date,
|
||||
required String type,
|
||||
required IconData icon,
|
||||
required VoidCallback onUnblock,
|
||||
required ColorScheme cs,
|
||||
}) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.error.withValues(alpha: 0.15)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: cs.error.withValues(alpha: 0.12),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: cs.error.withValues(alpha: 0.2)),
|
||||
),
|
||||
child: Icon(icon, color: cs.error, size: 22),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
phone,
|
||||
style: TextStyle(
|
||||
color: cs.onSurface,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15,
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.error.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
type,
|
||||
style: TextStyle(
|
||||
color: cs.error,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'السبب: $reason',
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 11,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
date,
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
GestureDetector(
|
||||
onTap: () => _showUnblockDialog(Get.context!, type, phone, onUnblock, cs),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF10B981).withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFF10B981).withValues(alpha: 0.2)),
|
||||
),
|
||||
child: Icon(Icons.settings_backup_restore_rounded,
|
||||
color: const Color(0xFF10B981), size: 18),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDriverList(QualityController controller) {
|
||||
if (controller.driversBlacklist.isEmpty) {
|
||||
return const Center(child: Text('لا يوجد سائقين محظورين حالياً'));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: controller.driversBlacklist.length,
|
||||
padding: const EdgeInsets.all(12),
|
||||
itemBuilder: (context, index) {
|
||||
var driver = controller.driversBlacklist[index];
|
||||
return Card(
|
||||
elevation: 3,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
child: ListTile(
|
||||
leading: const CircleAvatar(
|
||||
backgroundColor: Colors.redAccent,
|
||||
child: Icon(Icons.block, color: Colors.white),
|
||||
),
|
||||
title: Text('هاتف: ${driver['phone']}',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('السبب: ${driver['reason'] ?? "غير محدد"}'),
|
||||
Text('تاريخ الحظر: ${driver['created_at']}'),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.settings_backup_restore,
|
||||
color: Colors.green),
|
||||
onPressed: () {
|
||||
_showUnblockDialog(
|
||||
Get.context!,
|
||||
'سائق',
|
||||
driver['phone'],
|
||||
() => controller.unblockDriver(driver['phone'].toString()),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPassengerList(QualityController controller) {
|
||||
if (controller.passengersBlacklist.isEmpty) {
|
||||
return const Center(child: Text('لا يوجد ركاب محظورين حالياً'));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: controller.passengersBlacklist.length,
|
||||
padding: const EdgeInsets.all(12),
|
||||
itemBuilder: (context, index) {
|
||||
var passenger = controller.passengersBlacklist[index];
|
||||
return Card(
|
||||
elevation: 3,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
child: ListTile(
|
||||
leading: const CircleAvatar(
|
||||
backgroundColor: Colors.orangeAccent,
|
||||
child: Icon(Icons.person_off, color: Colors.white),
|
||||
),
|
||||
title: Text(
|
||||
'هاتف: ${passenger['phone'] ?? passenger['phone_normalized']}',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('السبب: ${passenger['reason'] ?? "غير محدد"}'),
|
||||
Text('تاريخ الحظر: ${passenger['created_at']}'),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.settings_backup_restore,
|
||||
color: Colors.green),
|
||||
onPressed: () {
|
||||
_showUnblockDialog(
|
||||
Get.context!,
|
||||
'راكب',
|
||||
passenger['phone_normalized'],
|
||||
() => controller.unblockPassenger(
|
||||
passenger['phone_normalized'].toString()),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showUnblockDialog(BuildContext context, String type, String identifier,
|
||||
VoidCallback onConfirm) {
|
||||
void _showUnblockDialog(
|
||||
BuildContext context, String type, String identifier, VoidCallback onConfirm, ColorScheme cs) {
|
||||
Get.defaultDialog(
|
||||
title: "تأكيد فك الحظر",
|
||||
titleStyle: TextStyle(color: cs.onSurface, fontWeight: FontWeight.bold),
|
||||
backgroundColor: cs.surface,
|
||||
middleText:
|
||||
"هل أنت متأكد من فك الحظر عن هذا ال$type ($identifier)؟\nسيتم تسجيل هذه العملية في الـ Audit Log.",
|
||||
textConfirm: "نعم، فك الحظر",
|
||||
textCancel: "تراجع",
|
||||
confirmTextColor: Colors.white,
|
||||
buttonColor: Colors.green,
|
||||
buttonColor: const Color(0xFF10B981),
|
||||
cancelTextColor: cs.onSurfaceVariant,
|
||||
onConfirm: () {
|
||||
Get.back();
|
||||
onConfirm();
|
||||
|
||||
Reference in New Issue
Block a user