import SwiftUI /// Alle Werte eines Geräts. Am iPhone stehen hier zusätzlich Verlauf und /// Diagnose – auf der Uhr wäre beides unlesbar und ist deshalb weggelassen. struct WatchDeviceDetailView: View { let deviceID: UUID @Environment(PhoneLink.self) private var link private var device: WatchDevice? { link.payload?.devices.first { $0.id == deviceID } } var body: some View { List { if let device { if let fridge = device.fridge { WatchFridgeControls(deviceID: device.id, fridge: fridge) } Section { ForEach(device.snapshot?.metrics.filter { $0.value != nil } ?? []) { metric in LabeledContent(metric.label) { Text(metric.formattedWithUnit) .monospacedDigit() } .font(.footnote) } } header: { Text("Messwerte") } Section { if let fault = device.snapshot?.fault { Label(fault, systemImage: "exclamationmark.triangle.fill") .font(.caption2) .foregroundStyle(.red) } if let state = device.snapshot?.state { Text(state).font(.caption2) } ForEach(device.snapshot?.offReasons ?? [], id: \.self) { reason in Text(reason) .font(.caption2) .foregroundStyle(.secondary) } Label(device.link.label, systemImage: "antenna.radiowaves.left.and.right") .font(.caption2) .foregroundStyle(.secondary) } } else { Text("Gerät ist nicht mehr im Fahrzeugprofil.") .font(.footnote) .foregroundStyle(.secondary) } } .navigationTitle(device?.name ?? "Gerät") } }