default: mac window size & opt.: snippet result
This commit is contained in:
@@ -134,15 +134,9 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
return;
|
||||
}
|
||||
final ids = servers.map((e) => e.spi.id).toList();
|
||||
final names = servers.map((e) => e.spi.name).toList();
|
||||
final results = await Pros.server.runSnippetsMulti(ids, [snippet]);
|
||||
final results = await Pros.server.runSnippetsMulti(ids, snippet);
|
||||
if (results.isNotEmpty) {
|
||||
// SERVER_NAME: RESULT
|
||||
final result = Map.fromIterables(
|
||||
names,
|
||||
results,
|
||||
);
|
||||
AppRoute.snippetResult(results: result).go(context);
|
||||
AppRoute.snippetResult(results: results).go(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/res/ui.dart';
|
||||
import 'package:toolbox/view/widget/cardx.dart';
|
||||
import 'package:toolbox/view/widget/custom_appbar.dart';
|
||||
import 'package:toolbox/view/widget/expand_tile.dart';
|
||||
|
||||
class SnippetResultPage extends StatelessWidget {
|
||||
final Map<String, String?> results;
|
||||
final List<SnippetResult?> results;
|
||||
|
||||
const SnippetResultPage({super.key, required this.results});
|
||||
|
||||
@@ -20,28 +22,30 @@ class SnippetResultPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
itemCount: results.length,
|
||||
itemBuilder: (_, index) {
|
||||
final key = results.keys.elementAt(index);
|
||||
final value = results[key];
|
||||
return CardX(
|
||||
ExpandTile(
|
||||
initiallyExpanded: results.length == 1,
|
||||
title: Text(key),
|
||||
children: [
|
||||
Text(
|
||||
value ?? '',
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
itemCount: results.length,
|
||||
itemBuilder: (_, index) {
|
||||
final item = results[index];
|
||||
if (item == null) return UIs.placeholder;
|
||||
return CardX(
|
||||
ExpandTile(
|
||||
initiallyExpanded: results.length == 1,
|
||||
title: Text(item.dest ?? ''),
|
||||
subtitle: Text(item.time.toString(), style: UIs.textGrey),
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Text(
|
||||
item.result,
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,10 @@ import 'package:toolbox/data/model/server/dist.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
|
||||
import '../../core/route.dart';
|
||||
import '../../core/utils/misc.dart';
|
||||
import '../../core/utils/server.dart';
|
||||
import '../../data/model/app/menu.dart';
|
||||
import '../../data/model/pkg/upgrade_info.dart';
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/model/server/snippet.dart';
|
||||
import 'popup_menu.dart';
|
||||
|
||||
class ServerFuncBtnsTopRight extends StatelessWidget {
|
||||
@@ -94,28 +92,29 @@ void _onTapMoreBtns(
|
||||
check: () => _checkClient(context, spi.id),
|
||||
);
|
||||
break;
|
||||
case ServerTabMenuType.snippet:
|
||||
final snippets = await context.showPickDialog<Snippet>(
|
||||
items: Pros.snippet.snippets,
|
||||
name: (e) => e.name,
|
||||
);
|
||||
if (snippets == null) {
|
||||
return;
|
||||
}
|
||||
final result = await Pros.server.runSnippets(spi.id, snippets);
|
||||
if (result != null && result.isNotEmpty) {
|
||||
context.showRoundDialog(
|
||||
title: Text(l10n.result),
|
||||
child: Text(result),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => copy2Clipboard(result),
|
||||
child: Text(l10n.copy),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
break;
|
||||
// case ServerTabMenuType.snippet:
|
||||
// final snippets = await context.showPickDialog<Snippet>(
|
||||
// items: Pros.snippet.snippets,
|
||||
// name: (e) => e.name,
|
||||
// multi: false
|
||||
// );
|
||||
// if (snippets == null || snippets.isEmpty) {
|
||||
// return;
|
||||
// }
|
||||
// final result = await Pros.server.runSnippets(spi.id, snippets.first);
|
||||
// if (result != null && result.isNotEmpty) {
|
||||
// context.showRoundDialog(
|
||||
// title: Text(l10n.result),
|
||||
// child: Text(result),
|
||||
// actions: [
|
||||
// TextButton(
|
||||
// onPressed: () => copy2Clipboard(result),
|
||||
// child: Text(l10n.copy),
|
||||
// )
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// break;
|
||||
case ServerTabMenuType.docker:
|
||||
AppRoute.docker(spi: spi).checkGo(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user