-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TNT-176] feat: 세션 체크 결과에 따라 홈 화면, 로그인 화면 이동 결정 로직 구현
- Loading branch information
Showing
4 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package co.kr.tnt.main | ||
|
||
import co.kr.tnt.navigation.Route | ||
import co.kr.tnt.ui.base.UiEvent | ||
import co.kr.tnt.ui.base.UiSideEffect | ||
import co.kr.tnt.ui.base.UiState | ||
|
||
internal class MainContract { | ||
data class MainUiState( | ||
val showSplash: Boolean = true, | ||
val startDestination: Route = Route.Login, | ||
) : UiState | ||
|
||
data object MainUiEvent : UiEvent | ||
|
||
data object MainSideEffect : UiSideEffect | ||
} |
38 changes: 38 additions & 0 deletions
38
feature/main/src/main/java/co/kr/tnt/main/MainViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package co.kr.tnt.main | ||
|
||
import androidx.lifecycle.viewModelScope | ||
import co.kr.tnt.domain.repository.LoginRepository | ||
import co.kr.tnt.main.MainContract.MainSideEffect | ||
import co.kr.tnt.main.MainContract.MainUiEvent | ||
import co.kr.tnt.main.MainContract.MainUiState | ||
import co.kr.tnt.navigation.Route | ||
import co.kr.tnt.ui.base.BaseViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
internal class MainViewModel @Inject constructor( | ||
loginRepository: LoginRepository, | ||
) : | ||
BaseViewModel<MainUiState, MainUiEvent, MainSideEffect>(MainUiState()) { | ||
init { | ||
viewModelScope.launch { | ||
val isNeedLogin = loginRepository.isNeedLogin() | ||
val startDestination: Route = if (isNeedLogin) { | ||
Route.Login | ||
} else { | ||
Route.HomeBase | ||
} | ||
|
||
updateState { | ||
copy( | ||
showSplash = false, | ||
startDestination = startDestination, | ||
) | ||
} | ||
} | ||
} | ||
|
||
override suspend fun handleEvent(event: MainUiEvent) = Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters