https://kotlinlang.org logo
z

Zoltan Demant

07/06/2023, 3:32 AM
BasicText now has a
ColorProducer
parameter; I think I get the gist of it, but are there any usage examples out there for a curious mind?
b

Ben Trengrove [G]

07/06/2023, 4:14 AM
It's a way to move the color change out of composition so it doesn't cause recomposition when changing. Its as simple as
Copy code
val color by animateColorAsState(if (enabled) Color.Green else Color.Red)

BasicText(text = "Hello", color = { color })
🙌 1
z

Zoltan Demant

07/06/2023, 4:17 AM
Thanks Ben! 💪🏽
s

shikasd

07/06/2023, 8:38 AM
ColorProducer
is basically
() -> Color
which doesn't box the color value
🙌 1
96 Views