mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new: pick dialog support tags
This commit is contained in:
@@ -122,11 +122,18 @@ void _onTapMoreBtns(
|
||||
);
|
||||
break;
|
||||
case ServerFuncBtn.snippet:
|
||||
final snippet = await context.showPickSingleDialog<Snippet>(
|
||||
items: Pros.snippet.snippets,
|
||||
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 (snippet == null) return;
|
||||
if (snippets == null || snippets.isEmpty) return;
|
||||
final snippet = snippets.first;
|
||||
|
||||
AppRoute.ssh(spi: spi, initCmd: snippet.fmtWith(spi)).checkGo(
|
||||
context: context,
|
||||
|
||||
@@ -184,14 +184,12 @@ class TagSwitcher extends StatelessWidget implements PreferredSizeWidget {
|
||||
final double width;
|
||||
final void Function(String?) onTagChanged;
|
||||
final String? initTag;
|
||||
final String all;
|
||||
|
||||
const TagSwitcher({
|
||||
super.key,
|
||||
required this.tags,
|
||||
required this.width,
|
||||
required this.onTagChanged,
|
||||
required this.all,
|
||||
this.initTag,
|
||||
});
|
||||
|
||||
@@ -213,7 +211,7 @@ class TagSwitcher extends StatelessWidget implements PreferredSizeWidget {
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
return TagBtn(
|
||||
content: item == null ? all : '#$item',
|
||||
content: item == null ? l10n.all : '#$item',
|
||||
isEnable: initTag == item,
|
||||
onTap: () => onTagChanged(item),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user