package com.example.todokotlin.ui

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.FilterChip
import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

data class PriorityOption(val name: String, val color: Color)

val priorities = listOf(
    PriorityOption("Low", Color(0xFF43A047)),
    PriorityOption("Medium", Color(0xFFFB8C00)),
    PriorityOption("High", Color(0xFFE53935))
)

fun priorityColor(priority: String): Color {
    return priorities.find { it.name == priority }?.color ?: Color(0xFFFB8C00)
}

@Composable
fun PriorityPicker(
    selected: String,
    onSelect: (String) -> Unit,
    modifier: Modifier = Modifier
) {
    Column(modifier = modifier.fillMaxWidth()) {
        Text(
            text = "Priority",
            style = MaterialTheme.typography.labelMedium,
            color = MaterialTheme.colorScheme.onSurfaceVariant
        )
        Row(
            horizontalArrangement = Arrangement.spacedBy(8.dp)
        ) {
            priorities.forEach { priority ->
                FilterChip(
                    selected = selected == priority.name,
                    onClick = { onSelect(priority.name) },
                    label = { Text(priority.name) },
                    colors = FilterChipDefaults.filterChipColors(
                        selectedContainerColor = priority.color.copy(alpha = 0.2f),
                        selectedLabelColor = priority.color
                    )
                )
            }
        }
    }
}
