diff --git a/client/lib/app_shortcuts.dart b/client/lib/app_shortcuts.dart index 3c11dd2c..59caae37 100644 --- a/client/lib/app_shortcuts.dart +++ b/client/lib/app_shortcuts.dart @@ -21,18 +21,10 @@ class ToggleSelectionIntent extends Intent { const ToggleSelectionIntent(); } -class ClearSelectionIntent extends Intent { - const ClearSelectionIntent(); -} - class SelectAllIntent extends Intent { const SelectAllIntent(); } -class OpenIntent extends Intent { - const OpenIntent(); -} - class DeleteIntent extends Intent { const DeleteIntent(); } @@ -59,6 +51,8 @@ class NavUpIntent extends Intent { Map getAppShortcuts() { return const { + SingleActivator(LogicalKeyboardKey.tab): NextFocusIntent(), + SingleActivator(LogicalKeyboardKey.tab, shift: true): PreviousFocusIntent(), SingleActivator(LogicalKeyboardKey.arrowUp): FocusUpIntent(SelectionMode.single), SingleActivator(LogicalKeyboardKey.arrowUp, shift: true): FocusUpIntent(SelectionMode.range), SingleActivator(LogicalKeyboardKey.arrowUp, control: true): FocusUpIntent(SelectionMode.multi), @@ -66,10 +60,11 @@ Map getAppShortcuts() { SingleActivator(LogicalKeyboardKey.arrowDown, shift: true): FocusDownIntent(SelectionMode.range), SingleActivator(LogicalKeyboardKey.arrowDown, control: true): FocusDownIntent(SelectionMode.multi), SingleActivator(LogicalKeyboardKey.space, control: true): ToggleSelectionIntent(), - SingleActivator(LogicalKeyboardKey.escape): ClearSelectionIntent(), + SingleActivator(LogicalKeyboardKey.escape): DismissIntent(), SingleActivator(LogicalKeyboardKey.keyA, control: true): SelectAllIntent(), SingleActivator(LogicalKeyboardKey.arrowUp, alt: true): NavUpIntent(), - SingleActivator(LogicalKeyboardKey.enter): OpenIntent(), + SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(), + SingleActivator(LogicalKeyboardKey.space): ActivateIntent(), SingleActivator(LogicalKeyboardKey.delete): DeleteIntent(), SingleActivator(LogicalKeyboardKey.keyN, control: true): NewFolderIntent(), SingleActivator(LogicalKeyboardKey.keyU, control: true): UploadFilesIntent(), diff --git a/client/lib/ui/folder/folder_contents_view.dart b/client/lib/ui/folder/folder_contents_view.dart index cc507733..51a59cf6 100644 --- a/client/lib/ui/folder/folder_contents_view.dart +++ b/client/lib/ui/folder/folder_contents_view.dart @@ -51,6 +51,8 @@ class _FolderContentsViewState extends State { Widget build(BuildContext context) { return Actions( actions: { + NextFocusIntent: CallbackAction(onInvoke: (i) => null), + PreviousFocusIntent: CallbackAction(onInvoke: (i) => null), FocusUpIntent: CallbackAction(onInvoke: (i) { if (resources.isEmpty) return; final index = focusIndex == -1 @@ -75,7 +77,7 @@ class _FolderContentsViewState extends State { context.read().setSelected(Set.of(resources.map((r) => r.id))); return null; }), - ClearSelectionIntent: CallbackAction(onInvoke: (i) { + DismissIntent: CallbackAction(onInvoke: (i) { context.read().setSelected(const {}); return null; }), @@ -83,7 +85,7 @@ class _FolderContentsViewState extends State { context.read().pop(); return null; }), - OpenIntent: CallbackAction(onInvoke: (i) { + ActivateIntent: CallbackAction(onInvoke: (i) { open(resources[focusIndex]); return null; }), diff --git a/client/lib/ui/folder/folder_view.dart b/client/lib/ui/folder/folder_view.dart index ba2c93bc..d6a66556 100644 --- a/client/lib/ui/folder/folder_view.dart +++ b/client/lib/ui/folder/folder_view.dart @@ -32,35 +32,27 @@ class _FolderViewState extends State { final account = context.read(); final theme = Theme.of(context); - return Focus( - onKeyEvent: (node, event) { - if (event.logicalKey == LogicalKeyboardKey.tab) { - return KeyEventResult.skipRemainingHandlers; - } - return KeyEventResult.ignored; - }, - child: ListTileTheme( - data: ListTileThemeData( - mouseCursor: const WidgetStatePropertyAll(SystemMouseCursors.basic), - selectedTileColor: theme.colorScheme.primaryContainer, - ), - child: RefreshIndicator( - onRefresh: _refresh, - child: StateNotifierProvider( - create: (context) => FolderSelectionManager(), - child: StreamBuilder( - stream: account.datastore.db.managers.resources - .filter((f) => f.parent.id.equals(widget.id) & f.deleted.equals(false)) - .orderBy((o) => o.dir.desc()) - .orderBy((o) => o.name.asc()) - .watch(), - builder: (context, snapshot) { - if (!snapshot.hasData) { - return Container(); - } - return FolderContentsView(resources: snapshot.data!); - }), - ), + return ListTileTheme( + data: ListTileThemeData( + mouseCursor: const WidgetStatePropertyAll(SystemMouseCursors.basic), + selectedTileColor: theme.colorScheme.primaryContainer, + ), + child: RefreshIndicator( + onRefresh: _refresh, + child: StateNotifierProvider( + create: (context) => FolderSelectionManager(), + child: StreamBuilder( + stream: account.datastore.db.managers.resources + .filter((f) => f.parent.id.equals(widget.id) & f.deleted.equals(false)) + .orderBy((o) => o.dir.desc()) + .orderBy((o) => o.name.asc()) + .watch(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return Container(); + } + return FolderContentsView(resources: snapshot.data!); + }), ), ), );