Michael Marshall
06/07/2024, 6:24 AMNavHost
that navigates between tabs
2. Each tab inside the NavHost
Composes the bottom nav bar themselves
My main consideration is I want to be able to navigate from each of those tabs to other deeper “fullscreen” screens without the nav bar visibleStylianos Gakis
06/07/2024, 9:28 AMStylianos Gakis
06/07/2024, 9:29 AMMichael Marshall
06/07/2024, 9:44 AMyou manage when it’s shown or not shown by looking at the NavControllers current destinationThis is what I was scared of - I’d much rather not hardcode the screens that should display it into the enclosing screen. It feels wrong for the parent Composable to manage it outside of configuring the
NavHost
, but maybe my instincts around component responsibilities aren’t right here.
you click on the item of the already highlighted tab.Do you mean you’d end up having a transition animation in this case, even though it’s the same tab? I’ve seen suggestions to use
launchSingleTop
which I thought would resolve that, but I haven’t tested it. e.g.
BottomNavigation {
items.forEach { screen ->
BottomNavigationItem(
icon = { /* Your Icon Here */ },
label = { Text(screen.capitalize()) },
selected = navController.currentDestination?.route?.startsWith(screen) == true,
onClick = {
navController.navigate(screen) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
}
)
}
}
The shared element APIs sound very interesting. I’ll take a look into those, thanks!Stylianos Gakis
06/07/2024, 10:13 AMColton Idle
06/07/2024, 12:50 PMColton Idle
06/07/2024, 12:50 PMColton Idle
06/07/2024, 12:50 PMStylianos Gakis
06/07/2024, 2:07 PMColton Idle
06/07/2024, 2:09 PMStylianos Gakis
06/07/2024, 3:38 PMStylianos Gakis
06/07/2024, 3:40 PMColton Idle
06/07/2024, 5:09 PM