fun Action()

in ui-components/src/commonMain/kotlin/org/jetbrains/kotlinconf/ui/components/Action.kt [28:78]


fun Action(
    label: String,
    icon: DrawableResource,
    size: ActionSize,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    iconRotation: Float = 0f,
) {
    val color by animateColorAsState(
        if (enabled) KotlinConfTheme.colors.primaryText
        else KotlinConfTheme.colors.noteText,
        ColorSpringSpec,
    )
    Row(
        horizontalArrangement = Arrangement.spacedBy(8.dp),
        verticalAlignment = Alignment.CenterVertically,
        modifier = modifier
            .clickable(
                onClick = onClick,
                enabled = enabled,
                interactionSource = null,
                indication = null,
                role = Role.Button,
            )
    ) {
        Text(
            text = label,
            color = color,
            style = when (size) {
                ActionSize.Medium -> KotlinConfTheme.typography.h4
                ActionSize.Large -> KotlinConfTheme.typography.h3
            },
            maxLines = 1,
            modifier = Modifier.weight(1f, fill = false),
        )
        Icon(
            modifier = Modifier
                .size(
                    when (size) {
                        ActionSize.Medium -> 20.dp
                        ActionSize.Large -> 24.dp
                    }
                )
                .rotate(iconRotation),
            painter = painterResource(icon),
            contentDescription = null,
            tint = color,
        )
    }
}