https://kotlinlang.org logo
#compose
Title
# compose
t

tylerwilson

10/28/2020, 11:05 PM
I too am excited about the navigation compose integration. Though I am wondering how to handle my current use case: I am experimenting with Compose in one Fragment in my app that already uses navigation. In my first composable I want to navigate to another composable, but have the parent navhost do the ‘right’ thing with the nav controller so it pops back to my previous composable. I would love to see an example of this in the docs. It appears to me the sample linked above assumes a fully composable app, not a ‘hybrid’, which I expect many people will be using in the short term. Thanks!
i

Ian Lake

10/28/2020, 11:14 PM
Let me see if I got this right. You're using
navigation-fragment
in your existing app to navigate between fragments in your app. Now, within one of your fragment destinations you want to have another, completely separate child
navigation-compose
navigation graph to navigate between two composables within that fragment? If so, yes, that's certainly possible and should just work ™️
Generally, we'd recommend doing one or the other and not both - use fragments that have their content as only a composable (ala Jetchat) or use composables alone (the pure Compose world using Navigation Compose)
t

tylerwilson

10/29/2020, 12:17 AM
I just fixed it up so that from the Fragment/AppCompat side I pass in the NavController from findNavController, and the composable will call navigate on that, which then navigates to another fragment wrapped composable. I guess that is the cleanest option until I convert everything to Compose. 🙂
i

Ian Lake

10/29/2020, 12:21 AM
Yep, that seems appropriate to me as part of the transition process and similar to what Jetchat does: https://github.com/android/compose-samples/blob/main/Jetchat/app/src/main/java/com/example/compose/jetchat/conversation/ConversationFragment.kt#L49
t

tylerwilson

10/29/2020, 12:25 AM
Cool, thanks! I will review that sample again.