mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-06 03:31:02 -06:00
[client] Clear selection on escape
This commit is contained in:
@@ -7,6 +7,7 @@ enum SelectionMode {
|
||||
range,
|
||||
multi,
|
||||
toggle,
|
||||
none,
|
||||
}
|
||||
|
||||
class FocusUpIntent extends Intent {
|
||||
|
||||
@@ -38,7 +38,7 @@ class ExplorerActions extends StatelessWidget {
|
||||
return null;
|
||||
}),
|
||||
DismissIntent: CallbackAction<DismissIntent>(onInvoke: (i) {
|
||||
context.read<ExplorerViewController>().updateSelection((i) => i, SelectionMode.single, true);
|
||||
context.read<ExplorerViewController>().updateSelection((i) => i, SelectionMode.none, true);
|
||||
return null;
|
||||
}),
|
||||
ActivateIntent: CallbackAction<ActivateIntent>(onInvoke: (i) {
|
||||
|
||||
@@ -21,6 +21,7 @@ class ExplorerViewState {
|
||||
String? get focusId => focussed?.id;
|
||||
Iterable<Resource> get selected => resources.where((r) => selectedIds.contains(r.id));
|
||||
Resource? get selectedSingle => selectedIds.length != 1 ? null : resources.where((r) => selectedIds.contains(r.id)).firstOrNull;
|
||||
Resource? get focussedIfSelected => selectedIds.isEmpty ? null : focussed;
|
||||
|
||||
const ExplorerViewState({
|
||||
this.folder,
|
||||
@@ -127,6 +128,10 @@ class ExplorerViewController extends StateNotifier<ExplorerViewState> {
|
||||
}
|
||||
selectionStartIndex = index;
|
||||
break;
|
||||
case SelectionMode.none:
|
||||
selectedIds = const {};
|
||||
selectionStartIndex = index;
|
||||
break;
|
||||
case SelectionMode.multi:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class ResourceInfoView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final resource = context.select<ExplorerViewState, Resource?>((state) {
|
||||
return state.focussed ?? state.folder;
|
||||
return state.focussedIfSelected ?? state.folder;
|
||||
});
|
||||
|
||||
if (resource == null) {
|
||||
|
||||
Reference in New Issue
Block a user