add new featurs like realtime 2026-5-10-25

This commit is contained in:
Hamza-Ayed
2026-05-10 17:38:33 +03:00
parent 0d9fab31bd
commit e17866aa2f
86 changed files with 1939 additions and 10 deletions

View File

@@ -0,0 +1,153 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../controller/admin/quality_controller.dart';
class BlacklistPage extends StatelessWidget {
const BlacklistPage({super.key});
@override
Widget build(BuildContext context) {
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 TabBarView(
children: [
_buildDriverList(controller),
_buildPassengerList(controller),
],
);
},
),
),
);
}
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) {
Get.defaultDialog(
title: "تأكيد فك الحظر",
middleText:
"هل أنت متأكد من فك الحظر عن هذا ال$type ($identifier\nسيتم تسجيل هذه العملية في الـ Audit Log.",
textConfirm: "نعم، فك الحظر",
textCancel: "تراجع",
confirmTextColor: Colors.white,
buttonColor: Colors.green,
onConfirm: () {
Get.back();
onConfirm();
},
);
}
}

View File

@@ -0,0 +1,240 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../controller/admin/quality_controller.dart';
class DriverScorecardPage extends StatelessWidget {
final String driverId;
const DriverScorecardPage({super.key, required this.driverId});
@override
Widget build(BuildContext context) {
QualityController controller = Get.put(QualityController());
// Fetch data when page opens
WidgetsBinding.instance.addPostFrameCallback((_) {
controller.fetchDriverScorecard(driverId);
});
return Scaffold(
appBar: AppBar(
title: const Text('بطاقة أداء السائق',
style: TextStyle(fontWeight: FontWeight.bold)),
backgroundColor: Colors.blueAccent,
),
body: GetBuilder<QualityController>(
builder: (controller) {
if (controller.isLoading) {
return const Center(child: CircularProgressIndicator());
}
if (controller.scorecardData.isEmpty) {
return const Center(
child: Text('لا توجد بيانات لهذا السائق أو حدث خطأ.'));
}
var basicInfo = controller.scorecardData['basic_info'];
var ridesStats = controller.scorecardData['rides_stats'];
var rating = controller.scorecardData['rating'];
var behavior = controller.scorecardData['behavior'];
var complaints = controller.scorecardData['complaints'];
num overallScore = controller.scorecardData['overall_score'] ?? 0;
Color scoreColor = _getScoreColor(overallScore);
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// رأس البطاقة - معلومات السائق والتقييم الإجمالي
Card(
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
CircleAvatar(
radius: 40,
backgroundColor: Colors.grey.shade300,
child: const Icon(Icons.person,
size: 50, color: Colors.white),
),
const SizedBox(height: 10),
Text(
'${basicInfo['first_name']} ${basicInfo['last_name']}',
style: const TextStyle(
fontSize: 22, fontWeight: FontWeight.bold)),
Text('هاتف: ${basicInfo['phone']}',
style: const TextStyle(color: Colors.grey)),
const Divider(height: 30),
Text('التقييم الشامل (Score)',
style: TextStyle(
fontSize: 18, color: Colors.grey.shade700)),
const SizedBox(height: 5),
Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 100,
height: 100,
child: CircularProgressIndicator(
value: overallScore / 100,
strokeWidth: 10,
backgroundColor: Colors.grey.shade200,
color: scoreColor,
),
),
Text('${overallScore.toStringAsFixed(1)}%',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: scoreColor)),
],
),
],
),
),
),
const SizedBox(height: 15),
// قسم إحصائيات الرحلات
_buildSectionTitle('إحصائيات الرحلات (الإنجاز)'),
Card(
elevation: 2,
child: ListTile(
leading: const Icon(Icons.drive_eta, color: Colors.blue),
title: const Text('نسبة الإنجاز'),
trailing: Text('${ridesStats['completion_rate']}%',
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.bold)),
subtitle: Text(
'إجمالي: ${ridesStats['total_rides']} | اكتمل: ${ridesStats['completed_rides']}\n'
'إلغاء سائق: ${ridesStats['driver_cancellations']} | إلغاء راكب: ${ridesStats['passenger_cancellations']}'),
),
),
const SizedBox(height: 10),
// قسم التقييم والشكاوى
_buildSectionTitle('رضا العملاء والشكاوى'),
Row(
children: [
Expanded(
child: Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
children: [
const Icon(Icons.star,
color: Colors.orange, size: 30),
const SizedBox(height: 5),
Text('${rating.toString()}/5.0',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold)),
const Text('متوسط التقييم',
style: TextStyle(
fontSize: 12, color: Colors.grey)),
],
),
),
),
),
Expanded(
child: Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
children: [
const Icon(Icons.warning,
color: Colors.redAccent, size: 30),
const SizedBox(height: 5),
Text('${complaints['total_complaints']} شكوى',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold)),
Text('${complaints['open_complaints']} مفتوحة',
style: const TextStyle(
fontSize: 12, color: Colors.red)),
],
),
),
),
),
],
),
const SizedBox(height: 10),
// قسم سلوك القيادة
_buildSectionTitle('سلوك القيادة والتتبع'),
Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
children: [
_buildBehaviorRow('متوسط سرعة السائق',
'${behavior['avg_max_speed']} كم/س', Icons.speed),
const Divider(),
_buildBehaviorRow(
'مرات الفرملة القاسية',
'${behavior['total_hard_brakes']}',
Icons.dangerous),
const Divider(),
_buildBehaviorRow(
'تسارع مفاجئ',
'${behavior['total_rapid_accel']}',
Icons.fast_forward),
const Divider(),
_buildBehaviorRow('تقييم السلوك الآلي',
'${behavior['avg_behavior_score']}%', Icons.memory),
],
),
),
),
],
),
);
},
),
);
}
Widget _buildSectionTitle(String title) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 4.0),
child: Text(title,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black87)),
);
}
Widget _buildBehaviorRow(String title, String value, IconData icon) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(icon, size: 20, color: Colors.grey.shade600),
const SizedBox(width: 8),
Text(title, style: const TextStyle(fontSize: 15)),
],
),
Text(value,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
],
);
}
Color _getScoreColor(num score) {
if (score >= 80) return Colors.green;
if (score >= 60) return Colors.orange;
return Colors.red;
}
}