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

[A11y][VoiceOver] Set accessibility value for the sheet expansion state #2101

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
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 @@ -174,15 +174,15 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
/// The message should convey the "Expand" action and will be used when the bottom sheet is collapsed.
@objc public var handleExpandCustomAccessibilityLabel: String? {
didSet {
updateResizingHandleViewAccessibility()
updateResizingHandleViewAccessibility(for: currentExpansionState)
}
}

/// A string to optionally customize the accessibility label of the bottom sheet handle.
/// The message should convey the "Collapse" action and will be used when the bottom sheet is expanded.
@objc public var handleCollapseCustomAccessibilityLabel: String? {
didSet {
updateResizingHandleViewAccessibility()
updateResizingHandleViewAccessibility(for: currentExpansionState)
}
}

Expand Down Expand Up @@ -496,6 +496,8 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
super.viewDidAppear(animated)

tokenSet.update(fluentTheme)

updateResizingHandleViewAccessibility(for: currentExpansionState)
}

public override func viewDidLayoutSubviews() {
Expand Down Expand Up @@ -523,6 +525,7 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
collapsedHeightInSafeArea = view.safeAreaLayoutGuide.layoutFrame.maxY - offset(for: .collapsed)

updateAppearance()

super.viewDidLayoutSubviews()
}

Expand Down Expand Up @@ -667,13 +670,15 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
move(to: isExpanded ? .collapsed : .expanded, interaction: .resizingHandleTap)
}

private func updateResizingHandleViewAccessibility() {
if currentExpansionState == .expanded {
private func updateResizingHandleViewAccessibility(for state: BottomSheetExpansionState) {
nodes11 marked this conversation as resolved.
Show resolved Hide resolved
if state == .expanded {
resizingHandleView.accessibilityLabel = handleCollapseCustomAccessibilityLabel ?? "Accessibility.Drawer.ResizingHandle.Label.Collapse".localized
resizingHandleView.accessibilityHint = "Accessibility.Drawer.ResizingHandle.Hint.Collapse".localized
} else {
resizingHandleView.accessibilityValue = "Accessibility.Drawer.ResizingHandle.Value.Expanded".localized
} else if state == .collapsed {
resizingHandleView.accessibilityLabel = handleExpandCustomAccessibilityLabel ?? "Accessibility.Drawer.ResizingHandle.Label.Expand".localized
resizingHandleView.accessibilityHint = "Accessibility.Drawer.ResizingHandle.Hint.Expand".localized
resizingHandleView.accessibilityValue = "Accessibility.Drawer.ResizingHandle.Value.Collapsed".localized
}
}

Expand Down Expand Up @@ -933,6 +938,8 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr

completeAnimationsIfNeeded()

updateResizingHandleViewAccessibility(for: targetExpansionState)

if currentSheetVerticalOffset != offset(for: targetExpansionState) {
delegate?.bottomSheetController?(self, willMoveTo: targetExpansionState, interaction: interaction)

Expand Down Expand Up @@ -1173,11 +1180,7 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr

private var currentStateChangeAnimator: UIViewPropertyAnimator?

private var currentExpansionState: BottomSheetExpansionState = .collapsed {
didSet {
updateResizingHandleViewAccessibility()
}
}
private var currentExpansionState: BottomSheetExpansionState = .collapsed

private var targetExpansionState: BottomSheetExpansionState?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@
"Accessibility.Drawer.ResizingHandle.Label.Expand" = "Expand";
/* Accessibility hint for drawer's resizing handle when it has expand action */
"Accessibility.Drawer.ResizingHandle.Hint.Expand" = "Double tap to expand";
/* Accessibility value for drawer's resizing handle when the sheet is in a collapsed state */
"Accessibility.Drawer.ResizingHandle.Value.Collapsed" = "Collapsed";
/* Accessibility label for drawer's resizing handle when it has collapse action */
"Accessibility.Drawer.ResizingHandle.Label.Collapse" = "Collapse";
/* Accessibility hint for drawer's resizing handle when it has collapse action */
"Accessibility.Drawer.ResizingHandle.Hint.Collapse" = "Double tap to collapse";
/* Accessibility value for drawer's resizing handle when the sheet is in a expanded state */
"Accessibility.Drawer.ResizingHandle.Value.Expanded" = "Expanded";

/* Accessibility label for when a task under progress has finished */
"Accessibility.HUD.Done" = "Done";
Expand Down
Loading