accessibility columns
This commit is contained in:
parent
843616f755
commit
cdbdb90771
@ -58,10 +58,8 @@ import Foundation
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
verticalStack.restack()
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = button.accessibilityTraits
|
||||
accessibilityHint = button.accessibilityHint
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -100,10 +98,8 @@ import Foundation
|
||||
// MARK: - Accessibility
|
||||
//--------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
func getAccessibilityMessage() -> String? {
|
||||
var message = ""
|
||||
|
||||
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
|
||||
message += eyebrowText + ", "
|
||||
}
|
||||
@ -123,8 +119,27 @@ import Foundation
|
||||
if let rightImageViewText = rightImageView.accessibilityLabel, !rightImageViewText.isEmpty {
|
||||
message += rightImageViewText
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
return message.count > 0 ? message : nil
|
||||
}
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
accessibilityTraits = .button
|
||||
if let accessoryView = accessoryView {
|
||||
// Both caret and button. Read all content on caret.
|
||||
isAccessibilityElement = false
|
||||
accessoryView.accessibilityLabel = getAccessibilityMessage()
|
||||
accessibilityElements = [accessoryView, button]
|
||||
} else {
|
||||
// Make whole cell focusable if no action.
|
||||
isAccessibilityElement = true
|
||||
accessibilityElements = nil
|
||||
if let message = getAccessibilityMessage(),
|
||||
let buttonTitle = button.titleLabel?.text {
|
||||
accessibilityLabel = message + ", " + buttonTitle
|
||||
} else {
|
||||
accessibilityLabel = getAccessibilityMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open override func accessibilityActivate() -> Bool {
|
||||
|
||||
@ -58,10 +58,8 @@ import Foundation
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
verticalStack.restack()
|
||||
isAccessibilityElement = true
|
||||
accessibilityTraits = button.accessibilityTraits
|
||||
accessibilityHint = button.accessibilityHint
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -100,10 +98,8 @@ import Foundation
|
||||
// MARK: - Accessibility
|
||||
//--------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
func getAccessibilityMessage() -> String? {
|
||||
var message = ""
|
||||
|
||||
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
|
||||
message += eyebrowText + ", "
|
||||
}
|
||||
@ -123,8 +119,27 @@ import Foundation
|
||||
if let rightImageViewText = rightImageView.accessibilityLabel, !rightImageViewText.isEmpty {
|
||||
message += rightImageViewText
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
return message.count > 0 ? message : nil
|
||||
}
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
accessibilityTraits = .button
|
||||
if let accessoryView = accessoryView {
|
||||
// Both caret and button. Read all content on caret.
|
||||
isAccessibilityElement = false
|
||||
accessoryView.accessibilityLabel = getAccessibilityMessage()
|
||||
accessibilityElements = [accessoryView, button]
|
||||
} else {
|
||||
// Make whole cell focusable if no action.
|
||||
isAccessibilityElement = true
|
||||
accessibilityElements = nil
|
||||
if let message = getAccessibilityMessage(),
|
||||
let buttonTitle = button.titleLabel?.text {
|
||||
accessibilityLabel = message + ", " + buttonTitle
|
||||
} else {
|
||||
accessibilityLabel = getAccessibilityMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open override func accessibilityActivate() -> Bool {
|
||||
|
||||
@ -54,8 +54,6 @@ import Foundation
|
||||
arrow.pinHeightAndWidth()
|
||||
arrowAndLabel2Stack.restack()
|
||||
stack.restack()
|
||||
isAccessibilityElement = true
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
@ -92,7 +90,7 @@ import Foundation
|
||||
//-----------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
isAccessibilityElement = true
|
||||
var message = ""
|
||||
|
||||
if let label1Text = label1.text, !label1Text.isEmpty {
|
||||
|
||||
@ -43,7 +43,6 @@ import Foundation
|
||||
super.setupView()
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
@ -72,8 +71,7 @@ import Foundation
|
||||
// MARK: - Accessibility
|
||||
//--------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
func getAccessibilityMessage() -> String? {
|
||||
var message = ""
|
||||
|
||||
if let eyebrowLabel = eyebrow.text, !eyebrowLabel.isEmpty {
|
||||
@ -91,19 +89,26 @@ import Foundation
|
||||
if let bodyLabel = body.text, !bodyLabel.isEmpty {
|
||||
message += bodyLabel
|
||||
}
|
||||
|
||||
return message.count > 0 ? message : nil
|
||||
}
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
let linkShowing = link.titleLabel?.text?.count ?? 0 > 0
|
||||
isAccessibilityElement = !linkShowing
|
||||
link.isAccessibilityElement = linkShowing
|
||||
|
||||
if !linkShowing {
|
||||
// Make whole cell focusable if no link.
|
||||
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, link]
|
||||
} else {
|
||||
// Allow only radio button and link to be focused on.
|
||||
var elements: [UIView] = []
|
||||
|
||||
|
||||
// Only link. Manually add accessibility elements to ensure they are read in the right order.
|
||||
var elements: [Any] = []
|
||||
if let eyeBrowText = eyebrow.text, !eyeBrowText.isEmpty {
|
||||
elements.append(eyebrow)
|
||||
}
|
||||
@ -119,11 +124,7 @@ import Foundation
|
||||
if let bodyText = body.text, !bodyText.isEmpty {
|
||||
elements.append(body)
|
||||
}
|
||||
|
||||
if linkShowing {
|
||||
elements.append(link)
|
||||
}
|
||||
|
||||
elements.append(link)
|
||||
accessibilityElements = elements
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,8 +24,6 @@ import Foundation
|
||||
super.setupView()
|
||||
|
||||
addMolecule(headlineBody)
|
||||
isAccessibilityElement = true
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?){
|
||||
@ -46,7 +44,7 @@ import Foundation
|
||||
//-----------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
isAccessibilityElement = true
|
||||
var message = ""
|
||||
|
||||
if let headlineLabel = headlineBody.headlineLabel.text {
|
||||
|
||||
@ -42,8 +42,6 @@ import Foundation
|
||||
super.setupView()
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
isAccessibilityElement = true
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -77,7 +75,7 @@ import Foundation
|
||||
//--------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
isAccessibilityElement = true
|
||||
var message = ""
|
||||
|
||||
if let leftText = leftLabel.text, !leftText.isEmpty {
|
||||
|
||||
@ -55,8 +55,6 @@ import Foundation
|
||||
arrow.pinHeightAndWidth()
|
||||
arrowAndLabel2Stack.restack()
|
||||
stack.restack()
|
||||
isAccessibilityElement = true
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
@ -87,7 +85,7 @@ import Foundation
|
||||
//--------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
isAccessibilityElement = true
|
||||
var message = ""
|
||||
|
||||
if let leftText = leftLabel.text, !leftText.isEmpty {
|
||||
|
||||
@ -54,7 +54,6 @@ import Foundation
|
||||
((molecule as? StackItem)?.view as? Stack<StackModel>)?.restack()
|
||||
}
|
||||
containingStack.restack()
|
||||
isAccessibilityElement = false
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
@ -67,9 +67,6 @@ import Foundation
|
||||
leftHeadline.numberOfLines = 1
|
||||
rightLabel.numberOfLines = 1
|
||||
rightSubLabel.numberOfLines = 1
|
||||
|
||||
isAccessibilityElement = true
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -107,7 +104,7 @@ import Foundation
|
||||
//----------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
isAccessibilityElement = true
|
||||
var message = ""
|
||||
|
||||
if let leftHeadline = leftHeadline.text, !leftHeadline.isEmpty {
|
||||
|
||||
@ -31,8 +31,6 @@ import UIKit
|
||||
containerHelper.constrainView(view)
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
isAccessibilityElement = true
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
@ -72,7 +70,7 @@ import UIKit
|
||||
//----------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
isAccessibilityElement = true
|
||||
var message = ""
|
||||
|
||||
if let leftLabel = leftLabel.text, !leftLabel.isEmpty {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user