add new featurs like new stat page

This commit is contained in:
Hamza-Ayed
2026-05-08 22:44:55 +03:00
parent efbc921273
commit 8f555691b9
33 changed files with 1194 additions and 585 deletions

View File

@@ -13,7 +13,7 @@ class DailyGoalWidget extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
color: FinanceDesignSystem.cardColor,
borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
boxShadow: [
BoxShadow(
@@ -55,17 +55,17 @@ class DailyGoalWidget extends StatelessWidget {
children: [
Text(
'Daily Goal'.tr,
style: const TextStyle(
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark,
),
),
Text(
'الهدف اليومي'.tr,
'Daily Goal'.tr,
style: TextStyle(
fontSize: 11,
color: Colors.grey.shade500,
color: FinanceDesignSystem.textSecondary,
),
),
],
@@ -80,13 +80,11 @@ class DailyGoalWidget extends StatelessWidget {
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Colors.grey.shade100,
color: FinanceDesignSystem.backgroundColor,
borderRadius: BorderRadius.circular(8),
),
child: Text(
controller.dailyGoal > 0
? 'Edit'.tr
: 'Set Goal'.tr,
controller.dailyGoal > 0 ? 'Edit'.tr : 'Set Goal'.tr,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
@@ -121,7 +119,7 @@ class DailyGoalWidget extends StatelessWidget {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.grey.shade400,
color: FinanceDesignSystem.textMuted,
),
),
],
@@ -135,7 +133,7 @@ class DailyGoalWidget extends StatelessWidget {
height: 12,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.grey.shade100,
color: FinanceDesignSystem.backgroundColor,
borderRadius: BorderRadius.circular(6),
),
),
@@ -197,7 +195,7 @@ class DailyGoalWidget extends StatelessWidget {
const SizedBox(width: 4),
Text(
'Goal Achieved!'.tr,
style: const TextStyle(
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.successGreen,
@@ -210,7 +208,7 @@ class DailyGoalWidget extends StatelessWidget {
'${'Remaining:'.tr} ${(controller.dailyGoal - controller.dailyEarnings).clamp(0, double.infinity).toStringAsFixed(0)} ${'SYP'.tr}',
style: TextStyle(
fontSize: 11,
color: Colors.grey.shade500,
color: FinanceDesignSystem.textSecondary,
),
),
],
@@ -228,6 +226,7 @@ class DailyGoalWidget extends StatelessWidget {
);
Get.defaultDialog(
backgroundColor: FinanceDesignSystem.cardColor,
title: 'Set Daily Goal'.tr,
titleStyle: FinanceDesignSystem.headingStyle,
content: Column(
@@ -252,13 +251,11 @@ class DailyGoalWidget extends StatelessWidget {
suffixText: 'SYP'.tr,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide:
BorderSide(color: Colors.grey.shade300),
borderSide: BorderSide(color: FinanceDesignSystem.borderColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide:
const BorderSide(color: FinanceDesignSystem.accentBlue),
borderSide: BorderSide(color: FinanceDesignSystem.accentBlue),
),
),
),
@@ -270,7 +267,8 @@ class DailyGoalWidget extends StatelessWidget {
return ActionChip(
label: Text('$goal'),
labelStyle: const TextStyle(fontSize: 12),
backgroundColor: FinanceDesignSystem.accentBlue.withOpacity(0.1),
backgroundColor:
FinanceDesignSystem.accentBlue.withOpacity(0.1),
side: BorderSide.none,
onPressed: () {
textController.text = goal.toString();
@@ -291,16 +289,15 @@ class DailyGoalWidget extends StatelessWidget {
style: ElevatedButton.styleFrom(
backgroundColor: FinanceDesignSystem.accentBlue,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 12),
),
child: Text('Save'.tr),
),
cancel: TextButton(
onPressed: () => Get.back(),
child: Text('Cancel'.tr,
style: const TextStyle(color: Colors.grey)),
child: Text('Cancel'.tr, style: const TextStyle(color: Colors.grey)),
),
);
}

View File

@@ -17,8 +17,12 @@ class LevelProgressWidget extends StatelessWidget {
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [level.color.withOpacity(0.08), level.gradientEnd.withOpacity(0.04)],
begin: Alignment.topLeft, end: Alignment.bottomRight,
colors: [
level.color.withOpacity(0.08),
level.gradientEnd.withOpacity(0.04)
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
border: Border.all(color: level.color.withOpacity(0.2), width: 1.5),
@@ -29,17 +33,27 @@ class LevelProgressWidget extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Driver Level'.tr, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
Text('Driver Level'.tr,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
padding:
const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
decoration: BoxDecoration(
gradient: LinearGradient(colors: [level.color, level.gradientEnd]),
gradient:
LinearGradient(colors: [level.color, level.gradientEnd]),
borderRadius: BorderRadius.circular(20),
),
child: Row(mainAxisSize: MainAxisSize.min, children: [
Text(level.emoji, style: const TextStyle(fontSize: 16)),
const SizedBox(width: 6),
Text(isAr ? level.nameAr : level.nameEn, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 13)),
Text(isAr ? level.nameAr : level.nameEn,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 13)),
]),
),
],
@@ -50,42 +64,94 @@ class LevelProgressWidget extends StatelessWidget {
final lvl = DriverLevels.all[i];
final isCurrent = lvl.id == level.id;
final isPast = DriverLevels.all.indexOf(level) > i;
return Expanded(child: Container(
margin: const EdgeInsets.symmetric(horizontal: 2), height: 8,
return Expanded(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 2),
height: 8,
decoration: BoxDecoration(
color: isCurrent ? lvl.color : isPast ? lvl.color.withOpacity(0.6) : Colors.grey.shade200,
color: isCurrent
? lvl.color
: isPast
? lvl.color.withOpacity(0.6)
: FinanceDesignSystem.backgroundColor,
borderRadius: BorderRadius.circular(4),
),
));
}),
),
const SizedBox(height: 6),
Row(children: DriverLevels.all.map((l) => Expanded(child: Text(l.emoji, textAlign: TextAlign.center, style: TextStyle(fontSize: l.id == level.id ? 16 : 12)))).toList()),
Row(
children: DriverLevels.all
.map((l) => Expanded(
child: Text(l.emoji,
textAlign: TextAlign.center,
style:
TextStyle(fontSize: l.id == level.id ? 16 : 12))))
.toList()),
const SizedBox(height: 16),
if (next != null) ...[
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text('${'Next Level:'.tr} ${isAr ? next.nameAr : next.nameEn}', style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.grey.shade700)),
Text('${(controller.progressToNext * 100).toStringAsFixed(0)}%', style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold, color: level.color)),
Text('${'Next Level:'.tr} ${isAr ? next.nameAr : next.nameEn}',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: FinanceDesignSystem.textSecondary)),
Text('${(controller.progressToNext * 100).toStringAsFixed(0)}%',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: level.color)),
]),
const SizedBox(height: 8),
Stack(children: [
Container(height: 10, decoration: BoxDecoration(color: Colors.grey.shade100, borderRadius: BorderRadius.circular(5))),
LayoutBuilder(builder: (ctx, c) => AnimatedContainer(
duration: const Duration(milliseconds: 800), curve: Curves.easeOutCubic, height: 10,
width: c.maxWidth * controller.progressToNext,
decoration: BoxDecoration(gradient: LinearGradient(colors: [level.color, level.gradientEnd]), borderRadius: BorderRadius.circular(5)),
)),
Container(
height: 10,
decoration: BoxDecoration(
color: FinanceDesignSystem.backgroundColor,
borderRadius: BorderRadius.circular(5))),
LayoutBuilder(
builder: (ctx, c) => AnimatedContainer(
duration: const Duration(milliseconds: 800),
curve: Curves.easeOutCubic,
height: 10,
width: c.maxWidth * controller.progressToNext,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [level.color, level.gradientEnd]),
borderRadius: BorderRadius.circular(5)),
)),
]),
const SizedBox(height: 6),
Text('${controller.totalPoints} / ${next.minPoints} ${'Points'.tr}', style: TextStyle(fontSize: 11, color: Colors.grey.shade500, fontFamily: 'digit')),
Text('${controller.totalPoints} / ${next.minPoints} ${'Points'.tr}',
style: TextStyle(
fontSize: 11,
color: FinanceDesignSystem.textMuted,
fontFamily: 'digit')),
] else
Center(child: Text('🏆 ${'Maximum Level Reached!'.tr}', style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: level.color))),
Center(
child: Text('🏆 ${'Maximum Level Reached!'.tr}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: level.color))),
const SizedBox(height: 16),
Wrap(spacing: 6, runSpacing: 6, children: level.perks.map((p) => Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(color: level.color.withOpacity(0.1), borderRadius: BorderRadius.circular(12)),
child: Text(p.tr, style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: level.color.withOpacity(0.8))),
)).toList()),
Wrap(
spacing: 6,
runSpacing: 6,
children: level.perks
.map((p) => Container(
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: level.color.withOpacity(0.1),
borderRadius: BorderRadius.circular(12)),
child: Text(p.tr,
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w600,
color: level.color.withOpacity(0.8))),
))
.toList()),
],
),
);

