Skip to content

Commit

Permalink
Fix a bug in the unlock flow and add VoiceOver hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Oct 19, 2023
1 parent 8629a85 commit d95971a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"a11y_notifications_mentions_only" = "Mentions only";
"a11y_notifications_muted" = "Muted";
"a11y_pause" = "Pause";
"a11y_pin_field" = "PIN field";
"a11y_play" = "Play";
"a11y_poll" = "Poll";
"a11y_poll_end" = "Ended poll";
Expand Down
16 changes: 16 additions & 0 deletions ElementX/Resources/Localizations/en.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>a11y_digits_entered</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@COUNT@</string>
<key>COUNT</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%1$d digit entered</string>
<key>other</key>
<string>%1$d digits entered</string>
</dict>
</dict>
<key>common_member_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
Expand Down
10 changes: 8 additions & 2 deletions ElementX/Sources/FlowCoordinators/AppLockFlowCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
}

private func applicationWillEnterForeground() {
guard appLockService.isEnabled, appLockService.computeNeedsUnlock(willEnterForegroundAt: .now) else { return }
showUnlockScreen()
guard appLockService.isEnabled else { return }

if appLockService.computeNeedsUnlock(willEnterForegroundAt: .now) {
showUnlockScreen()
} else {
// Reveal the app again if within the grace period.
actionsSubject.send(.unlockApp)
}
}

/// Displays the unlock flow with the app's placeholder view to hide obscure the view hierarchy in the app switcher.
Expand Down
6 changes: 6 additions & 0 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import Foundation
public enum L10n {
/// Delete
public static var a11yDelete: String { return L10n.tr("Localizable", "a11y_delete") }
/// Plural format key: "%#@COUNT@"
public static func a11yDigitsEntered(_ p1: Int) -> String {
return L10n.tr("Localizable", "a11y_digits_entered", p1)
}
/// Hide password
public static var a11yHidePassword: String { return L10n.tr("Localizable", "a11y_hide_password") }
/// Mentions only
Expand All @@ -20,6 +24,8 @@ public enum L10n {
public static var a11yNotificationsMuted: String { return L10n.tr("Localizable", "a11y_notifications_muted") }
/// Pause
public static var a11yPause: String { return L10n.tr("Localizable", "a11y_pause") }
/// PIN field
public static var a11yPinField: String { return L10n.tr("Localizable", "a11y_pin_field") }
/// Play
public static var a11yPlay: String { return L10n.tr("Localizable", "a11y_play") }
/// Poll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct AppLockScreen: View {
/// Used to animate the PIN input field on failure.
@State private var pinInputFieldOffset = 0.0

/// A focus state to highlight a failed PIN entry in VoiceOver.
@AccessibilityFocusState private var accessibilitySubtitleFocus: Bool

var subtitleColor: Color {
context.viewState.isSubtitleWarning ? .compound.textCriticalPrimary : .compound.textPrimary
}
Expand All @@ -39,8 +42,11 @@ struct AppLockScreen: View {
.offset(x: pinInputFieldOffset)
.onChange(of: context.viewState.numberOfPINAttempts) { newValue in
guard newValue > 0 else { return } // Reset without animation in Previews.
accessibilitySubtitleFocus = true
Task { await animatePINFailure() }
}
.accessibilityLabel(L10n.a11yPinField)
.accessibilityValue(L10n.a11yDigitsEntered(context.viewState.numberOfDigitsEntered))

AppLockScreenPINKeypad(pinCode: $context.pinCode)
.onChange(of: context.pinCode) { newValue in
Expand All @@ -61,6 +67,7 @@ struct AppLockScreen: View {
VStack(spacing: 8) {
CompoundIcon(\.lock, size: .medium, relativeTo: .compound.headingMDBold)
.padding(.bottom, 8)
.accessibilityHidden(true)

Text(L10n.commonEnterYourPin)
.font(.compound.headingMDBold)
Expand All @@ -71,6 +78,7 @@ struct AppLockScreen: View {
.font(.compound.bodyMD)
.foregroundColor(subtitleColor)
.multilineTextAlignment(.center)
.accessibilityFocused($accessibilitySubtitleFocus)
}
}

Expand Down

0 comments on commit d95971a

Please sign in to comment.