You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Annotated Composables with @Destination create and correspond to a single route in your graph. If you find yourself wanting to include it in multiple graphs that all have the same "root" graph (the one you pass to DestinationsNavHost), you'll have multiple destinations with the same route.
IMPORTANT
Generated Destinations contain navigation stuff like the route. Routes should be unique. So you cannot import another module's Destination to more than one graph.
So, if you find yourself wanting to do this, you should instead expose the actual Composable, untied from any navigation stuff, then preparing multiple @destination Composables that just call that one.
What I would do:
The module that is exposing this SettingsDestination, instead exposes a simple Composable function. Not tied to navigation in any way.
Next to the graphs where you want to include this screen, create an annotated Composable with @destination that calls your Composable from the other module.
Include that in your graph by simply adding the correct graph @Destination<GRAPH>. If these are both in the same module, you can actually make use of multiple @Destination annotations in one single Composable, example:
@Destination<BottomNavigationGraph>
@Destination<XGraph>
@Composable
funSettingsDestination() {
SettingsScreen() // from that other module that's exposing it.
}
Because you're in the module that knows both XGraph and BottomNavigationGraph, this works. It will create two Destinations, one for each graph, with different routes for each in this case.
I have
Also I have graph that belongs to
BottomNavigationGraph
and hasSettingsDestination
Simple workaround can be like that:
In that case I don't receive any benefit of splitting destinations to different modules. Am I missing some API ? May you suggest something ?
The text was updated successfully, but these errors were encountered: