diff --git a/core/designsystem/src/main/java/com/susu/core/designsystem/component/container/SusuRecentSearchContainer.kt b/core/designsystem/src/main/java/com/susu/core/designsystem/component/container/SusuRecentSearchContainer.kt index 99c78758..8fb69977 100644 --- a/core/designsystem/src/main/java/com/susu/core/designsystem/component/container/SusuRecentSearchContainer.kt +++ b/core/designsystem/src/main/java/com/susu/core/designsystem/component/container/SusuRecentSearchContainer.kt @@ -3,6 +3,8 @@ package com.susu.core.designsystem.component.container import androidx.annotation.DrawableRes import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -21,9 +23,12 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.susu.core.designsystem.R +import com.susu.core.designsystem.theme.Gray40 import com.susu.core.designsystem.theme.Orange60 import com.susu.core.designsystem.theme.SusuTheme import com.susu.core.ui.extension.susuClickable +import com.susu.core.ui.util.to_yyyy_dot_MM_dot_dd +import java.time.LocalDateTime @Composable fun SusuRecentSearchContainer( @@ -31,14 +36,17 @@ fun SusuRecentSearchContainer( @DrawableRes typeIconId: Int? = null, tint: Color = Orange60, typeIconContentDescription: String? = null, - text: String = "", + name: String = "", + category: String? = null, + startDate: LocalDateTime? = null, + endDate: LocalDateTime? = null, onClickCloseIcon: () -> Unit = {}, onClick: () -> Unit = {}, ) { Row( modifier = modifier - .height(30.dp) .fillMaxWidth() + .height(IntrinsicSize.Min) .susuClickable(onClick = onClick), horizontalArrangement = Arrangement.spacedBy(SusuTheme.spacing.spacing_m), verticalAlignment = Alignment.CenterVertically, @@ -52,13 +60,45 @@ fun SusuRecentSearchContainer( ) } - Text( + Column( modifier = Modifier.weight(1f), - text = text, - style = SusuTheme.typography.title_s, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) + ) { + Text( + modifier = Modifier.weight(1f), + text = name, + style = SusuTheme.typography.title_s, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + + if (category != null && startDate != null && endDate != null) { + Row( + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text( + text = category, + style = SusuTheme.typography.title_xxs, + color = Gray40, + ) + + val (startDateFormatted, endDateFormatted) = (startDate.to_yyyy_dot_MM_dot_dd() to endDate.to_yyyy_dot_MM_dot_dd()) + + if (startDateFormatted == endDateFormatted) { + Text( + text = startDateFormatted, + style = SusuTheme.typography.text_xxs, + color = Gray40, + ) + } else { + Text( + text = "$startDateFormatted-$endDateFormatted", + style = SusuTheme.typography.text_xxs, + color = Gray40, + ) + } + } + } + } if (typeIconId == null) { Image( @@ -77,10 +117,23 @@ fun SusuRecentSearchContainer( @Composable fun SusuRecentSearchContainerPreview() { SusuTheme { - SusuRecentSearchContainer( - text = "나의 결혼식나의 결혼식나의 결혼식나의 결혼식나의 결혼식나의 결혼식", - typeIconId = R.drawable.ic_clear, - typeIconContentDescription = "", - ) + Column( + verticalArrangement = Arrangement.spacedBy(10.dp), + ) { + SusuRecentSearchContainer( + name = "나의 결혼식나의 결혼식나의 결혼식나의 결혼식나의 결혼식나의 결혼식", + typeIconId = R.drawable.ic_clear, + typeIconContentDescription = "", + ) + + SusuRecentSearchContainer( + name = "나의 결혼식나의 결혼식나의 결혼식나의 결혼식나의 결혼식나의 결혼식", + typeIconId = R.drawable.ic_clear, + typeIconContentDescription = "", + category = "결혼식", + startDate = LocalDateTime.now(), + endDate = LocalDateTime.now(), + ) + } } } 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 501fcf10..1b925b2f 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 @@ -18,4 +18,5 @@ data class Envelope( val handedOverAt: LocalDateTime = java.time.LocalDateTime.now().toKotlinLocalDateTime(), val friend: Friend = Friend(), val relationship: Relationship = Relationship(), + val category: Category = Category(), ) diff --git a/feature/community/src/main/java/com/susu/feature/community/votesearch/VoteSearchScreen.kt b/feature/community/src/main/java/com/susu/feature/community/votesearch/VoteSearchScreen.kt index 6d6d0942..d64200a4 100644 --- a/feature/community/src/main/java/com/susu/feature/community/votesearch/VoteSearchScreen.kt +++ b/feature/community/src/main/java/com/susu/feature/community/votesearch/VoteSearchScreen.kt @@ -217,7 +217,7 @@ private fun RecentSearchColumn( ) recentSearchList.forEach { name -> SusuRecentSearchContainer( - text = name, + name = name, onClick = { onClickItem(name) }, onClickCloseIcon = { onClickCloseIcon(name) }, ) @@ -251,7 +251,7 @@ private fun SearchResultColumn( voteList.forEach { vote -> SusuRecentSearchContainer( typeIconId = R.drawable.ic_vote, - text = vote.content, + name = vote.content, onClick = { onClickItem(vote) }, ) } diff --git a/feature/received/src/main/java/com/susu/feature/received/ledgersearch/LedgerSearchScreen.kt b/feature/received/src/main/java/com/susu/feature/received/ledgersearch/LedgerSearchScreen.kt index cf158444..6029e68d 100644 --- a/feature/received/src/main/java/com/susu/feature/received/ledgersearch/LedgerSearchScreen.kt +++ b/feature/received/src/main/java/com/susu/feature/received/ledgersearch/LedgerSearchScreen.kt @@ -41,6 +41,7 @@ import kotlinx.collections.immutable.PersistentList import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.launch +import kotlinx.datetime.toJavaLocalDateTime @OptIn(FlowPreview::class) @Composable @@ -217,7 +218,7 @@ private fun RecentSearchColumn( ) recentSearchList.forEach { name -> SusuRecentSearchContainer( - text = name, + name = name, onClick = { onClickItem(name) }, onClickCloseIcon = { onClickCloseIcon(name) }, ) @@ -251,7 +252,10 @@ private fun SearchResultColumn( ledgerList.forEach { ledger -> SusuRecentSearchContainer( typeIconId = R.drawable.ic_ledger, - text = ledger.title, + name = ledger.title, + category = ledger.category.name, + startDate = ledger.startAt.toJavaLocalDateTime(), + endDate = ledger.endAt.toJavaLocalDateTime(), onClick = { onClickItem(ledger) }, ) } diff --git a/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchContract.kt b/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchContract.kt index f2bd3afb..9b3d82a5 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchContract.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchContract.kt @@ -1,6 +1,6 @@ package com.susu.feature.envelopesearch -import com.susu.core.model.Envelope +import com.susu.core.model.SearchEnvelope import com.susu.core.ui.base.SideEffect import com.susu.core.ui.base.UiState import kotlinx.collections.immutable.PersistentList @@ -9,7 +9,7 @@ import kotlinx.collections.immutable.persistentListOf data class EnvelopeSearchState( val searchKeyword: String = "", val recentSearchKeywordList: PersistentList = persistentListOf(), - val envelopeList: PersistentList = persistentListOf(), + val envelopeList: PersistentList = persistentListOf(), ) : UiState sealed interface EnvelopeSearchEffect : SideEffect { diff --git a/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchScreen.kt b/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchScreen.kt index f553c126..2d0b7f08 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchScreen.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchScreen.kt @@ -36,6 +36,7 @@ import com.susu.core.designsystem.theme.Gray60 import com.susu.core.designsystem.theme.Gray80 import com.susu.core.designsystem.theme.SusuTheme import com.susu.core.model.Envelope +import com.susu.core.model.SearchEnvelope import com.susu.core.ui.extension.collectWithLifecycle import com.susu.feature.sent.R import kotlinx.collections.immutable.PersistentList @@ -43,6 +44,7 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.launch +import kotlinx.datetime.toJavaLocalDateTime @OptIn(FlowPreview::class) @Composable @@ -230,7 +232,7 @@ fun RecentSearchColumn( ) { recentSearchList.forEach { keyword -> SusuRecentSearchContainer( - text = keyword, + name = keyword, onClick = { onClickItem(keyword) }, onClickCloseIcon = { onClickClearIcon(keyword) }, ) @@ -266,18 +268,21 @@ fun EmptySearchEnvelope( @Composable fun SearchEnvelopeColumn( modifier: Modifier = Modifier, - searchResult: PersistentList = persistentListOf(), + searchResult: PersistentList = persistentListOf(), onClickItem: (Envelope) -> Unit = {}, ) { Column( modifier = modifier, verticalArrangement = Arrangement.spacedBy(SusuTheme.spacing.spacing_m), ) { - searchResult.forEach { envelope -> + searchResult.forEach { searchEnvelope -> SusuRecentSearchContainer( typeIconId = R.drawable.ic_envelope, - text = stringResource(R.string.sent_envelope_search_who_envelope, envelope.friend.name), - onClick = { onClickItem(envelope) }, + name = stringResource(R.string.sent_envelope_search_who_envelope, searchEnvelope.friend.name), + category = searchEnvelope.category.name, + startDate = searchEnvelope.envelope.handedOverAt.toJavaLocalDateTime(), + endDate = searchEnvelope.envelope.handedOverAt.toJavaLocalDateTime(), + onClick = { onClickItem(searchEnvelope.envelope) }, ) } } diff --git a/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchViewModel.kt b/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchViewModel.kt index 378cd9f8..a02099ed 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchViewModel.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopesearch/SentEnvelopeSearchViewModel.kt @@ -78,7 +78,7 @@ class SentEnvelopeSearchViewModel @Inject constructor( // 두가지 조건을 검색 완료 시 결과를 통합 표시 if (envelopesByFriend.isSuccess && envelopesByAmount.isSuccess) { val searchedEnvelopes = - envelopesByFriend.getOrDefault(emptyList()).map { it.envelope } + envelopesByAmount.getOrDefault(emptyList()).map { it.envelope } + envelopesByFriend.getOrDefault(emptyList()) + envelopesByAmount.getOrDefault(emptyList()) intent { copy(envelopeList = searchedEnvelopes.toPersistentList()) } } }