package com.lazy.emulate.ui.components

import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.FilterChip
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.lazy.emulate.emulation.ConsoleType

@Composable
fun ConsoleFilter(
    selectedConsole: ConsoleType?,
    onConsoleSelected: (ConsoleType?) -> Unit,
    modifier: Modifier = Modifier
) {
    Row(
        modifier = modifier
            .horizontalScroll(rememberScrollState())
            .padding(horizontal = 16.dp),
        horizontalArrangement = Arrangement.spacedBy(8.dp)
    ) {
        FilterChip(
            selected = selectedConsole == null,
            onClick = { onConsoleSelected(null) },
            label = { Text("All") }
        )
        ConsoleType.entries.forEach { console ->
            FilterChip(
                selected = selectedConsole == console,
                onClick = { onConsoleSelected(console) },
                label = { Text(console.displayName) },
                enabled = console.isImplemented
            )
        }
    }
}
