Just a quick question about the compose navigation...
# compose
k
Just a quick question about the compose navigation, yes the one with NavHost. Just want to clarify, if it can be shared to iOS? or it is only working for Android?
k
@Stylianos Gakis I think that is for compose multiplatform. Just to add more details, for the UI I am using jetpack compose for android and will use swift UI in iOS.
s
Oh yeah then I highly doubt you’d be able to use those two together. I could be wrong of course but with the way I see it used right now I don’t think that’s something that will work
k
Okay, then I might need a plugin for navigation.
s
If you are not going to be sharing stuff on the UI layer, you will not need a shared navigation solution anyway right? Or what is it that you are thinking about here, I may be misunderstanding you
1
If you want to share some UI, I believe you could theoretically share the navigation stuff, but inside each screen implement the screen itself in compose for Android and in SwiftUI for iOS? I’ve never done CMP myself but I believe there are interop APIs to make this happen. You will lose out on most of the “SwiftUI magic” you get for free when using their own navigation solution of course, but it really depends on what you want to do here I think.
k
I am still unsure. But yeah, I can also consider using swift's navigation. Actually, the plan is the business logic is shared. But the UI's are native. So I need to code two times for each screen
s
Yeah so it sounds like to me you will want to not share the navigation, just share the things above the UI layer. Then expose the right state down so that android can use that to do androidx.navigation navigation, and your iOS app can use the same state to do normal SwiftUI navigation, without them caring necessarily that the state is shared
s
I read a blog post not long ago that mentioned that you can use Decompose to share navigation logic while keeping native UIs. I have never used it so can't confirm it, but might be worth looking into it
s
Yeah that would work too, but then you are again not using SwiftUI for navigation which I understood was the point here
👍 1
c
Same thoughts as Stylianos. If you're not sharing the UI layer, then I don't think you'd want to share the navigation layer.
k
Thanks for the input guys! I'll think about it, and I will also take a look to Decompose.
🙌 1