Skip to content

Instantly share code, notes, and snippets.

@zivkesten
Last active February 6, 2022 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zivkesten/86db567601475c9974498ddd2e55b857 to your computer and use it in GitHub Desktop.
Save zivkesten/86db567601475c9974498ddd2e55b857 to your computer and use it in GitHub Desktop.
PinkButton composable
@Composable
fun PinkButton(
text: String,
enabled: Boolean,
onClick: () -> Unit
) {
val animatedColor = animateColorAsState(
if (enabled) Color.Pink else Color.Grey
)
val buttonColors = ButtonDefaults.buttonColors(
backgroundColor = animatedColor.value
)
Button(
enabled = enabled,
colors = buttonColors,
onClick = { onClick() },
shape = RoundedCornerShape(10.dp),
modifier = Modifier
.padding(start = 15.dp, end = 15.dp, bottom = 15.dp)
.fillMaxWidth()
.height(58.dp)
.graphicsLayer(
translationY = animateFloatAsState(if (enabled) 0f else 10f).value)
) {
Text(...)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment