Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Implement maximum text length constraint for interval input field (#3371
Browse files Browse the repository at this point in the history
)

* Implement maximum text length constraint for interval input field

* refactor: Define character limit for interval input as a constant

* removed the width attribute
  • Loading branch information
akashs056 authored Jul 27, 2024
1 parent a887286 commit ffeb9f8
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit ffeb9f8

Please sign in to comment.