Skip to content

Commit

Permalink
Issue boostcampwm-2021#263 feat: 년도 표시 패딩 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Cha-Ji committed Nov 25, 2021
1 parent d86461f commit 5773943
Showing 1 changed file with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
})
}
}
}
Expand All @@ -76,18 +78,23 @@ 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 ->

val firstOfYear = LocalDate.of(slice.endDate.year, 1, 1)

// 해가 갱신될 때마다 상단에 연표시
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
)
}
Expand Down Expand Up @@ -133,7 +140,7 @@ fun PreviewCalendar() {
endDate = LocalDate.now().plusDays(30L)
))

viewModel.setCalendarSetList(newSlice)
// viewModel.setCalendarSetList(newSlice)

CustomTheme(design = viewModel.design.value) {
CalendarLazyColumn(
Expand Down

0 comments on commit 5773943

Please sign in to comment.