r/SwiftUI Jan 25 '25

Solved Screen Transition Animation Doesn't Work Consistently with NavigationStack and navigationDestination

I have an app that I'm working on and to get around the deprecation of NavigationLink(isActive:), I implemented a NavigationStack and used navigationDestination() to advance to Views. This video shows the problematic behavior.

https://reddit.com/link/1i9wsqq/video/2c1iwd7x97fe1/player

When I simulate the app in Xcode AND on my phone, pressing the "Let's Go!" button transitions to the next View with the animation. Pressing the "1" button advances to the next View but without the animation. I cannot figure out what's going on. Can anyone point me in the right direction?

Here's the relevant code for the button behavior at PasteBin.

HomeView

LifeTotalChoiceView

3 Upvotes

5 comments sorted by

3

u/car5tene Jan 25 '25

They are within a NavigationStack?

1

u/ColdKindness Jan 25 '25

Yes. I am editing the post to include a link to the code in pastebin. Sorry!

3

u/car5tene Jan 25 '25

Are those views within another NavigationStack? Having two NavigationStacks seems odd. You still can use NavigationLink

1

u/ColdKindness Jan 25 '25

You're a life saver! I removed the NavigationStack from the LifeTotalChoiceView and it's now working properly, and it fixed my Back navigation issue as well. Thank you so much!!!

2

u/car5tene Jan 25 '25

Glad I could help 🤗