From 211f7a64053151b208d7e04ea9cc7c4f4e95ebda Mon Sep 17 00:00:00 2001 From: kkh Date: Thu, 15 Aug 2024 23:55:51 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EC=86=8C=EC=85=9C=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8,=20=EB=A1=9C=EC=BB=AC=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=20=EC=97=90=EB=9F=AC=20ui=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Applied when(viewModel.loginStatusCode){ 401 -> "이메일 또는 비밀번호가 잘못되었습니다." 403 -> "권한이 존재하지 않습니다." 409 -> "중복된 이메일 계정이 존재합니다." else -> viewModel.loginStatusCode.toString() } --- .idea/deploymentTargetDropDown.xml | 17 +++++-- app/build.gradle.kts | 2 +- .../echoist/linkedout/page/login/LoginPage.kt | 51 ++++++++++++++++++- .../viewModels/SocialLoginViewModel.kt | 17 +++++-- 4 files changed, 77 insertions(+), 10 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 850d5dad..243647e8 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -37,13 +37,24 @@ - - + + - + + + + + + + + + + + + diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 21081a4d..de6fe994 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -22,7 +22,7 @@ android { applicationId = "com.echoist.linkedout" minSdk = 26 targetSdk = 34 - versionCode = 1 + versionCode = 3 //todo 릴리즈 생성마다 +1 versionName = "1.0.0" //git ignore 용입니다. //구글 네이티브 앱 키 diff --git a/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt b/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt index c0c66128..ef437700 100644 --- a/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt +++ b/app/src/main/java/com/echoist/linkedout/page/login/LoginPage.kt @@ -12,16 +12,24 @@ import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.FastOutSlowInEasing +import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.tween +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBarsPadding @@ -143,6 +151,7 @@ import com.navercorp.nid.NaverIdLoginSDK import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.delay import java.net.URLDecoder import java.nio.charset.StandardCharsets @@ -187,7 +196,7 @@ class LoginPage : ComponentActivity() { Log.d("Hash", keyHash) val navController = rememberNavController() - NavHost(navController = navController, startDestination = Routes.LoginPage) { + NavHost(navController = navController, startDestination = Routes.OnBoarding) { composable(Routes.OnBoarding) { OnBoardingPage(navController) } @@ -507,6 +516,17 @@ fun LoginPage( LaunchedEffect(key1 = Unit) { viewModel.requestAppVersion() } + + LaunchedEffect(key1 = viewModel.loginStatusCode) { + delay(1000) + viewModel.loginStatusCode = 200 + } + val errorText = when(viewModel.loginStatusCode){ + 401 -> "이메일 또는 비밀번호가 잘못되었습니다." + 403 -> "권한이 존재하지 않습니다." + 409 -> "중복된 이메일 계정이 존재합니다." + else -> viewModel.loginStatusCode.toString() + } LinkedOutTheme { Scaffold( @@ -609,6 +629,32 @@ fun LoginPage( SocialLoginBar(navController, viewModel) Spacer(modifier = Modifier.height(20.dp)) } + //에러 박스 + AnimatedVisibility( + visible = viewModel.loginStatusCode >= 400, + enter = fadeIn(animationSpec = tween(durationMillis = 500,easing = FastOutSlowInEasing)), + exit = fadeOut(animationSpec = tween(durationMillis = 0, easing = LinearEasing)) + ) + { + Box(modifier = Modifier + .fillMaxSize() + .background(Color.Black.copy(0.7f))){ + Box(modifier = Modifier.fillMaxWidth().align(Alignment.Center). + height(60.dp).padding(horizontal = 20.dp).background( + Color(0xFFE43446), + shape = RoundedCornerShape(10) + )){ + Text( + text = errorText, + color = Color.White, + modifier = Modifier.align( + Alignment.Center + ) + ) + } + + } + } } ) } @@ -742,6 +788,7 @@ fun LoginBtn( val interactionSource = remember { MutableInteractionSource() } // val isPressed by interactionSource.collectIsPressedAsState() val error = viewModel.userId.isEmpty() || viewModel.userPw.isEmpty() + LinkedOutTheme { Button( @@ -761,6 +808,8 @@ fun LoginBtn( ) { Text(text = "로그인") } + + } } diff --git a/app/src/main/java/com/echoist/linkedout/viewModels/SocialLoginViewModel.kt b/app/src/main/java/com/echoist/linkedout/viewModels/SocialLoginViewModel.kt index 4405066e..025888f4 100644 --- a/app/src/main/java/com/echoist/linkedout/viewModels/SocialLoginViewModel.kt +++ b/app/src/main/java/com/echoist/linkedout/viewModels/SocialLoginViewModel.kt @@ -110,6 +110,7 @@ class SocialLoginViewModel @Inject constructor( } } + var loginStatusCode by mutableStateOf(200) //로그인 fun login(navController: NavController) { viewModelScope.launch { @@ -120,7 +121,7 @@ class SocialLoginViewModel @Inject constructor( if (response.isSuccessful) { Log.i("server header token", response.headers()["authorization"].toString()) Token.accessToken = (response.headers()["authorization"].toString()) - Log.d("authApiSuccess3", "로그인 성공! ${response.headers()["authorization"]}") // 이값을 항상 헤더에 넣을것. + loginStatusCode = response.code() navController.popBackStack("OnBoarding", false) //onboarding까지 전부 삭제. if (response.code() == 202) // 탈퇴유저. 첫유저일리 없고 정보읽지않고 홈으로이동. @@ -128,7 +129,8 @@ class SocialLoginViewModel @Inject constructor( else readMyInfo(navController)// 첫 회원가입 여부 확인하고 화면이동 } else { - Log.e("login_failed", "${response.code()}") + loginStatusCode = response.code() + Log.e("login_failed", "$loginStatusCode") Log.e("login_failed", response.message()) } @@ -231,12 +233,13 @@ class SocialLoginViewModel @Inject constructor( Token.accessToken = (response.headers()["authorization"].toString()) Log.i("server header token(구글)", Token.accessToken) Log.d("응답코드로 탈퇴/밴 사용자 여부파악 202 -> 탈퇴신청유저 ", response.code().toString()) - + loginStatusCode = response.code() if (response.code() == 202) // 탈퇴유저. 첫유저일리 없고 정보읽지않고 홈으로이동. navController.navigate("HOME/${response.code()}") else readMyInfo(navController)// 첫 회원가입 여부 확인하고 화면이동 } else { //409는 중복. 502는 아예 서버 팅 + loginStatusCode = response.code() Log.e("google_login 서버와 api", "Failed ${response.code()}") } @@ -326,6 +329,7 @@ class SocialLoginViewModel @Inject constructor( Log.i("server header token(카카오)", response.headers()["authorization"].toString()) Token.accessToken = (response.headers()["authorization"].toString()) Log.d(TAG, "requestKakaoLogin: ${response.code()}") + loginStatusCode = response.code() if (response.code() == 202) // 탈퇴유저. 첫유저일리 없고 정보읽지않고 홈으로이동. navController.navigate("HOME/${response.code()}") @@ -335,6 +339,7 @@ class SocialLoginViewModel @Inject constructor( } else { Log.e("kakao_login 서버와 api", "Failed ${response.code()}") + loginStatusCode = response.code() } } catch (e: Exception) { @@ -450,7 +455,7 @@ class SocialLoginViewModel @Inject constructor( Log.i("server header token(네이버)", response.headers()["authorization"].toString()) Token.accessToken = (response.headers()["authorization"].toString()) Log.d(TAG, "requestNaverLogin: ${response.code()}") - + loginStatusCode = response.code() if (response.code() == 202) // 탈퇴유저. 첫유저일리 없고 정보읽지않고 홈으로이동. navController.navigate("HOME/${response.code()}") @@ -458,6 +463,7 @@ class SocialLoginViewModel @Inject constructor( else readMyInfo(navController)// 첫 회원가입 여부 확인하고 화면이동 } else { + loginStatusCode = response.code() Log.e("naver_login 서버와 api", "Failed ${response.code()}") } @@ -553,7 +559,7 @@ class SocialLoginViewModel @Inject constructor( Log.i("server header token(애플)", response.headers()["authorization"].toString()) Token.accessToken = (response.headers()["authorization"].toString()) Log.d(TAG, "requestAppleLogin: ${response.code()}") - + loginStatusCode = response.code() if (response.code() == 202) // 탈퇴유저. 첫유저일리 없고 정보읽지않고 홈으로이동. navController.navigate("HOME/${response.code()}") @@ -561,6 +567,7 @@ class SocialLoginViewModel @Inject constructor( else readMyInfo(navController)// 첫 회원가입 여부 확인하고 화면이동 } else { + loginStatusCode = response.code() Log.e("Apple_login 서버와 api", "Failed ${response.code()}") }