Skip to content

Commit

Permalink
[FEATURE]#74 : Navigator 전역 주입되도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Aug 4, 2024
1 parent 5ce4433 commit 5d5decd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.bff.wespot.entire.R
import com.bff.wespot.entire.screen.state.EntireAction
import com.bff.wespot.entire.screen.state.EntireSideEffect
import com.bff.wespot.entire.screen.viewmodel.EntireViewModel
import com.bff.wespot.navigation.Navigator
import com.ramcosta.composedestinations.annotation.Destination
import org.orbitmvi.orbit.compose.collectSideEffect

Expand All @@ -40,6 +41,7 @@ interface AccountSettingNavigator {
@Composable
fun AccountSettingScreen(
navigator: AccountSettingNavigator,
activityNavigator: Navigator,
viewModel: EntireViewModel = hiltViewModel(),
) {
val context = LocalContext.current
Expand All @@ -50,7 +52,7 @@ fun AccountSettingScreen(
viewModel.collectSideEffect {
when (it) {
is EntireSideEffect.NavigateToAuth -> {
val intent = it.navigator.navigateToAuth(context)
val intent = activityNavigator.navigateToAuth(context)
context.startActivity(intent)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.bff.wespot.entire.R
import com.bff.wespot.entire.screen.state.EntireAction
import com.bff.wespot.entire.screen.state.EntireSideEffect
import com.bff.wespot.entire.screen.viewmodel.EntireViewModel
import com.bff.wespot.navigation.Navigator
import com.bff.wespot.navigation.util.EXTRA_TOAST_MESSAGE
import com.bff.wespot.ui.WSBottomSheet
import com.ramcosta.composedestinations.annotation.Destination
Expand All @@ -54,6 +55,7 @@ interface RevokeConfirmNavigator {
@Composable
fun RevokeConfirmScreen(
navigator: RevokeConfirmNavigator,
activityNavigator: Navigator,
viewModel: EntireViewModel = hiltViewModel(),
) {
val context = LocalContext.current
Expand All @@ -66,7 +68,7 @@ fun RevokeConfirmScreen(
viewModel.collectSideEffect {
when (it) {
is EntireSideEffect.NavigateToAuth -> {
val intent = it.navigator.navigateToAuth(context)
val intent = activityNavigator.navigateToAuth(context)
intent.putExtra(EXTRA_TOAST_MESSAGE, context.getString(R.string.revoke_done))
context.startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.bff.wespot.entire.screen.state

import com.bff.wespot.navigation.Navigator

sealed class EntireSideEffect {
data class NavigateToAuth(val navigator: Navigator) : EntireSideEffect()
data object NavigateToAuth : EntireSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.bff.wespot.domain.repository.user.UserRepository
import com.bff.wespot.entire.screen.state.EntireAction
import com.bff.wespot.entire.screen.state.EntireSideEffect
import com.bff.wespot.entire.screen.state.EntireUiState
import com.bff.wespot.navigation.Navigator
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import org.orbitmvi.orbit.ContainerHost
Expand All @@ -26,7 +25,6 @@ class EntireViewModel @Inject constructor(
private val authRepository: AuthRepository,
private val messageRepository: MessageRepository,
private val messageStorageRepository: MessageStorageRepository,
private val navigator: Navigator,
) : ViewModel(), ContainerHost<EntireUiState, EntireSideEffect> {
override val container = container<EntireUiState, EntireSideEffect>(EntireUiState())

Expand Down Expand Up @@ -59,7 +57,7 @@ class EntireViewModel @Inject constructor(
// TODO Token 삭제
authRepository.revoke(state.revokeReasonList)
.onSuccess {
postSideEffect(EntireSideEffect.NavigateToAuth(navigator))
postSideEffect(EntireSideEffect.NavigateToAuth)
}
.onFailure {
Timber.e(it)
Expand All @@ -70,7 +68,7 @@ class EntireViewModel @Inject constructor(
private fun signOut() = intent {
viewModelScope.launch {
// TODO Token 삭제
postSideEffect(EntireSideEffect.NavigateToAuth(navigator))
postSideEffect(EntireSideEffect.NavigateToAuth)
}
}

Expand Down

0 comments on commit 5d5decd

Please sign in to comment.