Hi,
I am a bit confused as to how to approach this problem:
Suppose I have this kind of view:
struct RootView: View {
@State private var isFirstLaunch: Bool = true
@ViewBuilder var body: some View {
if isFirstLaunch {
FirstLaunchView(isFirstLaunch: $isFirstLaunch) // to change this once done
} else {
MainAppView()
}
}
}
Note: this is just an example, usually I'd persist the firstLaunch flag.
So I want to display a first launch view on the first launch, otherwise the app itself. This works nicely and now I want to work on transitioning between those states:
FirstLaunchView(isFirstLaunch: $isFirstLaunch)
.transition(.move(edge: .leading))
.animation(Animation.easeOut(duration: 0.6))
MainAppView()
.transition(.move(edge: .trailing))
.animation(Animation.easeOut(duration: 0.6))
Sort of like a paging animation. This also works great but here is what happens:
In my FirstLaunchView
I transition between the first launch pages (Welcome, Tutorial, etc.). I make use of .transition and .animation view modifiers as well and they look amazing. The only problem arises is that the top level view modifiers for transitioning between the views themselves messes up the animation in the views below like this:
FirstLaunchView(...).transition(.move(edge: .leading)).animation(Animation.easeOut(duration: 0.6)
turns into:
... pageView(for page: currentPage).transition(.slide).animation(.default).transition(.move(edge: .leading)).animation(Animation.easeOut(duration: 0.6))
and therefore the animations of the "subviews" in first launch are affected by the top level animations of the view transition.
Is there any way that I can make animation only apply when actually transitioning?
How can I animate and transition subviews while applying a different animation to a top level view? Thanks alot!