When I use a GeometryReader around views that contain controls such as Stepper or Toggle which are bound to an AppStorage var, the controls do not work in the app or preview.
If I remove the GeometryReader, or use a State var instead of AppStorage, then the controls work perfectly.
This was working well before; I believe it broke with iPadOS 16.5:
Sample below:
import SwiftUI
struct ContentView: View {
/*
To make the Stepper object function:
Either,
Comment out the stepperValue @AppStorage var and uncomment the @State stepperValue var
Or,
Comment out all references to the GeometryReader
(which breaks the requirement of using the entire vertical viewport)
*/
@AppStorage("stepperValue") var stepperValue = 5
//@State var stepperValue = 5
var body: some View {
GeometryReader { reader in
ScrollView {
ZStack {
Rectangle()
.fill(.blue.gradient)
.frame(minHeight: reader.size.height)
VStack {
Stepper(value: $stepperValue, in: 1...10) {
Text("Value:\t \(stepperValue)").font(.title3)
}
}.padding()
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}