Chris Fillmore
06/17/2021, 5:07 PM@Composable
fun MainNavHost(
navController: NavHostController,
plugin: Plugin,
) {
NavHost(...) {
// Define regular navigation within the activity
composable(...) {
...
}
// Call this here to define nested navigation for plugin(s)
plugin.navGraph(navController)
}
}
interface Plugin {
fun NavGraphBuilder.navGraph(navController: NavHostController)
...
}
This seems fine to me, though I don’t like passing navController
down to the plugin. But it isn’t obvious to me how to avoid this, since there will be navigation to do within the plugin.
But… does this seem sensible? Any risks stand out to you that I may not have considered? Any feedback is appreciated, thanks!pepos
06/17/2021, 6:01 PMpepos
06/17/2021, 6:03 PMnavigationEvent: (String) -> Unit
and listen for these events in your app and decide what to doChris Fillmore
06/17/2021, 6:06 PM@Composable
fun MainNavHost(
navController: NavHostController,
plugin: Plugin,
) {
NavHost(...) {
...
// Call this here to define nested navigation for plugin(s)
plugin.navGraph { route ->
navController.navigate(route)
}
}
}
interface Plugin {
fun NavGraphBuilder.navGraph(navigate: (String) -> Unit)
...
}
pepos
06/17/2021, 6:06 PMChris Fillmore
06/17/2021, 6:07 PMMarcin Mazurek
06/17/2021, 6:15 PMMarcin Mazurek
06/17/2021, 6:16 PM