I know ballast-navigation is not tied to any system. But is there an example to use in SwiftUI??
04/21/2023, 3:38 AM
I don’t think there is a specific example of SwiftUI with Ballast Navigation, mostly because I don’t know much about iOS dev and it’s not a target I use in my day-to-day development. But since the Router is just a normal Ballast ViewModel, the Ballast/SwiftUI guide should be able to setup and use the router just fine.
I haven’t actually run this code yet, but I think it should end up looking something like this: https://gist.github.com/cjbrooks12/d6934cfcb4e38ee3293e14d19007066d
04/21/2023, 10:33 AM
I'll try it out and let you know. SwiftUI navigation is soo confusing to me right now.
@Casey Brooks I read ballast implementation of ViewModel on iOS. I figured we still need to convert StateFlow to Publisher on iOS.
Can't we consume Flow directly from the callback in SwiftUI? Instead of wrapping it further in a publisher.
Thanks for your work on Ballast
04/23/2023, 5:34 PM
Unfortunately, some kind of wrapper is necessary, since Swift doesn't know anything about coroutines, and Swift UI needs needs the Combine framework for reactivity and can't use the default callbacks. Essentially the wrapper that I set up does just forward the Stateflow callback to a Publisher. You can also look into KMP-NativeCoroutines (https://github.com/rickclephas/KMP-NativeCoroutines) as another way that should be able to connect the Ballast StateFlows up to SwiftUI, though I haven't tried this either.
04/23/2023, 5:44 PM
Oh okay. I'll just go with what was stated in the documentation.
05/02/2023, 10:50 PM
@ayodele How did your experiments with navigation in iOS go? I haven't tried this yet myself but I'm interested in this approach also.
05/03/2023, 8:29 PM
Well the first issue we encountered was navigation on iOS is too closely tied to the UI. But we found out that we can use UINavigationController but it involves a lot of hacking.
We decided to make navigation purely SwiftUI, but we plan to experiment later