Guy Bieber
07/15/2020, 8:42 PM@Composable
override fun TextFieldStyled(
text: String,
onDone: (String) -> Unit,
//,hint: String = "enter value"
backgroundColor: Color,
textColor : Color,
height: Dp,
keyboardType: KeyboardType,
visualTransformation: VisualTransformation,
cursorColor : Color
) {
//val state = +state { "" }
//state.value = if (loginInput.usernameEntered) loginInput.username else hint
val state = state { TextFieldValue(text) }
Surface(color = backgroundColor) { //}, border = Border(5.dp, Color.White)) {
//Row {
Box(
modifier = Modifier.fillMaxSize(),
padding = 10.dp,
gravity = ContentGravity.CenterStart
) { //, padding = 15.dp) {
//drawClip(shape = RoundedCornerShape(15.dp)) {
//Padding(padding = 15.dp) {
TextField(
//modifier = Modifier.fillMaxSize(),
value = state.value,
textColor = textColor,
keyboardType = keyboardType,
imeAction = ImeAction.Done,
onValueChange = { state.value = it },
onImeActionPerformed = {
if (it == ImeAction.Done) {
onDone(state.value.text)// .substring(state.value.selection))
hideKeyboard()
}
},
cursorColor = cursorColor,
visualTransformation = visualTransformation
)
//}
}
}
}
state.value.text or state.value.text.substring(state.value.selection) don’t just give me the edited string. Grrr…
TextFieldValue(text=BIEB, selection=TextRange(start=4, end=4))
TextFieldValue(text=����BIEBER, selection=TextRange(start=8, end=8))
Some new data. The problem only occurs on an older phone using API 24. It looks like Shift keys are stored in the string as 00.