Presenting the latest mobile development and life of Engineers in LY Corporation and its group companies.
Po has recently built an app fully in Jetpack compose during his 1-month bootcamp training and is here to share his impression. And we've invited Kelvin, who is originally from Hong Kong and been working in LINE Fukuoka for the past 4 years, to share his experience about work and life in Fukuoka.
A series of Animation API have been introduced along with Compose UI
Compare to legacy Android animation API
A Quick Example of one of the animation API in Compose
@Preview
@Composable
fun PreviewOpenCloseButton() {
var uiState: UiState by remember { mutableStateOf(UiState.Closed) }
// delegate rotation value to animateFloatAsState() and depends on uiState for its value
val rotation by animateFloatAsState(
targetValue = when (uiState) {
UiState.Closed -> 0f
UiState.Opened -> 225f // 180 + 45
}
)
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
IconButton(
onClick = {
uiState = uiState.toggle()
}
) {
Icon(
Icons.Rounded.Add,
"switch button",
modifier = Modifier.graphicsLayer {
// assing the rotation to the icon's graphic layer
rotationZ = rotation
}
)
}
Text(text = uiState.label)
}
}
sealed class UiState(val label: String) {
object Closed : UiState("Open")
object Opened : UiState("Close")
fun toggle(): UiState = when(this) {
Closed -> Opened
Opened -> Closed
}
}