yurihondo
03/21/2024, 11:52 AMyurihondo
03/21/2024, 11:55 AMksp {
arg("compose-destinations.moduleName", "hoge")
arg("compose-destinations.mode", "navgraphs")
}
Navigation module:
object MainNavGraph : NavGraphSpec {
override val route = "main"
override val destinationsByRoute = emptyMap<String, DestinationSpec<*>>()
override val startRoute = HogeNavGraph
override val nestedNavGraphs = listOf(
HogeNavGraph,
FugaNavGraph,
OtherNavGraph,
)
}
yurihondo
03/21/2024, 11:56 AM@NavGraph<ExternalModuleGraph>
internal annotation class HogeNavGraph
HogeRoute:
@Destination<HogeNavGraph>
@Composable
fun HogeScreen(...){...}
Navigation module:
@NavHostGraph
annotation class MainGraph {
@ExternalNavGraph<HogeNavGraph>
@ExternalNavGraph<FugaNavGraph>
@ExternalNavGraph<OtherNavGraph>
companion object Include
}
yurihondo
03/21/2024, 11:58 AMRafael Costa
03/21/2024, 2:03 PMRafael Costa
03/21/2024, 2:06 PM@NavHostGraph
annotation class MainGraph {
@ExternalNavGraph<HogeNavGraph>(start = true) // 👈 ADDED THIS TO BE EQUAL TO THE v1 EXAMPLE
@ExternalNavGraph<FugaNavGraph>
@ExternalNavGraph<OtherNavGraph>
companion object Include
}
rather than on v1:
object MainNavGraph : NavGraphSpec {
override val route = "main"
override val destinationsByRoute = emptyMap<String, DestinationSpec<*>>()
override val startRoute = HogeNavGraph
override val nestedNavGraphs = listOf(
HogeNavGraph,
FugaNavGraph,
OtherNavGraph,
)
}
Rafael Costa
03/21/2024, 2:07 PMRafael Costa
03/21/2024, 2:07 PMRafael Costa
03/21/2024, 2:08 PMIt seems that the “RootNavGraph” on the Feature Module side is published without doing the above. However, because it includes the “root” Destination, using it might result in runtime errors when aggregating NavGraphs.The feature module should not be generating RootNavGraph, unless you are using RootGraph annotation in that module 🤔
yurihondo
03/22/2024, 8:02 AMyurihondo
03/22/2024, 8:06 AMThe feature module should not be generating RootNavGraph, unless you are using RootGraph annotation in that module 🤔I apologize for the lack of explanation🙇♂️ I attempted to link the Destinations on the FeatureModule side to the RootGraph in a similar manner to v1, aggregating the generated
RootNavGraph
in the Destination Module’s NavGraph, but it did not work as expected.
That comment was about that attempt. I believe that the RootNavGraph
generated in this way is not intended for aggregation purposes.Rafael Costa
03/22/2024, 8:43 AMRafael Costa
03/22/2024, 8:59 AM@Destination<MyGraph>
you could do @MyGraphAnnotation
. Not sure it’s worth it though, it’s almost the same number of characters. ( your destination could have a smaller name, but I guess including the name of the graph is what would make sense imo).
If you want to try that you can check this:
https://composedestinations.rafaelcosta.xyz/v2/defining-destinations#centralizing-destination-annotation-configuration (second example)yurihondo
03/25/2024, 11:25 AMRafael Costa
03/25/2024, 11:31 AM