Users of `ModalBottomSheetLayout`/`ModalBottomShee...
# compose
j
Users of `ModalBottomSheetLayout`/`ModalBottomSheet` - how do you wish progress was modelled and exposed? What are your use cases? 🧵
Replies in thread please 🙂
t
That's a pretty open question 🙂 One of my use case is that a bottomsheet is shown below a custom navigation bar (like a compact player bar) when expanding the bottomsheet the offset is used to animate the custom nav so that it hide and a top view of the sheet (so the compact player) is also animated out to show the full expanded player;
d
Same for animating the status bar padding when the switch is going into fully expanded mode. Touched upon here but I've not had a chance to raise a ticket yet https://kotlinlang.slack.com/archives/CJLTWPH7S/p1679938064426559?thread_ts=1679915731.622329&cid=CJLTWPH7S
j
@Tolriq is that for BottomSheetScaffold?
@dorche do you have a code sample roughly outlining what you'd like to achieve?
t
Yes it's on the scaffold and I also use the same kind for @dorche stuff for the status bar handling.
Copy code
val padding = WindowInsets.statusBars.only(WindowInsetsSides.Horizontal + <http://WindowInsetsSides.Top|WindowInsetsSides.Top>).asPaddingValues()
    val paddingPx = with(LocalDensity.current) { padding.calculateTopPadding().toPx() }
    val appliedOffset by remember {
        derivedStateOf {
            val offset = playlistSheetScaffoldState.bottomSheetState.offset.value
            if (offset < paddingPx) offset else paddingPx
        }
    }
 ... .offset { IntOffset(x = 0, y = -appliedOffset.roundToInt()) },
The normal bottom sheets don't support edge to edge properly so I'm using a modified one without animation on it for the moment 😞 But I'd like to do the same + top shape animation.
j
Thank you, this is very helpful! Do I understand that you would not need this if the sheet was expanding behind the status bar by default?
t
Depends on the cases. But as you can see in the animation I animate the offset to not have the sheet having an ugly useless top padding during the collapse. Just drawing under the status bar does not render nicely at all.
Same for normal bottom sheet being able to change the top shape from rounded corner to not rounded and decide how to deal with status bar is important for nice design touches.
127 Views