orbit-compose
orbit-compose copied to clipboard
Make TextField.error/info slots non-nullable
Currently, the only solution to this I have is to utilize SubcomposeLayout for rendering, that will make impossible intrinsic measuring on textfield.
But maybe it has its worth. When somebody needs intrinsic measuring, it is quite specific usecase that can be handled without this high-level component.
SubcomposeLayout { 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 -> Message.Info(info)
else -> null
}
val messagePlaceable = subcompose("message") {
AnimatedContent(state) { state -> ... }
}.first().measure(constraints)
layout(messagePlaceable.width, messagePlaceable.height) {
messagePlaceable.placeRelative(0, 0)
}
}
Solution to this: https://android-review.googlesource.com/c/platform/frameworks/support/+/2640210