package cl.homelogic.platform.designsystem.components.atoms

import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import cl.homelogic.platform.designsystem.extensions.clickable
import cl.homelogic.platform.designsystem.foundations.FeedbackType
import cl.homelogic.platform.designsystem.foundations.LocalHapticManager

@Composable
fun SimpleCheckbox(
    checked: Boolean = false,
    onCheckedChange: ((Boolean) -> Unit)? = {},
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
) {
    val haptic = LocalHapticManager.current

    Checkbox(
        checked = checked,
        onCheckedChange = {
            if (it) {
                haptic.performFeedback(FeedbackType.ToggleOn)
            } else {
                haptic.performFeedback(FeedbackType.ToggleOff)
            }
            onCheckedChange?.invoke(it)
        },
        modifier = modifier.clickable(enabled),
        enabled = enabled,
        colors = CheckboxDefaults.colors().copy(
            checkedCheckmarkColor = MaterialTheme.colorScheme.onTertiary,
            checkedBoxColor = MaterialTheme.colorScheme.tertiary,
            checkedBorderColor = MaterialTheme.colorScheme.tertiary,
            uncheckedBorderColor = MaterialTheme.colorScheme.outline,
            disabledBorderColor = MaterialTheme.colorScheme.tertiary,
            disabledCheckedBoxColor = MaterialTheme.colorScheme.tertiary,
        ),
    )
}
