-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animate Transitions of Root View? #33
Comments
Thanks @rhysm94! I’m afk today, but I think I’ve had the same trouble previously in TCACoordinators, where it doesn’t allow for animated transitions of the root screen, that are possible in FlowStacks. I’ll try to dig into why. In the meantime, perhaps a workaround would help. In your case, is the routes array’s count always one? If so, you might find it simpler not to use a Incidentally, I’ve tried in the past to come up with a general purpose transitioning API for FlowStacks, e.g. |
Hi @johnpatrickmorgan - sorry for the delayed response! Thanks for the workaround - it's not quite the case where the array count is always one, as I have a login screen to present too. Effectively, it would ideally look something like this: On app launch, load the Splash Screen view. Your hint to use a standard SwitchStore helped massively - I've just had to use an invisible Thanks again for the help, much appreciated! Frustrating that SwiftUI, even now, has these weird quirks where things don't work as you'd expect them, but it's good that there are mostly still workarounds! |
Great, glad you've reached an acceptable solution - yes, I've definitely found the transition API a bit of a head-scratcher! |
Hi again! I'm having an issue with what might be the same problem (i.e. SwiftUI being janky) but thought I'd double check quickly. My issue is that when I move on from Sign Up to the next screen, I want to remove the Sign Up screen from the underlying array of routes entirely so that the user can't swipe back to visit it again. state.routeIDs.remove(.signUp)
state.push(.viewAfterSignUp) which just causes an immediate, transition-less animation. I've tried swapping the order in which I do them, which does the same thing. I've also tried wrapping the above in I've also tried adding a separate action to remove the Sign Up ID from my routeIDs array like this: state.push(.viewAfterSignUp)
return .task {
try? await environment.mainQueue.sleep(for: .seconds(0.5))
return .removeSignUp
}
case .removeSignUp:
// look up index for .signUp and remove here but this one seems to trigger some double-presentation animation, where it presents the view after sign up normally, then immediately presents it again. This also seems to happen if I call routes.dismiss()
routes.push(.viewAfterSignUp) Is there any way that you know of to more easily remove this view from the underlying navigation array? Thanks! |
Thanks @rhysm94, this is a tricky one, without a great solution I know of... When you do: state.routeIDs.remove(.signUp)
state.push(.viewAfterSignUp) After One approach would be to have a single screen responsible for both Another approach would be to keep the Finally, it might work to take I'm not sure what your stack looks like before and after the removal and push, so some of those suggestions might not be viable. And unfortunately none of those approaches are ideal. In UIKit, |
Hi there!
I've got my initial app screen driven by a coordinator, where it tries to get some data to determine if the user is logged in or not, and goes to an appropriate screen. The app starts by showing a splash screen to perform that logic, before transitioning to either the logged in screen, or the onboarding screen.
Almost everything behaves exactly as expected, with the exception of transitions. The root views never transition between each other, they only ever immediately swap.
I've tried a few things - pushing those state changes into a separate action that I return with
.animate(.default)
after, wrapping thestate.routes = [.root(.onboarding)]
in awithAnimation
block, wrapping the initial action send in my splash screen withwithAnimation
, but none of them seem to work.Checking in the previous issues, it seems that some people have found a solution, but the code seems more geared towards FlowStacks than TCACoordinators. I'm wondering if there is a solution, even if it's potentially a bit hacky and verbose?
FWIW, a little sketch of how my main view is set up is here:
Have I placed the transition in the wrong place? Is there anything else I need to change?
Thanks for a great library 😃
The text was updated successfully, but these errors were encountered: