Apple sample code "Detecting Human Actions in a Live Video Feed" - accessing the observations associated with an action prediction

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?

Just wrap your Button in a condition:

if someBool {
    Button("Another button that may or may not show") {
        
    }
}

So:

struct ContentView: View {
    
    @State var showingAlert = false
    var someBool = false
    
    var body: some View {
        VStack {
            Text("Hello, world!")
            Button("Alert") {
                showingAlert.toggle()
            }
        }
        .alert("Here's an alert with multiple possible buttons.", isPresented: $showingAlert) {
            Button("OK") {
                
            }
            if someBool {
                Button("Another button that may or may not show") {
                    
                }
            }
        }
    }
}
Apple sample code "Detecting Human Actions in a Live Video Feed" - accessing the observations associated with an action prediction
 
 
Q