help composers, why this is not animating ? I put ...
# compose
s
help composers, why this is not animating ? I put log statement which gets printed with the changing float values (1f to 1.5f)
s
Seems .scale(scale.value) will helps.
s
Was my first approach, did not work
g
It doesn’t solve your issue but in this case you should use the lambda version to avoid recomposition
.graphicsLayer { scaleX = scale.value; scaleX = scale.value }
s
thanks for this tip
b
I think it's not animating because you don't give it content to animate :
Copy code
@Composable
fun FrameBox(modifier: Modifier = Modifier, content: @Composable BoxScope.() -> Unit) {
    val scale by rememberInfiniteTransition().animateFloat(
        initialValue = 1f,
        targetValue = 1.5f,
        animationSpec = infiniteRepeatable(
            animation = tween(1000, easing = LinearEasing),
            repeatMode = RepeatMode.Reverse
        )
    )
    
    Box(
        modifier
            .border(width = 2.dp, color = MaterialTheme.colors.secondary)
            .graphicsLayer {
                scaleX = scale
                scaleY = scale
            },
        content = content)
}
s
thanks, I will try this out.