Using Material3 design principle, I think (I may be wrong here) BottomSheetScaffold Composable should be used rather than ModalBottomSheet Composable, but the problem is that I didn’t find any way of using it with Bottom Navigation Bar.
Also, I could not control the visibility of the two different composable functions i.e. Now Playing screen when BottomSheet is expanded and Mini-Player when the BottomSheet is partially collapsed.
What is the recommended practice? Is there any other way to achieve this behavior or this is the one? If this is the way than how can I do it?
Just for more context, there is no bottomBar parameter in the BottomSheetScaffold like topBar to pass the Bottom Navigation Bar.
// there is no bottomBar parameter like topBar
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetContent = {
// This is where I want to have isExpanded condition to show mini-player or Now Playing screen
MyExpandedPlayerSampleScreen()
// Adding Bottom Navigation Bar here didn't work as expected
},
sheetPeekHeight = 72.dp,
sheetSwipeEnabled = true,
topBar = {
ExitUntilCollapsedLargeTopAppBar(
scrollBehavior = scrollBehavior
)
},
modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
) { innerPadding ->
FakeListItemsWithState(
paddingValues = innerPadding,
lazyListState = listState,
modifier = Modifier
)
}
Edit:
Here, I have attached an image and a short video of the behavior I want to achieve.
I want to have bottom sheet peek the required space on top of the bottom navigation bar and respond accordingly with respect the bottom sheet expansion.
I want Bottom Navigation Bar to exitOnBottomSheetExpand. (like in YouTube and YouTube Music App)
(Just to be clear, YouTube uses their custom bottom bar. However, many modern music player app uses Bottom Navigation Bar with bottom sheet to achieve this Layout/behavior.)
2
Answers
Thanks for asking the question. I am sorry for that, if I may misunderstood your question. What I had understood is that, You have to implement bottomSheet with bottom navigation, right. If this is your problem, I would recommend using Scaffold + ModalBottomSheetLayout. This is my personal go to approach. It gives more control over customize bottom sheet and I can use bottom navigation.
Here is one of my code’s composable, where I had implemented it.
Some clarification regarding my sample composable->
BottomSheetStructure() composable = It is the composable(in my code) that handles modal bottom sheet layout. I would share that also for more clarity.
TopBar = It is responsible for top bar of my screen. Same goes with BottomBar composable and DrawerItem composable , they manages bottom navigation and drawer item respectively.
)
}
BottomSheetStructure.kt (Just for reference on how can you use Modal bottom sheet layout with scaffold)->
I hope this approach will help if. If you have any other doubt regarding this or any doubt about jetpack or other android components , feel free to ask. I would love to answer it.
Thanks
Have you done it? I also want to achieve this. Got the same problem as you