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 lwacharactersheet.composeapp.generated.resources.Res
import lwacharactersheet.composeapp.generated.resources.chat__diminished_change
import org.jetbrains.compose.resources.stringResource

@Stable
data class DiminishedTextMessageUio(
    override val id: String,
    override val timestamp: String,
    val character: String,
    val diminished: Int,
) : TextMessage

@Composable
fun DiminishedTextMessage(
    modifier: Modifier = Modifier,
    message: DiminishedTextMessageUio,
) {
    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(
                Res.string.chat__diminished_change,
                message.character,
                message.diminished
            ),
        )
    }
}