当我双击同一项目或如果我很快进入每个可组合屏幕时,我会收到一条错误消息,我该如何解决此问题?我尝试改变一些东西,但我无法解决它,而且我找不到任何资源来解决这个问题。
底部导航实施
@Composable
fun BottomNav(
navController: NavController,
bottomNavState: MutableState<Boolean>,
) {
val navItems = listOf(
Screen.HomeScreen,
Screen.BookmarkScreen,
Screen.MyRecipesScreen,
Screen.FavouriteScreen
)
AnimatedVisibility(
visible = bottomNavState.value,
enter = slideInVertically(initialOffsetY = { it }),
exit = slideOutVertically(targetOffsetY = { it }),
content = {
BottomNavigation(
backgroundColor = Color.White,
elevation = 12.dp
) {
val bottomNavBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = bottomNavBackStackEntry?.destination
navItems.forEach { item ->
BottomNavigationItem(
icon = {
Icon(painter = painterResource(id = item.icon), contentDescription = "")
},
label = {
Text(text = …Run Code Online (Sandbox Code Playgroud) kotlin android-jetpack android-jetpack-navigation android-jetpack-compose