Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP DNR] Support the private back button trait #217

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ extension NSObject {
}

let hidesButtonTraitInContext = context?.hidesButtonTrait ?? false
let hidesButtonTraitFromTraits = [UIAccessibilityTraits.keyboardKey, .switchButton, .tabBarItem].contains(where: { accessibilityTraits.contains($0) })
let hidesButtonTraitFromTraits = [UIAccessibilityTraits.keyboardKey, .switchButton, .tabBarItem, .backButton].contains(where: { accessibilityTraits.contains($0) })
if accessibilityTraits.contains(.button) && !hidesButtonTraitFromTraits && !hidesButtonTraitInContext {
traitSpecifiers.append(strings.buttonTraitName)
}

if accessibilityTraits.contains(.backButton) {
traitSpecifiers.append(strings.backButtonTraitName)
}

if accessibilityTraits.contains(.switchButton) {
if accessibilityTraits.contains(.button) {
Expand Down Expand Up @@ -319,6 +323,8 @@ extension NSObject {
let notEnabledTraitName: String

let buttonTraitName: String

let backButtonTraitName: String

let tabTraitName: String

Expand Down Expand Up @@ -399,6 +405,11 @@ extension NSObject {
comment: "Description for the 'button' accessibility trait",
locale: locale
)
self.backButtonTraitName = "Back Button.".localized(
key: "trait.backbutton.description",
comment: "Description for the 'back button' accessibility trait",
locale: locale
)
self.tabTraitName = "Tab.".localized(
key: "trait.tab.description",
comment: "Description for the 'tab' accessibility trait",
Expand Down Expand Up @@ -580,6 +591,9 @@ extension UIAccessibilityTraits {
static let textEntry = UIAccessibilityTraits(rawValue: 0x0000000000040000)

static let scrollable = UIAccessibilityTraits(rawValue: 0x0000800000000000)

/// A private trait that UIKit uses internally for the back button in `UINavigationController` hierachies.
static let backButton = UIAccessibilityTraits(rawValue: 0x0000000008000000)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: convert this (and the others) to bitmask style 1 << X

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Convert to 1 << X style

}

// MARK: -
Expand Down
Loading