I'm using a Composable which take a content @Composable
in parameter, and it seems that with the final version of ConstraintLayout
, there is no update.
Here is the code
@Composable
fun Example(
modifier : Modifier = Modifier,
content : @Composable () -> Unit
) {
ConstraintLayout(modifier = modifier
.fillMaxSize()
.background(color = Color.Blue)
) {
val (title, someContent) = createRefs()
Text(text = "a text", modifier = Modifier.constrainAs(title) {
top.linkTo(parent.top)
height = Dimension.wrapContent
width = Dimension.wrapContent
})
Box(modifier = Modifier
.constrainAs(someContent) {
width = Dimension.fillToConstraints
linkTo(start = parent.start, end = parent.end)
linkTo(top = parent.top, bottom = parent.bottom, bias = 1.0f)
height = Dimension.preferredWrapContent
}
.background(color = Color.Yellow)) {
content()
}
}
}
The Box
height is initialized with the fist element received by the composable and does not change anymore.
For example, I send to this composable a Column
with [Button
+ result of a Webservice
]. The button is displayed at startup, and then after some times I received the result of the API, it does not recompose correctly, the size of the Box
stays wrapcontent with the button only!
Am I doing something wrong ?
Moreover, it seems that the behaviour in a compose MotionLayout
is the same (no update)