Skip to content

Commit

Permalink
fix accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimet-livefront committed Nov 22, 2024
1 parent 99008ad commit ac4c3e2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct ProfileSwitcherRow: View {
)
)
}
.onLongPressGesture(if: store.state.allowLockAndLogout) {
.onLongPressGesture(if: store.state.allowLock || store.state.allowLogout) {
await store.perform(
.longPressed(
isSelected
Expand All @@ -227,13 +227,13 @@ struct ProfileSwitcherRow: View {
await store.perform(.accessibility(.select(profileSwitcherItem)))
}
.conditionalAccessibilityAsyncAction(
if: store.state.allowLockAndLogout,
if: store.state.allowLock,
named: Localizations.lock
) {
await store.perform(.accessibility(.lock(profileSwitcherItem)))
}
.conditionalAccessibilityAction(
if: store.state.allowLockAndLogout,
if: store.state.allowLogout,
named: Localizations.logOut
) {
store.send(.accessibility(.logout(profileSwitcherItem)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ struct ProfileSwitcherRowState: Equatable {
case alternate(ProfileSwitcherItem)
}

/// Should the row allow lock and logout?
var allowLockAndLogout: Bool = true
/// Should the row allow lock.
var allowLock: Bool = true

/// Should the row allow logout.
var allowLogout: Bool = true

/// A flag for tracking accessibility focus
var shouldTakeAccessibilityFocus: Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ struct ProfileSwitcherView: View {
store: store.child(
state: { _ in
ProfileSwitcherRowState(
allowLockAndLogout: store.state.allowLockAndLogout,
allowLock: accountProfile.canBeLocked,
allowLogout: store.state.allowLockAndLogout,
shouldTakeAccessibilityFocus: store.state.isVisible
&& isActive,
showDivider: showDivider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ProfileSwitcherViewTests: BitwardenTestCase { // swiftlint:disable:this ty
@MainActor
func test_accountRow_longPress_currentAccount_noLockOrLogout() throws {
processor.state.allowLockAndLogout = false
processor.state.accounts[0].canBeLocked = false
let accountRow = try subject.inspect().find(button: "[email protected]")
XCTAssertThrowsError(try accountRow.labelView().recursiveCallOnLongPressGesture())
}
Expand Down Expand Up @@ -106,6 +107,7 @@ class ProfileSwitcherViewTests: BitwardenTestCase { // swiftlint:disable:this ty
@MainActor
func test_alternateAccountRow_longPress_currentAccount_noLockOrLogout() throws {
let alternate = ProfileSwitcherItem.fixture(
canBeLocked: false,
email: "[email protected]",
userInitials: "NA"
)
Expand Down

0 comments on commit ac4c3e2

Please sign in to comment.