diff --git a/CHANGELOG.md b/CHANGELOG.md index c92fa493f..9254e55bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - Collection: sort by duration - Map: open external map app from map views +- Explorer: stats ### Changed diff --git a/lib/view/src/actions/explorer.dart b/lib/view/src/actions/explorer.dart index 38fb845c3..9b5272637 100644 --- a/lib/view/src/actions/explorer.dart +++ b/lib/view/src/actions/explorer.dart @@ -9,6 +9,7 @@ extension ExtraExplorerActionView on ExplorerAction { return switch (this) { ExplorerAction.addShortcut => l10n.collectionActionAddShortcut, ExplorerAction.setHome => l10n.collectionActionSetHome, + ExplorerAction.stats => l10n.menuActionStats, }; } @@ -18,6 +19,7 @@ extension ExtraExplorerActionView on ExplorerAction { return switch (this) { ExplorerAction.addShortcut => AIcons.addShortcut, ExplorerAction.setHome => AIcons.home, + ExplorerAction.stats => AIcons.stats, }; } } diff --git a/lib/widgets/explorer/app_bar.dart b/lib/widgets/explorer/app_bar.dart index cdc0666c2..804af6a45 100644 --- a/lib/widgets/explorer/app_bar.dart +++ b/lib/widgets/explorer/app_bar.dart @@ -117,7 +117,10 @@ class _ExplorerAppBarState extends State with WidgetsBindingObse return [ ExplorerAction.addShortcut, ExplorerAction.setHome, - ].map((v) { + null, + ExplorerAction.stats, + ].map>((v) { + if (v == null) return const PopupMenuDivider(); return PopupMenuItem( value: v, child: MenuRow(text: v.getText(context), icon: v.getIcon()), diff --git a/lib/widgets/explorer/explorer_action_delegate.dart b/lib/widgets/explorer/explorer_action_delegate.dart index 82d938d52..fc7932c63 100644 --- a/lib/widgets/explorer/explorer_action_delegate.dart +++ b/lib/widgets/explorer/explorer_action_delegate.dart @@ -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/extensions/build_context.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:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -29,6 +30,8 @@ class ExplorerActionDelegate with FeedbackMixin { return isMain && device.canPinShortcut; case ExplorerAction.setHome: return isMain && !useTvLayout; + case ExplorerAction.stats: + return isMain; } } @@ -36,6 +39,7 @@ class ExplorerActionDelegate with FeedbackMixin { switch (action) { case ExplorerAction.addShortcut: case ExplorerAction.setHome: + case ExplorerAction.stats: return true; } } @@ -47,6 +51,8 @@ class ExplorerActionDelegate with FeedbackMixin { _addShortcut(context); case ExplorerAction.setHome: _setHome(context); + case ExplorerAction.stats: + _goToStats(context); } } @@ -82,4 +88,23 @@ class ExplorerActionDelegate with FeedbackMixin { settings.setHome(HomePageSetting.explorer, customExplorerPath: directory.dirPath); 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(), + filters: {filter}, + ); + + Navigator.maybeOf(context)?.push( + MaterialPageRoute( + settings: const RouteSettings(name: StatsPage.routeName), + builder: (context) => StatsPage( + entries: collection.sortedEntries.toSet(), + source: collection.source, + ), + ), + ); + } } diff --git a/plugins/aves_model/lib/src/actions/explorer.dart b/plugins/aves_model/lib/src/actions/explorer.dart index f71619c75..5d33f4fa7 100644 --- a/plugins/aves_model/lib/src/actions/explorer.dart +++ b/plugins/aves_model/lib/src/actions/explorer.dart @@ -1,4 +1,5 @@ enum ExplorerAction { addShortcut, setHome, + stats, }