Skip to content

Commit

Permalink
[feat] #75 최초 로그인이 아닐 경우 기프티콘 홈 화면으로 이동 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
ows3090 committed May 15, 2024
1 parent 0df29ee commit 950f376
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,18 @@ fun BuddyConNavHost(
}

composable(route = StartUpDestination.Login.route) {
LoginScreen {
navHostController.navigate(StartUpDestination.SignUp.route)
}
LoginScreen(
onNavigateToSignUp = {
navHostController.navigate(StartUpDestination.SignUp.route)
},
onNavigateToGifticon = {
navHostController.navigate(GifticonDestination.Gifticon.route) {
popUpTo(StartUpDestination.Login.route) {
inclusive = true
}
}
}
)
}

composable(route = StartUpDestination.SignUp.route) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ data class LoginResponse(
data class LoginResponseBody(
val accessToken: String,
val refreshToken: String,
val accessTokenExpiresIn: Long
val accessTokenExpiresIn: Long,
val isFirstLogin: Boolean
) {
fun toModel() = LoginModel(
accessToken = accessToken,
refreshToken = refreshToken,
accessTokenExpiresIn = accessTokenExpiresIn
accessTokenExpiresIn = accessTokenExpiresIn,
isFirstLogin = isFirstLogin
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package com.yapp.buddycon.domain.model.auth
data class LoginModel(
val accessToken: String = "",
val refreshToken: String = "",
val accessTokenExpiresIn: Long = Long.MAX_VALUE
val accessTokenExpiresIn: Long = Long.MAX_VALUE,
val isFirstLogin: Boolean = true
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ private val BuddyConLogoDescription = "BuddyConLogo"
@Composable
fun LoginScreen(
loginViewModel: LoginViewModel = hiltViewModel(),
onNavigateToSignUp: () -> Unit = {}
onNavigateToSignUp: () -> Unit = {},
onNavigateToGifticon: () -> Unit = {}
) {
val context = LocalContext.current
val coroutineScope = rememberCoroutineScope()
Expand All @@ -58,10 +59,14 @@ fun LoginScreen(
LaunchedEffect(Unit) {
loginViewModel.effect.collect { effect ->
when (effect) {
LoginSideEffect.Success -> {
LoginSideEffect.FirstLogin -> {
onNavigateToSignUp()
}

LoginSideEffect.ReLogin -> {
onNavigateToGifticon()
}

LoginSideEffect.KakaoLoginError -> {
isShowKakaoLoginError = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.yapp.buddycon.startup.login

enum class LoginSideEffect {
Success, KakaoLoginError, MoaLoginError
FirstLogin, ReLogin, KakaoLoginError, MoaLoginError
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LoginViewModel @Inject constructor(
tokenRepository.saveAccessToken(it.accessToken)
tokenRepository.saveRefreshToken(it.refreshToken)
tokenRepository.saveAccessTokenExpiresIn(it.accessTokenExpiresIn)
_effect.emit(LoginSideEffect.Success)
_effect.emit(if (it.isFirstLogin) LoginSideEffect.FirstLogin else LoginSideEffect.ReLogin)
}.launchIn(viewModelScope)
}

Expand Down

0 comments on commit 950f376

Please sign in to comment.