Trying to use router.showAlert( #46
-
I have:
later on in the view: ...
On alertButton I have two errors:
Is there a better way to use "router.showAlert" without it being called as part of a button action? |
Beta Was this translation helpful? Give feedback.
Answered by
nsarno-lucid
Jan 26, 2024
Replies: 2 comments
-
@jem5519 That closure for alert is @ViewBuilder var alertButtons: some View {
Button(role: .none, action: {
}, label: {
Text("Default")
})
Button(role: .cancel, action: {
}, label: {
Text("Cancel")
})
Button(role: .destructive, action: {
}, label: {
Text("Destructive")
})
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jem5519
-
That worked, thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jem5519 That closure for alert is
() -> View
. It comes from the native SwiftUI modifier itself (I also don't like how tricky it is to use - thinking about simplifying this in a fure update). However, I think you should be able to do something like this: