-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentView.Swift
More file actions
36 lines (33 loc) · 1.54 KB
/
ContentView.Swift
File metadata and controls
36 lines (33 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import SwiftUI
struct ContentView: View {
@ObservedObject var bluetooth = Bluetooth.init()
var body: some View {
CurrentTemperature(bluetooth: bluetooth)
let targetTemperature = Int(bluetooth.targetTemperature)/10
let displayTemperature = (bluetooth.isF ? bluetooth.cToF(temperatureInCelcius: targetTemperature) : targetTemperature)
let temperatureSuffix = bluetooth.isF ? "F" : "C"
Text("\(displayTemperature)°\(temperatureSuffix)")
.font(.largeTitle)
.foregroundColor(.white)
.onTapGesture {
bluetooth.SetIsF(useF: !bluetooth.isF)
}
.focusable()
.digitalCrownRotation(detent: $bluetooth.targetTemperature, from: 1700, through: 2300, by: 10,sensitivity: .high, isContinuous: false,
isHapticFeedbackEnabled: true) { event in
} onIdle: {
bluetooth.TurnHeatOn()
bluetooth.WriteTargetTemperature(tempInCelcius: Int(bluetooth.targetTemperature))
}
HStack{
FanOnButton(bluetooth: bluetooth)
HeatOnButton(bluetooth: bluetooth)
BLEDisconnect(bluetooth: bluetooth)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}