new: pick dialog support tags

This commit is contained in:
lollipopkit
2024-02-20 16:13:36 +08:00
parent 1a64dc5cba
commit ba564a886b
9 changed files with 125 additions and 40 deletions

View File

@@ -120,7 +120,6 @@ class _ServerPageState extends State<ServerPage>
_tag = p0;
}),
initTag: _tag,
all: l10n.all,
);
}

View File

@@ -71,7 +71,6 @@ class _SnippetListPageState extends State<SnippetListPage> {
tags: provider.tags,
onTagChanged: (tag) => setState(() => _tag = tag),
initTag: _tag,
all: l10n.all,
width: _media.size.width,
),
footer: UIs.height77,

View File

@@ -275,12 +275,20 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
}
break;
case VirtualKeyFunc.snippet:
final s = await context.showPickSingleDialog<Snippet>(
items: Pros.snippet.snippets,
name: (p0) => p0.name,
final snippets = await context.showPickWithTagDialog<Snippet>(
tags: Pros.snippet.tags,
itemsBuilder: (e) {
if (e == null) return Pros.snippet.snippets;
return Pros.snippet.snippets
.where((element) => element.tags?.contains(e) ?? false)
.toList();
},
name: (e) => e.name,
);
if (s == null) return;
_terminal.textInput(s.script);
if (snippets == null || snippets.isEmpty) return;
final snippet = snippets.first;
_terminal.textInput(snippet.script);
_terminal.keyInput(TerminalKey.enter);
break;
case VirtualKeyFunc.file: