#1000 collection: select all available as quick action

This commit is contained in:
Thibault Deckers 2024-05-02 20:42:05 +02:00
parent e359eb46f0
commit 4f746c2177
7 changed files with 21 additions and 9 deletions

View file

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
## <a id="unreleased"></a>[Unreleased]
### Added
- Collection: `select all` available as quick action
## <a id="v1.11.0"></a>[v1.11.0] - 2024-05-01
### Added

View file

@ -28,12 +28,15 @@ class Selection<T> extends ChangeNotifier {
void addToSelection(Iterable<T> items) {
if (items.isEmpty) return;
select();
_selectedItems.addAll(items);
notifyListeners();
}
void removeFromSelection(Iterable<T> items) {
if (items.isEmpty) return;
_selectedItems.removeAll(items);
notifyListeners();
}

View file

@ -379,7 +379,8 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
final browsingQuickActions = settings.collectionBrowsingQuickActions;
final selectionQuickActions = isTrash ? [EntrySetAction.delete, EntrySetAction.restore] : settings.collectionSelectionQuickActions;
final quickActionButtons = (isSelecting ? selectionQuickActions : browsingQuickActions).where(isVisible).map(
final quickActions = isSelecting ? selectionQuickActions : browsingQuickActions;
final quickActionButtons = quickActions.where(isVisible).map(
(action) => _buildButtonIcon(context, action, enabled: canApply(action), selection: selection),
);
@ -390,13 +391,13 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
// key is expected by test driver
key: const Key('appbar-menu-button'),
itemBuilder: (context) {
final generalMenuItems = EntrySetActions.general.where(isVisible).map(
bool _isValidForMenu(EntrySetAction? v) => v == null || (!quickActions.contains(v) && isVisible(v));
final generalMenuItems = EntrySetActions.general.where(_isValidForMenu).map(
(action) => _toMenuItem(action, enabled: canApply(action), selection: selection),
);
final browsingMenuActions = EntrySetActions.pageBrowsing.where((v) => !browsingQuickActions.contains(v));
final selectionMenuActions = EntrySetActions.pageSelection.where((v) => !selectionQuickActions.contains(v));
final contextualMenuActions = (isSelecting ? selectionMenuActions : browsingMenuActions).where((v) => v == null || isVisible(v)).fold(<EntrySetAction?>[], (prev, v) {
final allContextualActions = isSelecting ? EntrySetActions.pageSelection: EntrySetActions.pageBrowsing;
final contextualMenuActions = allContextualActions.where(_isValidForMenu).fold(<EntrySetAction?>[], (prev, v) {
if (v == null && (prev.isEmpty || prev.last == null)) return prev;
return [...prev, v];
});

View file

@ -66,7 +66,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
case EntrySetAction.select:
return appMode.canSelectMedia && !isSelecting;
case EntrySetAction.selectAll:
return isSelecting && selectedItemCount < itemCount;
return (isSelecting && selectedItemCount < itemCount) || (!isSelecting && settings.collectionBrowsingQuickActions.contains(action));
case EntrySetAction.selectNone:
return isSelecting && selectedItemCount == itemCount;
// browsing
@ -127,7 +127,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
case EntrySetAction.select:
return hasItems;
case EntrySetAction.selectAll:
return selectedItemCount < itemCount;
return selectedItemCount < itemCount || (!isSelecting && settings.collectionBrowsingQuickActions.contains(action));
case EntrySetAction.selectNone:
return hasSelection;
case EntrySetAction.searchCollection:

View file

@ -102,7 +102,6 @@ class _HiddenFilters extends StatelessWidget {
children: [
Expanded(
child: LayoutBuilder(builder: (context, constraints) {
debugPrint('TLAD constraints=$constraints');
return Row(
children: [
AvesFilterChip(

View file

@ -19,7 +19,9 @@ class CollectionActionEditorPage extends StatelessWidget {
Tab(text: l10n.settingsCollectionQuickActionTabBrowsing),
QuickActionEditorBody<EntrySetAction>(
bannerText: context.l10n.settingsCollectionBrowsingQuickActionEditorBanner,
allAvailableActions: const [EntrySetActions.collectionEditorBrowsing],
allAvailableActions: const [
EntrySetActions.collectionEditorBrowsing,
],
actionIcon: (action) => action.getIcon(),
actionText: (context, action) => action.getText(context),
load: () => settings.collectionBrowsingQuickActions,

View file

@ -65,6 +65,8 @@ class EntrySetActions {
EntrySetAction.map,
EntrySetAction.slideshow,
EntrySetAction.stats,
// only available as a quick action
EntrySetAction.selectAll,
];
// `null` items are converted to dividers
@ -98,6 +100,7 @@ class EntrySetActions {
EntrySetAction.map,
EntrySetAction.slideshow,
EntrySetAction.stats,
EntrySetAction.selectAll,
// editing actions are in their subsection
];