-
-
Save SG-K/567928e55c582cdcdb5cc608e6f3153f 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
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