Skip to content

Instantly share code, notes, and snippets.

@SG-K
Created July 23, 2022 06:17
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 SG-K/567928e55c582cdcdb5cc608e6f3153f to your computer and use it in GitHub Desktop.
Save SG-K/567928e55c582cdcdb5cc608e6f3153f to your computer and use it in GitHub Desktop.
enum class ConTentType{
WORK, PARTY
}
fun ConTentType.getOpposite() = run {
when(this){
ConTentType.PARTY -> ConTentType.WORK
ConTentType.WORK -> ConTentType.PARTY
}
}
fun ConTentType.getDisplayString() = run {
when(this){
ConTentType.PARTY -> "Party"
ConTentType.WORK -> "Work"
}
}
@Composable
fun CrossFaseLayouts(
){
var contenttype by remember{ mutableStateOf(ConTentType.WORK) }
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Crossfade(
targetState = contenttype,
animationSpec = tween(durationMillis = 500)
) { _contenttype->
when(_contenttype){
ConTentType.PARTY -> {
Icon(
imageVector = Icons.Default.Work,
contentDescription = "Work",
modifier = Modifier.size(50.dp)
)
}
ConTentType.WORK -> {
Icon(
imageVector = Icons.Default.Celebration,
contentDescription = "Party",
modifier = Modifier.size(50.dp)
)
}
}
}
Spacer(modifier = Modifier.size(20.dp))
Button(onClick = { contenttype = contenttype.getOpposite() }) {
Text(text = contenttype.getDisplayString() )
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment