package com.pixelized.headache.ui.page.summary.monthly.item

import android.annotation.SuppressLint
import android.icu.text.SimpleDateFormat
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import java.util.Date
import java.util.Locale

@Stable
data class MonthSummaryTitleUio(
    val date: Date,
)

@Stable
object MonthSummaryTitleDefault {

    @Stable
    val padding: PaddingValues = PaddingValues(start = 16.dp, top = 16.dp, end = 16.dp,)

    @SuppressLint("ConstantLocale")
    @Stable
    val formatter = SimpleDateFormat("yyyy", Locale.getDefault())
}

@Composable
fun MonthSummaryTitle(
    modifier: Modifier = Modifier,
    padding: PaddingValues = MonthSummaryTitleDefault.padding,
    formatter: SimpleDateFormat = MonthSummaryTitleDefault.formatter,
    item: MonthSummaryTitleUio,
) {
    Text(
        modifier = Modifier
            .padding(paddingValues = padding)
            .then(other = modifier),
        style = MaterialTheme.typography.displaySmall,
        text = formatter.format(item.date)
    )
}