package com.pixelized.desktop.lwa.ui.screen.campaign.chatbox.messages

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.pixelized.desktop.lwa.ui.theme.lwa
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.stringResource

@Stable
data class CharacteristicTextMessageUio(
    override val id: String,
    override val timestamp: String,
    val label: StringResource,
    val character: String,
    val value: Int,
    val armor: Int?,
) : TextMessage

@Composable
fun CharacteristicTextMessage(
    modifier: Modifier = Modifier,
    message: CharacteristicTextMessageUio,
) {
    Row(
        modifier = modifier,
        horizontalArrangement = Arrangement.spacedBy(space = 3.dp),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Text(
            modifier = Modifier.alignByBaseline(),
            style = MaterialTheme.lwa.typography.chat.timestamp,
            overflow = TextOverflow.Ellipsis,
            maxLines = 1,
            text = message.timestamp,
        )
        Text(
            modifier = Modifier.alignByBaseline(),
            style = MaterialTheme.lwa.typography.chat.timestamp,
            overflow = TextOverflow.Ellipsis,
            maxLines = 1,
            text = ">",
        )
        Text(
            modifier = Modifier.alignByBaseline(),
            style = MaterialTheme.lwa.typography.chat.text,
            overflow = TextOverflow.Ellipsis,
            maxLines = 1,
            text = stringResource(message.label, message.character, message.value, message.armor ?: 0),
        )
    }
}