https://kotlinlang.org logo
#compose
Title
# compose
u

ursus

10/15/2023, 10:36 PM
I was looking to add animations to the color changes in the
OutlinedTextField
by just basically copy pasting the source and
animateColorAsState
everything I see, but one thing made me think, if this is a good idea Why does the
TextFieldColors
return
State<Color>
?
Copy code
val textColor = textStyle.color.takeOrElse {
   colors.textColor(enabled).value
}
Copy code
@Stable
interface TextFieldColors {
    @Composable
    fun textColor(enabled: Boolean): State<Color>
why not simply
Color
?
z

Zach Klippenstein (he/him) [MOD]

10/16/2023, 2:57 AM
Probably so color changes can be consumed without recomposing
👆🏻 1
👆 1
u

ursus

10/16/2023, 1:37 PM
So.. is it a bad idea to add the animateColorAsState? I'm confused
s

Stylianos Gakis

10/16/2023, 1:57 PM
So.. is it a bad idea to add the animateColorAsState
animateColorAsState
also returns
State<Color>
? What do you think is a bad idea here?