[client] Select All / Clear

This commit is contained in:
Abhishek Shroff
2024-09-04 23:47:41 +05:30
parent c493c5748f
commit 458b165391
3 changed files with 20 additions and 2 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_state_notifier/flutter_state_notifier.dart';
import 'package:go_router/go_router.dart';
import 'package:offtheline/offtheline.dart';
import 'package:phylum/app_shortcut_manager.dart';
import 'package:phylum/app_shortcuts.dart';
import 'package:phylum/ui/home_page.dart';
import 'package:phylum/libphylum/phylum_account.dart';
import 'package:provider/provider.dart';
@@ -21,6 +21,14 @@ class ToggleSelectionIntent extends Intent {
const ToggleSelectionIntent();
}
class ClearSelectionIntent extends Intent {
const ClearSelectionIntent();
}
class SelectAllIntent extends Intent {
const SelectAllIntent();
}
class OpenIntent extends Intent {
const OpenIntent();
}
@@ -40,5 +48,7 @@ Map<ShortcutActivator, Intent> getAppShortcuts() {
SingleActivator(LogicalKeyboardKey.space, control: true): ToggleSelectionIntent(),
SingleActivator(LogicalKeyboardKey.enter): OpenIntent(),
SingleActivator(LogicalKeyboardKey.arrowUp, alt: true): NavUpIntent(),
SingleActivator(LogicalKeyboardKey.escape): ClearSelectionIntent(),
SingleActivator(LogicalKeyboardKey.keyA, control: true): SelectAllIntent(),
};
}
@@ -2,7 +2,7 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:phylum/app_shortcut_manager.dart';
import 'package:phylum/app_shortcuts.dart';
import 'package:phylum/libphylum/db/db.dart';
import 'package:phylum/ui/folder/folder_navigator_stack.dart';
import 'package:phylum/ui/folder/folder_selection_manager.dart';
@@ -68,6 +68,14 @@ class _FolderContentsViewState extends State<FolderContentsView> {
toggleSelection();
return null;
}),
SelectAllIntent: CallbackAction<SelectAllIntent>(onInvoke: (i) {
context.read<FolderSelectionManager>().setSelected(Set.of(resources.map((r) => r.id)));
return null;
}),
ClearSelectionIntent: CallbackAction<ClearSelectionIntent>(onInvoke: (i) {
context.read<FolderSelectionManager>().setSelected(const {});
return null;
}),
OpenIntent: CallbackAction<OpenIntent>(onInvoke: (i) {
open(resources[focusIndex]);
return null;