Skip to content

Commit

Permalink
feat: 받은 봉투 - 날짜 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jinukeu committed Jan 31, 2024
1 parent 36f7ccf commit a4af27c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/model/src/main/java/com/susu/core/model/Envelope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),
)
9 changes: 9 additions & 0 deletions core/ui/src/main/java/com/susu/core/ui/util/Date.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit a4af27c

Please sign in to comment.