ios – `NavigationStack`: how to navigate to a new view while old views are pushed with `NavigationLink(value:)`

0
176


I am using the new NavigationStack with the path argument. This let me easily show views. But sometimes I am using NavigationLink(value:) when dealing with a list. I use that NavigationLink in that way, because else I do not get the back-animation when swiping back to the list (when you tapped on an item in a list, it is gray. When you dismiss the view, the item will become slowly white. I want to keep this animation).

So I was wondering if I could combine NavigationLink(value:) and NavigationStack(path:). Because now, when I append to the path while I pushed a view with NavigationLink(value:), that view is gone. Probably because I set the path to 1 item (which is 1 view and dismisses the other one).

So either I am looking for:

  • A way to combine path on NavigationStack with NavigationLink(value:)
  • Keeping the ‘dismiss’ animation in a list item while pushing views to the path of the NavigationStack.