Skip to content

Commit

Permalink
fix: tags dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Aug 16, 2024
1 parent ef29767 commit b5329e2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/view/page/server/tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _ServerPageState extends State<ServerPage>
appBar: TagSwitcher(
tags: ServerProvider.tags,
onTagChanged: (p0) => _tag.value = p0,
tag: _tag,
initTag: _tag.value,
),
body: GestureDetector(
behavior: HitTestBehavior.opaque,
Expand Down Expand Up @@ -647,7 +647,7 @@ ${ss.err?.message ?? 'null'}

List<String> _filterServers(List<String> order) {
final tag = _tag.value;
if (tag.isEmpty) return order;
if (tag == kDefaultTag) return order;
return order.where((e) {
final tags = ServerProvider.pick(id: e)?.value.spi.tags;
if (tags == null) return false;
Expand Down
16 changes: 7 additions & 9 deletions lib/view/page/snippet/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
appBar: TagSwitcher(
tags: SnippetProvider.tags,
onTagChanged: (tag) => _tag.value = tag,
tag: _tag,
initTag: _tag.value,
),
body: _buildBody(),
floatingActionButton: FloatingActionButton(
Expand All @@ -36,24 +36,21 @@ class _SnippetListPageState extends State<SnippetListPage> {
Widget _buildBody() {
return SnippetProvider.snippets.listenVal(
(snippets) {
if (snippets.isEmpty) {
return Center(child: Text(libL10n.empty));
}

if (snippets.isEmpty) return Center(child: Text(libL10n.empty));
return _tag.listenVal((tag) => _buildSnippetList(snippets, tag));
},
);
}

Widget _buildSnippetList(List<Snippet> snippets, String tag) {
final filtered = tag.isEmpty
final filtered = tag == kDefaultTag
? snippets
: snippets.where((e) => e.tags?.contains(tag) ?? false).toList();

return ReorderableListView.builder(
padding: const EdgeInsets.symmetric(horizontal: 11),
padding: const EdgeInsets.symmetric(horizontal: 9),
itemCount: filtered.length,
onReorder: (oldIdx, newIdx) => setState(() {
onReorder: (oldIdx, newIdx) {
snippets.moveByItem(
oldIdx,
newIdx,
Expand All @@ -62,7 +59,8 @@ class _SnippetListPageState extends State<SnippetListPage> {
Stores.setting.snippetOrder.put(p0.map((e) => e.name).toList());
},
);
}),
SnippetProvider.snippets.notify();
},
footer: UIs.height77,
buildDefaultDragHandles: false,
itemBuilder: (context, idx) {
Expand Down
2 changes: 1 addition & 1 deletion lib/view/page/ssh/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class SSHPageState extends State<SSHPage>
title: l10n.snippet,
tags: SnippetProvider.tags,
itemsBuilder: (e) {
if (e == null) return SnippetProvider.snippets.value;
if (e == kDefaultTag) return SnippetProvider.snippets.value;
return SnippetProvider.snippets.value
.where((element) => element.tags?.contains(e) ?? false)
.toList();
Expand Down
2 changes: 1 addition & 1 deletion lib/view/widget/server_func_btns.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void _onTapMoreBtns(
title: l10n.snippet,
tags: SnippetProvider.tags,
itemsBuilder: (e) {
if (e == null) return SnippetProvider.snippets.value;
if (e == kDefaultTag) return SnippetProvider.snippets.value;
return SnippetProvider.snippets.value
.where((element) => element.tags?.contains(e) ?? false)
.toList();
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v1.0.141"
resolved-ref: "2fb1532cd2fd08dd807e9776b2b50b5d8ee94388"
ref: "v1.0.142"
resolved-ref: "0860beabd5096dd5f783d8c60b860c81895477dd"
url: "https://github.com/lppcg/fl_lib"
source: git
version: "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies:
fl_lib:
git:
url: https://github.com/lppcg/fl_lib
ref: v1.0.141
ref: v1.0.142

dependency_overrides:
# dartssh2:
Expand Down

0 comments on commit b5329e2

Please sign in to comment.