Skip to content

Commit

Permalink
moving item accessibility label to the label rather than the value
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalPineapple committed Mar 19, 2024
1 parent ef2bfab commit 5c68a31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions BlueprintUILists/Sources/ListReorderGesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct ListReorderGesture : Element
let actions : ReorderingActions

/// The acccessibility Label of the item that will be reordered.
/// This will be set as the gesture's accessibilityValue to provide a richer VoiceOver utterance.
/// This will be used to provide a richer VoiceOver utterance useful for disambiguation as to which element will br reordered.,
public var reorderItemAccessibilityLabel : String? = nil

/// Creates a new re-order gesture which wraps the provided element.
Expand Down Expand Up @@ -171,8 +171,12 @@ fileprivate extension ListReorderGesture
func apply(_ model: ListReorderGesture) {
blueprintView.element = model.element

proxyElement.accessibilityLabel = ListableLocalizedStrings.ReorderGesture.accessibilityLabel
proxyElement.accessibilityValue = model.reorderItemAccessibilityLabel
if let itemName = model.reorderItemAccessibilityLabel {
proxyElement.accessibilityLabel = String(format: ListableLocalizedStrings.ReorderGesture.accessibilityLabelFormat, itemName)
} else {
proxyElement.accessibilityLabel = ListableLocalizedStrings.ReorderGesture.accessibilityLabel
}

proxyElement.accessibilityHint = ListableLocalizedStrings.ReorderGesture.accessibilityHint
proxyElement.accessibilityTraits.formUnion(.button)
proxyElement.accessibilityCustomActions = model.accessibilityActions()
Expand Down
6 changes: 6 additions & 0 deletions ListableUI/Sources/ListableLocalizedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public struct ListableLocalizedStrings {
value: "Reorder",
comment: "Accessibility label for the reorder control on an item")

public static let accessibilityLabelFormat = NSLocalizedString("reorder.AccessibilityLabel",
tableName: nil,
bundle: .listableUIResources,
value: "Reorder %@",
comment: "Accessibility label for a reorder control with a provided name" )

public static let accessibilityHint = NSLocalizedString("reorder.AccessibilityHint",
tableName: nil,
bundle: .listableUIResources,
Expand Down

0 comments on commit 5c68a31

Please sign in to comment.