|
|
@@ -3,6 +3,7 @@ import 'package:fl_chart/fl_chart.dart';
|
|
|
import '../l10n/app_localizations.dart';
|
|
|
import '../utils/colors.dart';
|
|
|
import '../utils/score_manager.dart';
|
|
|
+import '../utils/theme_notifier.dart';
|
|
|
|
|
|
class StatsScreen extends StatefulWidget {
|
|
|
const StatsScreen({super.key});
|
|
|
@@ -38,51 +39,55 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Scaffold(
|
|
|
- backgroundColor: ZenColors.appBackground,
|
|
|
- appBar: AppBar(
|
|
|
- backgroundColor: ZenColors.appBackground,
|
|
|
- elevation: 0,
|
|
|
- leading: IconButton(
|
|
|
- onPressed: () => Navigator.of(context).pop(true),
|
|
|
- icon: const Icon(
|
|
|
- Icons.arrow_back,
|
|
|
- color: ZenColors.primaryText,
|
|
|
- ),
|
|
|
- ),
|
|
|
- title: Text(
|
|
|
- AppLocalizations.of(context)!.statistics,
|
|
|
- style: TextStyle(
|
|
|
- color: ZenColors.primaryText,
|
|
|
- fontSize: 24,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- ),
|
|
|
- ),
|
|
|
- centerTitle: true,
|
|
|
- bottom: TabBar(
|
|
|
- controller: _tabController,
|
|
|
- labelColor: ZenColors.buttonBackground,
|
|
|
- unselectedLabelColor: ZenColors.secondaryText,
|
|
|
- indicatorColor: ZenColors.buttonBackground,
|
|
|
- tabs: [
|
|
|
- Tab(text: AppLocalizations.of(context)!.overview),
|
|
|
- Tab(text: AppLocalizations.of(context)!.charts),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- body: _isLoading
|
|
|
- ? const Center(
|
|
|
- child: CircularProgressIndicator(
|
|
|
- valueColor: AlwaysStoppedAnimation<Color>(ZenColors.buttonBackground),
|
|
|
+ return ThemeAwareBuilder(
|
|
|
+ builder: (context, theme) {
|
|
|
+ return Scaffold(
|
|
|
+ backgroundColor: ZenColors.currentAppBackground,
|
|
|
+ appBar: AppBar(
|
|
|
+ backgroundColor: ZenColors.currentAppBackground,
|
|
|
+ elevation: 0,
|
|
|
+ leading: IconButton(
|
|
|
+ onPressed: () => Navigator.of(context).pop(true),
|
|
|
+ icon: Icon(
|
|
|
+ Icons.arrow_back,
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ title: Text(
|
|
|
+ AppLocalizations.of(context)!.statistics,
|
|
|
+ style: TextStyle(
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
+ fontSize: 24,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
),
|
|
|
- )
|
|
|
- : TabBarView(
|
|
|
+ ),
|
|
|
+ centerTitle: true,
|
|
|
+ bottom: TabBar(
|
|
|
controller: _tabController,
|
|
|
- children: [
|
|
|
- _buildOverviewTab(),
|
|
|
- _buildChartsTab(),
|
|
|
+ labelColor: ZenColors.currentButtonBackground,
|
|
|
+ unselectedLabelColor: ZenColors.currentSecondaryText,
|
|
|
+ indicatorColor: ZenColors.currentButtonBackground,
|
|
|
+ tabs: [
|
|
|
+ Tab(text: AppLocalizations.of(context)!.overview),
|
|
|
+ Tab(text: AppLocalizations.of(context)!.charts),
|
|
|
],
|
|
|
),
|
|
|
+ ),
|
|
|
+ body: _isLoading
|
|
|
+ ? Center(
|
|
|
+ child: CircularProgressIndicator(
|
|
|
+ valueColor: AlwaysStoppedAnimation<Color>(ZenColors.currentButtonBackground),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ : TabBarView(
|
|
|
+ controller: _tabController,
|
|
|
+ children: [
|
|
|
+ _buildOverviewTab(),
|
|
|
+ _buildChartsTab(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -114,7 +119,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
Text(
|
|
|
AppLocalizations.of(context)!.yourRelaxationJourney,
|
|
|
style: TextStyle(
|
|
|
- color: ZenColors.primaryText,
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
fontSize: 22,
|
|
|
fontWeight: FontWeight.bold,
|
|
|
),
|
|
|
@@ -132,7 +137,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
AppLocalizations.of(context)!.todaysPoints,
|
|
|
ScoreManager.todayScore.toString(),
|
|
|
Icons.today,
|
|
|
- ZenColors.buttonBackground,
|
|
|
+ ZenColors.currentButtonBackground,
|
|
|
),
|
|
|
_buildStatCard(
|
|
|
AppLocalizations.of(context)!.totalPoints,
|
|
|
@@ -174,7 +179,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
return Container(
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
decoration: BoxDecoration(
|
|
|
- color: ZenColors.uiElements.withValues(alpha: 0.3),
|
|
|
+ color: ZenColors.currentUiElements.withValues(alpha: 0.3),
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
border: Border.all(
|
|
|
color: color.withValues(alpha: 0.3),
|
|
|
@@ -192,8 +197,8 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
const SizedBox(height: 8),
|
|
|
Text(
|
|
|
value,
|
|
|
- style: const TextStyle(
|
|
|
- color: ZenColors.primaryText,
|
|
|
+ style: TextStyle(
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
fontSize: 20,
|
|
|
fontWeight: FontWeight.bold,
|
|
|
),
|
|
|
@@ -202,7 +207,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
Text(
|
|
|
title,
|
|
|
style: TextStyle(
|
|
|
- color: ZenColors.secondaryText,
|
|
|
+ color: ZenColors.currentSecondaryText,
|
|
|
fontSize: 12,
|
|
|
),
|
|
|
textAlign: TextAlign.center,
|
|
|
@@ -221,7 +226,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
Text(
|
|
|
AppLocalizations.of(context)!.achievements,
|
|
|
style: TextStyle(
|
|
|
- color: ZenColors.primaryText,
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
fontSize: 22,
|
|
|
fontWeight: FontWeight.bold,
|
|
|
),
|
|
|
@@ -255,13 +260,13 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
decoration: BoxDecoration(
|
|
|
color: unlocked
|
|
|
- ? ZenColors.buttonBackground.withValues(alpha: 0.2)
|
|
|
- : ZenColors.uiElements.withValues(alpha: 0.1),
|
|
|
+ ? ZenColors.currentButtonBackground.withValues(alpha: 0.2)
|
|
|
+ : ZenColors.currentUiElements.withValues(alpha: 0.1),
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
border: Border.all(
|
|
|
color: unlocked
|
|
|
- ? ZenColors.buttonBackground.withValues(alpha: 0.5)
|
|
|
- : ZenColors.uiElements.withValues(alpha: 0.3),
|
|
|
+ ? ZenColors.currentButtonBackground.withValues(alpha: 0.5)
|
|
|
+ : ZenColors.currentUiElements.withValues(alpha: 0.3),
|
|
|
width: 1,
|
|
|
),
|
|
|
),
|
|
|
@@ -270,14 +275,14 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
children: [
|
|
|
Icon(
|
|
|
icon,
|
|
|
- color: unlocked ? ZenColors.buttonBackground : ZenColors.mutedText,
|
|
|
+ color: unlocked ? ZenColors.currentButtonBackground : ZenColors.currentMutedText,
|
|
|
size: 32,
|
|
|
),
|
|
|
const SizedBox(height: 8),
|
|
|
Text(
|
|
|
title,
|
|
|
style: TextStyle(
|
|
|
- color: unlocked ? ZenColors.primaryText : ZenColors.mutedText,
|
|
|
+ color: unlocked ? ZenColors.currentPrimaryText : ZenColors.currentMutedText,
|
|
|
fontSize: 11,
|
|
|
fontWeight: unlocked ? FontWeight.w600 : FontWeight.normal,
|
|
|
),
|
|
|
@@ -339,7 +344,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
Text(
|
|
|
AppLocalizations.of(context)!.last7Days,
|
|
|
style: TextStyle(
|
|
|
- color: ZenColors.primaryText,
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
fontSize: 22,
|
|
|
fontWeight: FontWeight.bold,
|
|
|
),
|
|
|
@@ -348,7 +353,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
Container(
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
decoration: BoxDecoration(
|
|
|
- color: ZenColors.uiElements.withValues(alpha: 0.2),
|
|
|
+ color: ZenColors.currentUiElements.withValues(alpha: 0.2),
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
),
|
|
|
child: Column(
|
|
|
@@ -366,7 +371,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
child: Text(
|
|
|
dayName,
|
|
|
style: TextStyle(
|
|
|
- color: isToday ? ZenColors.buttonBackground : ZenColors.secondaryText,
|
|
|
+ color: isToday ? ZenColors.currentButtonBackground : ZenColors.currentSecondaryText,
|
|
|
fontSize: 14,
|
|
|
fontWeight: isToday ? FontWeight.bold : FontWeight.normal,
|
|
|
),
|
|
|
@@ -378,9 +383,9 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 10),
|
|
|
child: LinearProgressIndicator(
|
|
|
value: entry.value / (ScoreManager.bestDayScore.clamp(1, double.infinity)),
|
|
|
- backgroundColor: ZenColors.uiElements.withValues(alpha: 0.3),
|
|
|
+ backgroundColor: ZenColors.currentUiElements.withValues(alpha: 0.3),
|
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
|
- isToday ? ZenColors.buttonBackground : ZenColors.uiElements,
|
|
|
+ isToday ? ZenColors.currentButtonBackground : ZenColors.currentUiElements,
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
@@ -390,7 +395,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
child: Text(
|
|
|
entry.value.toString(),
|
|
|
style: TextStyle(
|
|
|
- color: isToday ? ZenColors.buttonBackground : ZenColors.primaryText,
|
|
|
+ color: isToday ? ZenColors.currentButtonBackground : ZenColors.currentPrimaryText,
|
|
|
fontSize: 14,
|
|
|
fontWeight: isToday ? FontWeight.bold : FontWeight.normal,
|
|
|
),
|
|
|
@@ -431,7 +436,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
Text(
|
|
|
AppLocalizations.of(context)!.dailyProgress14Days,
|
|
|
style: TextStyle(
|
|
|
- color: ZenColors.primaryText,
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
fontSize: 22,
|
|
|
fontWeight: FontWeight.bold,
|
|
|
),
|
|
|
@@ -441,7 +446,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
height: 300,
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
decoration: BoxDecoration(
|
|
|
- color: ZenColors.uiElements.withValues(alpha: 0.2),
|
|
|
+ color: ZenColors.currentUiElements.withValues(alpha: 0.2),
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
),
|
|
|
child: LineChart(
|
|
|
@@ -452,7 +457,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
drawVerticalLine: false,
|
|
|
getDrawingHorizontalLine: (value) {
|
|
|
return FlLine(
|
|
|
- color: ZenColors.uiElements.withValues(alpha: 0.3),
|
|
|
+ color: ZenColors.currentUiElements.withValues(alpha: 0.3),
|
|
|
strokeWidth: 1,
|
|
|
);
|
|
|
},
|
|
|
@@ -466,8 +471,8 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
final date = DateTime.parse(lastDays[value.toInt()].key);
|
|
|
return Text(
|
|
|
'${date.day}',
|
|
|
- style: const TextStyle(
|
|
|
- color: ZenColors.secondaryText,
|
|
|
+ style: TextStyle(
|
|
|
+ color: ZenColors.currentSecondaryText,
|
|
|
fontSize: 12,
|
|
|
),
|
|
|
);
|
|
|
@@ -483,8 +488,8 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
getTitlesWidget: (value, meta) {
|
|
|
return Text(
|
|
|
value.toInt().toString(),
|
|
|
- style: const TextStyle(
|
|
|
- color: ZenColors.secondaryText,
|
|
|
+ style: TextStyle(
|
|
|
+ color: ZenColors.currentSecondaryText,
|
|
|
fontSize: 12,
|
|
|
),
|
|
|
);
|
|
|
@@ -507,8 +512,8 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
isCurved: true,
|
|
|
gradient: LinearGradient(
|
|
|
colors: [
|
|
|
- ZenColors.buttonBackground.withValues(alpha: 0.8),
|
|
|
- ZenColors.buttonBackground,
|
|
|
+ ZenColors.currentButtonBackground.withValues(alpha: 0.8),
|
|
|
+ ZenColors.currentButtonBackground,
|
|
|
],
|
|
|
),
|
|
|
barWidth: 3,
|
|
|
@@ -517,9 +522,9 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
getDotPainter: (spot, percent, barData, index) {
|
|
|
return FlDotCirclePainter(
|
|
|
radius: 4,
|
|
|
- color: ZenColors.buttonBackground,
|
|
|
+ color: ZenColors.currentButtonBackground,
|
|
|
strokeWidth: 2,
|
|
|
- strokeColor: ZenColors.primaryText,
|
|
|
+ strokeColor: ZenColors.currentPrimaryText,
|
|
|
);
|
|
|
},
|
|
|
),
|
|
|
@@ -529,8 +534,8 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
begin: Alignment.topCenter,
|
|
|
end: Alignment.bottomCenter,
|
|
|
colors: [
|
|
|
- ZenColors.buttonBackground.withValues(alpha: 0.3),
|
|
|
- ZenColors.buttonBackground.withValues(alpha: 0.1),
|
|
|
+ ZenColors.currentButtonBackground.withValues(alpha: 0.3),
|
|
|
+ ZenColors.currentButtonBackground.withValues(alpha: 0.1),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
@@ -553,7 +558,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
Text(
|
|
|
AppLocalizations.of(context)!.weeklySummary8Weeks,
|
|
|
style: TextStyle(
|
|
|
- color: ZenColors.primaryText,
|
|
|
+ color: ZenColors.currentPrimaryText,
|
|
|
fontSize: 22,
|
|
|
fontWeight: FontWeight.bold,
|
|
|
),
|
|
|
@@ -563,7 +568,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
height: 300,
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
decoration: BoxDecoration(
|
|
|
- color: ZenColors.uiElements.withValues(alpha: 0.2),
|
|
|
+ color: ZenColors.currentUiElements.withValues(alpha: 0.2),
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
),
|
|
|
child: BarChart(
|
|
|
@@ -574,7 +579,7 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
drawVerticalLine: false,
|
|
|
getDrawingHorizontalLine: (value) {
|
|
|
return FlLine(
|
|
|
- color: ZenColors.uiElements.withValues(alpha: 0.3),
|
|
|
+ color: ZenColors.currentUiElements.withValues(alpha: 0.3),
|
|
|
strokeWidth: 1,
|
|
|
);
|
|
|
},
|
|
|
@@ -587,8 +592,8 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
if (value.toInt() >= 0 && value.toInt() < weeklyScores.length) {
|
|
|
return Text(
|
|
|
'W${value.toInt() + 1}',
|
|
|
- style: const TextStyle(
|
|
|
- color: ZenColors.secondaryText,
|
|
|
+ style: TextStyle(
|
|
|
+ color: ZenColors.currentSecondaryText,
|
|
|
fontSize: 12,
|
|
|
),
|
|
|
);
|
|
|
@@ -604,8 +609,8 @@ class _StatsScreenState extends State<StatsScreen> with TickerProviderStateMixin
|
|
|
getTitlesWidget: (value, meta) {
|
|
|
return Text(
|
|
|
value.toInt().toString(),
|
|
|
- style: const TextStyle(
|
|
|
- color: ZenColors.secondaryText,
|
|
|
+ style: TextStyle(
|
|
|
+ color: ZenColors.currentSecondaryText,
|
|
|
fontSize: 12,
|
|
|
),
|
|
|
);
|