add new featurs like new stat page
This commit is contained in:
@@ -16,8 +16,7 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
|
||||
final GamificationController gamController =
|
||||
Get.put(GamificationController());
|
||||
final StatisticsController statsController =
|
||||
Get.put(StatisticsController());
|
||||
final StatisticsController statsController = Get.put(StatisticsController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -25,154 +24,160 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
backgroundColor: FinanceDesignSystem.backgroundColor,
|
||||
body: GetBuilder<GamificationController>(
|
||||
builder: (gc) {
|
||||
if (gc.isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: FinanceDesignSystem.primaryDark),
|
||||
);
|
||||
}
|
||||
return GetBuilder<StatisticsController>(
|
||||
builder: (sc) {
|
||||
if (gc.isLoading || sc.isLoading) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: FinanceDesignSystem.primaryDark),
|
||||
);
|
||||
}
|
||||
|
||||
return CustomScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
slivers: [
|
||||
// ═══════ App Bar ═══════
|
||||
SliverAppBar(
|
||||
expandedHeight: 200,
|
||||
pinned: true,
|
||||
stretch: true,
|
||||
backgroundColor: FinanceDesignSystem.primaryDark,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_ios_new_rounded,
|
||||
color: Colors.white, size: 20),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh_rounded,
|
||||
color: Colors.white),
|
||||
onPressed: () => gc.fetchGamificationData(),
|
||||
),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
'Statistics'.tr,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
return CustomScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
slivers: [
|
||||
// ═══════ App Bar ═══════
|
||||
SliverAppBar(
|
||||
expandedHeight: 200,
|
||||
pinned: true,
|
||||
stretch: true,
|
||||
backgroundColor: Get.isDarkMode
|
||||
? FinanceDesignSystem.primaryDark
|
||||
: const Color(0xFF0A0E21),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_ios_new_rounded,
|
||||
color: Colors.white, size: 20),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
),
|
||||
background: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: FinanceDesignSystem.balanceGradient,
|
||||
),
|
||||
),
|
||||
// أيقونة زخرفية
|
||||
Positioned(
|
||||
right: -40,
|
||||
top: -20,
|
||||
child: Icon(
|
||||
Icons.bar_chart_rounded,
|
||||
size: 200,
|
||||
color: Colors.white.withOpacity(0.04),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: -30,
|
||||
bottom: 20,
|
||||
child: Icon(
|
||||
Icons.emoji_events_rounded,
|
||||
size: 120,
|
||||
color: Colors.white.withOpacity(0.03),
|
||||
),
|
||||
),
|
||||
// بطاقة المستوى في الهيدر
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 40),
|
||||
Text(
|
||||
gc.currentLevel.emoji,
|
||||
style: const TextStyle(fontSize: 40),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
Get.locale?.languageCode == 'ar'
|
||||
? gc.currentLevel.nameAr
|
||||
: gc.currentLevel.nameEn,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.9),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'${gc.unlockedCount}/${gc.totalAchievements} ${'Achievements'.tr}',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.5),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh_rounded,
|
||||
color: Colors.white),
|
||||
onPressed: () => gc.fetchGamificationData(),
|
||||
),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
'Statistics'.tr,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
background: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: FinanceDesignSystem.balanceGradient,
|
||||
),
|
||||
),
|
||||
// أيقونة زخرفية
|
||||
Positioned(
|
||||
right: -40,
|
||||
top: -20,
|
||||
child: Icon(
|
||||
Icons.bar_chart_rounded,
|
||||
size: 200,
|
||||
color: Colors.white.withOpacity(0.04),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: -30,
|
||||
bottom: 20,
|
||||
child: Icon(
|
||||
Icons.emoji_events_rounded,
|
||||
size: 120,
|
||||
color: Colors.white.withOpacity(0.03),
|
||||
),
|
||||
),
|
||||
// بطاقة المستوى في الهيدر
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 40),
|
||||
Text(
|
||||
gc.currentLevel.emoji,
|
||||
style: const TextStyle(fontSize: 40),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
Get.locale?.languageCode == 'ar'
|
||||
? gc.currentLevel.nameAr
|
||||
: gc.currentLevel.nameEn,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.9),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'${gc.unlockedCount}/${gc.totalAchievements} ${'Achievements'.tr}',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.5),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ═══════ المحتوى ═══════
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 24, 16, 40),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
// 1. بطاقات الإحصائيات الأربعة
|
||||
_buildSummaryCards(gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
// ═══════ المحتوى ═══════
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 24, 16, 40),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
// 1. بطاقات الإحصائيات الأربعة
|
||||
_buildSummaryCards(gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
|
||||
// 2. الهدف اليومي
|
||||
DailyGoalWidget(controller: gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
// 2. الهدف اليومي
|
||||
DailyGoalWidget(controller: gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
|
||||
// 3. تقدم المستوى
|
||||
LevelProgressWidget(controller: gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
// 3. تقدم المستوى
|
||||
LevelProgressWidget(controller: gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
|
||||
// 4. إحصائيات اليوم
|
||||
TodayChartWidget(),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
// 4. إحصائيات اليوم
|
||||
TodayChartWidget(),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
|
||||
// 5. الرسم البياني الأسبوعي
|
||||
const WeeklyChartWidget(),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
// 5. الرسم البياني الأسبوعي
|
||||
const WeeklyChartWidget(),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
|
||||
// 6. التقرير الشهري
|
||||
const MonthlyChartWidget(),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
// 6. التقرير الشهري
|
||||
const MonthlyChartWidget(),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
|
||||
// 7. تقييم سلوك القيادة
|
||||
_buildBehaviorSection(gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
// 7. تقييم سلوك القيادة
|
||||
_buildBehaviorSection(gc),
|
||||
const SizedBox(
|
||||
height: FinanceDesignSystem.verticalSectionPadding),
|
||||
|
||||
// 8. الإنجازات
|
||||
_buildAchievementsSection(gc),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
// 8. الإنجازات
|
||||
_buildAchievementsSection(gc),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -221,21 +226,27 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
Widget _buildBehaviorSection(GamificationController gc) {
|
||||
bool isExcellent = gc.behaviorScore >= 90;
|
||||
bool isGood = gc.behaviorScore >= 75 && gc.behaviorScore < 90;
|
||||
|
||||
Color statusColor = isExcellent
|
||||
? Colors.green
|
||||
: isGood ? Colors.orange : Colors.red;
|
||||
|
||||
String statusText = isExcellent
|
||||
? 'Excellent'.tr
|
||||
: isGood ? 'Good'.tr : 'Needs Improvement'.tr;
|
||||
Color statusColor = isExcellent
|
||||
? Colors.green
|
||||
: isGood
|
||||
? Colors.orange
|
||||
: Colors.red;
|
||||
|
||||
String statusText = isExcellent
|
||||
? 'Excellent'.tr
|
||||
: isGood
|
||||
? 'Good'.tr
|
||||
: 'Needs Improvement'.tr;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: FinanceDesignSystem.cardColor,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 10, offset: Offset(0, 4))],
|
||||
boxShadow: const [
|
||||
BoxShadow(color: Colors.black12, blurRadius: 10, offset: Offset(0, 4))
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -245,13 +256,16 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.shield_rounded, color: FinanceDesignSystem.accentBlue),
|
||||
Icon(Icons.shield_rounded,
|
||||
color: FinanceDesignSystem.accentBlue),
|
||||
const SizedBox(width: 8),
|
||||
Text('Driving Behavior'.tr, style: FinanceDesignSystem.headingStyle),
|
||||
Text('Driving Behavior'.tr,
|
||||
style: FinanceDesignSystem.headingStyle),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: statusColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
@@ -306,7 +320,11 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _behaviorStatItem({required String title, required String value, required IconData icon, required Color color}) {
|
||||
Widget _behaviorStatItem(
|
||||
{required String title,
|
||||
required String value,
|
||||
required IconData icon,
|
||||
required Color color}) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
@@ -318,18 +336,22 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
child: Icon(icon, color: color, size: 24),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(value, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16, color: FinanceDesignSystem.primaryDark)),
|
||||
Text(title, style: const TextStyle(fontSize: 12, color: FinanceDesignSystem.textSecondary)),
|
||||
Text(value,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
color: FinanceDesignSystem.primaryDark)),
|
||||
Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: FinanceDesignSystem.textSecondary)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ═══════ قسم الإنجازات ═══════
|
||||
Widget _buildAchievementsSection(GamificationController gc) {
|
||||
final unlockedAch =
|
||||
gc.achievements.where((a) => a.isUnlocked).toList();
|
||||
final lockedAch =
|
||||
gc.achievements.where((a) => !a.isUnlocked).toList();
|
||||
final unlockedAch = gc.achievements.where((a) => a.isUnlocked).toList();
|
||||
final lockedAch = gc.achievements.where((a) => !a.isUnlocked).toList();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -346,7 +368,7 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
),
|
||||
child: Text(
|
||||
'${gc.unlockedCount}/${gc.totalAchievements}',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
color: FinanceDesignSystem.accentBlue,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
@@ -397,9 +419,8 @@ class StatisticsDashboard extends StatelessWidget {
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: unlocked
|
||||
? ach.color.withOpacity(0.15)
|
||||
: Colors.grey.shade200,
|
||||
color:
|
||||
unlocked ? ach.color.withOpacity(0.15) : Colors.grey.shade200,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Icon(
|
||||
|
||||
Reference in New Issue
Block a user