mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
opt.: snippet result
This commit is contained in:
@@ -6,7 +6,6 @@ import 'package:toolbox/core/extension/order.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
|
||||
import '../../../core/utils/misc.dart';
|
||||
import '../../../data/model/server/server.dart';
|
||||
import '../../../data/model/server/snippet.dart';
|
||||
import '../../../data/res/ui.dart';
|
||||
@@ -135,23 +134,15 @@ 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]);
|
||||
if (results.isNotEmpty) {
|
||||
// SERVER_NAME: RESULT
|
||||
final result = Map.fromIterables(
|
||||
ids,
|
||||
names,
|
||||
results,
|
||||
).entries.map((e) => '${e.key}:\n${e.value}').join('\n');
|
||||
context.showRoundDialog(
|
||||
title: Text(l10n.result),
|
||||
child: Text(result),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => copy2Clipboard(result),
|
||||
child: Text(l10n.copy),
|
||||
)
|
||||
],
|
||||
);
|
||||
AppRoute.snippetResult(results: result).go(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
47
lib/view/page/snippet/result.dart
Normal file
47
lib/view/page/snippet/result.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.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;
|
||||
|
||||
const SnippetResultPage({super.key, required this.results});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: Text(l10n.result),
|
||||
),
|
||||
body: _buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
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 ?? '',
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user