Improve preview.

This commit is contained in:
Benoit Marty
2026-07-02 15:38:53 +02:00
parent 25716f6f3a
commit bf1ace48f2
@@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.BasicTextField
@@ -50,8 +49,9 @@ fun PinEntryTextField(
isSecured: Boolean, isSecured: Boolean,
onValueChange: (String) -> Unit, onValueChange: (String) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
initialIsFocus: Boolean = false,
) { ) {
var isFocused by remember { mutableStateOf(false) } var isFocused by remember { mutableStateOf(initialIsFocus) }
val filledCount = pinEntry.digits.count { it is PinDigit.Filled } val filledCount = pinEntry.digits.count { it is PinDigit.Filled }
val pinFieldLabel = stringResource(CommonStrings.a11y_pin_field) val pinFieldLabel = stringResource(CommonStrings.a11y_pin_field)
val digitsEnteredLabel = pluralStringResource(CommonPlurals.a11y_digits_entered, filledCount, filledCount) val digitsEnteredLabel = pluralStringResource(CommonPlurals.a11y_digits_entered, filledCount, filledCount)
@@ -137,18 +137,19 @@ private fun PinDigitView(
internal fun PinEntryTextFieldPreview() { internal fun PinEntryTextFieldPreview() {
ElementPreview { ElementPreview {
val pinEntry = PinEntry.createEmpty(4).fillWith("12") val pinEntry = PinEntry.createEmpty(4).fillWith("12")
Column { Column(
PinEntryTextField( verticalArrangement = Arrangement.spacedBy(16.dp),
pinEntry = pinEntry, ) {
isSecured = true, listOf(true, false).forEach { isSecured ->
onValueChange = {}, listOf(true, false).forEach { initialIsFocus ->
) PinEntryTextField(
Spacer(modifier = Modifier.size(16.dp)) pinEntry = pinEntry,
PinEntryTextField( isSecured = isSecured,
pinEntry = pinEntry, initialIsFocus = initialIsFocus,
isSecured = false, onValueChange = {},
onValueChange = {}, )
) }
}
} }
} }
} }