@@ -3,53 +3,14 @@ package me.ash.reader.ui.component.base
33import androidx.compose.foundation.layout.Column
44import androidx.compose.foundation.layout.Spacer
55import androidx.compose.foundation.layout.height
6- import androidx.compose.foundation.text.KeyboardActionScope
76import androidx.compose.foundation.text.KeyboardOptions
87import androidx.compose.foundation.text.input.KeyboardActionHandler
98import androidx.compose.foundation.text.input.TextFieldState
109import androidx.compose.runtime.Composable
1110import androidx.compose.ui.Modifier
12- import androidx.compose.ui.focus.FocusManager
1311import androidx.compose.ui.text.input.ImeAction
1412import androidx.compose.ui.unit.dp
1513
16- @Deprecated(" Use overloads with state instead" )
17- @Composable
18- fun ClipboardTextField (
19- modifier : Modifier = Modifier ,
20- readOnly : Boolean = false,
21- value : String = "",
22- singleLine : Boolean = true,
23- onValueChange : (String ) -> Unit = {},
24- placeholder : String = "",
25- isPassword : Boolean = false,
26- errorText : String = "",
27- imeAction : ImeAction = ImeAction .Done ,
28- focusManager : FocusManager ? = null,
29- onConfirm : (String ) -> Unit = {},
30- ) {
31- Column (modifier = modifier) {
32- Spacer (modifier = Modifier .height(10 .dp))
33- RYTextField2 (
34- readOnly = readOnly,
35- value = value,
36- singleLine = singleLine,
37- onValueChange = onValueChange,
38- placeholder = placeholder,
39- isPassword = isPassword,
40- errorMessage = errorText,
41- onKeyboardAction = if (imeAction != ImeAction .Default || imeAction != ImeAction .None ) {
42- KeyboardActionHandler { action(focusManager, onConfirm, value) }
43- } else null ,
44- keyboardOptions = KeyboardOptions (
45- imeAction = imeAction
46- ),
47- )
48- Spacer (modifier = Modifier .height(10 .dp))
49- }
50- }
51-
52-
5314@Composable
5415fun ClipboardTextField (
5516 state : TextFieldState ,
@@ -60,7 +21,6 @@ fun ClipboardTextField(
6021 isPassword : Boolean = false,
6122 errorText : String = "",
6223 imeAction : ImeAction = ImeAction .Done ,
63- focusManager : FocusManager ? = null,
6424 onConfirm : (String ) -> Unit = {},
6525) {
6626 Column (modifier = modifier) {
@@ -72,22 +32,12 @@ fun ClipboardTextField(
7232 placeholder = placeholder,
7333 isPassword = isPassword,
7434 errorMessage = errorText,
75- onKeyboardAction = if (imeAction != ImeAction .Default || imeAction != ImeAction .None ) {
76- KeyboardActionHandler { action(focusManager, onConfirm, state.text.toString()) }
77- } else null ,
78- keyboardOptions = KeyboardOptions (
79- imeAction = imeAction
80- ),
35+ onKeyboardAction =
36+ if (imeAction != ImeAction .Default || imeAction != ImeAction .None ) {
37+ KeyboardActionHandler { onConfirm(state.text.toString()) }
38+ } else null ,
39+ keyboardOptions = KeyboardOptions (imeAction = imeAction),
8140 )
8241 Spacer (modifier = Modifier .height(10 .dp))
8342 }
8443}
85-
86- private fun action (
87- focusManager : FocusManager ? ,
88- onConfirm : (String ) -> Unit ,
89- value : String ,
90- ): KeyboardActionScope .() -> Unit = {
91- focusManager?.clearFocus()
92- onConfirm(value)
93- }
0 commit comments