diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-01-04 04:04:03 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-01-04 04:04:03 +0300 |
commit | bb32e56ca28bb43d5d5afef737f25e4725887725 (patch) | |
tree | 519388eb284adeb47744a9ebc334bdf9ff5444a6 /watchos/InfiniSolar/InfiniSolar WatchKit Extension/RoomView.swift | |
parent | d549f428cbbd54c49a90f92928e670d373c4a0d9 (diff) |
move watchos app sources here (which should be rewritten anyway, and usable only in very specific conditions)
Diffstat (limited to 'watchos/InfiniSolar/InfiniSolar WatchKit Extension/RoomView.swift')
-rw-r--r-- | watchos/InfiniSolar/InfiniSolar WatchKit Extension/RoomView.swift | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/watchos/InfiniSolar/InfiniSolar WatchKit Extension/RoomView.swift b/watchos/InfiniSolar/InfiniSolar WatchKit Extension/RoomView.swift new file mode 100644 index 0000000..8bcf6d7 --- /dev/null +++ b/watchos/InfiniSolar/InfiniSolar WatchKit Extension/RoomView.swift @@ -0,0 +1,42 @@ +// +// MainRoomView.swift +// InfiniSolar WatchKit Extension +// +// Created by Evgeny Zinoviev on 08.08.2021. +// + +import SwiftUI + +struct RoomView: View { + @ObservedObject var state = RoomState() + + var body: some View { + VStack(alignment: .leading) { + Text("Room") + .font(.title2) + .fontWeight(.thin) + Spacer().frame(height: 10) + + if self.state.error { + Text("Failed to fetch data from si7021d.") + } + + else { + Text("Temperature is ").fontWeight(.thin) + Text(String(self.state.temp) + " °C") + Text("Rel. humidity is ").fontWeight(.thin) + Text(String(self.state.rh) + " %") + } + } + .onAppear() { + self.state.start() + } + .onDisappear() { + self.state.stop() + } + } +} + +struct RoomView_Previews: PreviewProvider { + static var previews: some View { + RoomView() + } +} |