From 63c8e3fc072ec0245a835a230c667b58bc6cf826 Mon Sep 17 00:00:00 2001 From: jinuemong Date: Sat, 3 Feb 2024 16:45:48 +0900 Subject: [PATCH] =?UTF-8?q?[fix]:=20QA=20=ED=9B=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/expansion/NumberCommaTransformation.kt | 4 +++- .../presentation/common/view/textfield/TypingPriceField.kt | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/expansion/NumberCommaTransformation.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/expansion/NumberCommaTransformation.kt index 41571e44..64b539b4 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/expansion/NumberCommaTransformation.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/expansion/NumberCommaTransformation.kt @@ -13,7 +13,9 @@ class NumberCommaTransformation : VisualTransformation { NumberFormat.getNumberInstance(Locale.US).format(this ?: 0) override fun filter(text: AnnotatedString): TransformedText { - val newText = AnnotatedString(text.text.toLongOrNull().formatWithComma() + "원") + val newText = AnnotatedString( + text = if (text.text.isEmpty()) "" else text.text.toLongOrNull().formatWithComma() + "원" + ) return TransformedText( text = newText, offsetMapping = object : OffsetMapping { diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/textfield/TypingPriceField.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/textfield/TypingPriceField.kt index 8732e923..ab98ea26 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/textfield/TypingPriceField.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/textfield/TypingPriceField.kt @@ -61,15 +61,13 @@ fun TypingPriceField( innerPadding: PaddingValues = PaddingValues(0.dp), textFieldHeight: Dp = 35.dp, keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword), + textFormat : VisualTransformation = NumberCommaTransformation(), fieldSubjectContent: (@Composable () -> Unit) = { FieldSubject() }, leadingIconContent: (@Composable () -> Unit)? = null, trailingIconContent: (@Composable () -> Unit)? = null, errorMessageContent: (@Composable () -> Unit) = { }, ) { val interactionSource: MutableInteractionSource = remember { MutableInteractionSource() } - val numberCommaTransFormation = remember { NumberCommaTransformation() } - val textFormat = - if (textValue.isEmpty()) VisualTransformation.None else numberCommaTransFormation var isTextFieldFocused by remember { mutableStateOf(false) } val scope = rememberCoroutineScope() val currentColor = if (isError) Negative else if (isTextFieldFocused) Primary3 else Gray500