Created
December 10, 2022 13:13
-
-
Save MrNtlu/d20b51e9a718bfefd8b88e03c5536fa1 to your computer and use it in GitHub Desktop.
Jetpack Compose Navigation Bar Alt
This file contains 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
//Instead of backStackEntry | |
var selectedItem by remember { mutableStateOf(0) } | |
//Replace bottomNavItems.forEach with, | |
bottomNavItems.forEachIndexed { index, item -> | |
NavigationBarItem( | |
selected = selectedItem == index, | |
onClick = { | |
selectedItem = index | |
navController.navigate(item.route) | |
}, | |
//Other parts will be the same | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment