From 597518971d1cd115927132df35e6e367d0bda974 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Mon, 21 Feb 2022 12:22:46 +0900 Subject: [PATCH] minor fixes --- lib/model/actions/entry_set_actions.dart | 27 ++++++++- lib/model/source/album.dart | 15 +++-- lib/widgets/collection/app_bar.dart | 55 ++++++++++--------- .../thumbnails/collection_actions_editor.dart | 4 +- 4 files changed, 63 insertions(+), 38 deletions(-) diff --git a/lib/model/actions/entry_set_actions.dart b/lib/model/actions/entry_set_actions.dart index 8ef89c1cf..8df63b991 100644 --- a/lib/model/actions/entry_set_actions.dart +++ b/lib/model/actions/entry_set_actions.dart @@ -42,7 +42,7 @@ class EntrySetActions { EntrySetAction.selectNone, ]; - static const browsing = [ + static const pageBrowsing = [ EntrySetAction.searchCollection, EntrySetAction.toggleTitleSearch, EntrySetAction.addShortcut, @@ -52,7 +52,17 @@ class EntrySetActions { EntrySetAction.emptyBin, ]; - static const selection = [ + // exclude bin related actions + static const collectionEditorBrowsing = [ + EntrySetAction.searchCollection, + EntrySetAction.toggleTitleSearch, + EntrySetAction.addShortcut, + EntrySetAction.map, + EntrySetAction.stats, + EntrySetAction.rescan, + ]; + + static const pageSelection = [ EntrySetAction.share, EntrySetAction.delete, EntrySetAction.restore, @@ -65,6 +75,19 @@ class EntrySetActions { // editing actions are in their subsection ]; + // exclude bin related actions + static const collectionEditorSelection = [ + EntrySetAction.share, + EntrySetAction.delete, + EntrySetAction.copy, + EntrySetAction.move, + EntrySetAction.toggleFavourite, + EntrySetAction.map, + EntrySetAction.stats, + EntrySetAction.rescan, + // editing actions are in their subsection + ]; + static const edit = [ EntrySetAction.editDate, EntrySetAction.editLocation, diff --git a/lib/model/source/album.dart b/lib/model/source/album.dart index 4a7ec4bf5..88aa723d6 100644 --- a/lib/model/source/album.dart +++ b/lib/model/source/album.dart @@ -118,7 +118,7 @@ mixin AlbumMixin on SourceBase { AvesEntry? albumRecentEntry(AlbumFilter filter) { return _filterRecentEntryMap.putIfAbsent(filter.album, () => sortedEntriesByDate.firstWhereOrNull(filter.test)); } - + // new albums void createAlbum(String directory) { @@ -136,7 +136,7 @@ mixin AlbumMixin on SourceBase { void forgetNewAlbums(Set directories) { _newAlbums.removeAll(directories); } - + // display names final Map _albumDisplayNamesWithContext = {}, _albumDisplayNamesWithoutContext = {}; @@ -152,18 +152,17 @@ mixin AlbumMixin on SourceBase { if (context != null) { final type = androidFileUtils.getAlbumType(dirPath); - final l10n = context.l10n; switch (type) { case AlbumType.camera: - return l10n.albumCamera; + return context.l10n.albumCamera; case AlbumType.download: - return l10n.albumDownload; + return context.l10n.albumDownload; case AlbumType.screenshots: - return l10n.albumScreenshots; + return context.l10n.albumScreenshots; case AlbumType.screenRecordings: - return l10n.albumScreenRecordings; + return context.l10n.albumScreenRecordings; case AlbumType.videoCaptures: - return l10n.albumVideoCaptures; + return context.l10n.albumVideoCaptures; case AlbumType.regular: case AlbumType.app: break; diff --git a/lib/widgets/collection/app_bar.dart b/lib/widgets/collection/app_bar.dart index 04add94fb..bb810f95d 100644 --- a/lib/widgets/collection/app_bar.dart +++ b/lib/widgets/collection/app_bar.dart @@ -120,32 +120,35 @@ class _CollectionAppBarState extends State with SingleTickerPr return Selector( selector: (context, query) => query.enabled, builder: (context, queryEnabled, child) { - return SliverAppBar( - leading: appMode.hasDrawer ? _buildAppBarLeading(isSelecting) : null, - title: SliverAppBarTitleWrapper( - child: _buildAppBarTitle(isSelecting), - ), - actions: _buildActions(selection), - bottom: PreferredSize( - preferredSize: Size.fromHeight(appBarBottomHeight), - child: Column( - children: [ - if (showFilterBar) - FilterBar( - filters: visibleFilters, - removable: removableFilters, - onTap: removableFilters ? collection.removeFilter : null, - ), - if (queryEnabled) - EntryQueryBar( - queryNotifier: context.select>((query) => query.queryNotifier), - focusNode: _queryBarFocusNode, - ) - ], + return Selector>( + selector: (context, s) => s.collectionBrowsingQuickActions, + builder: (context, _, child) => SliverAppBar( + leading: appMode.hasDrawer ? _buildAppBarLeading(isSelecting) : null, + title: SliverAppBarTitleWrapper( + child: _buildAppBarTitle(isSelecting), ), + actions: _buildActions(selection), + bottom: PreferredSize( + preferredSize: Size.fromHeight(appBarBottomHeight), + child: Column( + children: [ + if (showFilterBar) + FilterBar( + filters: visibleFilters, + removable: removableFilters, + onTap: removableFilters ? collection.removeFilter : null, + ), + if (queryEnabled) + EntryQueryBar( + queryNotifier: context.select>((query) => query.queryNotifier), + focusNode: _queryBarFocusNode, + ) + ], + ), + ), + titleSpacing: 0, + floating: true, ), - titleSpacing: 0, - floating: true, ); }, ); @@ -243,8 +246,8 @@ class _CollectionAppBarState extends State with SingleTickerPr (action) => _toMenuItem(action, enabled: canApply(action), selection: selection), ); - final browsingMenuActions = EntrySetActions.browsing.where((v) => !browsingQuickActions.contains(v)); - final selectionMenuActions = EntrySetActions.selection.where((v) => !selectionQuickActions.contains(v)); + final browsingMenuActions = EntrySetActions.pageBrowsing.where((v) => !browsingQuickActions.contains(v)); + final selectionMenuActions = EntrySetActions.pageSelection.where((v) => !selectionQuickActions.contains(v)); final contextualMenuItems = [ ...(isSelecting ? selectionMenuActions : browsingMenuActions).where(isVisible).map( (action) => _toMenuItem(action, enabled: canApply(action), selection: selection), diff --git a/lib/widgets/settings/thumbnails/collection_actions_editor.dart b/lib/widgets/settings/thumbnails/collection_actions_editor.dart index 05da541a0..a16a8977e 100644 --- a/lib/widgets/settings/thumbnails/collection_actions_editor.dart +++ b/lib/widgets/settings/thumbnails/collection_actions_editor.dart @@ -39,7 +39,7 @@ class CollectionActionEditorPage extends StatelessWidget { Tab(text: l10n.settingsCollectionQuickActionTabBrowsing), QuickActionEditorBody( bannerText: context.l10n.settingsCollectionBrowsingQuickActionEditorBanner, - allAvailableActions: EntrySetActions.browsing, + allAvailableActions: EntrySetActions.collectionEditorBrowsing, actionIcon: (action) => action.getIcon(), actionText: (context, action) => action.getText(context), load: () => settings.collectionBrowsingQuickActions, @@ -50,7 +50,7 @@ class CollectionActionEditorPage extends StatelessWidget { Tab(text: l10n.settingsCollectionQuickActionTabSelecting), QuickActionEditorBody( bannerText: context.l10n.settingsCollectionSelectionQuickActionEditorBanner, - allAvailableActions: EntrySetActions.selection, + allAvailableActions: EntrySetActions.collectionEditorSelection, actionIcon: (action) => action.getIcon(), actionText: (context, action) => action.getText(context), load: () => settings.collectionSelectionQuickActions,