Guy Bieber
08/13/2020, 6:53 PM@Composable
override fun TextFieldWithHint(
text: String,
hint: @Composable() () -> Unit,
onDone: (String) -> Unit,
backgroundColor: Color,
textColor : Color,
fontSize: TextUnit,
keyboardType: KeyboardType,
visualTransformation: VisualTransformation,
cursorColor : Color
) {
val state = state { TextFieldValue(text) } //, textRange) }
Surface(color = backgroundColor) { //}, border = Border(5.dp, Color.White)) {
//Row {
Box(
modifier = Modifier.fillMaxSize(),
padding = 10.dp,
gravity = ContentGravity.CenterStart
) { //, padding = 15.dp) {
Stack(Modifier.weight(1f)) {
TextField(
//modifier = Modifier.fillMaxSize(),
value = state.value,
textStyle = TextStyle (
color = textColor,
fontSize = fontSize
),
//textColor = textColor,
keyboardType = keyboardType,
imeAction = ImeAction.Done,
onValueChange = { state.value = it },
onImeActionPerformed = {
if (it == ImeAction.Done) {
//todo remove hack when android fixes it
//On older phones the shift key shows up as 00 in the string
val char : Char = 0x00.toChar()
var str = state.value.text.replace("${char}", "")
onDone(str) //.text.substring(state.value.selection))
hideKeyboard()
}
},
cursorColor = cursorColor,
visualTransformation = visualTransformation
)
if (state.value.text.isEmpty()) hint()
}
}
}
}
Alexandre Elias [G]
08/17/2020, 7:14 PMFocusRequester
~finalized in the upcoming dev17 release (already available in snapshot dailies). The current way to remove focus is to attach a new Focus
modifier on some random non-text composable and then invoke a FocusRequester
on it. (We also have plans to introduce a simpler "clear the focus" API later.)Alexandre Elias [G]
08/17/2020, 7:15 PM