код: < /p>
Код: Выделить всё
@OptIn(ExperimentalAnimationGraphicsApi::class)
@Composable
fun NavBar(
onNavItemClick:(Int, Any) -> Unit,
selectedItemIndex: Int
) {
NavigationBar {
navItems.forEachIndexed { index, navItem ->
val isSelected = index == selectedItemIndex
var animatedSelection by rememberSaveable { mutableStateOf(false) }
//Change local state to start animation
LaunchedEffect(isSelected) {
animatedSelection = isSelected
}
val animatedImage = AnimatedImageVector.animatedVectorResource(navItem.icon)
val animatedPainter = rememberAnimatedVectorPainter(animatedImageVector = animatedImage, atEnd = animatedSelection)
NavigationBarItem(
selected = isSelected,
onClick = {
if(!isSelected) {
onNavItemClick(index, navItem.destination)
}
},
icon = {
Image(
painter = animatedPainter,
contentDescription = null,
colorFilter = ColorFilter.tint(mColors.onSecondaryContainer)
)
},
label = {
Text(navItem.label)
}
)
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... -the-start