package com.pixelized.desktop.lwa.ui.screen.admin.action

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.minimumInteractiveComponentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.pixelized.desktop.lwa.ui.theme.lwa
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.painterResource


@Stable
object GmActionDefault {
    val padding = PaddingValues(horizontal = 16.dp)
}

@Composable
fun GMAction(
    modifier: Modifier = Modifier,
    paddingValues: PaddingValues = GmActionDefault.padding,
    icon: DrawableResource,
    label: String,
    onAction: () -> Unit,
) {
    Row(
        modifier = Modifier
            .clip(shape = MaterialTheme.lwa.shapes.gameMaster)
            .clickable(onClick = onAction)
            .background(color = MaterialTheme.lwa.colorScheme.elevated.base1dp)
            .minimumInteractiveComponentSize()
            .padding(paddingValues = paddingValues)
            .then(other = modifier),
        horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Icon(
            painter = painterResource(icon),
            tint = MaterialTheme.lwa.colorScheme.base.primary,
            contentDescription = null,
        )
        Text(
            style = MaterialTheme.lwa.typography.system.body1,
            text = label,
        )
    }
}