package com.sp365.calendar.components import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import java.time.LocalDate import java.time.format.TextStyle import java.util.Locale @Composable fun DayItem(date: LocalDate, isSelected: Boolean, isToday: Boolean, onClick: () -> Unit) { val backgroundColor = when { isSelected -> Color(0xFF1976D2) isToday -> Color(0xFFBBDEFB) else -> Color.Transparent } val textColor = when { isSelected -> Color.White isToday -> Color(0xFF1976D2) date.month != LocalDate.now().month -> Color.Gray else -> Color.Black } Box( contentAlignment = Alignment.Center, modifier = Modifier .size(48.dp) .background( backgroundColor, shape = CircleShape ) .clickable { onClick() } ) { Column( verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .size(48.dp) .background( backgroundColor, shape = CircleShape ) .clickable { onClick() } .align(Alignment.Center) ) { if (date.dayOfMonth == 1 && !isSelected) { // Hiển thị tên tháng nếu là ngày đầu tiên Text( text = date.month.getDisplayName(TextStyle.SHORT, Locale.getDefault()), fontSize = 12.sp, color = textColor, modifier = Modifier.padding(bottom = 0.dp) ) } // Hiển thị ngày Text( text = date.dayOfMonth.toString(), fontSize = 16.sp, color = textColor, textAlign = TextAlign.Center ) } } }