Skip to content

Commit

Permalink
[feature/#1029] 입력 텍스트 최대 조건 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 23, 2025
1 parent 430c906 commit 4a84b6a
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ import org.sopt.official.designsystem.Gray10
import org.sopt.official.designsystem.Gray100
import org.sopt.official.designsystem.SoptTheme
import org.sopt.official.designsystem.White
import org.sopt.official.feature.auth.component.BasicTextDefaults.MAX_CODE_NUMBER
import org.sopt.official.feature.auth.component.BasicTextDefaults.MAX_PHONE_NUMBER
import org.sopt.official.feature.auth.component.BasicTextDefaults.PHONE_HINT_TEXT
import org.sopt.official.feature.auth.utils.phoneNumberVisualTransformation

@Composable
Expand Down Expand Up @@ -106,7 +109,12 @@ internal fun AuthTextField(

BasicTextField(
value = labelText,
onValueChange = onTextChange,
onValueChange = { newValue ->
val maxLength = if (hintText.contains(PHONE_HINT_TEXT)) MAX_PHONE_NUMBER else MAX_CODE_NUMBER
if (newValue.length <= maxLength) {
onTextChange(newValue)
}
},
singleLine = true,
visualTransformation = visualTransformation,
textStyle = SoptTheme.typography.body16M.copy(color = Gray10),
Expand Down Expand Up @@ -138,6 +146,12 @@ internal fun AuthTextField(
}
}

object BasicTextDefaults {
const val PHONE_HINT_TEXT: String = "010"
const val MAX_PHONE_NUMBER: Int = 11
const val MAX_CODE_NUMBER: Int = 6
}

@Preview(showBackground = false)
@Composable
private fun AuthTextFieldPreview() {
Expand Down

0 comments on commit 4a84b6a

Please sign in to comment.