explorer: hide path action

This commit is contained in:
Thibault Deckers 2024-10-07 16:06:53 +02:00
parent eb1efe10e5
commit 8f431a5426
4 changed files with 18 additions and 6 deletions

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.hide => l10n.chipActionHide,
ExplorerAction.stats => l10n.menuActionStats, ExplorerAction.stats => l10n.menuActionStats,
}; };
} }
@ -19,6 +20,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.hide => AIcons.hide,
ExplorerAction.stats => AIcons.stats, ExplorerAction.stats => AIcons.stats,
}; };
} }

View file

@ -117,6 +117,7 @@ class _ExplorerAppBarState extends State<ExplorerAppBar> with WidgetsBindingObse
return [ return [
ExplorerAction.addShortcut, ExplorerAction.addShortcut,
ExplorerAction.setHome, ExplorerAction.setHome,
ExplorerAction.hide,
null, null,
ExplorerAction.stats, ExplorerAction.stats,
].map<PopupMenuEntry<ExplorerAction>>((v) { ].map<PopupMenuEntry<ExplorerAction>>((v) {

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/filter_grids/common/action_delegates/chip.dart';
import 'package:aves/widgets/stats/stats_page.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';
@ -30,6 +31,7 @@ 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.hide:
case ExplorerAction.stats: case ExplorerAction.stats:
return isMain; return isMain;
} }
@ -39,6 +41,7 @@ class ExplorerActionDelegate with FeedbackMixin {
switch (action) { switch (action) {
case ExplorerAction.addShortcut: case ExplorerAction.addShortcut:
case ExplorerAction.setHome: case ExplorerAction.setHome:
case ExplorerAction.hide:
case ExplorerAction.stats: case ExplorerAction.stats:
return true; return true;
} }
@ -51,14 +54,17 @@ class ExplorerActionDelegate with FeedbackMixin {
_addShortcut(context); _addShortcut(context);
case ExplorerAction.setHome: case ExplorerAction.setHome:
_setHome(context); _setHome(context);
case ExplorerAction.hide:
_hide(context);
case ExplorerAction.stats: case ExplorerAction.stats:
_goToStats(context); _goToStats(context);
} }
} }
PathFilter _getPathFilter() => PathFilter(directory.dirPath);
Future<void> _addShortcut(BuildContext context) async { Future<void> _addShortcut(BuildContext context) async {
final path = directory.dirPath; final filter = _getPathFilter();
final filter = PathFilter(path);
final defaultName = filter.getLabel(context); final defaultName = filter.getLabel(context);
final collection = CollectionLens( final collection = CollectionLens(
source: context.read<CollectionSource>(), source: context.read<CollectionSource>(),
@ -78,7 +84,7 @@ class ExplorerActionDelegate with FeedbackMixin {
final (coverEntry, name) = result; final (coverEntry, name) = result;
if (name.isEmpty) return; if (name.isEmpty) return;
await appService.pinToHomeScreen(name, coverEntry, explorerPath: path); await appService.pinToHomeScreen(name, coverEntry, explorerPath: filter.path);
if (!device.showPinShortcutFeedback) { if (!device.showPinShortcutFeedback) {
showFeedback(context, FeedbackType.info, context.l10n.genericSuccessFeedback); showFeedback(context, FeedbackType.info, context.l10n.genericSuccessFeedback);
} }
@ -89,12 +95,14 @@ class ExplorerActionDelegate with FeedbackMixin {
showFeedback(context, FeedbackType.info, context.l10n.genericSuccessFeedback); showFeedback(context, FeedbackType.info, context.l10n.genericSuccessFeedback);
} }
void _hide(BuildContext context) {
ChipActionDelegate().onActionSelected(context, _getPathFilter(), ChipAction.hide);
}
void _goToStats(BuildContext context) { void _goToStats(BuildContext context) {
final path = directory.dirPath;
final filter = PathFilter(path);
final collection = CollectionLens( final collection = CollectionLens(
source: context.read<CollectionSource>(), source: context.read<CollectionSource>(),
filters: {filter}, filters: {_getPathFilter()},
); );
Navigator.maybeOf(context)?.push( Navigator.maybeOf(context)?.push(

View file

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