diff --git a/core/common/src/main/java/com/teamwiney/core/common/base/CommonResponseStatus.kt b/core/common/src/main/java/com/teamwiney/core/common/base/CommonResponseStatus.kt index e648191e..7ac50446 100644 --- a/core/common/src/main/java/com/teamwiney/core/common/base/CommonResponseStatus.kt +++ b/core/common/src/main/java/com/teamwiney/core/common/base/CommonResponseStatus.kt @@ -126,6 +126,9 @@ enum class CommonResponseStatus(val code: String, val message: String) { ), VERIFICATION_DID_NOT_MATCH( "M004", "인증 번호가 일치하지 않습니다." - ); + ), + MESSAGE_SEND_TOO_MANY_ATTEMPTS( + "M005", "인증번호 요청 횟수가 초과되었습니다." + ) } \ No newline at end of file diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpAuthenticationScreen.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpAuthenticationScreen.kt index 73f772d5..66b315c1 100644 --- a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpAuthenticationScreen.kt +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpAuthenticationScreen.kt @@ -30,6 +30,7 @@ import com.teamwiney.auth.signup.SignUpContract.Companion.VERIFY_NUMBER_LENGTH import com.teamwiney.auth.signup.component.bottomsheet.AuthenticationFailedBottomSheet import com.teamwiney.auth.signup.component.bottomsheet.AuthenticationTimeOutBottomSheet import com.teamwiney.auth.signup.component.bottomsheet.ReturnToLoginBottomSheet +import com.teamwiney.auth.signup.component.bottomsheet.SendDisabledBottomSheet import com.teamwiney.auth.signup.component.bottomsheet.SendMessageBottomSheet import com.teamwiney.auth.signup.component.bottomsheet.SendMessageBottomSheetType import com.teamwiney.auth.signup.component.bottomsheet.SendTimeExceededLimitBottomSheet @@ -59,21 +60,7 @@ fun SignUpAuthenticationScreen( if (bottomSheetState.bottomSheetState.isVisible) { bottomSheetState.hideBottomSheet() } else { - bottomSheetState.showBottomSheet { - ReturnToLoginBottomSheet( - onConfirm = { - bottomSheetState.hideBottomSheet() - appState.navigate(AuthDestinations.Login.ROUTE) { - popUpTo(AuthDestinations.Login.ROUTE) { - inclusive = true - } - } - }, - onCancel = { - bottomSheetState.hideBottomSheet() - } - ) - } + viewModel.processEvent(SignUpContract.Event.BackToLogin) } } @@ -116,6 +103,19 @@ fun SignUpAuthenticationScreen( } } + is SignUpContract.BottomSheet.SendDisabled -> { + bottomSheetState.showBottomSheet { + SendDisabledBottomSheet { + bottomSheetState.hideBottomSheet() + appState.navigate(AuthDestinations.Login.ROUTE) { + popUpTo(AuthDestinations.SignUp.ROUTE) { + inclusive = true + } + } + } + } + } + is SignUpContract.BottomSheet.ReturnToLogin -> { bottomSheetState.showBottomSheet { ReturnToLoginBottomSheet( @@ -138,6 +138,11 @@ fun SignUpAuthenticationScreen( bottomSheetState.showBottomSheet { AuthenticationFailedBottomSheet { bottomSheetState.hideBottomSheet() + appState.navigate(AuthDestinations.Login.ROUTE) { + popUpTo(AuthDestinations.SignUp.ROUTE) { + inclusive = true + } + } } } } diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt index 05b42360..60fc4189 100644 --- a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpContract.kt @@ -19,6 +19,7 @@ class SignUpContract { val verifyNumber: String = "", val verifyNumberErrorState: Boolean = false, val verifyNumberErrorText: String = "인증번호", + val verifyNumberErrorCount: Int = 0, val isTimerRunning: Boolean = true, val isTimeOut: Boolean = false, val remainingTime: Int = VERIFY_NUMBER_TIMER, @@ -99,6 +100,7 @@ class SignUpContract { sealed class BottomSheet : UiSheet { object SendMessage : BottomSheet() object SendTimeExceededLimit : BottomSheet() + object SendDisabled : BottomSheet() object AuthenticationFailed : BottomSheet() object AuthenticationTimeOut : BottomSheet() object ReturnToLogin : BottomSheet() diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpFavoriteTasteScreen.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpFavoriteTasteScreen.kt index 32043794..c9952106 100644 --- a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpFavoriteTasteScreen.kt +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpFavoriteTasteScreen.kt @@ -52,7 +52,11 @@ fun SignUpFavoriteTasteScreen( if (bottomSheetState.bottomSheetState.isVisible) { bottomSheetState.hideBottomSheet() } else { - appState.navController.navigateUp() + if (pagerState.currentPage == 0) { + viewModel.processEvent(SignUpContract.Event.CancelTasteSelection) + } else { + scope.launch { pagerState.animateScrollToPage(pagerState.currentPage - 1) } + } } } @@ -90,8 +94,6 @@ fun SignUpFavoriteTasteScreen( else -> {} } } - - else -> {} } } } diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpPhoneScreen.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpPhoneScreen.kt index be1d7f1a..048215b6 100644 --- a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpPhoneScreen.kt +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpPhoneScreen.kt @@ -25,6 +25,7 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.teamwiney.auth.signup.SignUpContract.Companion.PHONE_NUMBER_LENGTH +import com.teamwiney.auth.signup.component.bottomsheet.SendDisabledBottomSheet import com.teamwiney.auth.signup.component.bottomsheet.SendMessageBottomSheet import com.teamwiney.auth.signup.component.bottomsheet.SendMessageBottomSheetType import com.teamwiney.auth.signup.component.bottomsheet.SendTimeExceededLimitBottomSheet @@ -94,6 +95,19 @@ fun SignUpPhoneScreen( } } + is SignUpContract.BottomSheet.SendDisabled -> { + bottomSheetState.showBottomSheet { + SendDisabledBottomSheet { + bottomSheetState.hideBottomSheet() + appState.navigate(AuthDestinations.Login.ROUTE) { + popUpTo(AuthDestinations.SignUp.ROUTE) { + inclusive = true + } + } + } + } + } + is SignUpContract.BottomSheet.UserAlreadyExists -> { bottomSheetState.showBottomSheet { val message = buildAnnotatedString { diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpViewModel.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpViewModel.kt index 8acbdddb..edb920d9 100644 --- a/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpViewModel.kt +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/SignUpViewModel.kt @@ -3,6 +3,7 @@ package com.teamwiney.auth.signup import androidx.lifecycle.viewModelScope import com.teamwiney.auth.signup.component.state.SignUpFavoriteCategoryUiState import com.teamwiney.core.common.base.BaseViewModel +import com.teamwiney.core.common.base.CommonResponseStatus import com.teamwiney.core.common.navigation.AuthDestinations import com.teamwiney.core.common.util.Constants import com.teamwiney.data.network.adapter.ApiResult @@ -96,10 +97,23 @@ class SignUpViewModel @Inject constructor( } is ApiResult.ApiError -> { - updateState(currentState.copy( - verifyNumberErrorText = "인증번호를 확인해주세요!", - verifyNumberErrorState = true - )) + val errorCount = currentState.verifyNumberErrorCount + 1 + + updateState( + currentState.copy( + verifyNumberErrorText = "인증번호를 확인해주세요!($errorCount/5)", + verifyNumberErrorState = true, + verifyNumberErrorCount = errorCount + ) + ) + + if (errorCount > 4) { + postEffect( + SignUpContract.Effect.ShowBottomSheet( + SignUpContract.BottomSheet.AuthenticationFailed + ) + ) + } } else -> { @@ -140,7 +154,27 @@ class SignUpViewModel @Inject constructor( } is ApiResult.ApiError -> { - postEffect(SignUpContract.Effect.ShowSnackBar(it.message)) + when (it.code) { + CommonResponseStatus.USER_ALREADY_EXISTS.code -> { + postEffect( + SignUpContract.Effect.ShowBottomSheet( + SignUpContract.BottomSheet.UserAlreadyExists( + it.message + ) + ) + ) + } + CommonResponseStatus.MESSAGE_SEND_TOO_MANY_ATTEMPTS.code -> { + postEffect( + SignUpContract.Effect.ShowBottomSheet( + SignUpContract.BottomSheet.SendDisabled + ) + ) + } + else -> { + postEffect(SignUpContract.Effect.ShowSnackBar(it.message)) + } + } } else -> { diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/component/bottomsheet/SendDisabledBottomSheet.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/component/bottomsheet/SendDisabledBottomSheet.kt new file mode 100644 index 00000000..abef03b9 --- /dev/null +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/component/bottomsheet/SendDisabledBottomSheet.kt @@ -0,0 +1,71 @@ +package com.teamwiney.auth.signup.component.bottomsheet + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import com.teamwiney.core.design.R +import com.teamwiney.ui.components.HeightSpacer +import com.teamwiney.ui.components.WButton +import com.teamwiney.ui.theme.WineyTheme + +@Composable +fun SendDisabledBottomSheet( + modifier: Modifier = Modifier, + containerColor: Color = WineyTheme.colors.gray_950, + onConfirm: () -> Unit +) { + Column( + modifier = modifier + .fillMaxWidth() + .background( + color = containerColor, + shape = RoundedCornerShape(topStart = 6.dp, topEnd = 6.dp) + ) + .padding(start = 24.dp, end = 24.dp, top = 10.dp, bottom = 20.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Spacer( + modifier = Modifier + .width(66.dp) + .height(5.dp) + .background( + color = WineyTheme.colors.gray_900, + shape = RoundedCornerShape(6.dp) + ) + ) + HeightSpacer(height = 20.dp) + Image( + painter = painterResource(id = R.mipmap.img_lock), + contentDescription = null + ) + HeightSpacer(height = 16.dp) + Text( + text = "아직 5분이 지나지 않았어요\n5분 후 인증을 진행해주세요!", + style = WineyTheme.typography.bodyB1, + color = WineyTheme.colors.gray_200, + textAlign = TextAlign.Center + ) + HeightSpacer(height = 72.dp) + WButton( + text = "확인", + onClick = { + onConfirm() + } + ) + HeightSpacer(height = 10.dp) + } +} \ No newline at end of file diff --git a/feature/auth/src/main/java/com/teamwiney/auth/signup/component/bottomsheet/SendTimeExceededLimitBottomSheet.kt b/feature/auth/src/main/java/com/teamwiney/auth/signup/component/bottomsheet/SendTimeExceededLimitBottomSheet.kt index ccc1d2a9..d51cd4b0 100644 --- a/feature/auth/src/main/java/com/teamwiney/auth/signup/component/bottomsheet/SendTimeExceededLimitBottomSheet.kt +++ b/feature/auth/src/main/java/com/teamwiney/auth/signup/component/bottomsheet/SendTimeExceededLimitBottomSheet.kt @@ -54,7 +54,7 @@ fun SendTimeExceededLimitBottomSheet( ) HeightSpacer(height = 16.dp) Text( - text = "인증 요청 제한 횟수를 초과했어요\n처음부터 다시 시도해주세요!", + text = "인증 요청 제한 횟수를 초과했어요\n5분 뒤 처음부터 진행해주세요!", style = WineyTheme.typography.bodyB1, color = WineyTheme.colors.gray_200, textAlign = TextAlign.Center