I have a bottom sheet in it's default open height ...
# compose
c
I have a bottom sheet in it's default open height (about half way up the screen) and I have a title aligned to the top in the middle. It looks and works great, but when the card is fully expanded, the title is under the status bar ever so slightly. "I know. I'll use accompanist insets to apply statusBarPadding()!" And yes, that works, but now my card in the default open height (half way open) now has wayyy too much padding in that state, but it looks great in the full expanded state. How do I go about solving this so that there is no padding in the default open state, but the extra padding is there during the fully open state?
a
Are you applying the padding modifier to the
ModalBottomSheetLayout
?
c
Nope. In my bottom sheet content (I'm using accompanist in order to have bottom sheets as destinations) I have a column. And on that column that's where I set the statusBarPadding.
a
So you should apply it to the
ModalBottomSheetLayout
(the container).
c
Okay cool. That definitely works as a possible solution. But now the shadow/scrim doesn't cover the status bar and the bottom sheet doesn't go all the way up to the top edge. Ideally, I'd still want the sheet to go up to the top, but just the status bar padding to only be applied when the composable is touching the status bar.
a
I don't think this is possible with current API. You can make your own
ModalBottomSheetLayout
or file a feature request.
c
Cool. Will do!
d
Yeah, I've had a lot of the same back-and-forth with non-modal bottom sheet and then ended up copying its source from compose and doing my own custom stuff. It wasn't only about padding, we also have some other "interesting" layout things going on, so copying was justified (I think). Also had to use SubComposeLayout, maybe it could somehow help you too.
c
Might have to go that route if my designers end up hating this solution. lol