ursus
09/02/2023, 3:47 AManimateColorAsState
But I don't want to do that, as I already specifcy my button colors via the ButtonDefault
which sets the color, so I don't want to fight it
Composable
fun AnimatedButton(enabled: Boolean, onClick: () -> Unit) {
val backgroundColor by animateColorAsState(
if (enabled) Color.Green else Color.Gray
)
Button(
onClick = onClick,
enabled = enabled,
colors = ButtonDefaults.buttonColors(
backgroundColor = backgroundColor
)
) {
Text("My Button")
}
}
This is obviously wrong as when the enabled is false, then the color wants to be gray. However that is backgroundColor
but nits disabled so the color changes to whatever default disabled it
Ofcourse I can set backgroundColor
and disabledColor
to the same value
but thats kinda stupid