إصلاح توافق فلاتر مع Theme الجديد

This commit is contained in:
Hamza-Ayed
2026-07-26 11:33:20 +03:00
parent 7830efead7
commit 3af99cc18a
31 changed files with 4256 additions and 2833 deletions
@@ -21,30 +21,24 @@ class SiroTrackerScreen extends StatefulWidget {
class _SiroTrackerScreenState extends State<SiroTrackerScreen>
with TickerProviderStateMixin {
// === Map Controller ===
final MapController _mapController = MapController();
List<Marker> _markers = [];
// === State Variables ===
bool isLiveMode = true;
bool isLoading = false;
String lastUpdated = "جاري التحميل...";
// === Counters ===
int liveCount = 0;
int dayCount = 0;
Timer? _timer;
// === Animation Controllers ===
late AnimationController _fadeController;
late AnimationController _scaleController;
// === Admin Info ===
String myPhone = box.read(BoxName.adminPhone).toString();
bool get isSuperAdmin =>
myPhone == '963942542053' || myPhone == '963992952235';
// === URLs ===
final String _baseDir = "${AppLink.server}/ride/location/";
@override
@@ -90,10 +84,11 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
}
void _showSnackBar(String message) {
final cs = Theme.of(context).colorScheme;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
backgroundColor: const Color(0xFF2C3E50),
backgroundColor: cs.surfaceContainerHighest,
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.all(16),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
@@ -160,6 +155,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
}
void _buildMarkers(List<dynamic> drivers) {
final cs = Theme.of(context).colorScheme;
List<Marker> newMarkers = [];
for (var d in drivers) {
@@ -192,7 +188,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
cancelled: cancelled,
);
},
child: _buildMarkerWidget(heading),
child: _buildMarkerWidget(heading, cs),
),
),
);
@@ -203,7 +199,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
});
}
Widget _buildMarkerWidget(double heading) {
Widget _buildMarkerWidget(double heading, ColorScheme cs) {
return Stack(
alignment: Alignment.center,
children: [
@@ -214,17 +210,17 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
shape: BoxShape.circle,
gradient: LinearGradient(
colors: isLiveMode
? [const Color(0xFF27AE60), const Color(0xFF229954)]
: [const Color(0xFF3498DB), const Color(0xFF2980B9)],
? [const Color(0xFF10B981), const Color(0xFF10B981)]
: [cs.tertiary, cs.tertiary],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
boxShadow: [
BoxShadow(
color: (isLiveMode
? const Color(0xFF27AE60)
: const Color(0xFF3498DB))
.withOpacity(0.5),
? const Color(0xFF10B981)
: cs.tertiary)
.withValues(alpha: 0.5),
blurRadius: 12,
spreadRadius: 2,
)
@@ -235,7 +231,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
angle: heading * (math.pi / 180),
child: Icon(
Icons.navigation,
color: Colors.white,
color: cs.onPrimary,
size: 26,
),
),
@@ -252,6 +248,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
required String completed,
required String cancelled,
}) {
final cs = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (_) => Dialog(
@@ -260,14 +257,14 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.white, Colors.grey.shade50],
colors: [cs.surface, cs.surfaceContainerHighest],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
color: cs.shadow.withValues(alpha: 0.15),
blurRadius: 30,
spreadRadius: 5,
)
@@ -284,38 +281,38 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
decoration: BoxDecoration(
gradient: LinearGradient(
colors: isLiveMode
? [const Color(0xFF27AE60), const Color(0xFF229954)]
: [const Color(0xFF3498DB), const Color(0xFF2980B9)],
? [const Color(0xFF10B981), const Color(0xFF10B981)]
: [cs.tertiary, cs.tertiary],
),
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.person_outline, color: Colors.white, size: 20),
Icon(Icons.person_outline, color: cs.onPrimary, size: 20),
const SizedBox(width: 8),
const Text(
Text(
"معلومات الكابتن",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
color: cs.onPrimary,
),
),
],
),
),
const SizedBox(height: 20),
_buildInfoCard(Icons.person, "الاسم", name),
_buildInfoCard(Icons.person, "الاسم", name, cs),
const SizedBox(height: 12),
_buildInfoCard(Icons.badge, "المعرف", driverId),
_buildInfoCard(Icons.badge, "المعرف", driverId, cs),
const SizedBox(height: 12),
_buildInfoCard(Icons.speed, "السرعة", "$speed كم/س"),
_buildInfoCard(Icons.speed, "السرعة", "$speed كم/س", cs),
const SizedBox(height: 20),
_buildStatsContainer(completed, cancelled),
_buildStatsContainer(completed, cancelled, cs),
if (isSuperAdmin) ...[
const SizedBox(height: 16),
_buildPhoneButton(phone),
_buildPhoneButton(phone, cs),
],
const SizedBox(height: 20),
SizedBox(
@@ -323,8 +320,8 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
child: ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2C3E50),
foregroundColor: Colors.white,
backgroundColor: cs.onSurface,
foregroundColor: cs.onPrimary,
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
@@ -348,19 +345,20 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
);
}
Widget _buildInfoCard(IconData icon, String label, String value) {
Widget _buildInfoCard(
IconData icon, String label, String value, ColorScheme cs) {
return Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: Colors.white,
color: cs.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey.shade200,
color: cs.outline,
width: 1,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
color: cs.shadow.withValues(alpha: 0.05),
blurRadius: 8,
)
],
@@ -370,10 +368,10 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.grey.shade100,
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8),
),
child: Icon(icon, color: const Color(0xFF2C3E50), size: 20),
child: Icon(icon, color: cs.onSurface, size: 20),
),
const SizedBox(width: 12),
Column(
@@ -383,17 +381,17 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
label,
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 4),
Text(
value,
style: const TextStyle(
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Color(0xFF2C3E50),
color: cs.onSurface,
),
),
],
@@ -403,34 +401,36 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
);
}
Widget _buildStatsContainer(String completed, String cancelled) {
Widget _buildStatsContainer(
String completed, String cancelled, ColorScheme cs) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.grey.shade50, Colors.grey.shade100],
colors: [cs.surfaceContainerHighest, cs.surfaceContainerHighest],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade200),
border: Border.all(color: cs.outline),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildStatItem("✓ مكتملة", completed, const Color(0xFF27AE60)),
_buildStatItem("✓ مكتملة", completed, const Color(0xFF10B981), cs),
Container(
width: 1,
height: 40,
color: Colors.grey.shade300,
color: cs.outline,
),
_buildStatItem("✕ ملغاة", cancelled, const Color(0xFFE74C3C)),
_buildStatItem("✕ ملغاة", cancelled, cs.error, cs),
],
),
);
}
Widget _buildStatItem(String label, String value, Color color) {
Widget _buildStatItem(
String label, String value, Color color, ColorScheme cs) {
return Column(
children: [
Text(
@@ -446,7 +446,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
label,
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
@@ -454,7 +454,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
);
}
Widget _buildPhoneButton(String phone) {
Widget _buildPhoneButton(String phone, ColorScheme cs) {
return InkWell(
onTap: () {
if (phone.isNotEmpty) _makePhoneCall(phone);
@@ -465,14 +465,14 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 14),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [const Color(0xFFFFA500), const Color(0xFFFF8C00)],
colors: [cs.tertiary, cs.tertiary],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: const Color(0xFFFFA500).withOpacity(0.4),
color: cs.tertiary.withValues(alpha: 0.4),
blurRadius: 12,
spreadRadius: 2,
)
@@ -481,13 +481,13 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.call, color: Colors.white, size: 20),
Icon(Icons.call, color: cs.onPrimary, size: 20),
const SizedBox(width: 10),
Expanded(
child: Text(
phone,
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: cs.onPrimary,
fontWeight: FontWeight.bold,
fontSize: 15,
),
@@ -502,6 +502,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
@@ -511,20 +512,19 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
title: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: const Color(0xFF2C3E50).withOpacity(0.9),
color: cs.onSurface.withValues(alpha: 0.9),
borderRadius: BorderRadius.circular(12),
// backdropFilter: const BackdropFilter(blur: 10),
),
child: const Text(
child: Text(
"نظام تتبع الكابتن",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
color: cs.onPrimary,
),
),
),
foregroundColor: Colors.white,
foregroundColor: cs.onPrimary,
),
body: Stack(
children: [
@@ -542,13 +542,13 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
MarkerLayer(markers: _markers),
],
),
_buildDashboard(),
_buildDashboard(cs),
],
),
);
}
Widget _buildDashboard() {
Widget _buildDashboard(ColorScheme cs) {
return Positioned(
top: 100,
right: 16,
@@ -559,11 +559,11 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
child: Container(
width: 300,
decoration: BoxDecoration(
color: Colors.white,
color: cs.surface,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
color: cs.shadow.withValues(alpha: 0.15),
blurRadius: 30,
spreadRadius: 5,
)
@@ -573,15 +573,11 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
borderRadius: BorderRadius.circular(20),
child: Column(
children: [
// Header
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
const Color(0xFF2C3E50),
const Color(0xFF34495E)
],
colors: [cs.onSurface, cs.onSurfaceVariant],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
@@ -589,12 +585,11 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(Icons.dashboard,
color: Colors.white, size: 22),
const Text(
Icon(Icons.dashboard, color: cs.onPrimary, size: 22),
Text(
"لوحة التحكم",
style: TextStyle(
color: Colors.white,
color: cs.onPrimary,
fontSize: 16,
fontWeight: FontWeight.bold,
),
@@ -607,7 +602,6 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// Mode Buttons
Row(
children: [
Expanded(
@@ -618,7 +612,8 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
setState(() => isLiveMode = false);
fetchData();
},
const Color(0xFF3498DB),
cs.tertiary,
cs,
),
),
const SizedBox(width: 10),
@@ -630,36 +625,35 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
setState(() => isLiveMode = true);
fetchData();
},
const Color(0xFF27AE60),
const Color(0xFF10B981),
cs,
),
),
],
),
const SizedBox(height: 16),
// Stats
_buildStatRow(
icon: Icons.live_tv,
label: "نشط الآن (مباشر)",
value: liveCount.toString(),
color: const Color(0xFF27AE60),
color: const Color(0xFF10B981),
cs: cs,
),
const SizedBox(height: 12),
_buildStatRow(
icon: Icons.history,
label: "إجمالي اليوم",
value: dayCount.toString(),
color: const Color(0xFF3498DB),
color: cs.tertiary,
cs: cs,
),
const SizedBox(height: 14),
// Last Update
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey.shade50,
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey.shade200),
border: Border.all(color: cs.outline),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -670,7 +664,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
: "تحديث: $lastUpdated",
style: TextStyle(
fontSize: 11,
color: Colors.grey.shade600,
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
@@ -679,23 +673,24 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
? Icons.hourglass_bottom
: Icons.check_circle,
size: 14,
color: isLoading ? Colors.orange : Colors.green,
color: isLoading
? cs.tertiary
: const Color(0xFF10B981),
),
],
),
),
const SizedBox(height: 12),
// Refresh Button
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: isLoading ? null : fetchData,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2C3E50),
foregroundColor: Colors.white,
disabledBackgroundColor: Colors.grey.shade300,
padding: const EdgeInsets.symmetric(vertical: 12),
backgroundColor: cs.onSurface,
foregroundColor: cs.onPrimary,
disabledBackgroundColor: cs.outline,
padding:
const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
@@ -705,13 +700,14 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isLoading)
const SizedBox(
SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white,
valueColor:
AlwaysStoppedAnimation<Color>(
cs.onPrimary,
),
),
)
@@ -746,6 +742,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
bool active,
VoidCallback onTap,
Color color,
ColorScheme cs,
) {
return InkWell(
onTap: onTap,
@@ -757,21 +754,21 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
decoration: BoxDecoration(
gradient: active
? LinearGradient(
colors: [color, color.withOpacity(0.8)],
colors: [color, color.withValues(alpha: 0.8)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
)
: null,
color: active ? null : Colors.grey.shade100,
color: active ? null : cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: active ? color : Colors.grey.shade300,
color: active ? color : cs.outline,
width: 1.5,
),
boxShadow: active
? [
BoxShadow(
color: color.withOpacity(0.3),
color: color.withValues(alpha: 0.3),
blurRadius: 8,
spreadRadius: 1,
)
@@ -781,7 +778,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
child: Text(
title,
style: TextStyle(
color: active ? Colors.white : Colors.grey.shade700,
color: active ? cs.onPrimary : cs.onSurfaceVariant,
fontWeight: active ? FontWeight.bold : FontWeight.w600,
fontSize: 13,
),
@@ -795,13 +792,14 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
required String label,
required String value,
required Color color,
required ColorScheme cs,
}) {
return Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
color: color.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(icon, color: color, size: 18),
@@ -815,7 +813,7 @@ class _SiroTrackerScreenState extends State<SiroTrackerScreen>
label,
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),