Skip to content

Commit

Permalink
#6 [REFACTOR] 초대 코드 입력 네비게이션 로직 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
youjin09222 committed Jan 3, 2025
1 parent 7a1dab4 commit fa7a0f5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,27 @@ import com.sopt.core.designsystem.theme.Gray900
import com.sopt.core.designsystem.theme.NoostakAndroidTheme
import com.sopt.core.designsystem.theme.NoostakTheme
import com.sopt.presentation.R
import com.sopt.presentation.auth.component.OtpInputField
import com.sopt.presentation.auth.component.AuthButton
import com.sopt.presentation.auth.component.OtpInputField

@Composable
fun InputGroupCodeRoute(
navigateToHome: () -> Unit,
navigateToGroup: () -> Unit,
navigateUp: () -> Unit,
inputGroupCodeViewModel: InputGroupCodeViewModel = hiltViewModel(),
) {
LaunchedEffect(inputGroupCodeViewModel.sideEffects) {
inputGroupCodeViewModel.sideEffects.collect { sideEffect ->
when (sideEffect) {
is InputGroupCodeSideEffect.NavigateUp -> navigateUp()
is InputGroupCodeSideEffect.NavigateToHome -> navigateToHome()
is InputGroupCodeSideEffect.NavigateToGroup -> navigateToGroup()
}
}
}

InputGroupCodeScreen(
onBackButtonClick = inputGroupCodeViewModel::navigateUp,
onCheckGroupCodeClick = {
inputGroupCodeViewModel.navigateToSignup()
}
onCheckGroupCodeClick = inputGroupCodeViewModel::navigateToGroup
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.sopt.presentation.auth.signup.inputGroupCode

sealed class InputGroupCodeSideEffect {
data object NavigateUp : InputGroupCodeSideEffect()
data object NavigateToHome : InputGroupCodeSideEffect()
data object NavigateToGroup : InputGroupCodeSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class InputGroupCodeViewModel @Inject constructor() : BaseViewModel<InputGroupCo
emitSideEffect(InputGroupCodeSideEffect.NavigateUp)
}

fun navigateToSignup() {
emitSideEffect(InputGroupCodeSideEffect.NavigateToHome)
fun navigateToGroup() {
emitSideEffect(InputGroupCodeSideEffect.NavigateToGroup)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import com.sopt.core.navigation.Route
import com.sopt.presentation.auth.signup.inputGroupCode.InputGroupCodeRoute
import com.sopt.presentation.group.navigation.navigateGroup
import kotlinx.serialization.Serializable

fun NavController.navigateInputGroupCode(navOptions: NavOptions? = null) {
fun NavController.navigateInputGroupCode(
navOptions: NavOptions? = null
) {
navigate(
route = InputGroupCode,
navOptions = navOptions
)
}

fun NavGraphBuilder.inputGroupCodeNavGraph(
navigateUp: () -> Unit,
navigateHome: () -> Unit
navHostController: NavController
) {
composable<InputGroupCode> {
InputGroupCodeRoute(
navigateUp = navigateUp,
navigateToHome = navigateHome
navigateUp = { navHostController.navigateUp() },
navigateToGroup = { navHostController.navigateGroup() }
)
}
}
Expand Down

0 comments on commit fa7a0f5

Please sign in to comment.