I have a view that starts setup like this.
var body: some View {
switch appState.userFlow {
case .onboarding:
Text("Not Yet Implemented")
case .login:
LandingPageView()
case .home:
HomeScreenView()
}
}
In each of those userFlow's I change the appState utilizing an @EnvironmentObject Whenever the object changes its state, the view blinks away and the new one is presented. This looks abrupt and ugly as it stands.
I attempted to do something along the lines of this. Which had no effect. What is the proper way to handle a transition when used in this context?
LandingPageView().transition(.opacity)
The
.transitionneeds to be applied to the container of the views that you want to switch over, so you'll need to embed yourswitchinside aGroup,VStack, or similar.Also, you need to have either a
.animation(.default)on the container, or changeappState.userFlowinside awithAnimation {}block to actually animate the change.Result: