A project for a watchOS navigation app I'm playing with.
I have a VStack with three related pieces of text. What I want to do is allow the user to double tap in the area of the VStack and then use the digital crown to adjust a particular value in the VStack group. So far I've got the following which sets my bearing to a new heading OK but how do I link the digital crown to range value I want to change?
struct WaypointPosition: View {
@ObservedObject var waypointManager = WaypointManager() // Where I want to go
@ObservedObject var locationManager = LocationManager() // Where I am currently
var bearing: String {return ("\(waypointManager.bearing)" + "º") }
var range: String {return ("\(waypointManager.range)" + "m") }
var body: some View {
VStack {
Text("\(waypointManager.position)").font(.system(size: 10))
HStack {
Text("\(waypointManager.bearing, specifier: "%3.0f")º" ).font(.system(size: 15))
Spacer()
Text("\(waypointManager.range)m" ).font(.system(size: 15))
.focusable(true)
}
}
.onTapGesture(count: 2, perform: {
// Edit Waypoint
waypointManager.bearing = locationManager.heading // New direction
})
}
}