add new featurs like new stat page
This commit is contained in:
@@ -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)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user