Skip to content

Commit

Permalink
feat(isReadOnly): make the InputText read only if needed Android_side… (
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo-lbg authored Jan 14, 2025
1 parent f59ab00 commit 1023ab9
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -215,7 +215,8 @@ InputText(
focusRequester = FocusRequester,
keyboardAction = ImeAction,
onKeyboardAction = () -> Unit,
onInput = (String) -> Unit
onInput = (String) -> Unit,
isReadOnly = Boolean
)
```

Original file line number Diff line number Diff line change
@@ -64,7 +64,8 @@ fun InputText(
focusRequester: FocusRequester = FocusRequester(),
keyboardAction: ImeAction = ImeAction.Next,
onKeyboardAction: () -> Unit = {},
onInput: (String) -> Unit = { input -> println("The input $input is typed") }
onInput: (String) -> Unit = { input -> println("The input $input is typed") },
isReadOnly : Boolean = false
) {
var input by remember { mutableStateOf(defaultInput) }
var passwordVisible by remember { mutableStateOf(false) }
@@ -123,6 +124,7 @@ fun InputText(
fontWeight = FontWeight.Normal,
color = inputColor
),
readOnly = isReadOnly,
modifier = Modifier
.fillMaxWidth()
.padding(
@@ -132,6 +134,7 @@ fun InputText(
.onFocusChanged { isFocused = it.isFocused }
.semantics { contentDescription = label }
.focusRequester(focusRequester)

)
}

@@ -212,7 +215,8 @@ fun InputTextPreview() {
defaultInput = "input",
labelSize = 14.sp,
inputSize = 16.sp,
focusRequester = test2FocusRequester
focusRequester = test2FocusRequester,
isReadOnly = true
)
Spacer(modifier = Modifier.height(16.dp))
InputText(

0 comments on commit 1023ab9

Please sign in to comment.