The regular case.
Open a sheet by clicking a button. Next close the sheet using a Cancel
button on it. The isPresented
state variable is changed immediately, but while the dismissing animation isn't totally finished it's impossible to click the Button
on the main parent screen and call the sheet presentation again.
As I understand UIKit works differently and lets us click the Button
but just calls a new modal view exactly after the previous animation is finished
struct MyView: View {
@State private var isPresented = false
public var body: some View {
VStack {
Button(action: {
isPresented = true
}, label: {
Text("Button")
})
Spacer()
}
.sheet(isPresented: $isPresented) {
sheetContent
}
}
var sheetContent: some View {
VStack {
Text("Cancel")
.onTapGesture {
isPresented = false
}
Spacer()
}
}
}
@Apple Could you please fix it in SwiftUI?