fix: sensors (#350)

This commit is contained in:
lollipopkit
2024-05-10 20:15:30 +08:00
parent ed5bcb17ed
commit f9efd6acfa
11 changed files with 118 additions and 222 deletions

View File

@@ -755,37 +755,26 @@ class _ServerDetailPageState extends State<ServerDetailPage>
}
Widget _buildSensorItem(SensorItem si) {
if (si.props.isEmpty) return UIs.placeholder;
return ListTile(
title: Text(si.device, style: UIs.text15),
subtitle: Column(
children: si.props.keys
.map((e) => _buildSensorDetailItem(e, si.props[e]))
.toList(),
if (si.val.isEmpty) return UIs.placeholder;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Text(si.device, style: UIs.text15Bold),
const Spacer(),
Text(si.adapter.raw, style: UIs.text13Grey),
],
),
Text(si.val, style: UIs.text13Grey),
],
),
);
}
Widget _buildSensorDetailItem(String key, SensorTemp? st) {
if (st == null) return UIs.placeholder;
final text = () {
final current = st.current?.toStringAsFixed(1);
final max = st.max?.toStringAsFixed(1);
final min = st.min?.toStringAsFixed(1);
final currentText = current == null ? '' : '$current°C';
final maxText = max == null ? '' : ' | ${l10n.max}:$max';
final minText = min == null ? '' : ' | ${l10n.min}:$min';
return '$currentText$maxText$minText';
}();
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(key, style: UIs.text13),
Text(text, style: UIs.text13Grey),
],
);
}
Widget _buildPve(_) {
final addr = widget.spi.custom?.pveAddr;
if (addr == null) return UIs.placeholder;