Навигационный элемент только обновления, когда я нажимаю вручную в панели навигации , когда я нажимаю обратно, наносится обратно, но выделенный элемент остается прежним
// navigation bar composable
@Composable
fun BottomBar(navController: NavController) {
// current destination and bottombar navigation items
var curDestination by remember { mutableStateOf( 0 )}
val items = listOf(
BottomBarItem.Home,
BottomBarItem.History
)
// navigation bar
NavigationBar {
items.forEachIndexed { index, item ->
NavigationBarItem(
selected = curDestination == index,
onClick = {
curDestination = index
navController.navigate(item.route)
},
label = { Text(text = item.label) },
icon = {
Icon(
painter = painterResource(
id = if (curDestination == index) item.iconSelected else item.icon),
contentDescription = item.label
)
}
)
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/708 ... press-back