Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions app/src/main/java/com/threegap/bitnagil/MainNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ fun MainNavHost(
popUpTo<Route.Splash> { inclusive = true }
}
},
navigateToHome = {
navigator.navController.navigate(Route.Home) {
popUpTo(navigator.navController.graph.startDestinationId) {
inclusive = true
}
}
},
navigateToHome = navigator::navigateToHomeAndClearStack,
)
}

Expand All @@ -56,13 +50,7 @@ fun MainNavHost(

composable<Route.Login> {
LoginScreenContainer(
navigateToHome = {
navigator.navController.navigate(Route.Home) {
popUpTo(navigator.navController.graph.startDestinationId) {
inclusive = true
}
}
},
navigateToHome = navigator::navigateToHomeAndClearStack,
navigateToTermsAgreement = { navigator.navController.navigate(Route.TermsAgreement) },
)
}
Expand Down Expand Up @@ -192,13 +180,7 @@ fun MainNavHost(

OnBoardingScreenContainer(
onBoardingViewModel = viewModel,
navigateToHome = {
navigator.navController.navigate(Route.Home) {
popUpTo(navigator.navController.graph.startDestinationId) {
inclusive = true
}
}
},
navigateToHome = navigator::navigateToHomeAndClearStack,
navigateToBack = {
if (navigator.navController.previousBackStackEntry != null) {
navigator.navController.popBackStack()
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/threegap/bitnagil/MainNavigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class MainNavigator(
val navController: NavHostController,
) {
val startDestination = Route.Splash

internal fun navigateToHomeAndClearStack() =
navController.navigate(Route.Home) {
popUpTo(0) {
inclusive = true
}
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal fun LoginResponseDto.toDomain() =
AuthSession(
accessToken = this.accessToken,
refreshToken = this.refreshToken,
role = UserRole.from(this.role),
role = UserRole.fromString(this.role),
)

// toDto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum class UserRole {
fun isGuest() = this == GUEST

companion object {
fun from(value: String): UserRole =
fun fromString(value: String): UserRole =
when (value) {
"USER" -> USER
"GUEST" -> GUEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -56,6 +57,10 @@ private fun IntroScreen(
val screenHeight = with(LocalDensity.current) {
windowInfo.containerSize.height.toDp()
}
val screenWidth = with(LocalDensity.current) {
windowInfo.containerSize.width.toDp()
}
val widthRatio = 260f / 360f

Column(
horizontalAlignment = Alignment.CenterHorizontally,
Expand All @@ -64,24 +69,26 @@ private fun IntroScreen(
.statusBarsPadding()
.background(BitnagilTheme.colors.white),
) {
Spacer(modifier = Modifier.height(screenHeight * 0.0748f))
Spacer(modifier = Modifier.height(screenHeight * 0.105f))

Text(
text = "당신의 하루 리듬을 이해하고,\n작은 변화를 함께 시작해볼게요.",
color = BitnagilTheme.colors.navy500,
style = BitnagilTheme.typography.title2Bold,
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.height(60.dp),
)

Spacer(modifier = Modifier.height(screenHeight * 0.151f))
Spacer(modifier = Modifier.height(screenHeight * 0.136f))

Image(
painter = painterResource(R.drawable.intro_character),
contentDescription = null,
contentScale = ContentScale.Fit,
modifier = Modifier
.padding(50.dp)
.width(screenWidth * widthRatio)
.aspectRatio(260f / 295f),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -44,12 +45,6 @@ fun LoginScreenContainer(

viewModel.collectSideEffect { sideEffect ->
when (sideEffect) {
is LoginSideEffect.RequestKakaoAccountLogin -> {
KakaoLoginHandlerImpl.accountLogin(context) { token, error ->
viewModel.kakaoLogin(token, error)
}
}

is LoginSideEffect.NavigateToHome -> {
navigateToHome()
}
Expand Down Expand Up @@ -78,6 +73,10 @@ private fun LoginScreen(
val screenHeight = with(LocalDensity.current) {
windowInfo.containerSize.height.toDp()
}
val screenWidth = with(LocalDensity.current) {
windowInfo.containerSize.width.toDp()
}
val widthRatio = 260f / 360f

Column(
horizontalAlignment = Alignment.CenterHorizontally,
Expand All @@ -86,24 +85,26 @@ private fun LoginScreen(
.statusBarsPadding()
.background(BitnagilTheme.colors.white),
) {
Spacer(modifier = Modifier.height(screenHeight * 0.0748f))
Spacer(modifier = Modifier.height(screenHeight * 0.105f))

Text(
text = "빛나길에 오신걸 환영해요!",
color = BitnagilTheme.colors.navy500,
style = BitnagilTheme.typography.title2Bold,
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.height(60.dp),
)

Spacer(modifier = Modifier.height(screenHeight * 0.185f))
Spacer(modifier = Modifier.height(screenHeight * 0.136f))

Image(
painter = painterResource(R.drawable.intro_character),
contentDescription = null,
contentScale = ContentScale.Fit,
modifier = Modifier
.padding(50.dp)
.width(screenWidth * widthRatio)
.aspectRatio(260f / 295f),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import android.util.Log
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
import com.threegap.bitnagil.domain.auth.usecase.LoginUseCase
import com.threegap.bitnagil.domain.error.model.BitnagilError
import com.threegap.bitnagil.presentation.common.mviviewmodel.MviViewModel
import com.threegap.bitnagil.presentation.login.model.LoginIntent
import com.threegap.bitnagil.presentation.login.model.LoginSideEffect
Expand All @@ -19,7 +16,7 @@ import javax.inject.Inject

@HiltViewModel
class LoginViewModel @Inject constructor(
private val savedStateHandle: SavedStateHandle,
savedStateHandle: SavedStateHandle,
private val loginUseCase: LoginUseCase,
) : MviViewModel<LoginState, LoginSideEffect, LoginIntent>(
initState = LoginState(),
Expand Down Expand Up @@ -49,7 +46,6 @@ class LoginViewModel @Inject constructor(
}

is LoginIntent.KakaoTalkLoginCancel -> {
sendSideEffect(LoginSideEffect.RequestKakaoAccountLogin)
state.copy(isLoading = false)
}

Expand All @@ -66,11 +62,6 @@ class LoginViewModel @Inject constructor(
processKakaoLoginSuccess(token)
}

error is ClientError && error.reason == ClientErrorCause.Cancelled -> {
Log.e("KakaoLogin", "카카오 로그인 취소", error)
sendIntent(LoginIntent.KakaoTalkLoginCancel)
}

error != null -> {
Log.e("KakaoLogin", "카카오 로그인 실패", error)
sendIntent(LoginIntent.LoginFailure)
Expand All @@ -90,9 +81,6 @@ class LoginViewModel @Inject constructor(
},
onFailure = { e ->
sendIntent(LoginIntent.LoginFailure)
if (e is BitnagilError) {
Log.e("Login", "${e.code} ${e.message}")
}
Log.e("Login", "${e.message}")
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.threegap.bitnagil.presentation.login.model
import com.threegap.bitnagil.presentation.common.mviviewmodel.MviSideEffect

sealed interface LoginSideEffect : MviSideEffect {
data object RequestKakaoAccountLogin : LoginSideEffect
data object NavigateToHome : LoginSideEffect
data object NavigateToTermsAgreement : LoginSideEffect
}