mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
#73 opt.: reorderable
This commit is contained in:
@@ -88,40 +88,13 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
all: _s.all,
|
||||
width: _media.size.width,
|
||||
),
|
||||
buildDefaultDragHandles: false,
|
||||
itemBuilder: (context, idx) {
|
||||
final snippet = filtered.elementAt(idx);
|
||||
return RoundRectCard(
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 23, right: 17),
|
||||
title: Text(
|
||||
snippet.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
subtitle: Text(
|
||||
snippet.script,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: grey,
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => AppRoute(
|
||||
SnippetEditPage(snippet: snippet),
|
||||
'snippet edit page',
|
||||
).go(context),
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _runSnippet(snippet),
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
return ReorderableDelayedDragStartListener(
|
||||
key: ValueKey(snippet.name),
|
||||
index: idx,
|
||||
child: _buildSnippetItem(snippet),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -129,6 +102,41 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSnippetItem(Snippet snippet) {
|
||||
return RoundRectCard(
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 23, right: 17),
|
||||
title: Text(
|
||||
snippet.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
subtitle: Text(
|
||||
snippet.script,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: grey,
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => AppRoute(
|
||||
SnippetEditPage(snippet: snippet),
|
||||
'snippet edit page',
|
||||
).go(context),
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _runSnippet(snippet),
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _runSnippet(Snippet snippet) async {
|
||||
final provider = locator<ServerProvider>();
|
||||
final servers = await showDialog<List<Server>>(
|
||||
|
||||
Reference in New Issue
Block a user