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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!
Recently I discovered the navigation branch which contains interesting additions to
ComposableArchitectureaimed to easily drive aSwiftUI.NavigationStackwithStore.@NavigationState and NavigationAction
The most interesting part for me, is the
@NavigationStateproperty wrapper, which can be used like this:@NavigationStateOf<Destination>provides the collection ofDestination.Statethat 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
UIKitin some projects. While the concept of a navigation stack is quite new inSwiftUIit existed inUIKitfor years now. I did a little experiment and implemented aUINavigationControllerthat 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
UIKitto show how it can be used. It looks like this:SwiftUI vs UIKit
The
SwiftUI.NavigationStackandUIKit.UINavigationControllercan be driven by the sameComposableArchitecturecomponent. There's however a difference in how they work.The
NavigationStackhas an additionalRootview displayed when there're no destinations (the path is empty), while theUINavigationControllerpresents 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
UIKitandSwiftUI. One way would be to use the first destination on the stack as aRootview inSwiftUI, and exclude it from the path. The other approach would be to allow providing arootViewControllerof theUINavigationControllerseparately, and then theviewControllersarray will be the root + destination view controllers.We can also do nothing and it should work well in both
UIKitandSwiftUI, assuming we accept that the actual UI behavior depends on the framework.I appreciate any feedback and support with development of the
UINavigationControllerdriven byStore. Let me know what you think, and what's your experience with usingComposableArchitectreandUIKit, regarding the navigation.My question to @stephencelis and @mbrandonw is - do you plan to support
UIKitwith the new navigation APIs introduced on the navigation branch? Or is it just focused on theSwfitUI? I think it could be used inUIKitout of the box, as my little PoC project proofs, but I might be wrong.Beta Was this translation helpful? Give feedback.
All reactions