I have several variables that have specific relationships with each other (ie each can be converted to each other via math functions). They are all adjustable by the user and I'd like them all to change any time one of them is updated. For example:
struct SliderView: View {
@State var feet: Float = 0
@State var yards: Float = 0
@State var miles: Float = 0
var body: some View {
VStack {
Text("Feet = \(feet)")
Slider(value: $feet, in: 0...5280, step: 1)
Text("Yards = \(yards)")
Slider(value: $yards, in: 0...1760, step: 0.1)
Text("Miles = \(miles)")
Slider(value: $miles, in: 0...1, step: 0.0001)
}
}
}
How can I make it such that changing one variable will automatically change the others?