From ffeb9f8f66bce27d34d52e5b3bcee3156ec3f15e Mon Sep 17 00:00:00 2001 From: Akash Subramanian <152642367+akashs056@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:41:11 +0530 Subject: [PATCH] Implement maximum text length constraint for interval input field (#3371) * Implement maximum text length constraint for interval input field * refactor: Define character limit for interval input as a constant * removed the width attribute --- .../legacy/legacy/ui/theme/components/IntervalPickerRow.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/IntervalPickerRow.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/IntervalPickerRow.kt index 506540d3a1..5df7290615 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/IntervalPickerRow.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/IntervalPickerRow.kt @@ -36,6 +36,8 @@ import com.ivy.wallet.ui.theme.Gradient import com.ivy.wallet.ui.theme.GradientIvy import com.ivy.wallet.ui.theme.White +private const val RepeatIntervalCharLimit = 5 + @Deprecated("Old design system. Use `:ivy-design` and Material3") @Composable fun IntervalPickerRow( @@ -73,13 +75,14 @@ fun IntervalPickerRow( textColor = if (validInput) White else UI.colors.pureInverse, hint = "0" ) { + val filteredText = it.text.take(RepeatIntervalCharLimit) if (it.text != interNTextFieldValue.text) { try { - onSetIntervalN(it.text.toInt()) + onSetIntervalN(filteredText.toInt()) } catch (e: Exception) { } } - interNTextFieldValue = it + interNTextFieldValue = it.copy(text = filteredText) } Spacer(Modifier.width(12.dp))