first commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
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")
|
||||
// Die Kühlbox wird nur verbunden, solange jemand sie ansieht. Das gilt
|
||||
// auch von hier aus – das iPhone verbindet auf Zuruf.
|
||||
.onAppear {
|
||||
//guard device?.fridge != nil else { return }
|
||||
//link.send(.fridgeSession(device: deviceID, wanted: true))
|
||||
}
|
||||
.onDisappear {
|
||||
// guard device?.fridge != nil else { return }
|
||||
//link.send(.fridgeSession(device: deviceID, wanted: false))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user