Skip to content

Commit 1023ab9

Browse files
authored
feat(isReadOnly): make the InputText read only if needed Android_side… (#34)
1 parent f59ab00 commit 1023ab9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ InputText(
215215
focusRequester = FocusRequester,
216216
keyboardAction = ImeAction,
217217
onKeyboardAction = () -> Unit,
218-
onInput = (String) -> Unit
218+
onInput = (String) -> Unit,
219+
isReadOnly = Boolean
219220
)
220221
```
221222

xpeho_ui_android/src/main/java/com/xpeho/xpeho_ui_android/InputText.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ fun InputText(
6464
focusRequester: FocusRequester = FocusRequester(),
6565
keyboardAction: ImeAction = ImeAction.Next,
6666
onKeyboardAction: () -> Unit = {},
67-
onInput: (String) -> Unit = { input -> println("The input $input is typed") }
67+
onInput: (String) -> Unit = { input -> println("The input $input is typed") },
68+
isReadOnly : Boolean = false
6869
) {
6970
var input by remember { mutableStateOf(defaultInput) }
7071
var passwordVisible by remember { mutableStateOf(false) }
@@ -123,6 +124,7 @@ fun InputText(
123124
fontWeight = FontWeight.Normal,
124125
color = inputColor
125126
),
127+
readOnly = isReadOnly,
126128
modifier = Modifier
127129
.fillMaxWidth()
128130
.padding(
@@ -132,6 +134,7 @@ fun InputText(
132134
.onFocusChanged { isFocused = it.isFocused }
133135
.semantics { contentDescription = label }
134136
.focusRequester(focusRequester)
137+
135138
)
136139
}
137140

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

0 commit comments

Comments
 (0)