Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 봉투 검색 시, 상세내역 보여주기 #166

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading