package com.syaroful.agrilinkvocpro.control_feature.core.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.syaroful.agrilinkvocpro.control_feature.R

@Composable
fun DisableControlCard(
    label: String,
    isOn: Boolean,
    iconRes: Int = R.drawable.ic_valve,
    backgroundColor: Color = Color.Gray.copy(alpha = 0.1f),
    iconTint: Color = Color.Gray,
    textColor: Color = Color.Gray,
) {
    Column(
        modifier = Modifier
            .padding(vertical = 8.dp)
            .clip(RoundedCornerShape(12.dp))
            .border(1.dp, backgroundColor.copy(alpha = 0.4f), RoundedCornerShape(12.dp))
            .background(backgroundColor)
            .padding(16.dp)
            .fillMaxWidth()
    ) {
        Row(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceBetween,
            modifier = Modifier.fillMaxWidth()
        ) {
            Box(
                modifier = Modifier
                    .size(32.dp)
                    .background(
                        color = iconTint.copy(alpha = 0.1f),
                        shape = CircleShape
                    ),
                contentAlignment = Alignment.Center
            ) {
                Icon(
                    painter = painterResource(id = iconRes),
                    contentDescription = null,
                    tint = iconTint,
                    modifier = Modifier.size(20.dp)
                )
            }
//            Switch(
//                checked = isOn,
//                onCheckedChange = onToggle,
//                colors = SwitchDefaults.colors(
//                    checkedThumbColor = Color.LightGray,
//                    uncheckedThumbColor = Color.LightGray,
//                    uncheckedBorderColor = trackColor,
//                    checkedTrackColor = backgroundColor,
//                    checkedBorderColor = trackColor,
//                    uncheckedTrackColor = trackColor
//                )
//            )
        }

        Spacer(modifier = Modifier.height(16.dp))

        Text(label, color = textColor)

        Text(
            if (isOn) "On" else "Off",
            color = Color.Gray,
            fontWeight = FontWeight.Bold
        )
    }
}

@Preview
@Composable
fun DisableControlCardPreview() {
    DisableControlCard(
        label = "Water Valve",
        isOn = false,
    )
}

