johnpatrickmorgan / FlowStacks

FlowStacks allows you to hoist SwiftUI navigation and presentation state into a Coordinator
MIT License
854 stars 66 forks source link

How do I animate between root screens. #19

Closed kgrigsby-codesmith closed 2 years ago

kgrigsby-codesmith commented 2 years ago

I have an app coordinator that has several child coordinators. I show each child by replacing the root of the app coordinator‘s routes property. Right now it immediately switch between them. Is it possible to dissolve between them?

kgrigsby-codesmith commented 2 years ago

I figured it out. I wrapped the assignment of routes with withAnimation.

       withAnimation {
            routes = [.root(.login(loginCoordinator))]
        }
johnpatrickmorgan commented 2 years ago

Thanks, glad you figured it out @kgrigsby-codesmith. Incidentally, I'd like to be able to offer some utility methods in this library to swap the top screen for a new one with a custom transition, but in my experimentation, SwiftUI's .transition(...) modifier only seems to work for the root screen.