https://kotlinlang.org logo
#compose
Title
# compose
m

Marko Novakovic

08/01/2022, 4:10 PM
ModalBottomSheetLayout
sheetContent
never leaves composition. is tracking offset the only way to observe is it visible or not?
m

MR3Y

08/01/2022, 5:56 PM
there is a
ModalBottomSheetState#isVisible
property to check if the bottomSheet is currently visible or hidden https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#isVisible(). Also, you can use `currentValue`(that is used by
isVisible
under the hood) to check for the intermediate states like
HalfExpanded
. https://developer.android.com/reference/kotlin/androidx/compose/material/SwipeableState#currentValue()
m

Marko Novakovic

08/02/2022, 9:27 AM
thanks. I should’ve make myself more clear. I need something observable state.
j

jossiwolf

08/02/2022, 11:33 AM
isVisible
reads from
currentValue
which is backed by snapshot state. If you read
isVisible
in any context that tracks state reads (Composition or i.e.
snapshotFlow
) you will receive updates to it 🙂
m

Marko Novakovic

08/02/2022, 11:43 AM
oh thanks
6 Views