Add an eye button to show the recovery key while entering it

The recovery key field now uses Compound's secure text field style, which
adds the show/hide button Android already has. Autocapitalisation and
autocorrection are off so a revealed key isn't altered while typing.

Compound's eye icon now shows a crossed eye while the text is hidden and an
open eye while it's shown, matching Android and Compound web.
This commit is contained in:
Mauro Romito
2026-10-19 12:58:59 +02:00
committed by Mauro
parent 2fb5c4c316
commit 155e478a77
8 changed files with 25 additions and 37 deletions
@@ -178,31 +178,19 @@ struct SecureBackupRecoveryKeyScreen: View {
}
private var confirmRecoveryKeySection: some View {
VStack(alignment: .leading, spacing: 8) {
Text(L10n.commonRecoveryKey)
.foregroundColor(.compound.textPrimary)
.font(.compound.bodySMSemibold)
SecureField(L10n.screenRecoveryKeyConfirmKeyPlaceholder, text: $context.confirmationRecoveryKey)
.tint(.compound.iconAccentTertiary)
.frame(maxWidth: .infinity)
.padding()
.background(Color.compound.bgSubtleSecondaryLevel0)
.clipShape(RoundedRectangle(cornerRadius: 8))
.id(textFieldIdentifier)
.focused($focused)
.submitLabel(.done)
.onSubmit {
context.send(viewAction: .confirmKey)
}
.accessibilityIdentifier(A11yIdentifiers.secureBackupRecoveryKeyScreen.recoveryKeyField)
if let subtitle = context.viewState.recoveryKeySubtitle {
Text(subtitle)
.foregroundColor(.compound.textSecondary)
.font(.compound.bodySM)
SecureField(L10n.screenRecoveryKeyConfirmKeyPlaceholder, text: $context.confirmationRecoveryKey)
.focused($focused)
.textFieldStyle(.compound(.plain(.secure(hideLabel: L10n.a11yHidePassword, showLabel: L10n.a11yShowPassword)),
labelText: L10n.commonRecoveryKey,
footerText: context.viewState.recoveryKeySubtitle,
accessibilityIdentifier: A11yIdentifiers.secureBackupRecoveryKeyScreen.recoveryKeyField))
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.submitLabel(.done)
.onSubmit {
context.send(viewAction: .confirmKey)
}
}
.id(textFieldIdentifier)
}
}
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:03c010893b3c40f14511b72f8e950ec51058103e19abf8c41a80931f1763054a
size 104073
oid sha256:4793acf1bdd66bcd53e80b406533c36c6d24fbe4c94465d3ef36d4ca91e3515c
size 106814
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:437e550de3c9ec1e6d64bd74e82f17c8b35b927fcf47033a0ebce4f2ce822e4d
size 117963
oid sha256:08b20475356dc4a07c98b807d76a9774e72b7c0917ee1283efd5c4c379eecc89
size 121744
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:23e99c6685ab645c5edb3005e171218d96abeef1d955da17aab112330116e9b6
size 60688
oid sha256:b49168b74b4db5b175c6bee22a45809ce444beb10725045d987d73e9cc91525a
size 62958
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f7b6bea3f15bb8b30731a2e48b4084538290f6d3e70733eaf7c8174bc490fcd8
size 80957
oid sha256:125c57f171d1a4178d645de5e6e47c92763fdf0868871f15e78a181b84bd1ab5
size 84092
@@ -233,7 +233,7 @@ public struct CompoundTextFieldStyle: @MainActor TextFieldStyle {
isSecureTextRevealed.toggle()
secureTextField?.isSecureTextEntry = !isSecureTextRevealed
} label: {
CompoundIcon(isSecureTextRevealed ? \.visibilityOff : \.visibilityOn,
CompoundIcon(isSecureTextRevealed ? \.visibilityOn : \.visibilityOff,
size: .medium,
relativeTo: .compound.bodyLG)
.foregroundStyle(.compound.iconSecondary)
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dbd4787ecee53978e01e90782f8e8704a424b486ed27f06fece2e5e5113b86aa
size 241919
oid sha256:b57abd80aba38391fbbd911f786fed1836caa60ffa3dd7af715472f44bc2b3de
size 242911
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:60ee1c44ab8ed1895c529c2c4d1bb749e6f71f73b3adbff2a67d0965c63af807
size 150593
oid sha256:f53a05a7d169748808ffeb7869dc84846bf30371c7800087b3b1ad6a17d26b24
size 151511