Skip to content

Commit

Permalink
feat: 보낸 봉투 검색 결과 클릭시 상세화면으로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsooplus committed Feb 5, 2024
1 parent 27be78c commit df5d697
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ data class EnvelopeSearchState(

sealed interface EnvelopeSearchEffect : SideEffect {
data object PopBackStack : EnvelopeSearchEffect
data class NavigateEnvelopDetail(val envelope: Envelope) : EnvelopeSearchEffect
data class NavigateEnvelopDetail(val envelopeId: Long) : EnvelopeSearchEffect
data object FocusClear : EnvelopeSearchEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ import kotlinx.coroutines.flow.debounce
@Composable
fun SentEnvelopeSearchRoute(
viewModel: EnvelopeSearchViewModel = hiltViewModel(),
navigateSentEnvelopeDetail: (Long) -> Unit,
popBackStack: () -> Unit,
) {
val uiState = viewModel.uiState.collectAsStateWithLifecycle().value

viewModel.sideEffect.collectWithLifecycle { sideEffect ->
when (sideEffect) {
EnvelopeSearchEffect.FocusClear -> {}
is EnvelopeSearchEffect.NavigateEnvelopDetail -> {}
is EnvelopeSearchEffect.NavigateEnvelopDetail -> navigateSentEnvelopeDetail(sideEffect.envelopeId)
EnvelopeSearchEffect.PopBackStack -> popBackStack()
}
}
Expand All @@ -70,6 +71,7 @@ fun SentEnvelopeSearchRoute(
},
onDeleteRecentSearch = viewModel::deleteEnvelopeRecentSearch,
popBackStack = popBackStack,
onClickEnvelope = { viewModel.navigateToEnvelopeDetail(it.id) },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class EnvelopeSearchViewModel @Inject constructor(
private val searchSentEnvelopeListUseCase: SearchSentEnvelopeListUseCase,
) : BaseViewModel<EnvelopeSearchState, EnvelopeSearchEffect>(EnvelopeSearchState()) {

fun navigateToEnvelopeDetail(id: Long) {
postSideEffect(EnvelopeSearchEffect.NavigateEnvelopDetail(id))
}

fun getEnvelopeRecentSearchList() {
viewModelScope.launch {
getEnvelopeRecentSearchUserCase().onSuccess(::updateRecentSearchList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ fun SentRoute(
onClickHistory = { friendId ->
viewModel.getEnvelopesHistoryList(friendId)
},
onClickHistoryShowAll = viewModel::navigateSentEnvelope,
onClickAddEnvelope = viewModel::navigateSentAdd,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fun NavGraphBuilder.sentNavGraph(

composable(route = SentRoute.sentEnvelopeSearchRoute) {
SentEnvelopeSearchRoute(
navigateSentEnvelopeDetail = navigateSentEnvelopeDetail,
popBackStack = popBackStack,
)
}
Expand Down

0 comments on commit df5d697

Please sign in to comment.