in ui-components/src/commonMain/kotlin/org/jetbrains/kotlinconf/ui/components/NowButton.kt [49:103]
fun NowButton(
time: NowButtonState,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = time != Current,
) {
val active = time != Current
val textColor by animateColorAsState(
if (active) KotlinConfTheme.colors.primaryTextWhiteFixed
else KotlinConfTheme.colors.noteText,
ColorSpringSpec,
)
val background by animateColorAsState(
if (active) KotlinConfTheme.colors.primaryBackground
else KotlinConfTheme.colors.tileBackground,
ColorSpringSpec,
)
Row(
modifier = modifier
.clip(NowButtonShape)
.clickable(onClick = onClick, enabled = enabled)
.background(background)
.width(72.dp)
.heightIn(min = 36.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
Text(
text = stringResource(UiRes.string.now),
style = KotlinConfTheme.typography.text2,
color = textColor,
)
AnimatedContent(
targetState = time,
transitionSpec = {
(fadeIn() + expandHorizontally(clip = false, expandFrom = Alignment.Start)) togetherWith
(fadeOut() + shrinkHorizontally(clip = false, shrinkTowards = Alignment.Start))
},
modifier = Modifier.height(16.dp)
) { targetTime ->
if (targetTime == Current) return@AnimatedContent
Spacer(Modifier.width(2.dp))
Icon(
painter = painterResource(UiRes.drawable.arrow_down_16),
contentDescription = null,
modifier = Modifier
.size(16.dp)
.rotate(if (targetTime == Before) 0f else 180f),
tint = textColor,
)
}
}
}