Skip to content

Commit f7670c4

Browse files
authored
Merge pull request #6633 from woocommerce/issue/6593-top-banner-voiceover-hint
Accessibility: Improve VoiceOver accessibility for top banner button
2 parents 4d33c0f + a9027a2 commit f7670c4

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [*] Share payment links from the order details screen. [https://github.com/woocommerce/woocommerce-ios/pull/6609]
77
- [internal] Reviews lists on Products and Menu tabs are refactored to avoid duplicated code. Please quickly smoke test them to make sure that everything still works as before. [https://github.com/woocommerce/woocommerce-ios/pull/6553]
88
- [**] Now it's possible to change the order of the product images. [https://github.com/woocommerce/woocommerce-ios/pull/6620]
9+
- [*] Improved accessibility for the error banner and info banner displayed in Orders and Products. [https://github.com/woocommerce/woocommerce-ios/pull/6633]
910

1011
8.9
1112
-----

WooCommerce/Classes/ViewRelated/Top Banner/TopBannerView.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ final class TopBannerView: UIView {
4444
return stackView
4545
}()
4646

47+
private let titleStackView: UIStackView = {
48+
let stackView = UIStackView()
49+
stackView.axis = .horizontal
50+
return stackView
51+
}()
52+
4753
// StackView to hold the action buttons. Needed to change the axis on larger accessibility traits
4854
private let buttonsStackView = UIStackView()
4955

@@ -126,6 +132,7 @@ private extension TopBannerView {
126132
dismissButton.setImage(UIImage.gridicon(.cross, size: CGSize(width: 24, height: 24)), for: .normal)
127133
dismissButton.tintColor = .textSubtle
128134
dismissButton.addTarget(self, action: #selector(onDismissButtonTapped), for: .touchUpInside)
135+
titleStackView.accessibilityHint = Localization.dismissHint
129136

130137
case .none:
131138
break
@@ -162,9 +169,12 @@ private extension TopBannerView {
162169

163170
func createInformationStackView(with viewModel: TopBannerViewModel) -> UIStackView {
164171
let topActionButton = topButton(for: viewModel.topButton)
165-
let titleStackView = UIStackView(arrangedSubviews: [titleLabel, topActionButton].compactMap { $0 })
166-
titleStackView.axis = .horizontal
172+
titleStackView.addArrangedSubviews([titleLabel, topActionButton].compactMap { $0 })
167173
titleStackView.spacing = 16
174+
titleStackView.isAccessibilityElement = true
175+
titleStackView.accessibilityTraits = .button
176+
titleStackView.accessibilityLabel = viewModel.title
177+
titleStackView.accessibilityIdentifier = topActionButton?.accessibilityIdentifier
168178

169179
// titleStackView will hidden if there is no title
170180
titleStackView.isHidden = viewModel.title == nil || viewModel.title?.isEmpty == true
@@ -287,8 +297,22 @@ private extension TopBannerView {
287297
if isActionEnabled {
288298
actionStackView.isHidden = !isExpanded
289299
}
300+
titleStackView.accessibilityHint = isExpanded ? Localization.collapseHint : Localization.expandHint
301+
titleStackView.accessibilityValue = isExpanded ? Localization.expanded : Localization.collapsed
290302

291303
let accessibleView = isExpanded ? infoLabel : nil
292304
UIAccessibility.post(notification: .layoutChanged, argument: accessibleView)
293305
}
294306
}
307+
308+
// MARK: Constants
309+
//
310+
private extension TopBannerView {
311+
enum Localization {
312+
static let expanded = NSLocalizedString("Expanded", comment: "Accessibility value when a banner is expanded")
313+
static let collapsed = NSLocalizedString("Collapsed", comment: "Accessibility value when a banner is collapsed")
314+
static let expandHint = NSLocalizedString("Double-tap for more information", comment: "Accessibility hint to expand a banner")
315+
static let collapseHint = NSLocalizedString("Double-tap to collapse", comment: "Accessibility hint to collapse a banner")
316+
static let dismissHint = NSLocalizedString("Double-tap to dismiss", comment: "Accessibility hint to dismiss a banner")
317+
}
318+
}

0 commit comments

Comments
 (0)