Update: 2026-05-08 14:05:50
This commit is contained in:
@@ -25,6 +25,7 @@ class DashboardController extends GetxController {
|
||||
|
||||
var isLoading = true.obs;
|
||||
var stats = {}.obs;
|
||||
var gamification = {}.obs;
|
||||
var recentActivities = [].obs;
|
||||
var userRole = ''.obs;
|
||||
|
||||
@@ -67,6 +68,12 @@ class DashboardController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch Gamification
|
||||
final gamificationResponse = await _dio.get('gamification/profile');
|
||||
if (gamificationResponse.data['success'] == true) {
|
||||
gamification.value = gamificationResponse.data['data'];
|
||||
}
|
||||
|
||||
// Fetch Recent Activity
|
||||
final activityResponse = await _dio.get('dashboard/recent-activity');
|
||||
if (activityResponse.data['success'] == true) {
|
||||
|
||||
@@ -74,6 +74,10 @@ class DashboardView extends GetView<DashboardController> {
|
||||
const SizedBox(height: 24),
|
||||
_buildAdminQuickActions(role, isDark),
|
||||
],
|
||||
if (controller.gamification.isNotEmpty) ...[
|
||||
const SizedBox(height: 24),
|
||||
_buildGamificationCard(controller.gamification, isDark),
|
||||
],
|
||||
const SizedBox(height: 32),
|
||||
const Text('إحصائيات الفواتير',
|
||||
style: TextStyle(
|
||||
@@ -386,6 +390,96 @@ class DashboardView extends GetView<DashboardController> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGamificationCard(Map gamification, bool isDark) {
|
||||
final points = gamification['points'] ?? 0;
|
||||
final level = gamification['level'] ?? 1;
|
||||
final levelName = gamification['level_name'] ?? 'مبتدئ';
|
||||
final currentLevelThreshold = gamification['current_level_threshold'] ?? 0;
|
||||
final nextLevelThreshold = gamification['next_level_threshold'] ?? 1000;
|
||||
final progress = (points - currentLevelThreshold) /
|
||||
((nextLevelThreshold - currentLevelThreshold) > 0
|
||||
? (nextLevelThreshold - currentLevelThreshold)
|
||||
: 1);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF6366F1), Color(0xFF8B5CF6)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF6366F1).withValues(alpha: 0.3),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.stars_rounded, color: Colors.amber, size: 32),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'المستوى $level: $levelName',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$points نقطة مكتسبة',
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white24,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: const Text(
|
||||
'المكافآت',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: LinearProgressIndicator(
|
||||
value: progress.clamp(0.0, 1.0).toDouble(),
|
||||
backgroundColor: Colors.white24,
|
||||
color: Colors.amber,
|
||||
minHeight: 8,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'باقي ${nextLevelThreshold - points} نقطة للمستوى القادم',
|
||||
style: const TextStyle(color: Colors.white70, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildQuotaMeter(Map subscription, bool isDark) {
|
||||
int limit = subscription['limit'] ?? 100;
|
||||
int used = subscription['used'] ?? 0;
|
||||
|
||||
Reference in New Issue
Block a user