package hu.bbara.purefin.ui.common.badge

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Check
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
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.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Composable
fun WatchStateBadge(
    watched: Boolean,
    watchedColor: Color = MaterialTheme.colorScheme.onPrimary,
    watchedBackgroundColor: Color = MaterialTheme.colorScheme.primary,
    size: Int = 24,
    modifier: Modifier = Modifier
) {
    if (!watched) {
        return
    }

    Box(
        contentAlignment = Alignment.Center,
        modifier = modifier
            .border(1.dp, watchedBackgroundColor, CircleShape)
            .background(watchedBackgroundColor, CircleShape)
            .size(size.dp)
            .clip(CircleShape)
    ) {
        Icon(
            imageVector = Icons.Outlined.Check,
            contentDescription = "Check",
            tint = watchedColor,
            modifier = Modifier
                .padding(1.dp)
                .matchParentSize()
        )
    }
}

@Preview
@Composable
private fun WatchStateBadgePreview() {
    Column {
        WatchStateBadge(
            watched = false,
        )
        WatchStateBadge(
            watched = true,
        )
        WatchStateBadge(
            watched = false,
        )
    }
}
