Hi, is LocalConfiguration available in compose mul...
# compose
s
Hi, is LocalConfiguration available in compose multiplatform? if not, what is the correct way to get screen width and height in common module that will work for all platforms?
p
Not sure about the correct way. What I do is I have a root composable that fills max size. Then, get the width/height when onSizeChange(), (there are a couple of ways to get the dimensions, onGlobalPositioned, onPlaced ...). Then set that value to a CompositionLocal provider. The window size class API is not available yet in multiplatform, afaik.
s
You mean that will be kind of platform specific but not in common module, right?
p
No, those are Modifier extensions in pure compose. Common to all platforms.
s
ok thnx
I have used BoxWithConstraints as root, actually main point is that we need to use SubcomposeLayout if we want to use the size values calculated during the measurement as parameters to pass down for the composition of the children, it will not work using any other normal composable as root.
and in BoxWithConstraints, we don need to use onSizeChanged and onGlobalPositioned etc., we can directly use constraints
p
That's right.
397 Views