Say I have an alert
@State var showingAlert = false
var body: some View {
Text("Hello, world!")
.alert("Here's an alert with multiple possible buttons.", isPresented: $showingAlert) {
Button("OK") {
}
Button("Another button that may or may not show") {
}
}
}
How could I display the second button based only on some condition?
I tried factoring out one button into
fileprivate func extractedFunc() -> Button<Text> {
return Button("OK") {
}
}
and this would work for conditionally displaying the button content given a fixed number of buttons, but how could optionality of buttons be taken into account?