From 2496763545857addeb9e4bf628c7a2fbaf5c6445 Mon Sep 17 00:00:00 2001 From: gabin_laigle Date: Thu, 10 Aug 2023 22:20:00 +0200 Subject: [PATCH] feat(stats): display session mean stat --- lib/session/view/session_stats.dart | 32 +++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/session/view/session_stats.dart b/lib/session/view/session_stats.dart index 87d6e80..b1d2bf4 100644 --- a/lib/session/view/session_stats.dart +++ b/lib/session/view/session_stats.dart @@ -17,9 +17,10 @@ class SessionStats extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ _getNumberText(solves, textStyle), - _getLastAverageText(solves, textStyle), _getBestText(solves, textStyle), _getWorstText(solves, textStyle), + _getMeanText(solves, textStyle), + _getLastAverageText(solves, textStyle), ], ); }, @@ -40,16 +41,6 @@ class SessionStats extends StatelessWidget { ); } - Widget _getLastAverageText(List solves, TextStyle? textStyle) { - final averageStat = StatsCalculator.computeAverage(solves, 5); - final statName = averageStat.getDisplayedName(); - final statValue = averageStat.getDisplayedValue(); - return Text( - 'Last $statName: $statValue', - style: textStyle, - ); - } - Widget _getBestText(List solves, TextStyle? textStyle) { final bestStat = StatsCalculator.computeBest(solves); final statName = bestStat.getDisplayedName(); @@ -69,4 +60,23 @@ class SessionStats extends StatelessWidget { style: textStyle, ); } + + Widget _getMeanText(List solves, TextStyle? textStyle) { + final meanStat = StatsCalculator.computeMean(solves); + final statValue = meanStat.getDisplayedValue(); + return Text( + 'Mean: $statValue', + style: textStyle, + ); + } + + Widget _getLastAverageText(List solves, TextStyle? textStyle) { + final averageStat = StatsCalculator.computeAverage(solves, 5); + final statName = averageStat.getDisplayedName(); + final statValue = averageStat.getDisplayedValue(); + return Text( + 'Last $statName: $statValue', + style: textStyle, + ); + } }