A cross platform Audiobookshelf client for Android and iOS
Dart
Move the stats heatmap out of the chart toggle and into the reorderable sections
Barnabas18cd88c9f925
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex 93bd5bd0..975b03fd 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -127,7 +127,7 @@ class _SettingsScreenState extends State<SettingsScreen> {// Recent sessions is intentionally absent: it infinite-scrolls, so it is// pinned to the bottom of the stats page and can't be reordered or hidden.static const _statsSectionIds = [- 'hero', 'goals', 'periods', 'activity', 'chart', 'dayofweek', 'top',+ 'hero', 'goals', 'periods', 'activity', 'chart', 'heatmap', 'dayofweek', 'top',];int _streamingCacheSizeMb = 0;bool _localServerEnabled = false;@@ -370,6 +370,7 @@ class _SettingsScreenState extends State<SettingsScreen> {case 'periods': return l.statsSectionTimePeriods;case 'activity': return l.statsActivity;case 'chart': return l.statsChartTitle;+ case 'heatmap': return l.statsChartHeatmap;case 'dayofweek': return l.statsDayOfWeek;case 'top': return l.statsMostListened;}@@ -383,6 +384,7 @@ class _SettingsScreenState extends State<SettingsScreen> {case 'periods': return Icons.date_range_rounded;case 'activity': return Icons.local_fire_department_rounded;case 'chart': return Icons.bar_chart_rounded;+ case 'heatmap': return Icons.calendar_view_month_rounded;case 'dayofweek': return Icons.view_week_rounded;case 'top': return Icons.star_outline_rounded;}@@ -1241,7 +1243,6 @@ class _SettingsScreenState extends State<SettingsScreen> {segments: [ButtonSegment(value: 'bar', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.statsChartBar, maxLines: 1))),ButtonSegment(value: 'line', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.statsChartLine, maxLines: 1))),- ButtonSegment(value: 'heatmap', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.statsChartHeatmap, maxLines: 1))),],selected: {_statsChartStyle},onSelectionChanged: _loaded ? (selected) {@@ -1251,25 +1252,23 @@ class _SettingsScreenState extends State<SettingsScreen> {style: const ButtonStyle(visualDensity: VisualDensity.compact),),),- if (_statsChartStyle != 'heatmap') ...[- const SizedBox(height: 8),- SizedBox(- width: double.infinity,- child: SegmentedButton<int>(- showSelectedIcon: false,- segments: [- ButtonSegment(value: 7, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.statsChartDays7, maxLines: 1))),- ButtonSegment(value: 30, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.statsChartDays30, maxLines: 1))),- ],- selected: {_statsChartRange},- onSelectionChanged: _loaded ? (selected) {- setState(() => _statsChartRange = selected.first);- PlayerSettings.setStatsChartRange(_statsChartRange);- } : null,- style: const ButtonStyle(visualDensity: VisualDensity.compact),- ),+ const SizedBox(height: 8),+ SizedBox(+ width: double.infinity,+ child: SegmentedButton<int>(+ showSelectedIcon: false,+ segments: [+ ButtonSegment(value: 7, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.statsChartDays7, maxLines: 1))),+ ButtonSegment(value: 30, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.statsChartDays30, maxLines: 1))),+ ],+ selected: {_statsChartRange},+ onSelectionChanged: _loaded ? (selected) {+ setState(() => _statsChartRange = selected.first);+ PlayerSettings.setStatsChartRange(_statsChartRange);+ } : null,+ style: const ButtonStyle(visualDensity: VisualDensity.compact),),- ],+ ),],),),diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex 548162e7..61966be9 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -170,8 +170,13 @@ class PlayerSettings {/// player as listening time accrues; read-only here.static Future<double> getStatsTimeSaved() => _get('stats_time_saved', 0.0);- /// Listening chart style on the stats page: 'bar' | 'line' | 'heatmap'.- static Future<String> getStatsChartStyle() => _get('stats_chart_style', 'bar');+ /// Listening chart style on the stats page: 'bar' | 'line'.+ /// 'heatmap' used to be a chart style; it's now its own stats section, so a+ /// saved 'heatmap' value is coerced back to 'bar'.+ static Future<String> getStatsChartStyle() async {+ final v = await _get('stats_chart_style', 'bar');+ return v == 'heatmap' ? 'bar' : v;+ }static Future<void> setStatsChartStyle(String value) => _set('stats_chart_style', value, notify: true);/// Days covered by the bar/line chart: 7 or 30. The heatmap is always a year.