From 843616f75570b34002f944f9b0d0f7c458171b83 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 12 Jun 2020 15:53:18 -0400 Subject: [PATCH] right variable changes --- .../List/ListProgressBarThin.swift | 5 +- .../List/RightVariable/ListRVWheel.swift | 5 +- ...stRightVariableButtonAllTextAndLinks.swift | 59 ++++++++--------- .../ListRightVariablePayments.swift | 5 +- ...htVariablePriceChangeAllTextAndLinks.swift | 61 +++++++----------- ...ListRightVariablePriceChangeBodyText.swift | 5 +- ...RightVariableTextLinkAllTextAndLinks.swift | 63 ++++++++----------- .../ListRightVariableTotalData.swift | 5 +- 8 files changed, 83 insertions(+), 125 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 08255db9..4e0eb83a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -78,8 +78,6 @@ import Foundation stack.restack() horizontalStack.restack() labelStack.restack() - isAccessibilityElement = true - updateAccessibilityLabel() } //------------------------------------------------------ @@ -115,7 +113,7 @@ import Foundation //------------------------------------------------------ func updateAccessibilityLabel() { - + isAccessibilityElement = true var message = "" if let leftHeadlineText = leftHeadline.text { @@ -135,5 +133,6 @@ import Foundation } accessibilityLabel = message + accessibilityTraits = (accessoryView != nil) ? .button : .none } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift index f410c635..58b9ada0 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift @@ -41,8 +41,6 @@ import Foundation rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) addMolecule(stack) stack.restack() - isAccessibilityElement = true - updateAccessibilityLabel() } //------------------------------------------------- @@ -75,7 +73,7 @@ import Foundation //-------------------------------------------------- func updateAccessibilityLabel() { - + isAccessibilityElement = true var message = "" if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty { @@ -91,5 +89,6 @@ import Foundation } accessibilityLabel = message + accessibilityTraits = (accessoryView != nil) ? .button : .none } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index 6e9503dc..c08d37cd 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -47,9 +47,9 @@ import Foundation addMolecule(stack) stack.restack() - updateAccessibilityLabel() accessibilityValue = button.accessibilityValue accessibilityHint = button.accessibilityHint + accessibilityTraits = .button } //----------------------------------------------------- @@ -74,48 +74,39 @@ import Foundation // MARK: - Accessibility //---------------------------------------------------- + func getAccessibilityMessage() -> String? { + guard let buttonText = button.titleLabel?.text else { + return eyebrowHeadlineBodyLink.getAccessibilityMessage() + } + guard let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() else { + return buttonText + } + return label + ", " + buttonText + } + func updateAccessibilityLabel() { - - var message = "" - - if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text { - message += eyebrowLabel + ", " - } - - if let headlineLabel = eyebrowHeadlineBodyLink.headline.text { - message += headlineLabel + ", " - } - - if let bodyLabel = eyebrowHeadlineBodyLink.body.text { - message += bodyLabel + ", " - } - - if let buttonLabel = button.accessibilityLabel { - message += buttonLabel - } - let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 - isAccessibilityElement = !linkShowing - button.isAccessibilityElement = linkShowing eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing - - if !linkShowing { - // Make whole cell focusable if no link. - accessibilityLabel = message + button.isAccessibilityElement = linkShowing + + if !linkShowing && accessoryView == nil { + // Make whole cell focusable if one action + accessibilityLabel = getAccessibilityMessage() + accessibilityElements = nil } else { - // Allow only radio button and link to be focused on. - button.accessibilityLabel = message - var elements: [UIView] = [] - - if !message.isEmpty { - elements.append(button) + // Make buttons focusable. + var elements: [Any] = [] + if let accessoryView = accessoryView { + accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage() + elements.append(accessoryView) + } else { + button.accessibilityLabel = getAccessibilityMessage() } - if linkShowing { elements.append(eyebrowHeadlineBodyLink.link) } - + elements.append(link) accessibilityElements = elements } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift index 5bb62b90..2b12a4c2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift @@ -40,8 +40,6 @@ import Foundation rightImage.addSizeConstraintsForAspectRatio = true addMolecule(stack) stack.restack() - isAccessibilityElement = true - updateAccessibilityLabel() } //---------------------------------------------------- @@ -72,7 +70,7 @@ import Foundation //-------------------------------------------------- func updateAccessibilityLabel() { - + isAccessibilityElement = true var message = "" if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty { @@ -84,5 +82,6 @@ import Foundation } accessibilityLabel = message + accessibilityTraits = (accessoryView != nil) ? .button : .none } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift index afbdd2b5..76ce1a37 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift @@ -67,7 +67,6 @@ import Foundation arrow.pinHeightAndWidth() addMolecule(stack) stack.restack() - updateAccessibilityLabel() } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -89,57 +88,39 @@ import Foundation // MARK: - Accessibility //-------------------------------------------------- + func getAccessibilityMessage() -> String? { + guard let rightLabelText = rightLabel.text else { + return eyebrowHeadlineBodyLink.getAccessibilityMessage() + } + guard let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() else { + return rightLabelText + } + return label + ", " + rightLabelText + } + func updateAccessibilityLabel() { - let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 isAccessibilityElement = !linkShowing + accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing if !linkShowing { // Make whole cell focusable if no link. - var message = "" - - if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text { - message += eyebrowLabel + ", " - } - - if let headlineLabel = eyebrowHeadlineBodyLink.headline.text { - message += headlineLabel + ", " - } - - if let bodyLabel = eyebrowHeadlineBodyLink.body.text { - message += bodyLabel + ", " - } - - if let rightLabelText = rightLabel.text { - message += rightLabelText - } - - accessibilityLabel = message - + accessibilityLabel = getAccessibilityMessage() + accessibilityElements = nil + } else if let accessoryView = accessoryView { + // Both caret and link. Read all content on caret. + accessoryView.accessibilityLabel = getAccessibilityMessage() + accessibilityElements = [accessoryView, eyebrowHeadlineBodyLink.link] } else { - var elements: [UIView] = [] - - if let eyebrowText = eyebrowHeadlineBodyLink.eyebrow.text, !eyebrowText.isEmpty { - elements.append(eyebrowHeadlineBodyLink.eyebrow) + // Only link. Manually add accessibility elements to ensure they are read in the right order. + var elements: [Any] = [] + if let otherElements = eyebrowHeadlineBodyLink.getAccessibilityElements() { + elements.append(otherElements) } - - if let headlineText = eyebrowHeadlineBodyLink.headline.text, !headlineText.isEmpty { - elements.append(eyebrowHeadlineBodyLink.headline) - } - - if let bodyText = eyebrowHeadlineBodyLink.body.text, !bodyText.isEmpty { - elements.append(eyebrowHeadlineBodyLink.body) - } - - if linkShowing { - elements.append(eyebrowHeadlineBodyLink.link) - } - if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty { elements.append(rightLabel) } - accessibilityElements = elements } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift index a93d50f9..8428dccc 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift @@ -54,8 +54,6 @@ import Foundation addMolecule(stack) stack.restack() arrowAndRightLabelStack.restack() - isAccessibilityElement = true - updateAccessibilityLabel() } //-------------------------------------------------- @@ -87,7 +85,7 @@ import Foundation //-------------------------------------------------- func updateAccessibilityLabel() { - + isAccessibilityElement = true var message = "" if let headlineText = headlineBody.headlineLabel.text, !headlineText.isEmpty { @@ -103,5 +101,6 @@ import Foundation } accessibilityLabel = message + accessibilityTraits = (accessoryView != nil) ? .button : .none } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift index 2dd2ca99..d6714f60 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift @@ -47,7 +47,6 @@ import Foundation addMolecule(stack) stack.restack() - updateAccessibilityLabel() } //-------------------------------------------------- @@ -72,52 +71,44 @@ import Foundation // MARK: - Accessibility //-------------------------------------------------- + func getAccessibilityMessage() -> String? { + guard let linkText = link.titleLabel?.text else { + return eyebrowHeadlineBodyLink.getAccessibilityMessage() + } + guard let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() else { + return linkText + } + return label + ", " + linkText + } + func updateAccessibilityLabel() { - - var message = "" - - if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text { - message += eyebrowLabel + ", " - } - - if let headlineLabel = eyebrowHeadlineBodyLink.headline.text { - message += headlineLabel + ", " - } - - if let bodyLabel = eyebrowHeadlineBodyLink.body.text { - message += bodyLabel + ", " - } - - if let linkLabel = link.accessibilityLabel { - message += linkLabel - } - let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 - isAccessibilityElement = !linkShowing - link.isAccessibilityElement = linkShowing + accessibilityTraits = .button eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing - - if !linkShowing { - // Make whole cell focusable if no link. - accessibilityLabel = message + link.isAccessibilityElement = linkShowing + + if !linkShowing && accessoryView == nil { + // Make whole cell focusable if one action + accessibilityLabel = getAccessibilityMessage() + accessibilityElements = nil } else { - // Allow only radio button and link to be focused on. - link.accessibilityLabel = message - var elements: [UIView] = [] - + // Make buttons focusable. + var elements: [Any] = [] + if let accessoryView = accessoryView { + accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage() + elements.append(accessoryView) + } else { + link.accessibilityLabel = getAccessibilityMessage() + } if linkShowing { elements.append(eyebrowHeadlineBodyLink.link) } - - if !message.isEmpty { - elements.append(link) - } - + elements.append(link) accessibilityElements = elements } } - + open override func accessibilityActivate() -> Bool { return link.accessibilityActivate() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift index a42cd81d..fe2c8a24 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift @@ -51,8 +51,6 @@ import Foundation rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) addMolecule(stack) stack.restack() - isAccessibilityElement = true - updateAccessibilityLabel() } //-------------------------------------------------- @@ -86,7 +84,7 @@ import Foundation //-------------------------------------------------- func updateAccessibilityLabel() { - + isAccessibilityElement = true var message = "" if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty { @@ -98,5 +96,6 @@ import Foundation } accessibilityLabel = message + accessibilityTraits = (accessoryView != nil) ? .button : .none } }