View File

@@ -14,63 +14,114 @@ class MonthlyChartWidget extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
color: FinanceDesignSystem.cardColor,
borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 10, offset: const Offset(0, 4))],
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.03),
blurRadius: 10,
offset: const Offset(0, 4))
],
),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text('Monthly Report'.tr, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text('Monthly Report'.tr,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
const SizedBox(height: 16),
// Summary Row
Row(children: [
_summaryTile('Total Earnings'.tr, '${sc.monthlyTotalEarnings.toStringAsFixed(0)} ${'SYP'.tr}', FinanceDesignSystem.successGreen),
_summaryTile(
'Total Earnings'.tr,
'${sc.monthlyTotalEarnings.toStringAsFixed(0)} ${'SYP'.tr}',
FinanceDesignSystem.successGreen),
const SizedBox(width: 12),
_summaryTile('Total Trips'.tr, '${sc.monthlyTotalTrips}', FinanceDesignSystem.accentBlue),
_summaryTile('Total Trips'.tr, '${sc.monthlyTotalTrips}',
FinanceDesignSystem.accentBlue),
const SizedBox(width: 12),
_summaryTile('Best Day'.tr, '${sc.bestDay}', const Color(0xFFFFD700)),
_summaryTile(
'Best Day'.tr, '${sc.bestDay}', const Color(0xFFFFD700)),
]),
const SizedBox(height: 20),
// Monthly Earnings Line Chart
SizedBox(
height: 200,
child: sc.monthlyEarnings.isEmpty
? Center(child: Text('No data yet'.tr, style: TextStyle(color: Colors.grey.shade400)))
? Center(
child: Text('No data yet'.tr,
style: TextStyle(color: Colors.grey.shade400)))
: LineChart(LineChartData(
lineTouchData: LineTouchData(
enabled: true,
touchTooltipData: LineTouchTooltipData(
getTooltipItems: (spots) => spots.map((s) => LineTooltipItem(
'${s.y.toStringAsFixed(0)} ${'SYP'.tr}',
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12),
)).toList(),
getTooltipItems: (spots) => spots
.map((s) => LineTooltipItem(
'${s.y.toStringAsFixed(0)} ${'SYP'.tr}',
const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 12),
))
.toList(),
),
),
gridData: FlGridData(show: true, drawVerticalLine: false,
getDrawingHorizontalLine: (v) => FlLine(color: Colors.grey.shade100, strokeWidth: 1),
gridData: FlGridData(
show: true,
drawVerticalLine: false,
getDrawingHorizontalLine: (v) => FlLine(
color: FinanceDesignSystem.borderColor,
strokeWidth: 1),
),
titlesData: FlTitlesData(
bottomTitles: AxisTitles(sideTitles: SideTitles(showTitles: true, interval: 5,
getTitlesWidget: (v, m) => Padding(padding: const EdgeInsets.only(top: 8),
child: Text('${v.toInt()}', style: TextStyle(fontSize: 10, color: Colors.grey.shade500)),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
interval: 5,
getTitlesWidget: (v, m) => Padding(
padding: const EdgeInsets.only(top: 8),
child: Text('${v.toInt()}',
style: TextStyle(
fontSize: 10,
color: FinanceDesignSystem.textSecondary)),
),
)),
leftTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
topTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
rightTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
leftTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false)),
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false)),
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false)),
),
borderData: FlBorderData(show: false),
lineBarsData: [
LineChartBarData(
spots: sc.monthlyEarnings.map((e) => FlSpot(e.day.toDouble(), e.pricePerDay)).toList(),
isCurved: true, curveSmoothness: 0.3,
color: FinanceDesignSystem.accentBlue, barWidth: 3,
dotData: FlDotData(show: true, getDotPainter: (s, p, d, i) =>
FlDotCirclePainter(radius: 3, color: FinanceDesignSystem.accentBlue, strokeWidth: 1, strokeColor: Colors.white),
spots: sc.monthlyEarnings
.map((e) =>
FlSpot(e.day.toDouble(), e.pricePerDay))
.toList(),
isCurved: true,
curveSmoothness: 0.3,
color: FinanceDesignSystem.accentBlue,
barWidth: 3,
dotData: FlDotData(
show: true,
getDotPainter: (s, p, d, i) => FlDotCirclePainter(
radius: 3,
color: FinanceDesignSystem.accentBlue,
strokeWidth: 1,
strokeColor: Colors.white),
),
belowBarData: BarAreaData(
show: true,
gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter,
colors: [FinanceDesignSystem.accentBlue.withOpacity(0.2), FinanceDesignSystem.accentBlue.withOpacity(0.0)],
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
FinanceDesignSystem.accentBlue.withOpacity(0.2),
FinanceDesignSystem.accentBlue.withOpacity(0.0)
],
),
),
),
@@ -87,11 +138,20 @@ class MonthlyChartWidget extends StatelessWidget {
return Expanded(
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(color: color.withOpacity(0.08), borderRadius: BorderRadius.circular(12)),
decoration: BoxDecoration(
color: color.withOpacity(0.08),
borderRadius: BorderRadius.circular(12)),
child: Column(children: [
Text(value, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w800, color: color)),
Text(value,
style: TextStyle(
fontSize: 14, fontWeight: FontWeight.w800, color: color)),
const SizedBox(height: 2),
Text(label, style: TextStyle(fontSize: 9, color: Colors.grey.shade600), textAlign: TextAlign.center, maxLines: 1, overflow: TextOverflow.ellipsis),
Text(label,
style: TextStyle(
fontSize: 9, color: FinanceDesignSystem.textSecondary),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis),
]),
),
);

