Closed josephktcheung closed 2 years ago
@johnpatrickmorgan not sure if manualNavigation
is a good name, or if I should reuse embedInNavigationView
boolean such that setting it to false would mean manualNavigation
is true, so that there's no need for a new boolean.
Thanks for raising this PR. This gives me a much clearer idea of the behaviour you wanted. It's a very interesting approach, and I think it fits nicely with some changes that I'm investigating for issue #21: I think the ability to customize the transition when 'manually navigating' would be very useful. If I can make the changes as I hope, it would allow for an API something like this:
routes.replaceCurrentScreen(with: .home, transition: .push)
Which would swap out the current screen for .home
, animating the change with the provided transition. But, in contrast to your proposed changes, it would not maintain a history of previous screens so that the transition could later be wound back with routes.goBack()
. I can see now how in some cases maintaining history would be desirable, so I think there's room for both styles to be supported.
The changes I'm looking into making for #21 involve a pretty major rewrite of Node
, so I don't think your proposed changes could be merged at the moment, but I'd like to try to incorporate your ideas into that work.
Thanks for raising this PR. This gives me a much clearer idea of the behaviour you wanted. It's a very interesting approach, and I think it fits nicely with some changes that I'm investigating for issue #21: I think the ability to customize the transition when 'manually navigating' would be very useful. If I can make the changes as I hope, it would allow for an API something like this:
routes.replaceCurrentScreen(with: .home, transition: .push)
Which would swap out the current screen for
.home
, animating the change with the provided transition. But, in contrast to your proposed changes, it would not maintain a history of previous screens so that the transition could later be wound back withroutes.goBack()
. I can see now how in some cases maintaining history would be desirable, so I think there's room for both styles to be supported.The changes I'm looking into making for #21 involve a pretty major rewrite of
Node
, so I don't think your proposed changes could be merged at the moment, but I'd like to try to incorporate your ideas into that work.
@johnpatrickmorgan thanks for the review. Since you're rewriting Node
, I'll keep this PR open until the feature is implemented in your next update.
Here I list out what I hope the next FlowStacks / TCACoordinators can achieve:
Problem:
NavigationView
, .sheet
or .cover
) has limited support in macOS (e.g. no StackNavigationViewStyle
).sheet
)How FlowStacks can solve the above problems:
(N)
N1 -> N2 // N stands for native navigation
A user can push a screen that uses 'manual' navigation if they specify it in the .push
method
(N) // N stands for native navigation
N1 -> N2 -> (M) // M stands for 'manual' navigation
M1
A user can further push any screen without specifying if the last one is native or not, the library can infer it based on the last element's attribute
(N) // N stands for native navigation
N1 -> N2 -> (M) // M stands for 'manual' navigation
M1 -> M2 -> (N)
N1 -> N2 ....
Let's see if the above points make sense.
Besides, if we take a step back, navigation boils down to transition of one screen to another. Hence no matter how deep one's route stack is, when one pushes / presents / overlays a new screen, what the app user sees is the interaction between current screen and next screen. And this is the gist of this PR as well.
Just a quick update: the latest version of SwiftUI allows stack-based navigation on macOS, albeit only for version 13 onwards, so there is a bit less motivation for this sort of change. I also realised that this approach differs from other forms of navigation in that moving back to a previous screen recreates the screen, re-initialising its state, which might be unexpected.
Thanks for taking a look into this @johnpatrickmorgan, I will close the PR.
This PR:
manualNavigation
toRoute
that allows user to create their own navigation flow without using Apple's nativeNavigationView
Manual
to demonstrate usingmanualNavigation
in both iOS and macOSThis addresses issue #22
iOS:
https://user-images.githubusercontent.com/4270232/165051259-680d3c3e-26fb-4ba4-9641-5acd3487295e.mp4
macOS:
https://user-images.githubusercontent.com/4270232/165051229-a5679de8-723c-473e-86a1-b8ef3caa9207.mov