From f666c03071d2a69719aa7b170c66adc71de47f31 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Fri, 19 Jul 2024 19:42:01 +0900 Subject: [PATCH] =?UTF-8?q?[FIX/#152]=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=9E=85=EB=A0=A5=20=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../textfield/TerningBasicTextField.kt | 2 +- .../onboarding/signup/SignUpViewModel.kt | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt index fd3bab05d..67c799550 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt @@ -61,7 +61,7 @@ fun TerningBasicTextField( BasicTextField( value = value, onValueChange = { - if (maxTextLength == null || it.length <= maxTextLength) { + if (maxTextLength == null || it.length <= maxTextLength + 1) { onValueChange(it) } }, diff --git a/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpViewModel.kt b/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpViewModel.kt index 7b3a1e170..15e268a75 100644 --- a/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpViewModel.kt +++ b/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpViewModel.kt @@ -34,7 +34,15 @@ class SignUpViewModel @Inject constructor( fun isInputValid(name: String) { val nameErrorRegex = Regex(NAME_ERROR) - val trimmedName = if (name.length > MAX_LENGTH) name.substring(0, MAX_LENGTH) else name +// val outOfBoundName = if(name.length > MAX_LENGTH + 1) name.substring(0, MAX_LENGTH) else name + var trimmedName : String = "" + var trimmedNameOutOfBound : String = "" + var outOfBoundName : Boolean = false + if(name.length > MAX_LENGTH) { + trimmedName = name.substring(0, MAX_LENGTH) + trimmedNameOutOfBound = name.substring(0, MAX_LENGTH + 1) + outOfBoundName = true + }else trimmedName = name when { nameErrorRegex.containsMatchIn(trimmedName) -> _state.value = _state.value.copy( @@ -55,6 +63,15 @@ class SignUpViewModel @Inject constructor( isButtonValid = false ) + outOfBoundName -> _state.value = _state.value.copy( + name = trimmedNameOutOfBound, + drawLineColor = WarningRed, + helper = R.string.sign_up_helper, + helperIcon = R.drawable.ic_sign_up_error, + helperColor = WarningRed, + isButtonValid = false + ) + else -> _state.value = _state.value.copy( name = trimmedName, drawLineColor = TerningMain,