Im have the following code running in ios 1. When the button "View A" is pressed the state variable nextModalView2 is set to NextModalView2.a But When the Sheet() call is executed the value of nextModalView2 is reset to .none.
How is it possible?
Alsoif you look at the screenshot, you will see that the debugger console panel is showing a value for nextModalView2 that is different from what shown in the variable panel of the debugger. How is that?
enum NextModalView2{
case none
case a
case b
}
struct Menu2: View {
@State private var isShowModally = false
@State private var nextModalView2 = NextModalView2.none
var body: some View {
VStack(alignment: .center) {
Button(action: {
self.isShowModally = true
self.nextModalView2 = .a
print("self.nextModalView = \(self.nextModalView2)")
}){ Text("View A")
}
Divider()
Button(action: {
self.isShowModally = true
self.nextModalView2 = .b
}){ Text("View B")
}
.padding(.top, 20)
}
.sheet(isPresented: $isShowModally){
Group{
if self.nextModalView2 == .a {
// case NextModalView2.a:
AnyView(Text("A"))
}
if self.nextModalView2 == NextModalView2.b{
AnyView(Text("B"))
}
if self.nextModalView2 == NextModalView2.none{
AnyView(EmptyView())
}
}
}
}
}