stats: top albums

This commit is contained in:
Thibault Deckers 2022-09-27 11:50:29 +02:00
parent eb6c9969f7
commit d27e3ccfc0
3 changed files with 33 additions and 11 deletions

View file

@ -814,6 +814,7 @@
"statsTopCountriesSectionTitle": "Top Countries", "statsTopCountriesSectionTitle": "Top Countries",
"statsTopPlacesSectionTitle": "Top Places", "statsTopPlacesSectionTitle": "Top Places",
"statsTopTagsSectionTitle": "Top Tags", "statsTopTagsSectionTitle": "Top Tags",
"statsTopAlbumsSectionTitle": "Top Albums",
"viewerOpenPanoramaButtonLabel": "OPEN PANORAMA", "viewerOpenPanoramaButtonLabel": "OPEN PANORAMA",
"viewerSetWallpaperButtonLabel": "SET WALLPAPER", "viewerSetWallpaperButtonLabel": "SET WALLPAPER",

View file

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:aves/model/entry.dart'; 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/filters.dart';
import 'package:aves/model/filters/location.dart'; import 'package:aves/model/filters/location.dart';
import 'package:aves/model/filters/rating.dart'; import 'package:aves/model/filters/rating.dart';
@ -47,7 +48,7 @@ class StatsPage extends StatefulWidget {
} }
class _StatsPageState extends State<StatsPage> { class _StatsPageState extends State<StatsPage> {
final Map<String, int> _entryCountPerCountry = {}, _entryCountPerPlace = {}, _entryCountPerTag = {}; final Map<String, int> _entryCountPerCountry = {}, _entryCountPerPlace = {}, _entryCountPerTag = {}, _entryCountPerAlbum = {};
final Map<int, int> _entryCountPerRating = Map.fromEntries(List.generate(7, (i) => MapEntry(5 - i, 0))); final Map<int, int> _entryCountPerRating = Map.fromEntries(List.generate(7, (i) => MapEntry(5 - i, 0)));
late final ValueNotifier<bool> _isPageAnimatingNotifier; late final ValueNotifier<bool> _isPageAnimatingNotifier;
@ -81,6 +82,11 @@ class _StatsPageState extends State<StatsPage> {
_entryCountPerTag[tag] = (_entryCountPerTag[tag] ?? 0) + 1; _entryCountPerTag[tag] = (_entryCountPerTag[tag] ?? 0) + 1;
}); });
final album = entry.directory;
if (album != null) {
_entryCountPerAlbum[album] = (_entryCountPerAlbum[album] ?? 0) + 1;
}
final rating = entry.rating; final rating = entry.rating;
_entryCountPerRating[rating] = (_entryCountPerRating[rating] ?? 0) + 1; _entryCountPerRating[rating] = (_entryCountPerRating[rating] ?? 0) + 1;
}); });
@ -177,6 +183,7 @@ class _StatsPageState extends State<StatsPage> {
), ),
); );
final showRatings = _entryCountPerRating.entries.any((kv) => kv.key != 0 && kv.value > 0); final showRatings = _entryCountPerRating.entries.any((kv) => kv.key != 0 && kv.value > 0);
final source = widget.source;
child = AnimationLimiter( child = AnimationLimiter(
child: ListView( child: ListView(
children: AnimationConfiguration.toStaggeredList( children: AnimationConfiguration.toStaggeredList(
@ -199,6 +206,7 @@ class _StatsPageState extends State<StatsPage> {
..._buildFilterSection<String>(context, l10n.statsTopCountriesSectionTitle, _entryCountPerCountry, (v) => LocationFilter(LocationLevel.country, v)), ..._buildFilterSection<String>(context, l10n.statsTopCountriesSectionTitle, _entryCountPerCountry, (v) => LocationFilter(LocationLevel.country, v)),
..._buildFilterSection<String>(context, l10n.statsTopPlacesSectionTitle, _entryCountPerPlace, (v) => LocationFilter(LocationLevel.place, v)), ..._buildFilterSection<String>(context, l10n.statsTopPlacesSectionTitle, _entryCountPerPlace, (v) => LocationFilter(LocationLevel.place, v)),
..._buildFilterSection<String>(context, l10n.statsTopTagsSectionTitle, _entryCountPerTag, TagFilter.new), ..._buildFilterSection<String>(context, l10n.statsTopTagsSectionTitle, _entryCountPerTag, TagFilter.new),
..._buildFilterSection<String>(context, l10n.statsTopAlbumsSectionTitle, _entryCountPerAlbum, (v) => AlbumFilter(v, source.getAlbumDisplayName(context, v))),
if (showRatings) ..._buildFilterSection<int>(context, l10n.searchRatingSectionTitle, _entryCountPerRating, RatingFilter.new, sortByCount: false, maxRowCount: null), if (showRatings) ..._buildFilterSection<int>(context, l10n.searchRatingSectionTitle, _entryCountPerRating, RatingFilter.new, sortByCount: false, maxRowCount: null),
], ],
), ),

View file

@ -6,7 +6,8 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"el": [ "el": [
@ -16,7 +17,8 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"es": [ "es": [
@ -42,6 +44,7 @@
"searchMetadataSectionTitle", "searchMetadataSectionTitle",
"settingsConfirmationAfterMoveToBinItems", "settingsConfirmationAfterMoveToBinItems",
"settingsWidgetOpenPage", "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle",
"viewerInfoLabelDescription" "viewerInfoLabelDescription"
], ],
@ -50,7 +53,8 @@
"widgetOpenPageViewer", "widgetOpenPageViewer",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"id": [ "id": [
@ -60,7 +64,8 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"it": [ "it": [
@ -70,7 +75,8 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"ja": [ "ja": [
@ -97,6 +103,7 @@
"settingsConfirmationAfterMoveToBinItems", "settingsConfirmationAfterMoveToBinItems",
"settingsViewerGestureSideTapNext", "settingsViewerGestureSideTapNext",
"settingsWidgetOpenPage", "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle",
"viewerInfoLabelDescription" "viewerInfoLabelDescription"
], ],
@ -105,7 +112,8 @@
"widgetOpenPageViewer", "widgetOpenPageViewer",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"nl": [ "nl": [
@ -115,7 +123,8 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"pt": [ "pt": [
@ -125,7 +134,8 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"ru": [ "ru": [
@ -135,7 +145,8 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
], ],
"tr": [ "tr": [
@ -189,6 +200,7 @@
"settingsScreenSaverPageTitle", "settingsScreenSaverPageTitle",
"settingsWidgetShowOutline", "settingsWidgetShowOutline",
"settingsWidgetOpenPage", "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle",
"viewerSetWallpaperButtonLabel", "viewerSetWallpaperButtonLabel",
"viewerInfoLabelDescription" "viewerInfoLabelDescription"
], ],
@ -200,6 +212,7 @@
"tileLayoutMosaic", "tileLayoutMosaic",
"albumGroupType", "albumGroupType",
"albumMimeTypeMixed", "albumMimeTypeMixed",
"settingsWidgetOpenPage" "settingsWidgetOpenPage",
"statsTopAlbumsSectionTitle"
] ]
} }