package com.syaroful.agrilinkvocpro.core.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.syaroful.agrilinkvocpro.R
import com.syaroful.agrilinkvocpro.presentation.theme.MainGreen

@Composable
fun MenuItemButton(
    label: String,
    icon: Painter,
    onClick: () -> Unit = {}
) {
    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        OutlinedButton(
            onClick = { onClick() },
            modifier = Modifier.size(48.dp),
            shape = CircleShape,
            border = BorderStroke(0.dp, Color.Transparent),
            contentPadding = PaddingValues(0.dp),
            colors = ButtonDefaults.outlinedButtonColors(containerColor = MainGreen.copy(alpha = 0.1f))
        ) {
            Icon(
                painter = icon,
                modifier = Modifier.size(28.dp),
                contentDescription = "icon",
                tint = MainGreen,
            )
        }
        Spacer(modifier = Modifier.height(16.dp))
        Text(
            label,
            textAlign = TextAlign.Center,
            fontSize = 12.sp,
            lineHeight = 12.sp
        )
    }
}


@Preview
@Composable
fun MenuItemPreview() {
    MenuItemButton(
        label = "Kontrol\nAktuator",
        icon = painterResource(id = R.drawable.control_actuator_icon)
    )
}