From ece74d755210ffbfcea438b14a2b1092870724a5 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Fri, 26 Apr 2024 20:11:03 +0800 Subject: [PATCH] opt. --- lib/data/model/app/server_detail_card.dart | 43 ++++++------------ lib/data/res/color.dart | 2 +- lib/view/page/home/home.dart | 21 +++++---- lib/view/page/server/detail/view.dart | 6 +-- lib/view/page/server/tab.dart | 1 + lib/view/page/setting/entry.dart | 53 ++++++++++++---------- lib/view/page/snippet/list.dart | 2 +- lib/view/page/ssh/tab.dart | 1 + lib/view/widget/server_func_btns.dart | 4 ++ 9 files changed, 67 insertions(+), 66 deletions(-) diff --git a/lib/data/model/app/server_detail_card.dart b/lib/data/model/app/server_detail_card.dart index 5cba92fe..a2c4a3cc 100644 --- a/lib/data/model/app/server_detail_card.dart +++ b/lib/data/model/app/server_detail_card.dart @@ -6,24 +6,26 @@ import 'package:toolbox/data/model/app/version_related.dart'; import 'package:toolbox/data/res/store.dart'; enum ServerDetailCards implements VersionRelated { - about, - cpu, - mem, - swap, - gpu, - disk, - net, - sensor, - temp, - battery, - pve(sinceBuild: 818), - custom(sinceBuild: 825), + about(Icons.info), + cpu(Icons.memory), + mem(Bootstrap.memory), + swap(Icons.swap_horiz), + gpu(Bootstrap.gpu_card), + disk(Bootstrap.device_hdd_fill), + net(ZondIcons.network), + sensor(MingCute.dashboard_4_line), + temp(FontAwesome.temperature_empty_solid), + battery(Icons.battery_full), + pve(BoxIcons.bxs_dashboard, sinceBuild: 818), + custom(Icons.code, sinceBuild: 825), ; @override final int? sinceBuild; - const ServerDetailCards({this.sinceBuild}); + final IconData icon; + + const ServerDetailCards(this.icon, {this.sinceBuild}); static ServerDetailCards? fromName(String str) => ServerDetailCards.values.firstWhereOrNull((e) => e.name == str); @@ -67,19 +69,4 @@ enum ServerDetailCards implements VersionRelated { } } } - - IconData get icon => switch (this) { - about => Icons.info, - cpu => Icons.memory, - mem => Bootstrap.memory, - swap => Icons.swap_horiz, - gpu => Bootstrap.gpu_card, - disk => Icons.storage, - net => ZondIcons.network, - sensor => MingCute.dashboard_4_line, - temp => FontAwesome.temperature_empty_solid, - battery => Icons.battery_full, - pve => BoxIcons.bxs_dashboard, - custom => Icons.code, - }; } diff --git a/lib/data/res/color.dart b/lib/data/res/color.dart index bea50d93..1f2675a3 100644 --- a/lib/data/res/color.dart +++ b/lib/data/res/color.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import '../model/app/dynamic_color.dart'; -late Color primaryColor; +var primaryColor = const Color(0xff8b2252); abstract final class DynamicColors { static const content = DynamicColor(Colors.black87, Colors.white70); diff --git a/lib/view/page/home/home.dart b/lib/view/page/home/home.dart index bce94f5c..9113c4f5 100644 --- a/lib/view/page/home/home.dart +++ b/lib/view/page/home/home.dart @@ -4,6 +4,7 @@ import 'package:after_layout/after_layout.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:get_it/get_it.dart'; +import 'package:icons_plus/icons_plus.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:toolbox/core/channel/bg_run.dart'; import 'package:toolbox/core/channel/home_widget.dart'; @@ -130,7 +131,7 @@ class _HomePageState extends State title: const Text(BuildData.name), actions: [ IconButton( - icon: const Icon(Icons.developer_mode, size: 23), + icon: const Icon(Icons.developer_mode, size: 21), tooltip: l10n.debug, onPressed: () => AppRoute.debug().go(context), ), @@ -177,9 +178,9 @@ class _HomePageState extends State labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected, destinations: [ NavigationDestination( - icon: const Icon(Icons.cloud_outlined), + icon: const Icon(BoxIcons.bx_server), label: l10n.server, - selectedIcon: const Icon(Icons.cloud), + selectedIcon: const Icon(BoxIcons.bxs_server), ), const NavigationDestination( icon: Icon(Icons.terminal_outlined), @@ -187,14 +188,14 @@ class _HomePageState extends State selectedIcon: Icon(Icons.terminal), ), NavigationDestination( - icon: const Icon(Icons.snippet_folder_outlined), + icon: const Icon(MingCute.file_code_line), label: l10n.snippet, - selectedIcon: const Icon(Icons.snippet_folder), + selectedIcon: const Icon(MingCute.file_code_fill), ), const NavigationDestination( - icon: Icon(Icons.network_check_outlined), + icon: Icon(MingCute.planet_line), label: 'Ping', - selectedIcon: Icon(Icons.network_check), + selectedIcon: Icon(MingCute.planet_fill), ), ], ); @@ -243,17 +244,17 @@ class _HomePageState extends State onTap: () => AppRoute.keyList().go(context), ), ListTile( - leading: const Icon(Icons.file_open), + leading: const Icon(BoxIcons.bxs_file_blank), title: Text(l10n.files), onTap: () => AppRoute.localStorage().go(context), ), ListTile( - leading: const Icon(Icons.import_export), + leading: const Icon(MingCute.file_import_fill), title: Text(l10n.backup), onTap: () => AppRoute.backup().go(context), ), ListTile( - leading: const Icon(Icons.text_snippet), + leading: const Icon(OctIcons.feed_discussion), title: Text('${l10n.about} & ${l10n.feedback}'), onTap: _showAboutDialog, ) diff --git a/lib/view/page/server/detail/view.dart b/lib/view/page/server/detail/view.dart index 5112cfa4..91e738a8 100644 --- a/lib/view/page/server/detail/view.dart +++ b/lib/view/page/server/detail/view.dart @@ -136,7 +136,7 @@ class _ServerDetailPageState extends State Widget _buildAbout(ServerStatus ss) { return CardX( child: ExpandTile( - leading: const Icon(Icons.computer), + leading: const Icon(MingCute.information_fill, size: 20), initiallyExpanded: _getInitExpand(ss.more.entries.length), title: Text(l10n.about), childrenPadding: const EdgeInsets.symmetric( @@ -496,7 +496,7 @@ class _ServerDetailPageState extends State child: ExpandTile( title: Text(l10n.disk), childrenPadding: const EdgeInsets.only(bottom: 7), - leading: const Icon(Icons.storage, size: 17), + leading: Icon(ServerDetailCards.disk.icon, size: 17), initiallyExpanded: _getInitExpand(children.length), children: children, ), @@ -570,6 +570,7 @@ class _ServerDetailPageState extends State } return CardX( child: ExpandTile( + leading: Icon(ServerDetailCards.net.icon, size: 17), title: Row( children: [ Text(l10n.net), @@ -600,7 +601,6 @@ class _ServerDetailPageState extends State ], ), childrenPadding: const EdgeInsets.only(bottom: 11), - leading: const Icon(Icons.device_hub, size: 17), initiallyExpanded: _getInitExpand(children.length), children: children, ), diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 4631afb0..3307ca2f 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -99,6 +99,7 @@ class _ServerPageState extends State }, ), floatingActionButton: FloatingActionButton( + heroTag: 'addServer', onPressed: () => AppRoute.serverEdit().go(context), tooltip: l10n.addAServer, child: const Icon(Icons.add), diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index f12df445..3bfedb31 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -753,29 +753,36 @@ class _SettingPageState extends State { final keys = Stores.server.box.keys.toList(); keys.removeWhere((element) => element == BoxX.lastModifiedKey); final all = keys.map( - (e) => TextButton( - onPressed: () => context.showRoundDialog( - title: Text(l10n.attention), - child: Text(l10n.askContinue( - '${l10n.delete} ${l10n.server}($e)', - )), - actions: [ - TextButton( - onPressed: () { - Pros.server.delServer(e); - ctx.pop(); - setState(() {}); - }, - child: Text(l10n.ok), - ) - ], - ), - child: Text(e), - ), + (e) { + final name = Pros.server.pick(id: e)?.spi.name; + return ListTile( + title: Text(name ?? e), + subtitle: name != null ? Text(e) : null, + onTap: () => context.showRoundDialog( + title: Text(l10n.attention), + child: Text(l10n.askContinue( + '${l10n.delete} ${l10n.server}($e)', + )), + actions: [ + TextButton( + onPressed: () { + Pros.server.delServer(e); + ctx.pop(); + setState(() {}); + }, + child: Text(l10n.ok), + ) + ], + ), + ); + }, ); - return Column( - mainAxisSize: MainAxisSize.min, - children: all.toList(), + return ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 377), + child: Column( + mainAxisSize: MainAxisSize.min, + children: all.toList(), + ), ); }), ), @@ -829,7 +836,7 @@ class _SettingPageState extends State { Widget _buildServerFuncBtns() { return ExpandTile( - leading: const Icon(TeenyIcons.button, size: _kIconSize), + leading: const Icon(BoxIcons.bxs_joystick_button, size: _kIconSize), title: Text(l10n.serverFuncBtns), children: [ _buildServerFuncBtnsSwitch(), diff --git a/lib/view/page/snippet/list.dart b/lib/view/page/snippet/list.dart index 48383241..099ee664 100644 --- a/lib/view/page/snippet/list.dart +++ b/lib/view/page/snippet/list.dart @@ -34,7 +34,7 @@ class _SnippetListPageState extends State { return Scaffold( body: _buildBody(), floatingActionButton: FloatingActionButton( - heroTag: 'snippet', + heroTag: 'snippetAdd', child: const Icon(Icons.add), onPressed: () => AppRoute.snippetEdit().go(context), ), diff --git a/lib/view/page/ssh/tab.dart b/lib/view/page/ssh/tab.dart index 7e185542..dfd2cc95 100644 --- a/lib/view/page/ssh/tab.dart +++ b/lib/view/page/ssh/tab.dart @@ -47,6 +47,7 @@ class _SSHTabPageState extends State builder: (_, __) { if (_fabRN.value != 0) return const SizedBox(); return FloatingActionButton( + heroTag: 'sshAddServer', onPressed: () => AppRoute.serverEdit().go(context), tooltip: l10n.addAServer, child: const Icon(Icons.add), diff --git a/lib/view/widget/server_func_btns.dart b/lib/view/widget/server_func_btns.dart index 5ace957b..698c56a0 100644 --- a/lib/view/widget/server_func_btns.dart +++ b/lib/view/widget/server_func_btns.dart @@ -125,6 +125,10 @@ void _onTapMoreBtns( ); break; case ServerFuncBtn.snippet: + if (Pros.snippet.snippets.isEmpty) { + context.showSnackBar(l10n.noSavedSnippet); + return; + } final snippets = await context.showPickWithTagDialog( tags: Pros.snippet.tags, itemsBuilder: (e) {