From 57739438b771fd1d9a15791555c876e297a10625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8E=E1=85=A1=E1=84=8C=E1=85=B5=E1=84=8B=E1=85=AF?= =?UTF-8?q?=E1=86=AB?= Date: Thu, 25 Nov 2021 15:07:02 +0900 Subject: [PATCH] =?UTF-8?q?Issue=20#263=20feat:=20=EB=85=84=EB=8F=84=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=20=ED=8C=A8=EB=94=A9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../composeView/CalendarLazyColumn.kt | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/library/src/main/java/com/drunkenboys/ckscalendar/yearcalendar/composeView/CalendarLazyColumn.kt b/library/src/main/java/com/drunkenboys/ckscalendar/yearcalendar/composeView/CalendarLazyColumn.kt index cf64e3d0..49d049b6 100644 --- a/library/src/main/java/com/drunkenboys/ckscalendar/yearcalendar/composeView/CalendarLazyColumn.kt +++ b/library/src/main/java/com/drunkenboys/ckscalendar/yearcalendar/composeView/CalendarLazyColumn.kt @@ -1,24 +1,22 @@ package com.drunkenboys.ckscalendar.yearcalendar.composeView import android.view.Gravity -import android.view.RoundedCorner import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.shape.CutCornerShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.layout import androidx.compose.ui.layout.layoutId import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -48,24 +46,28 @@ fun CalendarLazyColumn( when (clickedDay) { - day.date -> { Modifier.layoutId(day.date.toString()) - .border( - border = BorderStroke(width = 2.dp, color = Color(viewModel.design.value.selectedFrameColor)), - shape = RoundedCornerShape(6.dp) - ) - .clickable (onClick = { - onDaySecondClickListener?.onDayClick(day.date, 0) - }) + day.date -> { + Modifier + .layoutId(day.date.toString()) + .border( + border = BorderStroke(width = 2.dp, color = Color(viewModel.design.value.selectedFrameColor)), + shape = RoundedCornerShape(6.dp) + ) + .clickable(onClick = { + onDaySecondClickListener?.onDayClick(day.date, 0) + }) } - else -> { Modifier.layoutId(day.date.toString()) - .border( - border = BorderStroke(width = 0.1f.dp, color = Color(viewModel.design.value.weekDayTextColor).copy(alpha = 0.1f)) - ) - .clickable(onClick = { - onDayClickListener?.onDayClick(day.date, 0) - viewModel.clickDay(day) - }) + else -> { + Modifier + .layoutId(day.date.toString()) + .border( + border = BorderStroke(width = 0.1f.dp, color = Color(viewModel.design.value.weekDayTextColor).copy(alpha = 0.1f)) + ) + .clickable(onClick = { + onDayClickListener?.onDayClick(day.date, 0) + viewModel.clickDay(day) + }) } } } @@ -76,7 +78,9 @@ fun CalendarLazyColumn( // RecyclerView와 유사 LazyColumn( state = listState, - modifier = Modifier.background(color = MaterialTheme.colors.background).fillMaxHeight() + modifier = Modifier + .background(color = MaterialTheme.colors.background) + .fillMaxHeight() ) { items(calendar, key = { slice -> slice.startDate }) { slice -> @@ -84,10 +88,13 @@ fun CalendarLazyColumn( // 해가 갱신될 때마다 상단에 연표시 if (firstOfYear in slice.startDate..slice.endDate) { + Text( text = "${firstOfYear.year}년", color = MaterialTheme.colors.primary, - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .padding(top = 16.dp, bottom = 16.dp), textAlign = TextAlign.Center ) } @@ -133,7 +140,7 @@ fun PreviewCalendar() { endDate = LocalDate.now().plusDays(30L) )) - viewModel.setCalendarSetList(newSlice) +// viewModel.setCalendarSetList(newSlice) CustomTheme(design = viewModel.design.value) { CalendarLazyColumn(