Created
August 25, 2023 12:23
-
-
Save chiragthummar/24b421d6ba192ab42114194e84e84e1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun HomeBottomBar( | |
destinations: List<TopLevelDestination>, | |
currentDestination: NavDestination?, | |
onNavigateToDestination: (route: String) -> Unit | |
) { | |
NavigationBar( | |
modifier = Modifier | |
.windowInsetsPadding( | |
WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom) | |
) | |
.height(70.dp), | |
) { | |
destinations.forEach { destination -> | |
val selected = | |
currentDestination?.hierarchy?.any { it.route == destination.route } == true | |
NavigationBarItem( | |
selected = selected, | |
onClick = { onNavigateToDestination(destination.route) }, | |
icon = { | |
val icon = if (selected) { | |
destination.selectedIcon | |
} else { | |
destination.unselectedIcon | |
} | |
Icon( | |
imageVector = ImageVector.vectorResource(icon), | |
modifier = Modifier.size(16.dp), | |
contentDescription = null | |
) | |
}, | |
label = { | |
Text( | |
text = destination.iconText | |
) | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment