package com.craigvg.lichun_android.ui.components.buttons import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.tween import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.collectIsPressedAsState import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.OutlinedButton import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalView import androidx.compose.ui.unit.dp import com.craigvg.lichun_android.ui.theme.AppColors import com.craigvg.lichun_android.ui.theme.AppSpacing import com.craigvg.lichun_android.ui.theme.AppTypography import com.craigvg.lichun_android.utils.HapticFeedback @Composable fun SecondaryButton( text: String, onClick: () -> Unit, modifier: Modifier = Modifier, color: Color = AppColors.primary, enabled: Boolean = true ) { val view = LocalView.current val interactionSource = remember { MutableInteractionSource() } val isPressed by interactionSource.collectIsPressedAsState() val borderAlpha by animateColorAsState( targetValue = if (isPressed) color.copy(alpha = 0.7f) else color.copy(alpha = 0.4f), animationSpec = tween(200), label = "borderColor" ) val bgAlpha by animateColorAsState( targetValue = if (isPressed) color.copy(alpha = 0.15f) else color.copy(alpha = 0.08f), animationSpec = tween(200), label = "bgColor" ) val shadowElevation by animateDpAsState( targetValue = if (isPressed) 6.dp else 0.dp, animationSpec = tween(200), label = "shadow" ) OutlinedButton( onClick = { HapticFeedback.light(view) onClick() }, modifier = modifier .fillMaxWidth() .height(AppSpacing.buttonHeight - 4.dp) .shadow( elevation = shadowElevation, shape = RoundedCornerShape(AppSpacing.pillCornerRadius - 2.dp), ambientColor = color.copy(alpha = 0.4f), spotColor = color.copy(alpha = 0.4f) ), enabled = enabled, shape = RoundedCornerShape(AppSpacing.pillCornerRadius - 2.dp), border = BorderStroke( width = if (isPressed) 3.dp else 2.dp, color = if (enabled) borderAlpha else AppColors.disabledText.copy(alpha = 0.3f) ), colors = ButtonDefaults.outlinedButtonColors( containerColor = if (enabled) bgAlpha else Color.Transparent, contentColor = if (enabled) color else AppColors.disabledText, disabledContainerColor = Color.Transparent, disabledContentColor = AppColors.disabledText ), interactionSource = interactionSource ) { Text(text = text, style = AppTypography.headline, maxLines = 1) } }