PIN : fix some pin setup related code
This commit is contained in:
@@ -47,11 +47,11 @@ fun PinEntryTextField(
|
||||
) {
|
||||
BasicTextField(
|
||||
modifier = modifier,
|
||||
value = TextFieldValue(pinEntry.toText()),
|
||||
value = pinEntry.toText(),
|
||||
onValueChange = {
|
||||
onValueChange(it.text)
|
||||
onValueChange(it)
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword),
|
||||
decorationBox = {
|
||||
PinEntryRow(pinEntry = pinEntry)
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ data class PinEntry(
|
||||
* @return the new PinEntry
|
||||
*/
|
||||
fun fillWith(text: String): PinEntry {
|
||||
val newDigits = digits.toMutableList()
|
||||
val newDigits = MutableList<PinDigit>(size) { PinDigit.Empty }
|
||||
text.forEachIndexed { index, char ->
|
||||
if (index < size) {
|
||||
if (index < size && char.isDigit()) {
|
||||
newDigits[index] = PinDigit.Filled(char)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class SetupPinNode @AssistedInject constructor(
|
||||
val state = presenter.present()
|
||||
SetupPinView(
|
||||
state = state,
|
||||
onBackClicked = { },
|
||||
onBackClicked = this::navigateUp,
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
||||
@@ -29,8 +29,12 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -105,12 +109,17 @@ private fun SetupPinContent(
|
||||
state: SetupPinState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) {
|
||||
focusRequester.requestFocus()
|
||||
}
|
||||
PinEntryTextField(
|
||||
state.activePinEntry,
|
||||
onValueChange = {
|
||||
state.eventSink(SetupPinEvents.OnPinEntryChanged(it))
|
||||
},
|
||||
modifier = modifier
|
||||
.focusRequester(focusRequester)
|
||||
.padding(top = 36.dp)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user