updated helper

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-06-29 10:24:28 -05:00
parent f6287df8f4
commit 90e88f37da
2 changed files with 8 additions and 8 deletions

View File

@ -414,7 +414,7 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
/// Used to update any Accessibility properties. /// Used to update any Accessibility properties.
open override var accessibilityElements: [Any]? { open override var accessibilityElements: [Any]? {
get { get {
var views = [UIView]() var views = [AnyObject]()
// grab the available views in order // grab the available views in order
if badgeModel != nil { if badgeModel != nil {
@ -422,9 +422,9 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
} }
if titleModel != nil || subTitleModel != nil || eyebrowModel != nil { if titleModel != nil || subTitleModel != nil || eyebrowModel != nil {
views.append(titleLockup) let titleLockupViews = gatherAccessibilityElements(from: titleLockup)
views.append(contentsOf: titleLockupViews)
} }
containerView.setAccessibilityLabel(for: views) containerView.setAccessibilityLabel(for: views)
// get the views to return // get the views to return

View File

@ -14,14 +14,14 @@ extension UIView {
/// - views: Array of Views that you want to join the accessibilityLabel. /// - views: Array of Views that you want to join the accessibilityLabel.
/// - separator: Separator used between the accessibilityLabel for each UIView. /// - separator: Separator used between the accessibilityLabel for each UIView.
/// - Returns: Joined String. /// - Returns: Joined String.
public func combineAccessibilityLabel(for views: [UIView], separator: String = ", ") -> String? { public func combineAccessibilityLabel(for views: [AnyObject], separator: String = ", ") -> String? {
let labels = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0}) let labels: [String] = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0})
return labels.joined(separator: separator) return labels.joined(separator: separator)
} }
/// AccessibilityLabel helper for joining the accessibilityLabel property of all views passed in. /// AccessibilityLabel helper for joining the accessibilityLabel property of all views passed in.
/// - Parameter views: Array of Views that you want to join the accessibilityLabel. /// - Parameter views: Array of Views that you want to join the accessibilityLabel.
public func setAccessibilityLabel(for views: [UIView]) { public func setAccessibilityLabel(for views: [AnyObject]) {
accessibilityLabel = combineAccessibilityLabel(for: views) accessibilityLabel = combineAccessibilityLabel(for: views)
} }
@ -50,8 +50,8 @@ extension UIView {
return isIntersecting return isIntersecting
} }
public func gatherAccessibilityElements(from view: UIView) -> [Any] { public func gatherAccessibilityElements(from view: AnyObject) -> [AnyObject] {
var elements: [Any] = [] var elements: [AnyObject] = []
for subview in view.subviews { for subview in view.subviews {
if subview.isAccessibilityElement && subview.isVisibleOnScreen { if subview.isAccessibilityElement && subview.isVisibleOnScreen {