eneim
05/20/2026, 11:56 AMcalculateOcclusions information. It seems to work well on Android but iOS always return an empty list. Is there any information about this? Thanks a lot.Hristijan
05/20/2026, 12:36 PMeneim
05/20/2026, 12:42 PM@Composable
@Preview
fun App() {
MaterialTheme {
var showContent by remember { mutableStateOf(false) }
Column(
modifier = Modifier
.background(MaterialTheme.colorScheme.primaryContainer)
.safeContentPadding()
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Button(onClick = { showContent = !showContent }) {
Text("Click me!")
}
AnimatedVisibility(showContent) {
var occlusions by remember { mutableStateOf<List<IntRect>>(emptyList()) }
var bounds by remember { mutableStateOf<IntRect?>(null) }
Box(
modifier = Modifier.fillMaxSize()
) {
Column(
modifier = Modifier.fillMaxWidth().align(Alignment.Center)
.onLayoutRectChanged(0, 0) {
occlusions = it.calculateOcclusions()
bounds = it.boundsInScreen
println(
"""
---
${it.calculateOcclusions()},
${it.boundsInScreen},
${it.width} x ${it.height}
${it.fractionVisibleInWindow()}
---
""".trimIndent()
)
},
horizontalAlignment = Alignment.CenterHorizontally,
) {
Image(painterResource(Res.drawable.compose_multiplatform), null)
Text("Occlusions: $occlusions\nBounds: $bounds")
}
Box(
modifier = Modifier.size(64.dp).background(Color.Red).align(Alignment.Center),
)
}
}
}
}
}
I place a Red box above the default view which should report at least an occlusion element if it works as expected.
I attach the screen record to demonstrate it.