package com.example.what_the_fantasy.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.example.what_the_fantasy.R
import com.example.what_the_fantasy.data.model.Quote
import com.example.what_the_fantasy.ui.theme.gradienBox

@Composable
fun LittleQuoteComponent(quote : Quote){
    Row(
        modifier = Modifier
            .fillMaxWidth(0.9f)
            .clip(RoundedCornerShape(16.dp))
            .background(gradienBox)
    ) {
        val sizeTextInfoQuote = 13
        val lineHeightText = 12
        val sizeTextQuote = 16

        AsyncImage(
            model = quote.imgUrl,
            contentDescription = "Quote picture",
            modifier = Modifier
                .size(130.dp)
                .clip(RoundedCornerShape(16.dp))
        )
        Column(modifier = Modifier.padding(10.dp)) {

            TextInfoQuote(
                quote.content,
                sizeTextQuote,
                lineHeightText
            )

            SpaceHeightComponent(40)

            TextInfoQuote("${stringResource(R.string.dateQuote)} : ${quote.date}", sizeTextInfoQuote, lineHeightText)
            TextInfoQuote("${quote.type} : ${quote.source}", sizeTextInfoQuote, lineHeightText)
            TextInfoQuote("${stringResource(R.string.CharacterQuote)}: ${quote.character}", sizeTextInfoQuote, lineHeightText)
        }
    }
}

@Composable
fun TextInfoQuote(text : String, fontSizeText : Int, lineHeightText : Int){
    Text(text,
        color = Color.White,
        fontSize = fontSizeText.sp,
        maxLines = 1,
        overflow = TextOverflow.Ellipsis,
        lineHeight = lineHeightText.sp)
}