I’m curious to hear about some use cases: do you a...
# compose-android
a
I’m curious to hear about some use cases: do you all use `LocalConfiguration.current.screenWidthDp`/`screenHeightDp` in your projects? And if so, for what sort of purposes?
p
Didn't know it existed. I am taking those from my root composable.onSizeChanged. It is setup to fillMaxSize
c
Didn't know it existed either lol. I've seen some projects im on where we have a root BoxWithConstraints though for figuring out width. 😱 wish there was a doc I could point to that was like "please dont do this"
p
I was using before the WindowSizeClass in
androidx.compose.material3.windowsizeclass
but stop using it, didn’t quite like the API design. It is not multiplatform either, that I remember.
My purpose is basically for adaptive design, detecting large/medium/small. But I also use it to position/sizing some elements in the screen based on percentage/ratio to afore mention dimensions.
y
For a round screen, understanding the circle size so can position just enough away from the edge to not get clipped on the sides.
a
We were using it for some offset calculations before but soon realised issues with
systembarsPadding/
navigationBarsPadding
and issues with comparing to pixels, then stopped using it. The main use case was getting parent size while in a bottom panel.
s
We use it to get a WindowSizeClass instance inside our @Previews with this
Copy code
@Composable
fun WindowSizeClass.Companion.calculateForPreview(): WindowSizeClass {
  val configuration = LocalConfiguration.current
  return calculateFromSize(DpSize(configuration.screenWidthDp.dp, configuration.screenHeightDp.dp))
}
a
@Pablichjenkov you didn’t like the
windowsizeclass
API, or the
LocalConfiguration.current
API?
p
The WindowSizeClass I feel like it is missing information about aspect ratio which is important sometimes.