From 5acbc3f6d32eb0b68671120e936a06ddced37bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=ED=98=84=EC=84=9C?= Date: Thu, 11 Jul 2024 15:14:05 +0900 Subject: [PATCH 1/4] :sparkles: :: Create formatDate function --- .../com/goms/design_system/util/formatDate.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt diff --git a/core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt b/core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt new file mode 100644 index 00000000..be9fc9ed --- /dev/null +++ b/core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt @@ -0,0 +1,17 @@ +package com.goms.design_system.util + +import kotlinx.datetime.LocalDate +import java.time.format.TextStyle +import java.util.Locale + +fun String.formatDate(): String { + val date = LocalDate.parse(this) + + val year = date.year + val month = date.monthNumber + val day = date.dayOfMonth + + val dayOfWeek = date.dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.KOREAN) + + return "${year}년 ${month}월 ${day}일 ($dayOfWeek)" +} \ No newline at end of file From 631c9581580daf274fc799621a661f525c4bb7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=ED=98=84=EC=84=9C?= Date: Thu, 11 Jul 2024 15:15:23 +0900 Subject: [PATCH 2/4] :sparkles: :: Change type string -> localdate --- .../java/com/goms/design_system/util/formatDate.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt b/core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt index be9fc9ed..20f58f34 100644 --- a/core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt +++ b/core/design-system/src/main/java/com/goms/design_system/util/formatDate.kt @@ -4,14 +4,12 @@ import kotlinx.datetime.LocalDate import java.time.format.TextStyle import java.util.Locale -fun String.formatDate(): String { - val date = LocalDate.parse(this) +fun LocalDate.formatDate(): String { + val year = this.year + val month = this.monthNumber + val day = this.dayOfMonth - val year = date.year - val month = date.monthNumber - val day = date.dayOfMonth - - val dayOfWeek = date.dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.KOREAN) + val dayOfWeek = this.dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.KOREAN) return "${year}년 ${month}월 ${day}일 ($dayOfWeek)" } \ No newline at end of file From 8672e471d7e8bbc2bab036e82de368e27a1a3557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=ED=98=84=EC=84=9C?= Date: Thu, 11 Jul 2024 15:15:40 +0900 Subject: [PATCH 3/4] :lipstick: :: Add LocalDateText --- .../com/goms/main/component/LocalDateText.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 feature/main/src/main/java/com/goms/main/component/LocalDateText.kt diff --git a/feature/main/src/main/java/com/goms/main/component/LocalDateText.kt b/feature/main/src/main/java/com/goms/main/component/LocalDateText.kt new file mode 100644 index 00000000..8ea5d95a --- /dev/null +++ b/feature/main/src/main/java/com/goms/main/component/LocalDateText.kt @@ -0,0 +1,19 @@ +package com.goms.main.component + +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.text.font.FontWeight +import com.goms.design_system.theme.GomsTheme.colors +import com.goms.design_system.theme.GomsTheme.typography +import com.goms.design_system.util.formatDate +import kotlinx.datetime.LocalDate + +@Composable +internal fun LocalDateText(date: LocalDate) { + Text( + text = date.formatDate(), + style = typography.textSmall, + fontWeight = FontWeight.SemiBold, + color = colors.WHITE + ) +} \ No newline at end of file From 85a1d54b71e39bb923b5f26ed2c22e8ab9347d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=ED=98=84=EC=84=9C?= Date: Thu, 11 Jul 2024 15:16:52 +0900 Subject: [PATCH 4/4] :sparkles: :: Change the date to appear on the late list --- feature/main/src/main/java/com/goms/main/LateListScreen.kt | 1 + .../main/src/main/java/com/goms/main/component/LateList.kt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/feature/main/src/main/java/com/goms/main/LateListScreen.kt b/feature/main/src/main/java/com/goms/main/LateListScreen.kt index 2110d186..219c1622 100644 --- a/feature/main/src/main/java/com/goms/main/LateListScreen.kt +++ b/feature/main/src/main/java/com/goms/main/LateListScreen.kt @@ -106,6 +106,7 @@ private fun LateListScreen( GomsSpacer(size = SpacerSize.ExtraSmall) LateList( getLateListUiState = getLateListUiState, + localDate = selectedLocalDate, onBottomSheetOpenClick = { onDatePickerBottomSheetOpenClick = true }, onErrorToast = onErrorToast ) diff --git a/feature/main/src/main/java/com/goms/main/component/LateList.kt b/feature/main/src/main/java/com/goms/main/component/LateList.kt index 3ba2eb17..a1ce3349 100644 --- a/feature/main/src/main/java/com/goms/main/component/LateList.kt +++ b/feature/main/src/main/java/com/goms/main/component/LateList.kt @@ -38,11 +38,13 @@ import com.goms.main.data.LateData import com.goms.main.data.toData import com.goms.main.viewmodel.uistate.GetLateListUiState import com.goms.ui.toText +import kotlinx.datetime.LocalDate @Composable internal fun LateList( modifier: Modifier = Modifier, getLateListUiState: GetLateListUiState, + localDate: LocalDate, onErrorToast: (throwable: Throwable?, message: Int?) -> Unit, onBottomSheetOpenClick: () -> Unit ) { @@ -55,7 +57,7 @@ internal fun LateList( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { - SearchResultText(modifier = Modifier) + LocalDateText(date = localDate) FilterText(onFilterTextClick = onBottomSheetOpenClick) } when (getLateListUiState) {