Skip to content

Commit

Permalink
Add maxLength to InputPhoneNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Jun 10, 2024
1 parent 22dec35 commit 6665d7f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.internal.RegExValidations
* @param title: controls the text to be shown for the title.
* @param onCallActionClicked: callback to when call phone number button is clicked.
* @param modifier: allows a modifier to be passed externally.
* @param maxLength: number of characters/digits that can be entered.
* @param minLength: number of characters/digits that needs be entered to enable phone button.
* @param state: Manages the InputShell state.
* @param inputStyle: manages the InputShell style.
Expand All @@ -41,6 +42,7 @@ fun InputPhoneNumber(
title: String,
onCallActionClicked: () -> Unit,
modifier: Modifier = Modifier,
maxLength: Int = 12,
minLength: Int = 4,
state: InputShellState,
inputStyle: InputStyle = InputStyle.DataInputStyle(),
Expand All @@ -67,7 +69,11 @@ fun InputPhoneNumber(
isRequiredField = isRequiredField,
onNextClicked = onNextClicked,
onValueChanged = {
onValueChanged?.invoke(it)
if ((it.text.length) <= maxLength) {
onValueChanged?.invoke(it)
} else {
// no-op
}
},
keyboardOptions = KeyboardOptions(
imeAction = imeAction,
Expand Down

0 comments on commit 6665d7f

Please sign in to comment.