right variable changes
This commit is contained in:
parent
061e9e6bd9
commit
843616f755
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user