Pop to specific View
View1 -> View2 -> View3 -> View4 How can I pop from View4 directly to View2 considering that we do not have control over the navigation stack ?
This framework is very use full for navigation. But I am also looking for above issue. I also want to navigate back to some specific screen
The way to do it currently would be to keep the reference to the router for each view. If you call "dismissScreen" on View3's Router, it should dismiss both View3 and View4.
The recommended approach would be to display View3 as a .sheet or .fullScreenCover, so that you could call "dismissEnvironment" to dismiss View3 and View4 (see Enter Screen Flows in the ReadMe: https://github.com/SwiftfulThinking/SwiftfulRouting).
In regards to pop to a specific view, this seems doable but it's quite difficult to implement - this isn't in the native SwiftUI framework either. I attempted it a few weeks ago and got pretty close but I need more time to implement it fully.
Thanks a lot @SwiftfulThinking
Please take care of this in ur future releases as it will be very helpful to the developers.
The way to do it currently would be to keep the reference to the router for each view. If you call "dismissScreen" on View3's Router, it should dismiss both View3 and View4.
@SwiftfulThinking I tried this, but it didn't seems to work for me. View1 -> View2 -> View3 -> View4. When I call dismissScreen in View4 with the router of View3, nothing happens. Is that correct?
Please take care of this in ur future releases as it will be very helpful to the developers.
this isn't in the native SwiftUI framework either.
I thought you could do this with the native framework. You would just update the stack/path. It's just an array. So, you could do path.removeLast(2) or use something like lastIndex(where:) to pop back to a specific screen. I actually need this functionality currently. Hope this makes it in very soon. 🤞
Added additional dismiss support, including "dismiss count" and "dismiss to id" in Version 6 (https://github.com/SwiftfulThinking/SwiftfulRouting/releases/tag/beta-6.1)