Kazemihabib1996
04/12/2020, 8:07 PMColor(0.0, 1.0, 0.0, 1.0, sRGB IEC61966-2.1)
to Color(1.0, 0.0, 0.0, 1.0, sRGB IEC61966-2.1)
@Composable
fun SingleValueAnimationDemo() {
val enabled = state { true }
Clickable({ enabled.value = !enabled.value }) {
val color = animate(if (enabled.value) Color.Green else Color.Red)
Box(Modifier.fillMaxSize(), backgroundColor = color)
}
}
@Composable
fun SingleValueAnimationDemo() {
val enabled = state { true }
Clickable({ enabled.value = !enabled.value }) {
val animColor = animatedColor(if (enabled.value) Color.Green else Color.Red)
animColor.animateTo(if (enabled.value) Color.Red else Color.Green, anim = TweenBuilder<Color>().apply {
duration = 1000
easing = LinearEasing}
)
Log.d("Animation", animColor.value.toString())
Box(Modifier.fillMaxSize(), backgroundColor = animColor.value)
}
}
but I don't understand why the above not worksval anim = remember(clock, converter) {
AnimatedValueModel(target, converter, clock)
}
converter changes each time so the callback reevaluates then we have new anim
then it just do return anim.value
that's are new colorVinay Gaba
04/13/2020, 2:38 AMstate
as well but I’m sure there’s a better way to do this - https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/blob/master/app/src/main/java/com/example/jetpackcompose/animation/Animation2Activity.ktKazemihabib1996
04/13/2020, 7:23 AM