I am looking to present a new view properly on top of the navigation stack in SwiftUI.
If I have a navigation stack, with A being the root view:
A -> B -> C -> D -> E
In this scenario, I have a method on view B that has an onOpenURL(perform:) modifier. I have some specific use cases where if a deeplink is opened (for example: my-app://example), that some logic handles opening this in a new view (think like in a social media, opening a tagged user's page from a link like @example). This @example tag will then be passed as a parameter to a new view, F.
This onOpenURL method then handles passing the deeplink variable into a new view, which goes into a navigationDestination inside B. This is where the issue occurs.
The earliest onOpenURL method in the stack presides over any that follow it. When this logic happens and it opens a new view, it does this:
A -> B -> F
It erases the navigation stack.
I want the new view to be presented on top of the navigation stack as a user would expect, like this:
A -> B -> C -> D -> E -> F
I have tried working with the navigation path, but I am unsure of how to simply pass a new view on top of it as the stack grows as the user navigates around. The problem is that the view at B is opening it with a navigationDestination, which simply creates a new navigationstack and removes any previous ones. This presents an issue.
I cannot use a .sheet or .overlay as the new view has its own navigation options that would lead to this same scenario.