Tomáš Procházka
04/30/2025, 11:20 PMDestinationsNavHost
?
I get deep link intent from the Activity and pass it to my compose app.
But DestinationsNavHost
has just start
parameter, there is no way how to put there deep link Uri.
I found that this works:
val navController = rememberNavController()
val destinationNavigator = navController.rememberDestinationsNavigator()
DestinationsNavHost(
...
)
navController.handleDeepLink(deepLinkIntent)
But the issue is that it always display the start
screen first and then replace it by the screen resolved from deeplink, which doesn't looks good.
Maybe I can put some empty screen as defaultStartDestionation
but this also looks like hack to me.Tomáš Procházka
05/01/2025, 4:46 PMRyan
05/05/2025, 3:55 PMfun RootScreen(activity: MainActivity, viewModel: MainActivityViewModel) {
val navController = rememberNavController()
val destinationsNavigator = navController.rememberDestinationsNavigator()
val destination by viewModel.deepLink.collectAsStateWithLifecycle()
LaunchedEffect(destination) {
destination?.let {
destinationsNavigator.navigate(it)
viewModel.completeDeepLink()
}
}
CoreScaffold(
navController = navController,
topBar = { _, _ -> },
bottomBar = { BottomBar(navController, visible = it.showsBottomBar()) },
) {
DestinationsNavHost(
navController = navController,
navGraph = NavGraphs.root,
modifier = Modifier.fillMaxSize(),
)
}
}
Tomáš Procházka
05/05/2025, 8:55 PMTomáš Procházka
05/05/2025, 8:56 PM