I've been playing around with SwiftUI and got stumped on this simple thing. Basically, I'm trying to trigger a modal after tapping on an ActionSheet.Button. Here's my code so far:
struct SomePage: View {
@State var showSheet = false
var body: some View {
Button(action: {
self.showSheet = true
}) {
Text("Show ation sheet")
}.presentation(sheet)
}
private var sheet: ActionSheet? {
let button = ActionSheet.Button.default(Text("Button") {
self.showSheet = false
// what now??
}
let action = ActionSheet(title: Text("Title"),
message: nil,
buttons: [button])
return showSheet ? action : nil
}
// This is the modal I'm trying to present
// after tapping on the action sheet button
private var modal: Modal {
return Modal(SomePage())
}
}
I've tried adding a second presentation handler to the button and toggling a showModal property but obviously the debugger complained about attempting a second modal presentation while the first one was still being presented.
Does anybody have an idea on how to make this work?
