Skip to content

Commit

Permalink
feat(stats): display session mean stat
Browse files Browse the repository at this point in the history
  • Loading branch information
GabinL21 committed Aug 10, 2023
1 parent dc1a06d commit 2496763
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions lib/session/view/session_stats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
);
},
Expand All @@ -40,16 +41,6 @@ class SessionStats extends StatelessWidget {
);
}

Widget _getLastAverageText(List<Solve> 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<Solve> solves, TextStyle? textStyle) {
final bestStat = StatsCalculator.computeBest(solves);
final statName = bestStat.getDisplayedName();
Expand All @@ -69,4 +60,23 @@ class SessionStats extends StatelessWidget {
style: textStyle,
);
}

Widget _getMeanText(List<Solve> solves, TextStyle? textStyle) {
final meanStat = StatsCalculator.computeMean(solves);
final statValue = meanStat.getDisplayedValue();
return Text(
'Mean: $statValue',
style: textStyle,
);
}

Widget _getLastAverageText(List<Solve> solves, TextStyle? textStyle) {
final averageStat = StatsCalculator.computeAverage(solves, 5);
final statName = averageStat.getDisplayedName();
final statValue = averageStat.getDisplayedValue();
return Text(
'Last $statName: $statValue',
style: textStyle,
);
}
}

0 comments on commit 2496763

Please sign in to comment.