https://kotlinlang.org logo
Title
j

jossiwolf

03/31/2023, 6:07 PM
Users of `ModalBottomSheetLayout`/`ModalBottomSheet` - how do you wish progress was modelled and exposed? What are your use cases? 🧵
Replies in thread please 🙂
t

Tolriq

03/31/2023, 6:28 PM
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

dorche

03/31/2023, 6:34 PM
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

jossiwolf

04/03/2023, 6:30 AM
@Tolriq is that for BottomSheetScaffold?
@dorche do you have a code sample roughly outlining what you'd like to achieve?
t

Tolriq

04/03/2023, 6:33 AM
Yes it's on the scaffold and I also use the same kind for @dorche stuff for the status bar handling.
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

jossiwolf

04/03/2023, 7:45 AM
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

Tolriq

04/03/2023, 7:49 AM
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.