with navigation-compose... what is the proper way ...
# compose
c
with navigation-compose... what is the proper way to structure your nav graph so that a destination can be accessed by several different nested nav graphs? For example - you're using bottom navigation and each tab is its own nested nav graph. However, you would like to be able to access a "support" screen destination from all of them.
Copy code
NavHost(...) {
    navigation<Products>(startDestination = ProductCatalog) {
        composable<ProductCatalog> {...}
        composable<ProductDetail> {...}
        composable<Support> {...}
    }

    navigation<Stores>(startDestination = StoresMap) {
        composable<StoresMap> {...}
        composable<StoreDetail> {...}
        composable<Support> {...}
    }
}
Also, how would you construct a deep link for this "Support" destination that is used in multiple graphs?
Should a unique route be used for the Support page inside each graph instead?
i
You can reuse the same route in multiple graphs if you want, there was even a recent fix in Navigation (that is in every stable version of Navigation 2.8) to ensure the copy in your current graph is always used when you navigate to that route: https://developer.android.com/jetpack/androidx/releases/navigation#2.8.0-beta07
👍 1
c
nice - Ill give that spin
s
Also, if you for some reason want the deep link to take you to a specific one of the places you call this destination, you can always have a unique destination for that place, and instead have it call the exact same shared composable. But otherwise, the module which contains this destination can expose a
fun NavGraphBuilder.profile()
function which you can call from your :app module and put inside any other place, without those other modules having to know anything about it. Or it can even expose two functions
profileWithDeepLink
being the second one, or something like that 🤷