تصميم عالمي جديد، وإصلاح الخرائط ومراقب السيرفرات
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_admin/constant/colors.dart';
|
||||
import 'package:siro_admin/constant/theme.dart';
|
||||
import 'package:siro_admin/controller/admin/dashboard_v2_controller.dart';
|
||||
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
||||
import 'package:siro_admin/views/widgets/glass_container.dart';
|
||||
@@ -10,15 +10,17 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return GetBuilder<DashboardV2Controller>(
|
||||
init: DashboardV2Controller(),
|
||||
builder: (ctrl) {
|
||||
if (ctrl.isLoading) {
|
||||
return const SliverToBoxAdapter(
|
||||
return SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 150,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(color: AppColor.accent),
|
||||
child: CircularProgressIndicator(color: cs.primary),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -28,16 +30,13 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 1. Real-time stats
|
||||
_buildSectionTitle('مركز العمليات الحي (Real-time)'),
|
||||
_buildRealtimeStats(ctrl.realtimeData),
|
||||
|
||||
_buildSectionTitle('مركز العمليات الحي (Real-time)', cs),
|
||||
_buildRealtimeStats(ctrl.realtimeData, cs),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 2. Smart Alerts
|
||||
if (ctrl.smartAlerts.isNotEmpty) ...[
|
||||
_buildSectionTitle('التنبيهات الذكية (${ctrl.smartAlerts.length})'),
|
||||
_buildSmartAlerts(ctrl.smartAlerts),
|
||||
_buildSectionTitle(
|
||||
'التنبيهات الذكية (${ctrl.smartAlerts.length})', cs),
|
||||
_buildSmartAlerts(ctrl.smartAlerts, cs),
|
||||
const SizedBox(height: 10),
|
||||
]
|
||||
],
|
||||
@@ -47,7 +46,7 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
Widget _buildSectionTitle(String title, ColorScheme cs) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 8, 20, 10),
|
||||
child: Row(
|
||||
@@ -56,15 +55,15 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
width: 3,
|
||||
height: 14,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.danger, // Distinct color
|
||||
color: cs.error,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: AppColor.textSecondary,
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 0.5,
|
||||
@@ -75,43 +74,43 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRealtimeStats(Map<String, dynamic> data) {
|
||||
Widget _buildRealtimeStats(Map<String, dynamic> data, ColorScheme cs) {
|
||||
final stats = [
|
||||
{
|
||||
'title': 'رحلات نشطة',
|
||||
'value': data['active_rides']?.toString() ?? '0',
|
||||
'icon': Icons.directions_car_rounded,
|
||||
'color': AppColor.info,
|
||||
'color': cs.tertiary,
|
||||
},
|
||||
{
|
||||
'title': 'سائقون أونلاين',
|
||||
'value': data['online_drivers']?.toString() ?? '0',
|
||||
'icon': Icons.wifi_tethering,
|
||||
'color': AppColor.success,
|
||||
'color': const Color(0xFF10B981),
|
||||
},
|
||||
{
|
||||
'title': 'إيرادات اليوم',
|
||||
'value': '${data['revenue_today'] ?? 0}',
|
||||
'icon': Icons.monetization_on_rounded,
|
||||
'color': AppColor.warning,
|
||||
'color': const Color(0xFFF59E0B),
|
||||
},
|
||||
{
|
||||
'title': 'إيرادات الأمس',
|
||||
'value': '${data['revenue_yesterday'] ?? 0}',
|
||||
'icon': Icons.history_rounded,
|
||||
'color': Colors.grey,
|
||||
'color': cs.onSurfaceVariant,
|
||||
},
|
||||
{
|
||||
'title': 'شكاوى مفتوحة',
|
||||
'value': data['new_complaints']?.toString() ?? '0',
|
||||
'icon': Icons.warning_rounded,
|
||||
'color': AppColor.danger,
|
||||
'color': cs.error,
|
||||
},
|
||||
{
|
||||
'title': 'رخص تنتهي قريبًا',
|
||||
'value': data['expiring_licenses']?.toString() ?? '0',
|
||||
'icon': Icons.sd_card_alert_rounded,
|
||||
'color': Colors.orangeAccent,
|
||||
'color': const Color(0xFFF97316),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -125,22 +124,22 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
final stat = stats[i];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 10),
|
||||
child: _buildStatCard(stat),
|
||||
child: _buildStatCard(stat, cs),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard(Map<String, dynamic> stat) {
|
||||
Widget _buildStatCard(Map<String, dynamic> stat, ColorScheme cs) {
|
||||
final color = stat['color'] as Color;
|
||||
return GlassContainer(
|
||||
width: 150,
|
||||
padding: const EdgeInsets.all(16),
|
||||
borderRadius: 16,
|
||||
gradientColors: [
|
||||
color.withOpacity(0.15),
|
||||
color.withOpacity(0.05),
|
||||
color.withValues(alpha: 0.15),
|
||||
color.withValues(alpha: 0.05),
|
||||
],
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -151,36 +150,34 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.15),
|
||||
color: color.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(stat['icon'] as IconData, color: color, size: 16),
|
||||
),
|
||||
const Spacer(),
|
||||
// Pulsing indicator for active things
|
||||
if (stat['title'] == 'رحلات نشطة' || stat['title'] == 'سائقون أونلاين')
|
||||
if (stat['title'] == 'رحلات نشطة' ||
|
||||
stat['title'] == 'سائقون أونلاين')
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: color,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: color.withOpacity(0.5),
|
||||
blurRadius: 4,
|
||||
spreadRadius: 1,
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: color,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: color.withValues(alpha: 0.5),
|
||||
blurRadius: 4,
|
||||
spreadRadius: 1,
|
||||
)
|
||||
])),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
stat['value'].toString(),
|
||||
style: const TextStyle(
|
||||
color: AppColor.textPrimary,
|
||||
style: TextStyle(
|
||||
color: cs.onSurface,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -188,8 +185,8 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
stat['title'].toString(),
|
||||
style: const TextStyle(
|
||||
color: AppColor.textSecondary,
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
@@ -201,12 +198,12 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSmartAlerts(List<dynamic> alerts) {
|
||||
Widget _buildSmartAlerts(List<dynamic> alerts, ColorScheme cs) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: alerts.length > 5 ? 5 : alerts.length, // Show top 5
|
||||
itemCount: alerts.length > 5 ? 5 : alerts.length,
|
||||
itemBuilder: (context, index) {
|
||||
final alert = alerts[index];
|
||||
return AnimationConfiguration.staggeredList(
|
||||
@@ -215,7 +212,7 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
child: SlideAnimation(
|
||||
verticalOffset: 20.0,
|
||||
child: FadeInAnimation(
|
||||
child: _buildAlertItem(alert),
|
||||
child: _buildAlertItem(alert, cs),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -223,17 +220,17 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAlertItem(Map<String, dynamic> alert) {
|
||||
Widget _buildAlertItem(Map<String, dynamic> alert, ColorScheme cs) {
|
||||
Color getSeverityColor(String severity) {
|
||||
switch (severity) {
|
||||
case 'high':
|
||||
return AppColor.danger;
|
||||
return cs.error;
|
||||
case 'medium':
|
||||
return AppColor.warning;
|
||||
return const Color(0xFFF59E0B);
|
||||
case 'warning':
|
||||
return Colors.orangeAccent;
|
||||
return const Color(0xFFF97316);
|
||||
default:
|
||||
return AppColor.info;
|
||||
return cs.tertiary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,12 +254,12 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.surface,
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: color.withOpacity(0.4)),
|
||||
border: Border.all(color: color.withValues(alpha: 0.4)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: color.withOpacity(0.05),
|
||||
color: color.withValues(alpha: 0.05),
|
||||
blurRadius: 5,
|
||||
offset: const Offset(0, 2),
|
||||
)
|
||||
@@ -274,7 +271,7 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
color: color.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(icon, color: color, size: 20),
|
||||
@@ -286,8 +283,8 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
alert['title'] ?? '',
|
||||
style: const TextStyle(
|
||||
color: AppColor.textPrimary,
|
||||
style: TextStyle(
|
||||
color: cs.onSurface,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -295,8 +292,8 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
alert['description'] ?? '',
|
||||
style: const TextStyle(
|
||||
color: AppColor.textSecondary,
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 11,
|
||||
),
|
||||
maxLines: 2,
|
||||
@@ -314,14 +311,14 @@ class DashboardV2Widget extends StatelessWidget {
|
||||
alert['date'] != null
|
||||
? alert['date'].toString().split(' ')[0]
|
||||
: '',
|
||||
style: const TextStyle(
|
||||
color: AppColor.textSecondary,
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Icon(Icons.arrow_forward_ios_rounded,
|
||||
color: AppColor.textSecondary, size: 12),
|
||||
color: cs.onSurfaceVariant, size: 12),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user