Skip to content

Commit

Permalink
#28 Feat : 인증 시간 초과 바텀 시트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
DongChyeon committed Feb 7, 2024
1 parent 0e2bb7a commit 5f51483
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
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.SendMessageBottomSheet
import com.teamwiney.auth.signup.component.bottomsheet.SendMessageBottomSheetType
Expand Down Expand Up @@ -57,7 +58,21 @@ fun SignUpAuthenticationScreen(
if (bottomSheetState.bottomSheetState.isVisible) {
bottomSheetState.hideBottomSheet()
} else {
appState.navController.navigateUp()
bottomSheetState.showBottomSheet {
ReturnToLoginBottomSheet(
onConfirm = {
bottomSheetState.hideBottomSheet()
appState.navigate(AuthDestinations.Login.ROUTE) {
popUpTo(AuthDestinations.Login.ROUTE) {
inclusive = true
}
}
},
onCancel = {
bottomSheetState.hideBottomSheet()
}
)
}
}
}

Expand Down Expand Up @@ -93,7 +108,7 @@ fun SignUpAuthenticationScreen(
onConfirm = {
bottomSheetState.hideBottomSheet()
appState.navigate(AuthDestinations.Login.ROUTE) {
popUpTo(AuthDestinations.SignUp.ROUTE) {
popUpTo(AuthDestinations.Login.ROUTE) {
inclusive = true
}
}
Expand All @@ -113,6 +128,14 @@ fun SignUpAuthenticationScreen(
}
}

is SignUpContract.BottomSheet.AuthenticationTimeOut -> {
bottomSheetState.showBottomSheet {
AuthenticationTimeOutBottomSheet {
bottomSheetState.hideBottomSheet()
}
}
}

else -> { }
}
}
Expand Down Expand Up @@ -154,7 +177,7 @@ fun SignUpAuthenticationScreen(
Text(
text = uiState.verifyNumberErrorText,
color = if (uiState.verifyNumberErrorState) WineyTheme.colors.error else WineyTheme.colors.gray_600,
style = WineyTheme.typography.bodyM2
style = if (uiState.verifyNumberErrorState) WineyTheme.typography.bodyM2 else WineyTheme.typography.bodyB2
)
HeightSpacer(10.dp)
WTextField(
Expand Down Expand Up @@ -218,5 +241,5 @@ private fun Int.toMinuteSeconds(): String {
val minutes = this / 60
val remainingSeconds = this % 60

return if (this < 0) "-:--" else String.format("%d:%02d", minutes, remainingSeconds)
return if (this < 0) "0:00" else String.format("%d:%02d", minutes, remainingSeconds)
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class SignUpContract {
sealed class BottomSheet : UiSheet {
object SendMessage : BottomSheet()
object AuthenticationFailed : BottomSheet()
object AuthenticationTimeOut : BottomSheet()
object ReturnToLogin : BottomSheet()
class UserAlreadyExists(val message: String) : BottomSheet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ fun SignUpPhoneScreen(
}
}

LaunchedEffect(uiState.phoneNumber) {
viewModel.updatePhoneNumberErrorState(
!(uiState.phoneNumber.length == PHONE_NUMBER_LENGTH || uiState.phoneNumber.isEmpty())
)
}

val keyboardController = LocalSoftwareKeyboardController.current

Column(
Expand Down Expand Up @@ -148,9 +154,6 @@ fun SignUpPhoneScreen(
viewModel.updatePhoneNumber(it.filter { symbol ->
symbol.isDigit()
})
viewModel.updatePhoneNumberErrorState(
!(uiState.phoneNumber.length == PHONE_NUMBER_LENGTH || uiState.phoneNumber.isEmpty())
)
},
placeholderText = "${PHONE_NUMBER_LENGTH}자리 입력",
maxLength = PHONE_NUMBER_LENGTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ class SignUpViewModel @Inject constructor(
fun updateIsTimeOut(isTimeOut: Boolean) = viewModelScope.launch {
updateState(currentState.copy(isTimeOut = isTimeOut))
if (isTimeOut) {
updateState(currentState.copy(
verifyNumberErrorText = "인증시간이 초과되었어요. 재전송 버튼을 눌러주세요.",
verifyNumberErrorState = true
))
postEffect(
SignUpContract.Effect.ShowBottomSheet(
SignUpContract.BottomSheet.AuthenticationTimeOut
)
)
}
}

Expand All @@ -209,6 +210,7 @@ class SignUpViewModel @Inject constructor(
currentState.copy(
remainingTime = SignUpContract.VERIFY_NUMBER_TIMER,
isTimerRunning = true,
isTimeOut = false,
isLoading = false
)
)
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 AuthenticationTimeOutBottomSheet(
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 = "인증번호 재전송 버튼을 눌러\n새로운 인증번호를 입력해주세요!",
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 @@ -71,7 +71,7 @@ fun ReturnToLoginBottomSheet(
onConfirm = { onConfirm() },
onCancel = { onCancel() }
)
HeightSpacer(height = 20.dp)
HeightSpacer(height = 10.dp)
}
}

Expand Down

0 comments on commit 5f51483

Please sign in to comment.