Update: 2026-07-05 00:06:55
This commit is contained in:
@@ -757,6 +757,8 @@ class _AdminHomePageState extends State<AdminHomePage>
|
||||
() => Get.toNamed('/complaints')),
|
||||
ActionItem('مراجعة الوثائق', Icons.assignment_ind_rounded, _info,
|
||||
() => Get.toNamed('/driver-docs')),
|
||||
ActionItem('استخبارات السوشيال', Icons.insights_rounded, const Color(0xFFC792EA),
|
||||
() => Get.toNamed('/social-intelligence')),
|
||||
],
|
||||
),
|
||||
ActionCategory(
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import 'dart:convert';
|
||||
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 {
|
||||
var isLoading = true.obs;
|
||||
var reports = [].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
fetchReports();
|
||||
}
|
||||
|
||||
Future<void> fetchReports() async {
|
||||
try {
|
||||
isLoading(true);
|
||||
final url = Uri.parse(
|
||||
'${AppLink.server}/marketing_engine/index.php?action=get_reports');
|
||||
final response = await http.get(url);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
if (data['status'] == 'success') {
|
||||
reports.value = data['data'] ?? [];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching reports: $e');
|
||||
} finally {
|
||||
isLoading(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SocialIntelligenceScreen extends StatelessWidget {
|
||||
const SocialIntelligenceScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = Get.put(SocialIntelligenceController());
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.bg,
|
||||
appBar: AppBar(
|
||||
title: const Text(
|
||||
'استخبارات السوشيال ميديا (Social Intelligence)',
|
||||
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 16),
|
||||
),
|
||||
backgroundColor: AppColor.bg,
|
||||
elevation: 0,
|
||||
foregroundColor: AppColor.textPrimary,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () => controller.fetchReports(),
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: AppColor.accent));
|
||||
}
|
||||
|
||||
if (controller.reports.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'لا توجد تقارير حالياً',
|
||||
style: TextStyle(color: AppColor.textSecondary),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: controller.reports.length,
|
||||
itemBuilder: (context, index) {
|
||||
final report = controller.reports[index];
|
||||
final isWeekly = report['is_weekly'].toString() == '1';
|
||||
|
||||
return Card(
|
||||
color: AppColor.surface,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: BorderSide(
|
||||
color: isWeekly ? AppColor.accent : AppColor.divider,
|
||||
width: isWeekly ? 1.5 : 1.0),
|
||||
),
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
child: ExpansionTile(
|
||||
iconColor: AppColor.accent,
|
||||
collapsedIconColor: AppColor.textSecondary,
|
||||
title: Text(
|
||||
isWeekly
|
||||
? '📈 تقرير السوق الأسبوعي الشامل'
|
||||
: '📊 تقرير ${report['platform'].toString().toUpperCase()}',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isWeekly ? AppColor.accent : AppColor.textPrimary,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
report['created_at'].toString(),
|
||||
style: const TextStyle(
|
||||
color: AppColor.textSecondary, fontSize: 11),
|
||||
),
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
width: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(top: BorderSide(color: AppColor.divider)),
|
||||
),
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: HtmlWidget(
|
||||
report['report_html'] ?? '',
|
||||
textStyle: const TextStyle(
|
||||
color: AppColor.textPrimary,
|
||||
fontSize: 13,
|
||||
height: 1.6),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user