mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-07 20:20:58 -06:00
[client] Play nice with existing shortcuts and intents
This commit is contained in:
@@ -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<ShortcutActivator, Intent> 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<ShortcutActivator, Intent> 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(),
|
||||
|
||||
@@ -51,6 +51,8 @@ class _FolderContentsViewState extends State<FolderContentsView> {
|
||||
Widget build(BuildContext context) {
|
||||
return Actions(
|
||||
actions: {
|
||||
NextFocusIntent: CallbackAction<NextFocusIntent>(onInvoke: (i) => null),
|
||||
PreviousFocusIntent: CallbackAction<PreviousFocusIntent>(onInvoke: (i) => null),
|
||||
FocusUpIntent: CallbackAction<FocusUpIntent>(onInvoke: (i) {
|
||||
if (resources.isEmpty) return;
|
||||
final index = focusIndex == -1
|
||||
@@ -75,7 +77,7 @@ class _FolderContentsViewState extends State<FolderContentsView> {
|
||||
context.read<FolderSelectionManager>().setSelected(Set.of(resources.map((r) => r.id)));
|
||||
return null;
|
||||
}),
|
||||
ClearSelectionIntent: CallbackAction<ClearSelectionIntent>(onInvoke: (i) {
|
||||
DismissIntent: CallbackAction<DismissIntent>(onInvoke: (i) {
|
||||
context.read<FolderSelectionManager>().setSelected(const {});
|
||||
return null;
|
||||
}),
|
||||
@@ -83,7 +85,7 @@ class _FolderContentsViewState extends State<FolderContentsView> {
|
||||
context.read<FolderNavigatorStack>().pop();
|
||||
return null;
|
||||
}),
|
||||
OpenIntent: CallbackAction<OpenIntent>(onInvoke: (i) {
|
||||
ActivateIntent: CallbackAction<ActivateIntent>(onInvoke: (i) {
|
||||
open(resources[focusIndex]);
|
||||
return null;
|
||||
}),
|
||||
|
||||
@@ -32,35 +32,27 @@ class _FolderViewState extends State<FolderView> {
|
||||
final account = context.read<PhylumAccount>();
|
||||
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<FolderSelectionManager, FolderSelectionState>(
|
||||
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<FolderSelectionManager, FolderSelectionState>(
|
||||
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!);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user