View File

@@ -20,7 +20,7 @@ class StatSummaryCard extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
color: FinanceDesignSystem.cardColor,
borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
boxShadow: [
BoxShadow(
@@ -68,7 +68,7 @@ class StatSummaryCard extends StatelessWidget {
label,
style: TextStyle(
fontSize: 11,
color: Colors.grey.shade500,
color: FinanceDesignSystem.textSecondary,
fontWeight: FontWeight.w500,
),
maxLines: 1,

View File

@@ -13,26 +13,42 @@ class TodayChartWidget extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
color: FinanceDesignSystem.cardColor,
borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
boxShadow: [
BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 10, offset: const Offset(0, 4)),
BoxShadow(
color: Colors.black.withOpacity(0.03),
blurRadius: 10,
offset: const Offset(0, 4)),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Today Overview'.tr, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
Text('Today Overview'.tr,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
const SizedBox(height: 4),
Text('نظرة عامة على اليوم'.tr, style: TextStyle(fontSize: 11, color: Colors.grey.shade500)),
Text('Summary of your daily activity'.tr,
style: TextStyle(
fontSize: 11, color: FinanceDesignSystem.textSecondary)),
const SizedBox(height: 20),
_buildRow(Icons.monetization_on_rounded, 'Earnings'.tr, '${hc.totalMoneyToday} ${'SYP'.tr}', FinanceDesignSystem.successGreen),
_buildRow(
Icons.monetization_on_rounded,
'Earnings'.tr,
'${hc.totalMoneyToday} ${'SYP'.tr}',
FinanceDesignSystem.successGreen),
const Divider(height: 24),
_buildRow(Icons.local_taxi_rounded, 'Rides'.tr, hc.countRideToday, FinanceDesignSystem.accentBlue),
_buildRow(Icons.local_taxi_rounded, 'Rides'.tr, hc.countRideToday,
FinanceDesignSystem.accentBlue),
const Divider(height: 24),
Obx(() => _buildRow(Icons.timer_rounded, 'Online Duration'.tr, hc.totalDurationDisplay.value, const Color(0xFFFF9800))),
Obx(() => _buildRow(Icons.timer_rounded, 'Online Duration'.tr,
hc.totalDurationDisplay.value, const Color(0xFFFF9800))),
const Divider(height: 24),
_buildRow(Icons.cancel_outlined, 'Refused'.tr, hc.countRefuse, FinanceDesignSystem.dangerRed),
_buildRow(Icons.cancel_outlined, 'Refused'.tr, hc.countRefuse,
FinanceDesignSystem.dangerRed),
],
),
);
@@ -45,12 +61,24 @@ class TodayChartWidget extends StatelessWidget {
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(color: color.withOpacity(0.1), borderRadius: BorderRadius.circular(10)),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(10)),
child: Icon(icon, color: color, size: 20),
),
const SizedBox(width: 14),
Expanded(child: Text(label, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.grey.shade700))),
Text(value, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w800, color: FinanceDesignSystem.primaryDark, fontFamily: 'digit')),
Expanded(
child: Text(label,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: FinanceDesignSystem.primaryDark))),
Text(value,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
color: FinanceDesignSystem.primaryDark,
fontFamily: 'digit')),
],
);
}

