Zoltan Demant
03/14/2023, 10:25 AMModifier.alpha(0f)
works, but I can still click elements in the hidden composable (which makes sense). Is there another way?Stylianos Gakis
03/14/2023, 10:45 AMZoltan Demant
03/14/2023, 10:55 AMStylianos Gakis
03/14/2023, 11:01 AMZoltan Demant
03/14/2023, 11:01 AMStylianos Gakis
03/14/2023, 11:02 AMZoltan Demant
03/14/2023, 11:03 AMZoltan Demant
03/14/2023, 11:03 AMKeep {}
then using whatever AnimatedVisibility inside the block.
@Composable
fun Keep(
content: @Composable BoxScope.() -> Unit,
) {
Box(
modifier = Modifier.keepSize(),
content = content,
)
}
private fun Modifier.keepSize(): Modifier {
return composed {
var maxSize by remember {
mutableStateOf(Zero)
}
layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
val width = placeable.width.coerceAtLeast(maxSize.width)
val height = placeable.height.coerceAtLeast(maxSize.height)
maxSize = IntSize(
width = width,
height = height,
)
layout(
width = width,
height = height,
) {
placeable.placeRelative(IntOffset.Zero)
}
}
}
}
Zoltan Demant
03/14/2023, 11:11 AM