iamthevoid
07/23/2021, 10:11 AMthe picture from internets▾
iamthevoid
07/23/2021, 10:20 AMLocalTextInputService.current
Looks like it is what am i looking foriamthevoid
07/23/2021, 10:20 AMiamthevoid
07/23/2021, 10:32 AMimeOptions
exactly what i am looking for! Thanks everybody )Albert Chang
07/23/2021, 12:04 PMthat▾
iamthevoid
07/23/2021, 12:08 PMJeff
07/23/2021, 3:10 PMiamthevoid
07/23/2021, 3:18 PMiamthevoid
07/26/2021, 7:31 AM@Composable
fun CodeDots(
state: CodeState,
onCodeChange: (String) -> Unit,
onCodeCompleted: (CodeState) -> Unit,
modifier: Modifier = Modifier
) {
val focusRequester = remember { FocusRequester() }
RequestFocusOnStart(focusRequester = focusRequester)
Box(
modifier = modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = focusRequester::requestFocus
),
contentAlignment = Alignment.Center
) {
BasicTextField(
value = state.code,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword),
onValueChange = {
filterInput(it, state.codeLength).also { code ->
onCodeChange(code)
if (code.length == state.codeLength) {
onCodeCompleted(state.copy(code = code))
}
}
},
textStyle = TextStyle.Default.copy(color = Color.Transparent),
modifier = Modifier.focusRequester(focusRequester),
cursorBrush = SolidColor(Color.Transparent)
)
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
for (i in 0 until state.codeLength) {
Element(char = state.code.getOrNull(i), error = state.error)
}
}
}
}
Nipun Rajput
07/26/2021, 8:23 AMiamthevoid
07/26/2021, 8:26 AMNipun Rajput
07/26/2021, 8:26 AMNipun Rajput
07/26/2021, 8:27 AMJeff
07/26/2021, 11:00 AM