Skip to content

Commit 7656c49

Browse files
authored
Merge pull request #79 from YAPP-Github/fix/#77-login-logic
[Fix/#77] 로그인 관련 문제사항 수정
2 parents af43a04 + ce0eb17 commit 7656c49

File tree

8 files changed

+35
-51
lines changed

8 files changed

+35
-51
lines changed

app/src/main/java/com/threegap/bitnagil/MainNavHost.kt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,7 @@ fun MainNavHost(
3838
popUpTo<Route.Splash> { inclusive = true }
3939
}
4040
},
41-
navigateToHome = {
42-
navigator.navController.navigate(Route.Home) {
43-
popUpTo(navigator.navController.graph.startDestinationId) {
44-
inclusive = true
45-
}
46-
}
47-
},
41+
navigateToHome = navigator::navigateToHomeAndClearStack,
4842
)
4943
}
5044

@@ -56,13 +50,7 @@ fun MainNavHost(
5650

5751
composable<Route.Login> {
5852
LoginScreenContainer(
59-
navigateToHome = {
60-
navigator.navController.navigate(Route.Home) {
61-
popUpTo(navigator.navController.graph.startDestinationId) {
62-
inclusive = true
63-
}
64-
}
65-
},
53+
navigateToHome = navigator::navigateToHomeAndClearStack,
6654
navigateToTermsAgreement = { navigator.navController.navigate(Route.TermsAgreement) },
6755
)
6856
}
@@ -192,13 +180,7 @@ fun MainNavHost(
192180

193181
OnBoardingScreenContainer(
194182
onBoardingViewModel = viewModel,
195-
navigateToHome = {
196-
navigator.navController.navigate(Route.Home) {
197-
popUpTo(navigator.navController.graph.startDestinationId) {
198-
inclusive = true
199-
}
200-
}
201-
},
183+
navigateToHome = navigator::navigateToHomeAndClearStack,
202184
navigateToBack = {
203185
if (navigator.navController.previousBackStackEntry != null) {
204186
navigator.navController.popBackStack()

app/src/main/java/com/threegap/bitnagil/MainNavigator.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ class MainNavigator(
99
val navController: NavHostController,
1010
) {
1111
val startDestination = Route.Splash
12+
13+
internal fun navigateToHomeAndClearStack() =
14+
navController.navigate(Route.Home) {
15+
popUpTo(0) {
16+
inclusive = true
17+
}
18+
}
1219
}
1320

1421
@Composable

data/src/main/java/com/threegap/bitnagil/data/auth/mapper/AuthMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal fun LoginResponseDto.toDomain() =
1111
AuthSession(
1212
accessToken = this.accessToken,
1313
refreshToken = this.refreshToken,
14-
role = UserRole.from(this.role),
14+
role = UserRole.fromString(this.role),
1515
)
1616

1717
// toDto

domain/src/main/java/com/threegap/bitnagil/domain/auth/model/UserRole.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enum class UserRole {
88
fun isGuest() = this == GUEST
99

1010
companion object {
11-
fun from(value: String): UserRole =
11+
fun fromString(value: String): UserRole =
1212
when (value) {
1313
"USER" -> USER
1414
"GUEST" -> GUEST

presentation/src/main/java/com/threegap/bitnagil/presentation/intro/IntroScreen.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
1010
import androidx.compose.foundation.layout.height
1111
import androidx.compose.foundation.layout.padding
1212
import androidx.compose.foundation.layout.statusBarsPadding
13+
import androidx.compose.foundation.layout.width
1314
import androidx.compose.material3.Text
1415
import androidx.compose.runtime.Composable
1516
import androidx.compose.ui.Alignment
@@ -56,6 +57,10 @@ private fun IntroScreen(
5657
val screenHeight = with(LocalDensity.current) {
5758
windowInfo.containerSize.height.toDp()
5859
}
60+
val screenWidth = with(LocalDensity.current) {
61+
windowInfo.containerSize.width.toDp()
62+
}
63+
val widthRatio = 260f / 360f
5964

6065
Column(
6166
horizontalAlignment = Alignment.CenterHorizontally,
@@ -64,24 +69,26 @@ private fun IntroScreen(
6469
.statusBarsPadding()
6570
.background(BitnagilTheme.colors.white),
6671
) {
67-
Spacer(modifier = Modifier.height(screenHeight * 0.0748f))
72+
Spacer(modifier = Modifier.height(screenHeight * 0.105f))
6873

6974
Text(
7075
text = "당신의 하루 리듬을 이해하고,\n작은 변화를 함께 시작해볼게요.",
7176
color = BitnagilTheme.colors.navy500,
7277
style = BitnagilTheme.typography.title2Bold,
7378
textAlign = TextAlign.Center,
74-
modifier = Modifier.fillMaxWidth(),
79+
modifier = Modifier
80+
.fillMaxWidth()
81+
.height(60.dp),
7582
)
7683

77-
Spacer(modifier = Modifier.height(screenHeight * 0.151f))
84+
Spacer(modifier = Modifier.height(screenHeight * 0.136f))
7885

7986
Image(
8087
painter = painterResource(R.drawable.intro_character),
8188
contentDescription = null,
8289
contentScale = ContentScale.Fit,
8390
modifier = Modifier
84-
.padding(50.dp)
91+
.width(screenWidth * widthRatio)
8592
.aspectRatio(260f / 295f),
8693
)
8794

presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginScreen.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
1212
import androidx.compose.foundation.layout.height
1313
import androidx.compose.foundation.layout.padding
1414
import androidx.compose.foundation.layout.statusBarsPadding
15+
import androidx.compose.foundation.layout.width
1516
import androidx.compose.foundation.shape.RoundedCornerShape
1617
import androidx.compose.material3.Text
1718
import androidx.compose.runtime.Composable
@@ -44,12 +45,6 @@ fun LoginScreenContainer(
4445

4546
viewModel.collectSideEffect { sideEffect ->
4647
when (sideEffect) {
47-
is LoginSideEffect.RequestKakaoAccountLogin -> {
48-
KakaoLoginHandlerImpl.accountLogin(context) { token, error ->
49-
viewModel.kakaoLogin(token, error)
50-
}
51-
}
52-
5348
is LoginSideEffect.NavigateToHome -> {
5449
navigateToHome()
5550
}
@@ -78,6 +73,10 @@ private fun LoginScreen(
7873
val screenHeight = with(LocalDensity.current) {
7974
windowInfo.containerSize.height.toDp()
8075
}
76+
val screenWidth = with(LocalDensity.current) {
77+
windowInfo.containerSize.width.toDp()
78+
}
79+
val widthRatio = 260f / 360f
8180

8281
Column(
8382
horizontalAlignment = Alignment.CenterHorizontally,
@@ -86,24 +85,26 @@ private fun LoginScreen(
8685
.statusBarsPadding()
8786
.background(BitnagilTheme.colors.white),
8887
) {
89-
Spacer(modifier = Modifier.height(screenHeight * 0.0748f))
88+
Spacer(modifier = Modifier.height(screenHeight * 0.105f))
9089

9190
Text(
9291
text = "빛나길에 오신걸 환영해요!",
9392
color = BitnagilTheme.colors.navy500,
9493
style = BitnagilTheme.typography.title2Bold,
9594
textAlign = TextAlign.Center,
96-
modifier = Modifier.fillMaxWidth(),
95+
modifier = Modifier
96+
.fillMaxWidth()
97+
.height(60.dp),
9798
)
9899

99-
Spacer(modifier = Modifier.height(screenHeight * 0.185f))
100+
Spacer(modifier = Modifier.height(screenHeight * 0.136f))
100101

101102
Image(
102103
painter = painterResource(R.drawable.intro_character),
103104
contentDescription = null,
104105
contentScale = ContentScale.Fit,
105106
modifier = Modifier
106-
.padding(50.dp)
107+
.width(screenWidth * widthRatio)
107108
.aspectRatio(260f / 295f),
108109
)
109110

presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginViewModel.kt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import android.util.Log
44
import androidx.lifecycle.SavedStateHandle
55
import androidx.lifecycle.viewModelScope
66
import com.kakao.sdk.auth.model.OAuthToken
7-
import com.kakao.sdk.common.model.ClientError
8-
import com.kakao.sdk.common.model.ClientErrorCause
97
import com.threegap.bitnagil.domain.auth.usecase.LoginUseCase
10-
import com.threegap.bitnagil.domain.error.model.BitnagilError
118
import com.threegap.bitnagil.presentation.common.mviviewmodel.MviViewModel
129
import com.threegap.bitnagil.presentation.login.model.LoginIntent
1310
import com.threegap.bitnagil.presentation.login.model.LoginSideEffect
@@ -19,7 +16,7 @@ import javax.inject.Inject
1916

2017
@HiltViewModel
2118
class LoginViewModel @Inject constructor(
22-
private val savedStateHandle: SavedStateHandle,
19+
savedStateHandle: SavedStateHandle,
2320
private val loginUseCase: LoginUseCase,
2421
) : MviViewModel<LoginState, LoginSideEffect, LoginIntent>(
2522
initState = LoginState(),
@@ -49,7 +46,6 @@ class LoginViewModel @Inject constructor(
4946
}
5047

5148
is LoginIntent.KakaoTalkLoginCancel -> {
52-
sendSideEffect(LoginSideEffect.RequestKakaoAccountLogin)
5349
state.copy(isLoading = false)
5450
}
5551

@@ -66,11 +62,6 @@ class LoginViewModel @Inject constructor(
6662
processKakaoLoginSuccess(token)
6763
}
6864

69-
error is ClientError && error.reason == ClientErrorCause.Cancelled -> {
70-
Log.e("KakaoLogin", "카카오 로그인 취소", error)
71-
sendIntent(LoginIntent.KakaoTalkLoginCancel)
72-
}
73-
7465
error != null -> {
7566
Log.e("KakaoLogin", "카카오 로그인 실패", error)
7667
sendIntent(LoginIntent.LoginFailure)
@@ -90,9 +81,6 @@ class LoginViewModel @Inject constructor(
9081
},
9182
onFailure = { e ->
9283
sendIntent(LoginIntent.LoginFailure)
93-
if (e is BitnagilError) {
94-
Log.e("Login", "${e.code} ${e.message}")
95-
}
9684
Log.e("Login", "${e.message}")
9785
},
9886
)

presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginSideEffect.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.threegap.bitnagil.presentation.login.model
33
import com.threegap.bitnagil.presentation.common.mviviewmodel.MviSideEffect
44

55
sealed interface LoginSideEffect : MviSideEffect {
6-
data object RequestKakaoAccountLogin : LoginSideEffect
76
data object NavigateToHome : LoginSideEffect
87
data object NavigateToTermsAgreement : LoginSideEffect
98
}

0 commit comments

Comments
 (0)