I'm new to SwiftUI and I'm trying to display an alert that does only close on some conditions but not on every click on its buttons.
Is that possible or does it strike against the concept of alerts?
My code is like this:
.alert("title", isPresented: $presented) {
Button(action: {
NSWorkspace.shared.open(URL(string: "https://myurl")!)
}) {
Text("Download ...")
}
} message: {
Text("message")
}
But when I click the button presented
gets set to false. Can I prevent this somehow? Or intercept when it gets set to false so I can check if it should actualle stay true and change it again?