right variable changes
This commit is contained in:
parent
061e9e6bd9
commit
843616f755
@ -78,8 +78,6 @@ import Foundation
|
|||||||
stack.restack()
|
stack.restack()
|
||||||
horizontalStack.restack()
|
horizontalStack.restack()
|
||||||
labelStack.restack()
|
labelStack.restack()
|
||||||
isAccessibilityElement = true
|
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
@ -115,7 +113,7 @@ import Foundation
|
|||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
func updateAccessibilityLabel() {
|
func updateAccessibilityLabel() {
|
||||||
|
isAccessibilityElement = true
|
||||||
var message = ""
|
var message = ""
|
||||||
|
|
||||||
if let leftHeadlineText = leftHeadline.text {
|
if let leftHeadlineText = leftHeadline.text {
|
||||||
@ -135,5 +133,6 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessibilityLabel = message
|
accessibilityLabel = message
|
||||||
|
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,6 @@ import Foundation
|
|||||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
isAccessibilityElement = true
|
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -75,7 +73,7 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func updateAccessibilityLabel() {
|
func updateAccessibilityLabel() {
|
||||||
|
isAccessibilityElement = true
|
||||||
var message = ""
|
var message = ""
|
||||||
|
|
||||||
if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty {
|
if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty {
|
||||||
@ -91,5 +89,6 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessibilityLabel = message
|
accessibilityLabel = message
|
||||||
|
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,9 +47,9 @@ import Foundation
|
|||||||
|
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
updateAccessibilityLabel()
|
|
||||||
accessibilityValue = button.accessibilityValue
|
accessibilityValue = button.accessibilityValue
|
||||||
accessibilityHint = button.accessibilityHint
|
accessibilityHint = button.accessibilityHint
|
||||||
|
accessibilityTraits = .button
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
@ -74,48 +74,39 @@ import Foundation
|
|||||||
// MARK: - Accessibility
|
// 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() {
|
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
|
let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0
|
||||||
|
|
||||||
isAccessibilityElement = !linkShowing
|
isAccessibilityElement = !linkShowing
|
||||||
button.isAccessibilityElement = linkShowing
|
|
||||||
eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing
|
eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing
|
||||||
|
button.isAccessibilityElement = linkShowing
|
||||||
if !linkShowing {
|
|
||||||
// Make whole cell focusable if no link.
|
if !linkShowing && accessoryView == nil {
|
||||||
accessibilityLabel = message
|
// Make whole cell focusable if one action
|
||||||
|
accessibilityLabel = getAccessibilityMessage()
|
||||||
|
accessibilityElements = nil
|
||||||
} else {
|
} else {
|
||||||
// Allow only radio button and link to be focused on.
|
// Make buttons focusable.
|
||||||
button.accessibilityLabel = message
|
var elements: [Any] = []
|
||||||
var elements: [UIView] = []
|
if let accessoryView = accessoryView {
|
||||||
|
accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage()
|
||||||
if !message.isEmpty {
|
elements.append(accessoryView)
|
||||||
elements.append(button)
|
} else {
|
||||||
|
button.accessibilityLabel = getAccessibilityMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
if linkShowing {
|
if linkShowing {
|
||||||
elements.append(eyebrowHeadlineBodyLink.link)
|
elements.append(eyebrowHeadlineBodyLink.link)
|
||||||
}
|
}
|
||||||
|
elements.append(link)
|
||||||
accessibilityElements = elements
|
accessibilityElements = elements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,8 +40,6 @@ import Foundation
|
|||||||
rightImage.addSizeConstraintsForAspectRatio = true
|
rightImage.addSizeConstraintsForAspectRatio = true
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
isAccessibilityElement = true
|
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
@ -72,7 +70,7 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func updateAccessibilityLabel() {
|
func updateAccessibilityLabel() {
|
||||||
|
isAccessibilityElement = true
|
||||||
var message = ""
|
var message = ""
|
||||||
|
|
||||||
if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty {
|
if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty {
|
||||||
@ -84,5 +82,6 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessibilityLabel = message
|
accessibilityLabel = message
|
||||||
|
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,6 @@ import Foundation
|
|||||||
arrow.pinHeightAndWidth()
|
arrow.pinHeightAndWidth()
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
@ -89,57 +88,39 @@ import Foundation
|
|||||||
// MARK: - Accessibility
|
// 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() {
|
func updateAccessibilityLabel() {
|
||||||
|
|
||||||
let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0
|
let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0
|
||||||
isAccessibilityElement = !linkShowing
|
isAccessibilityElement = !linkShowing
|
||||||
|
accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none
|
||||||
eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing
|
eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing
|
||||||
|
|
||||||
if !linkShowing {
|
if !linkShowing {
|
||||||
// Make whole cell focusable if no link.
|
// Make whole cell focusable if no link.
|
||||||
var message = ""
|
accessibilityLabel = getAccessibilityMessage()
|
||||||
|
accessibilityElements = nil
|
||||||
if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text {
|
} else if let accessoryView = accessoryView {
|
||||||
message += eyebrowLabel + ", "
|
// Both caret and link. Read all content on caret.
|
||||||
}
|
accessoryView.accessibilityLabel = getAccessibilityMessage()
|
||||||
|
accessibilityElements = [accessoryView, eyebrowHeadlineBodyLink.link]
|
||||||
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
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var elements: [UIView] = []
|
// Only link. Manually add accessibility elements to ensure they are read in the right order.
|
||||||
|
var elements: [Any] = []
|
||||||
if let eyebrowText = eyebrowHeadlineBodyLink.eyebrow.text, !eyebrowText.isEmpty {
|
if let otherElements = eyebrowHeadlineBodyLink.getAccessibilityElements() {
|
||||||
elements.append(eyebrowHeadlineBodyLink.eyebrow)
|
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 {
|
if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty {
|
||||||
elements.append(rightLabel)
|
elements.append(rightLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
accessibilityElements = elements
|
accessibilityElements = elements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,8 +54,6 @@ import Foundation
|
|||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
arrowAndRightLabelStack.restack()
|
arrowAndRightLabelStack.restack()
|
||||||
isAccessibilityElement = true
|
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -87,7 +85,7 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func updateAccessibilityLabel() {
|
func updateAccessibilityLabel() {
|
||||||
|
isAccessibilityElement = true
|
||||||
var message = ""
|
var message = ""
|
||||||
|
|
||||||
if let headlineText = headlineBody.headlineLabel.text, !headlineText.isEmpty {
|
if let headlineText = headlineBody.headlineLabel.text, !headlineText.isEmpty {
|
||||||
@ -103,5 +101,6 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessibilityLabel = message
|
accessibilityLabel = message
|
||||||
|
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,6 @@ import Foundation
|
|||||||
|
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -72,52 +71,44 @@ import Foundation
|
|||||||
// MARK: - Accessibility
|
// 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() {
|
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
|
let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0
|
||||||
|
|
||||||
isAccessibilityElement = !linkShowing
|
isAccessibilityElement = !linkShowing
|
||||||
link.isAccessibilityElement = linkShowing
|
accessibilityTraits = .button
|
||||||
eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing
|
eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing
|
||||||
|
link.isAccessibilityElement = linkShowing
|
||||||
if !linkShowing {
|
|
||||||
// Make whole cell focusable if no link.
|
if !linkShowing && accessoryView == nil {
|
||||||
accessibilityLabel = message
|
// Make whole cell focusable if one action
|
||||||
|
accessibilityLabel = getAccessibilityMessage()
|
||||||
|
accessibilityElements = nil
|
||||||
} else {
|
} else {
|
||||||
// Allow only radio button and link to be focused on.
|
// Make buttons focusable.
|
||||||
link.accessibilityLabel = message
|
var elements: [Any] = []
|
||||||
var elements: [UIView] = []
|
if let accessoryView = accessoryView {
|
||||||
|
accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage()
|
||||||
|
elements.append(accessoryView)
|
||||||
|
} else {
|
||||||
|
link.accessibilityLabel = getAccessibilityMessage()
|
||||||
|
}
|
||||||
if linkShowing {
|
if linkShowing {
|
||||||
elements.append(eyebrowHeadlineBodyLink.link)
|
elements.append(eyebrowHeadlineBodyLink.link)
|
||||||
}
|
}
|
||||||
|
elements.append(link)
|
||||||
if !message.isEmpty {
|
|
||||||
elements.append(link)
|
|
||||||
}
|
|
||||||
|
|
||||||
accessibilityElements = elements
|
accessibilityElements = elements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func accessibilityActivate() -> Bool {
|
open override func accessibilityActivate() -> Bool {
|
||||||
return link.accessibilityActivate()
|
return link.accessibilityActivate()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,8 +51,6 @@ import Foundation
|
|||||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
isAccessibilityElement = true
|
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -86,7 +84,7 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func updateAccessibilityLabel() {
|
func updateAccessibilityLabel() {
|
||||||
|
isAccessibilityElement = true
|
||||||
var message = ""
|
var message = ""
|
||||||
|
|
||||||
if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty {
|
if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty {
|
||||||
@ -98,5 +96,6 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessibilityLabel = message
|
accessibilityLabel = message
|
||||||
|
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user