Last active
March 26, 2021 05:11
-
-
Save pranavjayaraj/af0182873aaf734e013087aa32045ae4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun AnimationLayout() { | |
var state by remember { mutableStateOf(false) } | |
val startColor = Color.Blue | |
val endColor = Color.Green | |
val backgroundColor by animateColorAsState( | |
if (state) endColor else startColor | |
) | |
Column( | |
modifier = Modifier.fillMaxSize().background(backgroundColor), | |
verticalArrangement = Arrangement.Center | |
) { | |
AnimationButtons(onValueChanged = { currState -> | |
state = currState | |
}, state = state) | |
} | |
} | |
@Composable | |
fun AnimationButton(onValueChanged: (Boolean) -> Unit, state: Boolean) { | |
Button( | |
onClick = { onValueChanged(!state) }, | |
modifier = Modifier.height(50.dp).width(100.dp).padding(top = 10.dp), | |
content = { | |
Text(text = "Animate", color = Color.White) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment