https://kotlinlang.org logo
#ios
Title
# ios
c

Carlo De Chellis

05/31/2023, 2:34 PM
Hi to all. I'm experimenting Compose for Ios and I would like to know, is there a way to achieve real time WindowSize just like the android composable like this:
Copy code
@Composable
private fun Activity.rememberWindowSize(): WindowSize {
    val configuration = LocalConfiguration.current
    val windowMetrics = remember(configuration) {
        WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(this)
    }
    val windowDpSize = with(LocalDensity.current) {
        windowMetrics.bounds.toComposeRect().size.toDpSize()
    }
    return WindowSize.basedOnWidth(windowDpSize.width)
}
? Thanks in advance.
a

Andrew Reed

06/01/2023, 8:15 AM
Not sure if there is a compose way, but you should be able to get this from the ios foundation libs. Something like UIDevice would probably give you this info
x

xxfast

06/09/2023, 3:19 PM
This might not be the best way to do this, but I hacked it like this. Source here