From a4af27c7cd036ceedc339f7397e4fd66bb6ac2db Mon Sep 17 00:00:00 2001 From: jinukeu Date: Wed, 31 Jan 2024 10:55:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B0=9B=EC=9D=80=20=EB=B4=89=ED=88=AC?= =?UTF-8?q?=20-=20=EB=82=A0=EC=A7=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/model/src/main/java/com/susu/core/model/Envelope.kt | 3 ++- core/ui/src/main/java/com/susu/core/ui/util/Date.kt | 9 +++++++++ .../susu/data/remote/model/response/EnvelopeResponse.kt | 2 +- .../envelopedetail/ReceivedEnvelopeDetailScreen.kt | 8 ++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/model/src/main/java/com/susu/core/model/Envelope.kt b/core/model/src/main/java/com/susu/core/model/Envelope.kt index 37c71fed..501fcf10 100644 --- a/core/model/src/main/java/com/susu/core/model/Envelope.kt +++ b/core/model/src/main/java/com/susu/core/model/Envelope.kt @@ -2,6 +2,7 @@ package com.susu.core.model import androidx.compose.runtime.Stable import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.toKotlinLocalDateTime import kotlinx.serialization.Serializable @Stable @@ -14,7 +15,7 @@ data class Envelope( val gift: String? = null, val memo: String? = null, val hasVisited: Boolean? = null, - val handedOverAt: LocalDateTime? = null, + val handedOverAt: LocalDateTime = java.time.LocalDateTime.now().toKotlinLocalDateTime(), val friend: Friend = Friend(), val relationship: Relationship = Relationship(), ) diff --git a/core/ui/src/main/java/com/susu/core/ui/util/Date.kt b/core/ui/src/main/java/com/susu/core/ui/util/Date.kt index d0e7fa04..a9973a8e 100644 --- a/core/ui/src/main/java/com/susu/core/ui/util/Date.kt +++ b/core/ui/src/main/java/com/susu/core/ui/util/Date.kt @@ -14,6 +14,15 @@ fun LocalDateTime.to_yyyy_dot_MM_dot_dd(): String { return this.format(formatter) } +/** + * 2023년 11월 25일 + */ +@Suppress("detekt:FunctionNaming") +fun LocalDateTime.to_yyyy_korYear_MM_korMonth_dd_korDay(): String { + val formatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일") + return this.format(formatter) +} + fun getSafeLocalDateTime(year: Int, month: Int, day: Int): LocalDateTime = try { LocalDateTime.of(year, month, day, 0, 0) } catch (e: DateTimeException) { diff --git a/data/src/main/java/com/susu/data/remote/model/response/EnvelopeResponse.kt b/data/src/main/java/com/susu/data/remote/model/response/EnvelopeResponse.kt index bfd4c319..7cf0366e 100644 --- a/data/src/main/java/com/susu/data/remote/model/response/EnvelopeResponse.kt +++ b/data/src/main/java/com/susu/data/remote/model/response/EnvelopeResponse.kt @@ -22,7 +22,7 @@ data class EnvelopeInfo( val gift: String? = null, val memo: String? = null, val hasVisited: Boolean? = null, - val handedOverAt: LocalDateTime? = null, + val handedOverAt: LocalDateTime, ) @Serializable diff --git a/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt b/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt index ec4d41ac..7d3c47d1 100644 --- a/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt +++ b/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt @@ -29,8 +29,11 @@ import com.susu.core.ui.DialogToken import com.susu.core.ui.SnackbarToken import com.susu.core.ui.extension.collectWithLifecycle import com.susu.core.ui.extension.toMoneyFormat +import com.susu.core.ui.util.to_yyyy_dot_MM_dot_dd +import com.susu.core.ui.util.to_yyyy_korYear_MM_korMonth_dd_korDay import com.susu.feature.received.R import com.susu.feature.received.envelopedetail.component.DetailItem +import kotlinx.datetime.toJavaLocalDateTime @Composable fun ReceivedEnvelopeDetailRoute( @@ -146,6 +149,11 @@ fun ReceivedEnvelopeDetailScreen( contentText = uiState.envelope.relationship.customRelation ?: uiState.envelope.relationship.relation, isEmptyContent = false, ) + DetailItem( + categoryText = stringResource(com.susu.core.ui.R.string.word_date), + contentText = uiState.envelope.handedOverAt.toJavaLocalDateTime().to_yyyy_korYear_MM_korMonth_dd_korDay(), + isEmptyContent = false, + ) DetailItem( categoryText = stringResource(com.susu.core.ui.R.string.word_is_visited), contentText = if (uiState.envelope.hasVisited == true) stringResource(id = com.susu.core.ui.R.string.word_yes) else stringResource(