UINavigationController with Store #1674
Replies: 2 comments 6 replies
-
Hey @darrarski, this looks really awesome, thanks for sharing! I've only briefly perused the code, but it's very exciting to see that you were able to leverage all of the core navigation tools ( Our plan is to support UIKit as much as we can, though our initial focus has been on SwiftUI since we feel that helps us best understand the problem space, and then we apply those ideas to UIKit. But your experiment shows that even if we don't get around to fully supporting UIKit, it can always be provided by the community. |
Beta Was this translation helpful? Give feedback.
-
I've tried to migrate my PoC to the latest Composable Architecture (v1.9.3) but I'm experiencing two issues, that were absent when using the navigation-beta branch. You can find the updated PoC on a separate branch.
I'm a bit stuck with the above issues. I can't make it work with Composable Architecture v1.9.3. @mbrandonw @Alex293 I would appreciate your support! |
Beta Was this translation helpful? Give feedback.
-
Hello everyone!
Recently I discovered the navigation branch which contains interesting additions to
ComposableArchitecture
aimed to easily drive aSwiftUI.NavigationStack
withStore
.@NavigationState and NavigationAction
The most interesting part for me, is the
@NavigationState
property wrapper, which can be used like this:@NavigationStateOf<Destination>
provides the collection ofDestination.State
that drives the navigation stack. It allows to update the stack easily:NavigationActionOf<Destination>
can be used to update the navigation state:There's a new case study that shows how it can be used in
SwiftUI
, and it's great. Navigation is simple, decoupled, and ongoing effects are automatically canceled once the destination that produced them is dismissed.UIKit and UINavigationController
In my daily work, I still use
UIKit
in some projects. While the concept of a navigation stack is quite new inSwiftUI
it existed inUIKit
for years now. I did a little experiment and implemented aUINavigationController
that drives its view controller stack with aStore
. It uses the sameComposableArchitecture
's API as mentioned above.It's open source and you can find it here:
👉 https://github.com/darrarski/store-navigation-controller
I've included an example iOS application built with
UIKit
to show how it can be used. It looks like this:SwiftUI vs UIKit
The
SwiftUI.NavigationStack
andUIKit.UINavigationController
can be driven by the sameComposableArchitecture
component. There's however a difference in how they work.The
NavigationStack
has an additionalRoot
view displayed when there're no destinations (the path is empty), while theUINavigationController
presents the first view controller on the stack as root. My initial approach to this issue is to ignore it 😄At the moment I'm not sure if, and how, we can implement consistent behavior in
UIKit
andSwiftUI
. One way would be to use the first destination on the stack as aRoot
view inSwiftUI
, and exclude it from the path. The other approach would be to allow providing arootViewController
of theUINavigationController
separately, and then theviewControllers
array will be the root + destination view controllers.We can also do nothing and it should work well in both
UIKit
andSwiftUI
, assuming we accept that the actual UI behavior depends on the framework.I appreciate any feedback and support with development of the
UINavigationController
driven byStore
. Let me know what you think, and what's your experience with usingComposableArchitectre
andUIKit
, regarding the navigation.My question to @stephencelis and @mbrandonw is - do you plan to support
UIKit
with the new navigation APIs introduced on the navigation branch? Or is it just focused on theSwfitUI
? I think it could be used inUIKit
out of the box, as my little PoC project proofs, but I might be wrong.Beta Was this translation helpful? Give feedback.
All reactions