fixed drone status menue grid view bug. fields are shown again

This commit is contained in:
Constantin Leue
2026-08-05 21:11:28 +02:00
parent 4982341203
commit c7e4e5bf63
4 changed files with 150 additions and 16 deletions
@@ -127,11 +127,12 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
);
return ListView(
padding: const EdgeInsets.all(16),
children: [
children: _statusGrid([
// Farbcodierte Felder zuerst (Doku: "drone status felder im
// menue auch farblich kodieren", Schwellwerte je Drohnenprofil -
// siehe computeTelemetryFieldStatus), informelle Felder ohne
// Ampel-Bewertung (Koordinaten/Heading/Alt/Speed) danach.
// Ampel-Bewertung (Koordinaten/Heading/Alt/Speed) danach. Je 2
// Felder pro Zeile (Doku: "platz effizienter nutzen").
_statusRow('GPS satellites', '${frame.numSat}', level: fieldStatus.numSat),
_statusRow(
'GPS precision (HDOP)',
@@ -159,7 +160,7 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
_statusRow('Heading', '${frame.headingDeg.round()}°'),
_statusRow('Altitude', '${frame.altitudeM.toStringAsFixed(0)} m'),
_statusRow('Speed', '${frame.speedMs.toStringAsFixed(1)} m/s'),
],
]),
);
},
loading: () => const Center(
@@ -171,33 +172,81 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
);
}
/// Ordnet die Statuszeilen zu je 2 pro Zeile an (Doku: "2 felder pro zeile
/// im drone status menue erlauben um platz effizienter zu nutzen") - bei
/// ungerader Feldanzahl bleibt die letzte Zeile einspaltig statt sie
/// kuenstlich zu strecken.
List<Widget> _statusGrid(List<Widget> tiles) {
final rows = <Widget>[];
for (var i = 0; i < tiles.length; i += 2) {
final hasPair = i + 1 < tiles.length;
// Kein CrossAxisAlignment.stretch: diese Row sitzt direkt als
// ListView-Kind, das seinen Kindern unbegrenzte Hoehe gibt (0<=h<=
// Infinity) - stretch verlangt aber eine endliche Hoehe, um die Kacheln
// darauf zu strecken, und wirft sonst "BoxConstraints forces an
// infinite height" (fuehrte zum komplett schwarzen Status-Tab). Default
// (center) reicht, da beide Kacheln einer Zeile ohnehin fast gleich
// hohen Inhalt haben.
rows.add(Row(
children: [
Expanded(child: tiles[i]),
if (hasPair) ...[
const SizedBox(width: 8),
Expanded(child: tiles[i + 1]),
],
],
));
}
return rows;
}
static const _signalColors = {
SignalLevel.green: DmcColors.flyModeColor,
SignalLevel.yellow: DmcColors.pafAmber,
SignalLevel.red: DmcColors.warnRed,
};
// Label ueber Wert statt nebeneinander (Doku: "2 felder pro zeile") - bei
// halber Zeilenbreite kollidiert ein nebeneinander angeordnetes Label wie
// "GPS precision (HDOP)" sonst mit dem Wert; gestapelt bleibt auch bei
// laengeren Labeln/Werten genug Platz.
Widget _statusRow(String label, String value, {SignalLevel? level}) {
final valueColor = level != null ? _signalColors[level]! : Colors.white;
return Container(
margin: const EdgeInsets.symmetric(vertical: 4),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.04),
borderRadius: BorderRadius.circular(10),
),
child: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: Text(label, style: const TextStyle(color: Colors.white70))),
if (level != null) ...[
Container(
width: 8,
height: 8,
margin: const EdgeInsets.only(right: 8),
decoration: BoxDecoration(color: valueColor, shape: BoxShape.circle),
),
],
Text(value, style: TextStyle(color: valueColor, fontWeight: FontWeight.w600)),
Text(
label,
style: const TextStyle(color: Colors.white70, fontSize: 12),
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Row(
children: [
if (level != null) ...[
Container(
width: 8,
height: 8,
margin: const EdgeInsets.only(right: 6),
decoration: BoxDecoration(color: valueColor, shape: BoxShape.circle),
),
],
Flexible(
child: Text(
value,
style: TextStyle(color: valueColor, fontWeight: FontWeight.w600),
overflow: TextOverflow.ellipsis,
),
),
],
),
],
),
);