Siyamed
09/01/2020, 10:55 PMGuy Bieber
09/01/2020, 11:02 PMSiyamed
09/01/2020, 11:07 PMGuy Bieber
09/01/2020, 11:15 PMSiyamed
09/01/2020, 11:19 PMGuy Bieber
09/01/2020, 11:25 PM@Composable
fun TextFieldWithHint(
text: String,
hint: @Composable() () -> Unit,
onDone: (String) -> Unit = {},
backgroundColor: Color = nikolaColors.color19,
textColor : Color = nikolaColors.White,
fontSize : TextUnit = 18.sp,
trailingIcon: @Composable (() -> Unit)? = null,
keyboardType: KeyboardType = KeyboardType.Text,
visualTransformation: VisualTransformation = VisualTransformation.None,
cursorColor : Color = nikolaColors.White
) {
val mText =
savedInstanceState(saver = TextFieldValue.Saver) { TextFieldValue(text) }
OutlinedTextField(
value = mText.value,
label = hint,
textStyle = TextStyle (
color = textColor,
fontSize = fontSize
),
keyboardType = keyboardType,
imeAction = ImeAction.Done,
trailingIcon = trailingIcon,
onValueChange = {
mText.value = it
},
onImeActionPerformed = { action, softKeyboard ->
if (action == 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 = mText.value.text.replace("${char}", "")
onDone(str)
hideKeyboard()
}
},
activeColor = cursorColor,
visualTransformation = visualTransformation
)
}
Siyamed
09/01/2020, 11:30 PMGuy Bieber
09/01/2020, 11:41 PM