i have a Jetpack Compose project that includes navigating using a Scaffold
with a BottomBar
. By the way, in specific screens, i would like to being able to navigate outside of the innerPadding
scope of the Scaffold
and just have the composable to be displayed in full screen.
Using official docs approach is fine only until you just need to navigate clicking on the items of the BottomBar
.
I found a workaround solution in this post where you use this:
@Composable
fun OneScreen(navController: NavHostController) {
MainScaffold(
bottomBar = { BottomBar(navController = navController) },
content = {
// content
})
}
for screens where BottomBar
needs to be displayed and this:
@Composable
fun AnotherScreen() {
MainScaffold () {
//content
}
}
for the screens where you don't need it to be diplayed.
I call this a "workaround solution" because in this way you need to regenerate the BottomBar
on every screen, making it flashing everytime you click on one item because of recomposition (differently from standard BottomBar navigation).
I'm getting the feeling that there should be a more elegant solution, but i lack the experience to be sure of it and i have not been able to find it until now.
EDIT: I was WRONG on a relevant aspect. The flashing is not because of recomposition but because of the Transition Animation
(Fade out/Fade in) provided by the Navigation
component. Hence, it is possible to eliminate the 'flashing' issue setting No animation on transition. Of course this is still a work-around solution because it limit the user on the flexibility in animating the app.