Skip to content

Commit

Permalink
Merge pull request #57 from AdultOfNineteen/fix/issue-56
Browse files Browse the repository at this point in the history
[FIX] 회원가입 수정 fix
  • Loading branch information
DongChyeon authored Mar 5, 2024
2 parents 79f7635 + 55691a5 commit 4ee22c9
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ enum class CommonResponseStatus(val code: String, val message: String) {
),
VERIFICATION_DID_NOT_MATCH(
"M004", "인증 번호가 일치하지 않습니다."
);
),
MESSAGE_SEND_TOO_MANY_ATTEMPTS(
"M005", "인증번호 요청 횟수가 초과되었습니다."
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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(
Expand All @@ -138,6 +138,11 @@ fun SignUpAuthenticationScreen(
bottomSheetState.showBottomSheet {
AuthenticationFailedBottomSheet {
bottomSheetState.hideBottomSheet()
appState.navigate(AuthDestinations.Login.ROUTE) {
popUpTo(AuthDestinations.SignUp.ROUTE) {
inclusive = true
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
}

Expand Down Expand Up @@ -90,8 +94,6 @@ fun SignUpFavoriteTasteScreen(
else -> {}
}
}

else -> {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 -> {
Expand Down Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ee22c9

Please sign in to comment.