hey i’m trying out the constraint layout in jetpac...
# compose
s
hey i’m trying out the constraint layout in jetpack compose. Here are my gradle dependencies:
Copy code
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
And here’s the basic attempt on using ConstraintLayout:
Copy code
@Composable
@Preview
fun PreviewGreeting() {
    ConstraintLayout(constraintSet = ConstraintSet {
        tag("someTag")
    }) {
        Greeting(greeting = "Hello world")
    }
}
I get the error thou saying unresolved reference tag. can smbd please tell me which dependency am I missing?
r
Which version of Compose are you using?
s
1.0.0-alpha02
r
The CL API has changed quite a bit since Developer Preview 2
The API now looks like this:
Copy code
ConstraintLayout(modifier = Modifier.padding(12.dp).fillMaxWidth()) {
        val (decreaseRef, increaseRef, labelRef, colorRef, amountRef) = createRefs()

        SmallButton(
            modifier = Modifier.constrainAs(decreaseRef) {
                start.linkTo(parent.start)
                centerVerticallyTo(parent)
            },
            onClick = { decrease(product) }
        ) {
            Image(Icons.Sharp.Remove)
        }
        // ...
}
s
understood, thanks for the clarification.
r
You don’t use tags anymore but
createRef()
and
createRefs()
👍 1
s
Thank you