إصلاح توافق فلاتر مع 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
@@ -15,16 +15,14 @@ class _HeatmapPageState extends State<HeatmapPage> {
List<CircleMarker> _markers = [];
bool _isLoading = true;
// ─── فلاتر ───
String _selectedSource = 'all'; // all | geofence | app_usage | silent_push
String _selectedCountry = 'all'; // all | JO | SY | EG | IQ
String _selectedSource = 'all';
String _selectedCountry = 'all';
int _daysFilter = 7;
final MapController _mapController = MapController();
// مراكز كل دولة للانتقال السريع
final Map<String, LatLng> _countryCenters = {
'all': const LatLng(31.9522, 35.9334), // عمان
'all': const LatLng(31.9522, 35.9334),
'JO': const LatLng(31.9522, 35.9334),
'SY': const LatLng(33.5138, 36.2765),
'EG': const LatLng(30.0444, 31.2357),
@@ -60,18 +58,17 @@ class _HeatmapPageState extends State<HeatmapPage> {
final lng = double.tryParse(point['longitude'].toString()) ?? 0.0;
final source = point['source'].toString();
// ألوان حسب المصدر
Color markerColor;
switch (source) {
case 'geofence':
markerColor = Colors.green.withOpacity(0.65); // 🟢 دخل منطقة
markerColor = Colors.green.withValues(alpha: 0.65);
break;
case 'silent_push':
markerColor = Colors.orange.withOpacity(0.55); // 🟠 إيقاظ صامت
markerColor = Colors.orange.withValues(alpha: 0.55);
break;
case 'app_usage':
default:
markerColor = Colors.blue.withOpacity(0.5); // 🔵 فتح عادي
markerColor = Colors.blue.withValues(alpha: 0.5);
}
return CircleMarker(
@@ -93,22 +90,23 @@ class _HeatmapPageState extends State<HeatmapPage> {
void _applyFilter() {
_fetchHeatmapData();
// تحريك الخريطة لمركز الدولة المختارة
final center = _countryCenters[_selectedCountry] ?? _countryCenters['all']!;
_mapController.move(center, 11.0);
}
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: const Color(0xFF0F0F1A),
backgroundColor: cs.surface,
appBar: AppBar(
title: const Text(
'خريطة النشاط الحرارية',
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 15),
),
backgroundColor: const Color(0xFF1A1A2E),
foregroundColor: Colors.white,
backgroundColor: cs.surface,
foregroundColor: cs.onSurface,
centerTitle: true,
actions: [
IconButton(
@@ -120,14 +118,13 @@ class _HeatmapPageState extends State<HeatmapPage> {
),
body: Column(
children: [
// ─── شريط الفلاتر ───
Container(
color: const Color(0xFF1A1A2E),
color: cs.surfaceContainerHighest,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Column(
children: [
// فلتر المصدر
_buildFilterRow(
cs: cs,
label: 'المصدر:',
options: const {
'all': 'الكل',
@@ -139,8 +136,8 @@ class _HeatmapPageState extends State<HeatmapPage> {
onChanged: (v) => setState(() => _selectedSource = v),
),
const SizedBox(height: 6),
// فلتر الدولة
_buildFilterRow(
cs: cs,
label: 'الدولة:',
options: const {
'all': 'الكل',
@@ -153,10 +150,9 @@ class _HeatmapPageState extends State<HeatmapPage> {
onChanged: (v) => setState(() => _selectedCountry = v),
),
const SizedBox(height: 6),
// فلتر الفترة الزمنية + زر تطبيق
Row(
children: [
const Text('الفترة:', style: TextStyle(color: Colors.white54, fontSize: 11, fontWeight: FontWeight.bold)),
Text('الفترة:', style: TextStyle(color: cs.onSurfaceVariant, fontSize: 11, fontWeight: FontWeight.bold)),
const SizedBox(width: 8),
...[1, 7, 30].map((days) => Padding(
padding: const EdgeInsets.only(right: 6),
@@ -166,19 +162,19 @@ class _HeatmapPageState extends State<HeatmapPage> {
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: _daysFilter == days
? const Color(0xFF6366F1)
: const Color(0xFF2D2D42),
? cs.primary
: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: _daysFilter == days
? const Color(0xFF818CF8)
? cs.primary
: Colors.transparent,
),
),
child: Text(
'$days يوم',
style: TextStyle(
color: _daysFilter == days ? Colors.white : Colors.white54,
color: _daysFilter == days ? cs.onSurface : cs.onSurfaceVariant,
fontSize: 10,
fontWeight: FontWeight.bold,
),
@@ -192,8 +188,8 @@ class _HeatmapPageState extends State<HeatmapPage> {
icon: const Icon(Icons.filter_alt_rounded, size: 14),
label: const Text('تطبيق', style: TextStyle(fontSize: 11)),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF6366F1),
foregroundColor: Colors.white,
backgroundColor: cs.primary,
foregroundColor: cs.onPrimary,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
),
@@ -204,18 +200,17 @@ class _HeatmapPageState extends State<HeatmapPage> {
),
),
// ─── الخريطة ───
Expanded(
child: Stack(
children: [
_isLoading
? const Center(
? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(color: Color(0xFF6366F1)),
SizedBox(height: 12),
Text('جاري تحميل البيانات...', style: TextStyle(color: Colors.white54, fontSize: 12)),
CircularProgressIndicator(color: cs.primary),
const SizedBox(height: 12),
Text('جاري تحميل البيانات...', style: TextStyle(color: cs.onSurfaceVariant, fontSize: 12)),
],
),
)
@@ -234,44 +229,42 @@ class _HeatmapPageState extends State<HeatmapPage> {
],
),
// ─── مفتاح الألوان ───
Positioned(
bottom: 12,
right: 12,
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xFF1A1A2E).withOpacity(0.9),
color: cs.surfaceContainerHighest.withValues(alpha: 0.9),
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.white12),
border: Border.all(color: cs.outline.withValues(alpha: 0.3)),
),
child: const Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_LegendItem(color: Colors.green, label: 'دخل منطقة سياج'),
SizedBox(height: 4),
_LegendItem(color: Colors.blue, label: 'فتح عادي للتطبيق'),
SizedBox(height: 4),
_LegendItem(color: Colors.orange, label: 'إيقاظ صامت'),
_LegendItem(color: Colors.green, label: 'دخل منطقة سياج', cs: cs),
const SizedBox(height: 4),
_LegendItem(color: Colors.blue, label: 'فتح عادي للتطبيق', cs: cs),
const SizedBox(height: 4),
_LegendItem(color: Colors.orange, label: 'إيقاظ صامت', cs: cs),
],
),
),
),
// ─── عدد النقاط ───
Positioned(
top: 12,
left: 12,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: const Color(0xFF1A1A2E).withOpacity(0.9),
color: cs.surfaceContainerHighest.withValues(alpha: 0.9),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.white12),
border: Border.all(color: cs.outline.withValues(alpha: 0.3)),
),
child: Text(
'${_markers.length} نقطة',
style: const TextStyle(color: Colors.white, fontSize: 11, fontWeight: FontWeight.bold),
style: TextStyle(color: cs.onSurface, fontSize: 11, fontWeight: FontWeight.bold),
),
),
),
@@ -284,6 +277,7 @@ class _HeatmapPageState extends State<HeatmapPage> {
}
Widget _buildFilterRow({
required ColorScheme cs,
required String label,
required Map<String, String> options,
required String selected,
@@ -291,7 +285,7 @@ class _HeatmapPageState extends State<HeatmapPage> {
}) {
return Row(
children: [
Text(label, style: const TextStyle(color: Colors.white54, fontSize: 11, fontWeight: FontWeight.bold)),
Text(label, style: TextStyle(color: cs.onSurfaceVariant, fontSize: 11, fontWeight: FontWeight.bold)),
const SizedBox(width: 8),
Expanded(
child: SingleChildScrollView(
@@ -306,16 +300,16 @@ class _HeatmapPageState extends State<HeatmapPage> {
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: isSelected ? const Color(0xFF6366F1) : const Color(0xFF2D2D42),
color: isSelected ? cs.primary : cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: isSelected ? const Color(0xFF818CF8) : Colors.transparent,
color: isSelected ? cs.primary : Colors.transparent,
),
),
child: Text(
e.value,
style: TextStyle(
color: isSelected ? Colors.white : Colors.white54,
color: isSelected ? cs.onSurface : cs.onSurfaceVariant,
fontSize: 10,
fontWeight: FontWeight.bold,
),
@@ -335,7 +329,8 @@ class _HeatmapPageState extends State<HeatmapPage> {
class _LegendItem extends StatelessWidget {
final Color color;
final String label;
const _LegendItem({required this.color, required this.label});
final ColorScheme cs;
const _LegendItem({required this.color, required this.label, required this.cs});
@override
Widget build(BuildContext context) {
@@ -344,7 +339,7 @@ class _LegendItem extends StatelessWidget {
children: [
Container(width: 10, height: 10, decoration: BoxDecoration(color: color, shape: BoxShape.circle)),
const SizedBox(width: 6),
Text(label, style: const TextStyle(color: Colors.white70, fontSize: 10)),
Text(label, style: TextStyle(color: cs.onSurfaceVariant, fontSize: 10)),
],
);
}
File diff suppressed because it is too large Load Diff
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
import '../../../constant/colors.dart';
import '../../../constant/links.dart';
class SocialIntelligenceController extends GetxController {
@@ -42,36 +41,38 @@ class SocialIntelligenceScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final controller = Get.put(SocialIntelligenceController());
return Scaffold(
backgroundColor: AppColor.bg,
backgroundColor: cs.surface,
appBar: AppBar(
title: const Text(
title: Text(
'استخبارات السوشيال ميديا (Social Intelligence)',
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 16),
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 16, color: cs.onSurface),
),
backgroundColor: AppColor.bg,
backgroundColor: cs.surface,
elevation: 0,
foregroundColor: AppColor.textPrimary,
foregroundColor: cs.onSurface,
iconTheme: IconThemeData(color: cs.onSurface),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
icon: Icon(Icons.refresh, color: cs.onSurface),
onPressed: () => controller.fetchReports(),
)
],
),
body: Obx(() {
if (controller.isLoading.value) {
return const Center(
child: CircularProgressIndicator(color: AppColor.accent));
return Center(
child: CircularProgressIndicator(color: cs.primary));
}
if (controller.reports.isEmpty) {
return const Center(
return Center(
child: Text(
'لا توجد تقارير حالياً',
style: TextStyle(color: AppColor.textSecondary),
style: TextStyle(color: cs.onSurfaceVariant),
),
);
}
@@ -84,45 +85,45 @@ class SocialIntelligenceScreen extends StatelessWidget {
final isWeekly = report['is_weekly'].toString() == '1';
return Card(
color: AppColor.surface,
color: cs.surfaceContainerHighest,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(
color: isWeekly ? AppColor.accent : AppColor.divider,
color: isWeekly ? cs.primary : cs.outline,
width: isWeekly ? 1.5 : 1.0),
),
margin: const EdgeInsets.only(bottom: 16),
child: ExpansionTile(
iconColor: AppColor.accent,
collapsedIconColor: AppColor.textSecondary,
iconColor: cs.primary,
collapsedIconColor: cs.onSurfaceVariant,
title: Text(
isWeekly
? '📈 تقرير السوق الأسبوعي الشامل'
: '📊 تقرير ${report['platform'].toString().toUpperCase()}',
style: TextStyle(
fontWeight: FontWeight.bold,
color: isWeekly ? AppColor.accent : AppColor.textPrimary,
color: isWeekly ? cs.primary : cs.onSurface,
fontSize: 14,
),
),
subtitle: Text(
report['created_at'].toString(),
style: const TextStyle(
color: AppColor.textSecondary, fontSize: 11),
style: TextStyle(
color: cs.onSurfaceVariant, fontSize: 11),
),
children: [
Container(
padding: const EdgeInsets.all(16),
width: double.infinity,
decoration: const BoxDecoration(
border: Border(top: BorderSide(color: AppColor.divider)),
decoration: BoxDecoration(
border: Border(top: BorderSide(color: cs.outline)),
),
child: Directionality(
textDirection: TextDirection.rtl,
child: HtmlWidget(
report['report_html'] ?? '',
textStyle: const TextStyle(
color: AppColor.textPrimary,
textStyle: TextStyle(
color: cs.onSurface,
fontSize: 13,
height: 1.6),
),