Arun Joseph
09/14/2022, 7:41 AMLocalConfiguration.current.screenHeightDp.dp.toPx()
is doing some rounding and I get errors when comparing with Offset
from LayoutCoordinates
.Alex Vanyo
09/14/2022, 4:54 PMLayoutCoordinates
?
There’s some tricky subtlety there that you might be running intoArun Joseph
09/14/2022, 7:27 PMbottomSheetOffset
using onPlaced
and pass to the scaffold
bottomSheet = {
Surface(
swipeable
.fillMaxWidth()
.onPlaced {
bottomSheetOffset =
it.positionInParent()
},
shape = sheetShape,
elevation = sheetElevation,
color = sheetBackgroundColor,
contentColor = sheetContentColor,
content = {
scaffoldState.bottomSheetState.sheetContent()
}
)
},
and in scaffold, I calculate padding in pixels for main content as LocalConfiguration.current.screenHeightDp.dp.toPx() - bottomSheetOffset.y
On Pixel 6. when bottom sheet is fully collapsed, I get bottomSheetOffset.y
as 2274.0 and LocalConfiguration.current.screenHeightDp.dp.toPx()
as 2273.25Alex Vanyo
09/14/2022, 7:32 PMpositionInParent
, can you use the parent size directly?
That’s going to be the more directly meaningful number than the size reported by the configuration.Alex Vanyo
09/14/2022, 7:44 PMLocalConfiguration.current.screenHeightDp
can also be different from the actual window size because of insets.Arun Joseph
09/14/2022, 7:52 PMAlex Vanyo
09/14/2022, 7:53 PMit.parentCoordinates.size
?Arun Joseph
09/14/2022, 7:55 PMit.parentLayoutCoordinates?.size?.height?.toFloat()!!
Arun Joseph
09/14/2022, 7:58 PMparentCoordinates
is reporting
it.parentLayoutCoordinates?.size - it.positionInParent().size
Alex Vanyo
09/14/2022, 7:58 PM