Hi,
In AppKit, there's the famous NSViewController
that can be used to display the whole content of a window. One can easily switch the contents of a window there, by simply swapping the view controller with another one.
How can that be achieved in SwiftUI?
I know one way, but it doesn't seem idiomatic at all, something like:
struct MyView : View {
@State var setupIsDone = false
var body: some View {
if setupIsDone {
FirstView()
} else {
SecondPage()
}
}
}
So this is really tedious, it will turn into a switch statement and you'd have to pass down the the state variable to each subview in order for the subview to change the screen, like a state machine, only badly implemented.