From 3733ee7e802361fa5be553ff67565cf21cd81b9b Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 24 Oct 2023 11:30:43 +0200 Subject: [PATCH] PinEntryTextField : add isSecured parameter --- .../impl/components/PinEntryTextField.kt | 16 ++++++++++++---- .../lockscreen/impl/setup/SetupPinView.kt | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/components/PinEntryTextField.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/components/PinEntryTextField.kt index a8e2b896f6..017a926b61 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/components/PinEntryTextField.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/components/PinEntryTextField.kt @@ -30,7 +30,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.dp import io.element.android.features.lockscreen.impl.pin.model.PinDigit import io.element.android.features.lockscreen.impl.pin.model.PinEntry @@ -42,6 +41,7 @@ import io.element.android.libraries.theme.ElementTheme @Composable fun PinEntryTextField( pinEntry: PinEntry, + isSecured: Boolean, onValueChange: (String) -> Unit, modifier: Modifier = Modifier, ) { @@ -53,7 +53,7 @@ fun PinEntryTextField( }, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword), decorationBox = { - PinEntryRow(pinEntry = pinEntry) + PinEntryRow(pinEntry = pinEntry, isSecured = isSecured) } ) } @@ -61,6 +61,7 @@ fun PinEntryTextField( @Composable private fun PinEntryRow( pinEntry: PinEntry, + isSecured: Boolean, modifier: Modifier = Modifier, ) { Row( @@ -69,7 +70,7 @@ private fun PinEntryRow( verticalAlignment = Alignment.CenterVertically, ) { for (digit in pinEntry.digits) { - PinDigitView(digit = digit) + PinDigitView(digit = digit, isSecured = isSecured) } } } @@ -77,6 +78,7 @@ private fun PinEntryRow( @Composable private fun PinDigitView( digit: PinDigit, + isSecured: Boolean, modifier: Modifier = Modifier, ) { val shape = RoundedCornerShape(8.dp) @@ -96,8 +98,13 @@ private fun PinDigitView( ) { if (digit is PinDigit.Filled) { + val text = if(isSecured) { + "•" + } else { + digit.value.toString() + } Text( - text = digit.toText(), + text = text, style = ElementTheme.typography.fontHeadingMdBold ) } @@ -111,6 +118,7 @@ internal fun PinEntryTextFieldPreview() { ElementPreview { PinEntryTextField( pinEntry = PinEntry.createEmpty(4).fillWith("12"), + isSecured = true, onValueChange = {}, ) } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/SetupPinView.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/SetupPinView.kt index b2174d2233..537a90d0b6 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/SetupPinView.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/SetupPinView.kt @@ -114,7 +114,8 @@ private fun SetupPinContent( focusRequester.requestFocus() } PinEntryTextField( - state.activePinEntry, + pinEntry = state.activePinEntry, + isSecured = true, onValueChange = { state.eventSink(SetupPinEvents.OnPinEntryChanged(it)) },