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

Archie

12/02/2020, 11:29 AM
Hi @Ian Lake, Is it a bad idea to nest compose
NavGraph
?
Copy code
NavHost(mainNavController, startDestination = STARTING) {
    composable(STARTING) {
        StartScreen(navController)
    }
    composable(NEXT) {
        Scaffold(
            topbar = { TopAppBar(...) }
        ) {
            val nestedNavController = ...
            NavHost(nestedNavController, startDestination = FLOW1) {
                composable(FLOW1) {
                    Flow1Screen(navController)
                }
                composable(FLOW2) {
                    Flow1Screen(navController)
                }
                ...
            }
        }
    }
}
👀 1
h

Halil Ozercan

12/02/2020, 11:37 AM
I don't think it's a bad idea, even I'd say it's going to be a regular practice. I'm not sure where it was mentioned but this situation is kind of the reason why
AmbientNavController
doesn't exist. Apart from the usual reasons like "magical dependency injection", Ambients make it hard to find what you are looking for in nested structures. NavController not having a such ambient might be an indication of possibly nesting navigation graphs.
a

Archie

12/02/2020, 11:40 AM
I actually got this idea in that thread and wanted to make sure that this is what implied there. (just to be really sure). I find that using only the nested navigation (
navigation(...)
) doesn't solve shared ui across screens really well. So doing something like this make it really possible.
@Halil Ozercan, I was wondering how DeepLink would be handled when doing this? Do you have any idea?