I'm rather new to SwiftUI, so please bear with in case I mix up the nomenclature.
I have an Int @State property that is used in a TabView to hold the current index. Then I have a function that takes a Binding<Bool> to display another view.
What I basically want to do is pass a condition into the function whenever my Int state reaches a given value.
Sample code:
import SwiftUI
struct FooTabView: View {
@State private var selected = 0
@State private var shouldShow: Bool = false
var body: some View {
TabView(selection: $selected) {
Text("Hello")
.tabItem {
Text("Foo")
}.tag(0)
Text("World")
.tabItem {
Text("Bar")
}.tag(1)
}.anotherFunctionReturningAView(show: shouldShow)
}
}
Lets say shouldShow should only be true, when selected is equal to 1. How would I do that?