accessibility as a cell

This commit is contained in:
Kevin G Christiano 2020-04-27 15:06:09 -04:00
parent 2574772585
commit ac158381be

View File

@ -46,6 +46,11 @@ import UIKit
stack.restack()
eyebrowHeadlineBodyLink.body.textColor = .mvmOrangeAA
eyebrowHeadlineBodyLink.headline.styleBoldBodySmall(true)
isAccessibilityElement = true
updateAccessibilityLabel()
accessibilityTraits = .button
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint")
}
open override func reset() {
@ -64,6 +69,7 @@ import UIKit
radioButton.set(with: model.radioButton, delegateObject, additionalData)
leftImage.set(with: model.image, delegateObject, additionalData)
eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
updateAccessibilityLabel()
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -73,4 +79,31 @@ import UIKit
public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
radioButton.tapAction()
}
func updateAccessibilityLabel() {
var message = "Radio Button, "
if let radioButtonLabel = radioButton.accessibilityLabel {
message += radioButtonLabel + ", "
}
if let leftImageLabel = leftImage.accessibilityLabel {
message += leftImageLabel + ", "
}
if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text {
message += eyebrowLabel + ", "
}
if let headlineLabel = eyebrowHeadlineBodyLink.headline.text {
message += headlineLabel + ", "
}
if let bodyLabel = eyebrowHeadlineBodyLink.eyebrow.text {
message += bodyLabel
}
accessibilityLabel = message
}
}