Prashant Priyadarshi
11/28/2020, 2:01 PM@Composable
fun inputTextField(value : MutableState<String> = mutableStateOf(""),
modifier: Modifier = Modifier, onChange : (String)-> Unit= {}) {
Box(modifier = modifier, children = {
TextField(
value = value.value,
onValueChange = { newValue ->
value.value = newValue
onChange(newValue)
},
backgroundColor = Color.White,
modifier = Modifier.fillMaxWidth(0.75f).preferredHeight(35.dp)
.align(Alignment.CenterStart),
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Send,
onImeActionPerformed = { action: ImeAction,
keyboard: SoftwareKeyboardController? ->
keyboard?.hideSoftwareKeyboard()
},
placeholder = {
Text(
text = "some text", color = MaterialDesignColors.grey800,
modifier = Modifier.align(Alignment.TopStart)
)
},
trailingIcon = {
if (value.value.isNotBlank())
Icon(
asset = Outlined.Close,
modifier = Modifier.align(Alignment.CenterEnd)
// .padding(end = 5.dp)
.clickable(onClick = {
value.value = ""
onChange("")
})
)
}
)
})
}
None of the following functions can be called with the arguments supplied:
public fun TextField(value: TextFieldValue, onValueChange: (TextFieldValue) -> Unit, modifier: Modifier = ..., textStyle: TextStyle = ..., label: (() -> Unit)? = ..., placeholder: (() -> Unit)? = ..., leadingIcon: (() -> Unit)? = ..., trailingIcon: (() -> Unit)? = ..., isErrorValue: Boolean = ..., visualTransformation: VisualTransformation = ..., keyboardOptions: KeyboardOptions = ..., maxLines: Int = ..., onImeActionPerformed: (ImeAction, SoftwareKeyboardController?) -> Unit = ..., onTextInputStarted: (SoftwareKeyboardController) -> Unit = ..., interactionState: InteractionState = ..., activeColor: Color = ..., inactiveColor: Color = ..., errorColor: Color = ..., backgroundColor: Color = ..., shape: Shape = ...): Unit defined in androidx.compose.material
public fun TextField(value: String, onValueChange: (String) -> Unit, modifier: Modifier = ..., textStyle: TextStyle = ..., label: (() -> Unit)? = ..., placeholder: (() -> Unit)? = ..., leadingIcon: (() -> Unit)? = ..., trailingIcon: (() -> Unit)? = ..., isErrorValue: Boolean = ..., visualTransformation: VisualTransformation = ..., keyboardOptions: KeyboardOptions = ..., maxLines: Int = ..., onImeActionPerformed: (ImeAction, SoftwareKeyboardController?) -> Unit = ..., onTextInputStarted: (SoftwareKeyboardController) -> Unit = ..., interactionState: InteractionState = ..., activeColor: Color = ..., inactiveColor: Color = ..., errorColor: Color = ..., backgroundColor: Color = ..., shape: Shape = ...): Unit defined in androidx.compose.material
spierce7
11/28/2020, 2:46 PMAlexander Sitnikov
11/28/2020, 6:30 PMkeyboardType
and imeAction
with single parameter keyboardOptions
. These parameters were recently extracted to new KeyboardOptions
class
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Send,
),