iOS simple controller works
This commit is contained in:
@@ -10,27 +10,33 @@ import SwiftUI
|
||||
|
||||
struct SimpleControllerView: View {
|
||||
@EnvironmentObject var server: ServerData
|
||||
|
||||
// Need lazy so that we can initialise with local properties.
|
||||
@ObservedObject var grpcController: PiLoader = PiLoader()
|
||||
|
||||
var body: some View {
|
||||
HStack{
|
||||
Slider(value: $grpcController.throttle, in: 0...1){_ in
|
||||
self.grpcController.throttle = 0.5
|
||||
VStack (alignment: .trailing, spacing: 0){
|
||||
Spacer()
|
||||
HStack{
|
||||
// Move this up a bit, due to being rotated.
|
||||
Slider(value: self.$grpcController.throttle, in: 0...1){_ in
|
||||
self.grpcController.throttle = 0.5
|
||||
}
|
||||
.offset(x: 200)
|
||||
.frame(width: 300)
|
||||
.rotationEffect(.degrees(270))
|
||||
Spacer()
|
||||
Slider(value: self.$grpcController.steering, in: 0...1){_ in
|
||||
self.grpcController.steering = 0.5
|
||||
}
|
||||
.frame(width:300)
|
||||
.offset(x: -50, y: -200)
|
||||
.padding()
|
||||
}
|
||||
.rotationEffect(.degrees(270))
|
||||
|
||||
Slider(value: $grpcController.steering, in: 0...1){_ in
|
||||
self.grpcController.steering = 0.5
|
||||
.onAppear(){
|
||||
self.grpcController.startUpdating(forPort: self.server.grpcPort, atHost: self.server.host)
|
||||
}
|
||||
.onDisappear(){
|
||||
self.grpcController.stop()
|
||||
}
|
||||
}
|
||||
.onAppear(){
|
||||
self.grpcController.startUpdating()
|
||||
}
|
||||
.onDisappear(){
|
||||
// Stop the gRPC updater.
|
||||
self.grpcController.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user