Luis Daivid
01/08/2022, 2:08 PMBy using the saveState and restoreState flags, the state and back stack of that item is correctly saved and restored as you swap between bottom navigation items.
and of course it is recomposed every time even though it is applied. What should I do?fun navigateToBottomBarRoute(route: String) {
if (route != currentRoute) {
navController.navigate(route) {
launchSingleTop = true
restoreState = true
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
}
}
}
val appState = rememberPwwAppState()
Scaffold(
bottomBar = {
if (appState.shouldShowBottomBar) {
BottomNavigation {
appState.bottomBarTabs.forEach { screen ->
BottomNavigationItem(
selected = appState.currentRoute == screen.route,
label = { Text(text = screen.name) },
onClick = {
appState.navigateToBottomBarRoute(screen.route)
},
icon = {})
}
}
}
},
) { innerPaddingModifier ->
...
}
allan.conda
01/08/2022, 3:01 PMIan Lake
01/08/2022, 11:46 PM