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",
"statsTopPlacesSectionTitle": "Top Places",
"statsTopTagsSectionTitle": "Top Tags",
"statsTopAlbumsSectionTitle": "Top Albums",
"viewerOpenPanoramaButtonLabel": "OPEN PANORAMA",
"viewerSetWallpaperButtonLabel": "SET WALLPAPER",

View file

@ -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<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)));
late final ValueNotifier<bool> _isPageAnimatingNotifier;
@ -81,6 +82,11 @@ class _StatsPageState extends State<StatsPage> {
_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<StatsPage> {
),
);
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<StatsPage> {
..._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.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),
],
),

View file

@ -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"
]
}