View File

@@ -4,7 +4,6 @@ import 'package:fl_chart/fl_chart.dart';
import '../../../../constant/finance_design_system.dart';
import '../../../../controller/home/statistics/statistics_controller.dart';
class WeeklyChartWidget extends StatelessWidget {
const WeeklyChartWidget({super.key});
@@ -15,32 +14,56 @@ class WeeklyChartWidget extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
color: FinanceDesignSystem.cardColor,
borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 10, offset: const Offset(0, 4))],
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.03),
blurRadius: 10,
offset: const Offset(0, 4))
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text('Weekly Earnings'.tr, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
Text('Weekly Earnings'.tr,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(color: FinanceDesignSystem.successGreen.withOpacity(0.1), borderRadius: BorderRadius.circular(12)),
child: Text('${sc.weeklyEarnings.toStringAsFixed(0)} ${'SYP'.tr}', style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold, color: FinanceDesignSystem.successGreen)),
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: FinanceDesignSystem.successGreen.withOpacity(0.1),
borderRadius: BorderRadius.circular(12)),
child: Text(
'${sc.weeklyEarnings.toStringAsFixed(0)} ${'SYP'.tr}',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.successGreen)),
),
]),
const SizedBox(height: 8),
Row(children: [
_miniStat(Icons.local_taxi_rounded, '${sc.weeklyTrips}', 'Rides'.tr, FinanceDesignSystem.accentBlue),
_miniStat(Icons.local_taxi_rounded, '${sc.weeklyTrips}',
'Rides'.tr, FinanceDesignSystem.accentBlue),
const SizedBox(width: 16),
_miniStat(Icons.timer_rounded, '${sc.weeklyHours.toStringAsFixed(1)}h', 'Hours'.tr, const Color(0xFFFF9800)),
_miniStat(
Icons.timer_rounded,
'${sc.weeklyHours.toStringAsFixed(1)}h',
'Hours'.tr,
const Color(0xFFFF9800)),
]),
const SizedBox(height: 20),
SizedBox(
height: 180,
child: sc.weeklyStats.isEmpty
? Center(child: Text('No data yet'.tr, style: TextStyle(color: Colors.grey.shade400)))
? Center(
child: Text('No data yet'.tr,
style: TextStyle(color: Colors.grey.shade400)))
: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
@@ -48,24 +71,43 @@ class WeeklyChartWidget extends StatelessWidget {
barTouchData: BarTouchData(
enabled: true,
touchTooltipData: BarTouchTooltipData(
getTooltipItem: (group, gi, rod, ri) => BarTooltipItem(
getTooltipItem: (group, gi, rod, ri) =>
BarTooltipItem(
'${rod.toY.toStringAsFixed(0)} ${'SYP'.tr}',
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12),
const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 12),
),
),
),
titlesData: FlTitlesData(
show: true,
bottomTitles: AxisTitles(sideTitles: SideTitles(showTitles: true, getTitlesWidget: (v, m) {
final idx = v.toInt();
if (idx >= 0 && idx < sc.weeklyStats.length) {
return Padding(padding: const EdgeInsets.only(top: 8), child: Text(sc.weeklyStats[idx].dayName.tr, style: TextStyle(fontSize: 10, color: Colors.grey.shade500)));
}
return const SizedBox.shrink();
})),
leftTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
topTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
rightTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (v, m) {
final idx = v.toInt();
if (idx >= 0 &&
idx < sc.weeklyStats.length) {
return Padding(
padding:
const EdgeInsets.only(top: 8),
child: Text(
sc.weeklyStats[idx].dayName.tr,
style: TextStyle(
fontSize: 10,
color: FinanceDesignSystem
.textSecondary)));
}
return const SizedBox.shrink();
})),
leftTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false)),
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false)),
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false)),
),
borderData: FlBorderData(show: false),
gridData: const FlGridData(show: false),
@@ -76,12 +118,22 @@ class WeeklyChartWidget extends StatelessWidget {
BarChartRodData(
toY: stat.earnings,
width: 20,
borderRadius: const BorderRadius.vertical(top: Radius.circular(6)),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(6)),
gradient: LinearGradient(
begin: Alignment.bottomCenter, end: Alignment.topCenter,
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: isToday
? [FinanceDesignSystem.accentBlue, const Color(0xFF82B1FF)]
: [FinanceDesignSystem.primaryDark.withOpacity(0.6), FinanceDesignSystem.primaryDark.withOpacity(0.3)],
? [
FinanceDesignSystem.accentBlue,
const Color(0xFF82B1FF)
]
: [
FinanceDesignSystem.primaryDark
.withOpacity(0.6),
FinanceDesignSystem.primaryDark
.withOpacity(0.3)
],
),
),
]);
@@ -100,9 +152,15 @@ class WeeklyChartWidget extends StatelessWidget {
return Row(children: [
Icon(icon, size: 16, color: color),
const SizedBox(width: 4),
Text(value, style: TextStyle(fontSize: 13, fontWeight: FontWeight.bold, color: FinanceDesignSystem.primaryDark)),
Text(value,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark)),
const SizedBox(width: 4),
Text(label, style: TextStyle(fontSize: 11, color: Colors.grey.shade500)),
Text(label,
style: TextStyle(
fontSize: 11, color: FinanceDesignSystem.textSecondary)),
]);
}