explorer: stats

This commit is contained in:
Thibault Deckers 2024-08-07 20:19:52 +02:00
parent 94cb6e2b80
commit 59de10a1ce
5 changed files with 33 additions and 1 deletions

View file

@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
- Viewer: long descriptions are scrollable when overlay is expanded by tap - Viewer: long descriptions are scrollable when overlay is expanded by tap
- Collection: sort by duration - Collection: sort by duration
- Map: open external map app from map views - Map: open external map app from map views
- Explorer: stats
### Changed ### Changed

View file

@ -9,6 +9,7 @@ extension ExtraExplorerActionView on ExplorerAction {
return switch (this) { return switch (this) {
ExplorerAction.addShortcut => l10n.collectionActionAddShortcut, ExplorerAction.addShortcut => l10n.collectionActionAddShortcut,
ExplorerAction.setHome => l10n.collectionActionSetHome, ExplorerAction.setHome => l10n.collectionActionSetHome,
ExplorerAction.stats => l10n.menuActionStats,
}; };
} }
@ -18,6 +19,7 @@ extension ExtraExplorerActionView on ExplorerAction {
return switch (this) { return switch (this) {
ExplorerAction.addShortcut => AIcons.addShortcut, ExplorerAction.addShortcut => AIcons.addShortcut,
ExplorerAction.setHome => AIcons.home, ExplorerAction.setHome => AIcons.home,
ExplorerAction.stats => AIcons.stats,
}; };
} }
} }

View file

@ -117,7 +117,10 @@ class _ExplorerAppBarState extends State<ExplorerAppBar> with WidgetsBindingObse
return [ return [
ExplorerAction.addShortcut, ExplorerAction.addShortcut,
ExplorerAction.setHome, ExplorerAction.setHome,
].map((v) { null,
ExplorerAction.stats,
].map<PopupMenuEntry<ExplorerAction>>((v) {
if (v == null) return const PopupMenuDivider();
return PopupMenuItem( return PopupMenuItem(
value: v, value: v,
child: MenuRow(text: v.getText(context), icon: v.getIcon()), child: MenuRow(text: v.getText(context), icon: v.getIcon()),

View file

@ -9,6 +9,7 @@ import 'package:aves/services/common/services.dart';
import 'package:aves/widgets/common/action_mixins/feedback.dart'; import 'package:aves/widgets/common/action_mixins/feedback.dart';
import 'package:aves/widgets/common/extensions/build_context.dart'; import 'package:aves/widgets/common/extensions/build_context.dart';
import 'package:aves/widgets/dialogs/add_shortcut_dialog.dart'; import 'package:aves/widgets/dialogs/add_shortcut_dialog.dart';
import 'package:aves/widgets/stats/stats_page.dart';
import 'package:aves_model/aves_model.dart'; import 'package:aves_model/aves_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -29,6 +30,8 @@ class ExplorerActionDelegate with FeedbackMixin {
return isMain && device.canPinShortcut; return isMain && device.canPinShortcut;
case ExplorerAction.setHome: case ExplorerAction.setHome:
return isMain && !useTvLayout; return isMain && !useTvLayout;
case ExplorerAction.stats:
return isMain;
} }
} }
@ -36,6 +39,7 @@ class ExplorerActionDelegate with FeedbackMixin {
switch (action) { switch (action) {
case ExplorerAction.addShortcut: case ExplorerAction.addShortcut:
case ExplorerAction.setHome: case ExplorerAction.setHome:
case ExplorerAction.stats:
return true; return true;
} }
} }
@ -47,6 +51,8 @@ class ExplorerActionDelegate with FeedbackMixin {
_addShortcut(context); _addShortcut(context);
case ExplorerAction.setHome: case ExplorerAction.setHome:
_setHome(context); _setHome(context);
case ExplorerAction.stats:
_goToStats(context);
} }
} }
@ -82,4 +88,23 @@ class ExplorerActionDelegate with FeedbackMixin {
settings.setHome(HomePageSetting.explorer, customExplorerPath: directory.dirPath); settings.setHome(HomePageSetting.explorer, customExplorerPath: directory.dirPath);
showFeedback(context, FeedbackType.info, context.l10n.genericSuccessFeedback); showFeedback(context, FeedbackType.info, context.l10n.genericSuccessFeedback);
} }
void _goToStats(BuildContext context) {
final path = directory.dirPath;
final filter = PathFilter(path);
final collection = CollectionLens(
source: context.read<CollectionSource>(),
filters: {filter},
);
Navigator.maybeOf(context)?.push(
MaterialPageRoute(
settings: const RouteSettings(name: StatsPage.routeName),
builder: (context) => StatsPage(
entries: collection.sortedEntries.toSet(),
source: collection.source,
),
),
);
}
} }

View file

@ -1,4 +1,5 @@
enum ExplorerAction { enum ExplorerAction {
addShortcut, addShortcut,
setHome, setHome,
stats,
} }