Skip to content

Commit

Permalink
Merge pull request #166 from YAPP-Github/feature/MZ-244-search-detail
Browse files Browse the repository at this point in the history
feat: 봉투 검색 시, 상세내역 보여주기
  • Loading branch information
jinukeu authored Apr 28, 2024
2 parents f9a4acb + eae03ec commit 572f589
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,24 +23,30 @@ 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(
modifier: Modifier = Modifier,
@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,
Expand All @@ -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(
Expand All @@ -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(),
)
}
}
}
1 change: 1 addition & 0 deletions core/model/src/main/java/com/susu/core/model/Envelope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private fun RecentSearchColumn(
)
recentSearchList.forEach { name ->
SusuRecentSearchContainer(
text = name,
name = name,
onClick = { onClickItem(name) },
onClickCloseIcon = { onClickCloseIcon(name) },
)
Expand Down Expand Up @@ -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) },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -217,7 +218,7 @@ private fun RecentSearchColumn(
)
recentSearchList.forEach { name ->
SusuRecentSearchContainer(
text = name,
name = name,
onClick = { onClickItem(name) },
onClickCloseIcon = { onClickCloseIcon(name) },
)
Expand Down Expand Up @@ -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) },
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,7 +9,7 @@ import kotlinx.collections.immutable.persistentListOf
data class EnvelopeSearchState(
val searchKeyword: String = "",
val recentSearchKeywordList: PersistentList<String> = persistentListOf(),
val envelopeList: PersistentList<Envelope> = persistentListOf(),
val envelopeList: PersistentList<SearchEnvelope> = persistentListOf(),
) : UiState

sealed interface EnvelopeSearchEffect : SideEffect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ 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
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
Expand Down Expand Up @@ -230,7 +232,7 @@ fun RecentSearchColumn(
) {
recentSearchList.forEach { keyword ->
SusuRecentSearchContainer(
text = keyword,
name = keyword,
onClick = { onClickItem(keyword) },
onClickCloseIcon = { onClickClearIcon(keyword) },
)
Expand Down Expand Up @@ -266,18 +268,21 @@ fun EmptySearchEnvelope(
@Composable
fun SearchEnvelopeColumn(
modifier: Modifier = Modifier,
searchResult: PersistentList<Envelope> = persistentListOf(),
searchResult: PersistentList<SearchEnvelope> = 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) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) }
}
}
Expand Down

0 comments on commit 572f589

Please sign in to comment.