Jan Skrasek
04/19/2024, 9:34 PM@Composable () -> Unit
blocks and I need to animate (ideally using AnimatedContent or something similarly trivial) from one to another based on the fact it the first lambda "renders" anything.
I hoped that new GraphicsLayer
api would help here, yet I cannot come up with anything reasonable.
The only implementation I was able to do was one based on subcomposition (in thread) or using nullable blocks, but that's the thing I want to rewrite.
Any other ideas?Jan Skrasek
04/19/2024, 9:34 PMSubcomposeLayout { constraints ->
val errorPlaceable = subcompose("error") {
error()
}.firstOrNull()?.measure(constraints)
val infoPlaceable = subcompose("info") {
info()
}.firstOrNull()?.measure(constraints)
val hasError = errorPlaceable != null && errorPlaceable.height > 0
val hasInfo = infoPlaceable != null && infoPlaceable.height > 0
val state = when {
hasError -> Message.Error(error)
hasInfo -> <http://Message.Info|Message.Info>(info)
else -> null
}
val messagePlaceable = subcompose("message") {
AnimatedContent(state) { state -> ... }
}.first().measure(constraints)
layout(messagePlaceable.width, messagePlaceable.height) {
messagePlaceable.placeRelative(0, 0)
}
}
Ben Trengrove [G]
04/19/2024, 10:13 PMJan Skrasek
04/19/2024, 10:43 PM