Hi to all. I'm experimenting Compose for Ios and I...
# compose-ios
c
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.
o
LocalUIViewController - is a Composition Local you can use to access the UIViewController. Then you can get UIView from it and its frame.
c
Great!!! Thank you
s
But when I'm trying to access in iosMain in shared module, then using UIViewController.current.view.frame that frame has only variable: align and size So How can I get height and width through that? e.x. : it doesn't work like width and height
Copy code
@Composable
actual fun getScreenDimensions(): Pair<Int, Int> {
    val config = LocalUIViewController.current.view().frame
    return Pair(config.size, config.align)
}
b
Did you ever figure this out? I need screen dimensions as well for the iOS side