I'm trying to implement a TextField with a number input together with Stepper to control quantity. After entering a number in the TextField the Stepper loses the ability to change the number. I'm pretty sure there is a trick with Binding value, but can't figure out what exactly.
struct TestView: View {
@State var quantity: Int = 0
var body: some View {
HStack {
TextField("", value: $quantity, formatter: NumberFormatter())
Stepper("", onIncrement: {
self.quantity += 1
}, onDecrement: {
self.quantity -= 1
})
}
}
}