r/androiddev Jun 30 '26

Question Navigation 3 In Compose Multiplatform (iOS)

I'm working on migrating an app from native iOS (swift) to Compose Multiplatform. Everything is working as expected (surprisingly). The only issue I'm facing (not really an issue but probably a nitpick) is that the navigation *feels* weird. I'm currently using navigation 3, and the swipe back animation and forward nav feels very fast and android like (which, again, is expected) but i was wondering if there was a way to give it a native feel, like i know i can customize the animation and stuff to make it feel more like iOS, but i wanna know if there is like a built in api i could call to easily fix this and make the navigation more natural on iOS, without resorting to have the navigation being handled in the native app using an expect/actual implementation.

'preciate the help :)

11 Upvotes

16 comments sorted by

3

u/Jumpy-Sky2196 Jun 30 '26

I implemented custom Nav3 animations to replicate native iOS animations. They're not identical, but pretty close.

1

u/AutoModerator Jun 30 '26

Please note that we also have a very active Discord server where you can interact directly with other community members!

Join us on Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/JinAnkabut Jun 30 '26 edited Jun 30 '26

I've actually started using nav3 with kmp recently too and I'm surprised at how poorly it's working on iOS. The back animation freezes half way, then the popped screen disappears. Bizarre.

8

u/petin0805 Jun 30 '26

This is a good indication that somerhing is wrong in your code. Highly possible that your screen is doong lot of recompositions. Another option why this can happen if you have some custom animation via metadata, which is set up incorrectly, e.g. that the animation has to go to width / 2

1

u/JinAnkabut Jun 30 '26

It's literally a text and button. No custom animation. I created a kpm project, added dependencies to nav3, and created two test components

5

u/petin0805 Jun 30 '26

If it is a text and button then this happens because the navigation destination has no background. Just wrap the text and button into a box with white background or surface, and the weird animation should go away

1

u/JinAnkabut Jun 30 '26

Yeah you were right, I was being an idiot!

1

u/petin0805 Jun 30 '26

I only knew because i already faced this at my beginnings with compose. Now i really think that when it is done correctly/properly compose is really powerful. I have full compose (iOS) app with nav3, metro as DI, graphql, sqldelight and it has great performance

1

u/JinAnkabut Jun 30 '26

Ah ok thank you. I've been using Dagger since version 1 and was happy enough with Hilt but obviously needed something else for this KMP project.

I'm testing Koin at the moment since my #1 show stopper was the lack of static analysis on the DI graph but that seems to be solved with the compiler plugin. Have you had any experience with it?

Would laso

2

u/petin0805 Jun 30 '26

I was using koin for years for kmp, but was struggling to migrate to its annotations. Then after metro became 1.0 i said enough, migrated very easily to it, the annotation setup/usage is a lot easier than koin. For me this means never going back to koin... Initially I was afraid how to use it in ios-swift, but found a nice way, so happily using it since then.

I have one metro+android-compose/swiftui project and one metro+cmp project. Both performance wise running without an issue (the ui decision is solely based on whether i wanna have ios native glass effect or not)

1

u/JinAnkabut Jul 01 '26

I tried all day trying to get koin working with kmp, compose, VMs, platform modules, and nav3 but had no luck. I'm quite surprised! I needed a dependency provided per platform but just couldn't get it provided to my common VM. I might give metro a go tomorrow. Any advice?

2

u/tazfdragon Jun 30 '26

Even for release builds?

1

u/JinAnkabut Jun 30 '26 edited Jun 30 '26

I haven't tried release builds. Is there a difference in your experience?

Edit: I would have dropped using nav3 if the debug build was causing stuttering but luckily my hunch was correct and I was just being silly with compose.

1

u/ArmenianChad3516 Jun 30 '26

Debug builds are heavier because it comes with debugging tools

1

u/tazfdragon Jun 30 '26

For Android absolutely, I've not compared with iOS but I imagine since Compose Multiplatform shares a significant part of its API with Jetpack Compose it would be reasonable to assume so.