From d27e3ccfc082900292c4ca8e8de23e400deabd7a Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Tue, 27 Sep 2022 11:50:29 +0200 Subject: [PATCH] stats: top albums --- lib/l10n/app_en.arb | 1 + lib/widgets/stats/stats_page.dart | 10 +++++++++- untranslated.json | 33 +++++++++++++++++++++---------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f489120dc..8444c25c8 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -814,6 +814,7 @@ "statsTopCountriesSectionTitle": "Top Countries", "statsTopPlacesSectionTitle": "Top Places", "statsTopTagsSectionTitle": "Top Tags", + "statsTopAlbumsSectionTitle": "Top Albums", "viewerOpenPanoramaButtonLabel": "OPEN PANORAMA", "viewerSetWallpaperButtonLabel": "SET WALLPAPER", diff --git a/lib/widgets/stats/stats_page.dart b/lib/widgets/stats/stats_page.dart index e1479b427..5c77257f5 100644 --- a/lib/widgets/stats/stats_page.dart +++ b/lib/widgets/stats/stats_page.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:aves/model/entry.dart'; +import 'package:aves/model/filters/album.dart'; import 'package:aves/model/filters/filters.dart'; import 'package:aves/model/filters/location.dart'; import 'package:aves/model/filters/rating.dart'; @@ -47,7 +48,7 @@ class StatsPage extends StatefulWidget { } class _StatsPageState extends State { - final Map _entryCountPerCountry = {}, _entryCountPerPlace = {}, _entryCountPerTag = {}; + final Map _entryCountPerCountry = {}, _entryCountPerPlace = {}, _entryCountPerTag = {}, _entryCountPerAlbum = {}; final Map _entryCountPerRating = Map.fromEntries(List.generate(7, (i) => MapEntry(5 - i, 0))); late final ValueNotifier _isPageAnimatingNotifier; @@ -81,6 +82,11 @@ class _StatsPageState extends State { _entryCountPerTag[tag] = (_entryCountPerTag[tag] ?? 0) + 1; }); + final album = entry.directory; + if (album != null) { + _entryCountPerAlbum[album] = (_entryCountPerAlbum[album] ?? 0) + 1; + } + final rating = entry.rating; _entryCountPerRating[rating] = (_entryCountPerRating[rating] ?? 0) + 1; }); @@ -177,6 +183,7 @@ class _StatsPageState extends State { ), ); final showRatings = _entryCountPerRating.entries.any((kv) => kv.key != 0 && kv.value > 0); + final source = widget.source; child = AnimationLimiter( child: ListView( children: AnimationConfiguration.toStaggeredList( @@ -199,6 +206,7 @@ class _StatsPageState extends State { ..._buildFilterSection(context, l10n.statsTopCountriesSectionTitle, _entryCountPerCountry, (v) => LocationFilter(LocationLevel.country, v)), ..._buildFilterSection(context, l10n.statsTopPlacesSectionTitle, _entryCountPerPlace, (v) => LocationFilter(LocationLevel.place, v)), ..._buildFilterSection(context, l10n.statsTopTagsSectionTitle, _entryCountPerTag, TagFilter.new), + ..._buildFilterSection(context, l10n.statsTopAlbumsSectionTitle, _entryCountPerAlbum, (v) => AlbumFilter(v, source.getAlbumDisplayName(context, v))), if (showRatings) ..._buildFilterSection(context, l10n.searchRatingSectionTitle, _entryCountPerRating, RatingFilter.new, sortByCount: false, maxRowCount: null), ], ), diff --git a/untranslated.json b/untranslated.json index bfcc646a4..541bdd91f 100644 --- a/untranslated.json +++ b/untranslated.json @@ -6,7 +6,8 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "el": [ @@ -16,7 +17,8 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "es": [ @@ -42,6 +44,7 @@ "searchMetadataSectionTitle", "settingsConfirmationAfterMoveToBinItems", "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle", "viewerInfoLabelDescription" ], @@ -50,7 +53,8 @@ "widgetOpenPageViewer", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "id": [ @@ -60,7 +64,8 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "it": [ @@ -70,7 +75,8 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "ja": [ @@ -97,6 +103,7 @@ "settingsConfirmationAfterMoveToBinItems", "settingsViewerGestureSideTapNext", "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle", "viewerInfoLabelDescription" ], @@ -105,7 +112,8 @@ "widgetOpenPageViewer", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "nl": [ @@ -115,7 +123,8 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "pt": [ @@ -125,7 +134,8 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "ru": [ @@ -135,7 +145,8 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ], "tr": [ @@ -189,6 +200,7 @@ "settingsScreenSaverPageTitle", "settingsWidgetShowOutline", "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle", "viewerSetWallpaperButtonLabel", "viewerInfoLabelDescription" ], @@ -200,6 +212,7 @@ "tileLayoutMosaic", "albumGroupType", "albumMimeTypeMixed", - "settingsWidgetOpenPage" + "settingsWidgetOpenPage", + "statsTopAlbumsSectionTitle" ] }