mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-31 13:25:10 +01:00
opt.: collapse custom cmd output
This commit is contained in:
@@ -63,4 +63,17 @@ final class ServerCustom {
|
||||
String toString() {
|
||||
return toJson().toString();
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is ServerCustom &&
|
||||
//other.temperature == temperature &&
|
||||
other.pveAddr == pveAddr &&
|
||||
other.pveIgnoreCert == pveIgnoreCert &&
|
||||
other.cmds == cmds &&
|
||||
other.preferTempDev == preferTempDev;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => toString().hashCode;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,13 @@ extension ServerX on Server {
|
||||
return l10n.disconnected;
|
||||
case ServerState.finished:
|
||||
// Highest priority of temperature display
|
||||
final cmdTemp = status.customCmds['server_card_top_right'];
|
||||
final cmdTemp = () {
|
||||
final val = status.customCmds['server_card_top_right'];
|
||||
if (val == null) return null;
|
||||
// This returned value is used on server card top right, so it should
|
||||
// be a single line string.
|
||||
return val.split('\n').lastOrNull;
|
||||
}();
|
||||
final temperatureVal = () {
|
||||
// Second priority
|
||||
final preferTempDev = spi.custom?.preferTempDev;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 881;
|
||||
static const int build = 882;
|
||||
static const String engine = "3.19.6";
|
||||
static const String buildAt = "2024-05-09 14:50:53";
|
||||
static const int modifications = 12;
|
||||
static const String buildAt = "2024-05-09 15:29:37";
|
||||
static const int modifications = 3;
|
||||
static const int script = 46;
|
||||
}
|
||||
|
||||
@@ -781,13 +781,41 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
leading: const Icon(MingCute.command_line, size: 17),
|
||||
title: Text(l10n.customCmd),
|
||||
initiallyExpanded: _getInitExpand(ss.customCmds.length),
|
||||
children: [
|
||||
for (final cmd in ss.customCmds.entries)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 7),
|
||||
child: KvRow(k: cmd.key, v: cmd.value),
|
||||
children: ss.customCmds.entries.map(_buildCustomItem).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCustomItem(MapEntry<String, String> cmd) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 7),
|
||||
child: KvRow(
|
||||
k: cmd.key,
|
||||
v: cmd.value,
|
||||
vBuilder: () {
|
||||
if (!cmd.value.contains('\n')) return null;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.showRoundDialog(
|
||||
title: Text(cmd.key),
|
||||
child: SingleChildScrollView(
|
||||
child: Text(cmd.value, style: UIs.text13Grey),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(l10n.close),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.info_outline,
|
||||
size: 17,
|
||||
color: Colors.grey,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,16 @@ final class KvRow extends StatelessWidget {
|
||||
final String k;
|
||||
final String v;
|
||||
final void Function()? onTap;
|
||||
final Widget? Function()? kBuilder;
|
||||
final Widget? Function()? vBuilder;
|
||||
|
||||
const KvRow({
|
||||
super.key,
|
||||
required this.k,
|
||||
required this.v,
|
||||
this.onTap,
|
||||
this.kBuilder,
|
||||
this.vBuilder,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -22,9 +26,9 @@ final class KvRow extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(k, style: UIs.text12),
|
||||
kBuilder?.call() ?? Text(k, style: UIs.text12),
|
||||
UIs.width7,
|
||||
Text(
|
||||
vBuilder?.call() ?? Text(
|
||||
v,
|
||||
style: UIs.text11Grey,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
||||
Reference in New Issue
Block a user