sunnat629
03/03/2022, 6:55 AMimplementation "androidx.navigation:navigation-compose:2.4.1"
compose version, I tried both 1.1.0 and 1.2.0-alpha04
I am trying to use this and where I create and add the bottomBar , I got Skipped * frames! The application may be doing too much work on its main thread* without adding any view.
my code snaps -
@Composable
fun BottomNavigationBar(navController: NavHostController) {
BottomNavigation(
backgroundColor = AppColors.BottomNav,
) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
items.forEach { screen ->
BottomNavigationItem(
icon = {
Icon(
painterResource(screen.drawableResId),
tint = AppColors.secondary,
contentDescription = screen.route
)
},
label = { Text(stringResource(screen.resourceId)) },
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {}
)
}
}
}
@ExperimentalMaterialApi
@ExperimentalFoundationApi
@Composable
fun SportWorldUi() {
val navController = rememberNavController()
Scaffold(
topBar = { TopBar(navController) },
bottomBar = { BottomNavigationBar(navController) },
// backgroundColor = Color.Transparent,
modifier = Modifier.fillMaxSize()
) { innerPadding -> }
If I remove bottomBar = { BottomNavigationBar(navController) },
, it works fine.
Where is the issue here?
ThanksEric Chee
03/03/2022, 5:59 PM