package com.sp365.calendar.components import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.sp365.calendar.utils.* import java.time.LocalDate @Composable fun MonthCalendar( currentDate: LocalDate, onDateSelected: (LocalDate) -> Unit ) { val currentMonthIndex = remember { calculateMonthsFromStart(currentDate) } val lazyListState = rememberLazyListState(initialFirstVisibleItemIndex = currentMonthIndex + 1100) LazyColumn( state = lazyListState, modifier = Modifier .fillMaxWidth() .height(300.dp) // Giới hạn chiều cao của lịch tháng ở 200dp .background(Color.White) .padding(8.dp) ) { items(Int.MAX_VALUE) { index -> val startOfMonth = LocalDate.now().withDayOfMonth(1).plusMonths(index.toLong() - 1100) MonthView( startOfMonth = startOfMonth, currentDate = currentDate, onDateSelected = onDateSelected ) } } }