Added accessibilityText for ListOneColumnTextWithWhitespaceDividerTall
DOPMO-153745
This commit is contained in:
parent
6449d68f4f
commit
34ef2e5c81
@ -17,6 +17,7 @@ import Foundation
|
|||||||
public var stack: Stack<StackModel>
|
public var stack: Stack<StackModel>
|
||||||
public let headline = Label(fontStyle: .BoldTitleMedium)
|
public let headline = Label(fontStyle: .BoldTitleMedium)
|
||||||
public let body = Label(fontStyle: .RegularBodySmall)
|
public let body = Label(fontStyle: .RegularBodySmall)
|
||||||
|
public var accessibilityText: String? = nil
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -41,7 +42,6 @@ import Foundation
|
|||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
isAccessibilityElement = true
|
isAccessibilityElement = true
|
||||||
updateAccessibilityLabel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -53,7 +53,8 @@ import Foundation
|
|||||||
|
|
||||||
guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return }
|
guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return }
|
||||||
stack.updateContainedMolecules(with: [model.headline, model.body], delegateObject, additionalData)
|
stack.updateContainedMolecules(with: [model.headline, model.body], delegateObject, additionalData)
|
||||||
updateAccessibilityLabel()
|
|
||||||
|
updateAccessibilityLabel(model: model)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
@ -70,18 +71,23 @@ import Foundation
|
|||||||
// MARK: - Accessibility
|
// MARK: - Accessibility
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
||||||
func updateAccessibilityLabel() {
|
func updateAccessibilityLabel(model: ListOneColumnTextWithWhitespaceDividerTallModel) {
|
||||||
|
if let accessibilityText = model.accessibilityText {
|
||||||
var message = ""
|
accessibilityLabel = accessibilityText
|
||||||
|
}else {
|
||||||
if let headlineLabel = headline.text, !headlineLabel.isEmpty {
|
var message = ""
|
||||||
message += headlineLabel + ", "
|
|
||||||
|
if let headlineLabel = headline.text, !headlineLabel.isEmpty {
|
||||||
|
message += headlineLabel + ", "
|
||||||
|
}
|
||||||
|
|
||||||
|
if let bodyLabel = body.text, !bodyLabel.isEmpty {
|
||||||
|
message += bodyLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
accessibilityLabel = message
|
||||||
}
|
}
|
||||||
|
|
||||||
if let bodyLabel = body.text, !bodyLabel.isEmpty {
|
|
||||||
message += bodyLabel
|
|
||||||
}
|
|
||||||
|
|
||||||
accessibilityLabel = message
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,14 +17,16 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol
|
|||||||
public static var identifier: String = "list1CTxtDiv2"
|
public static var identifier: String = "list1CTxtDiv2"
|
||||||
public var headline: LabelModel
|
public var headline: LabelModel
|
||||||
public var body: LabelModel?
|
public var body: LabelModel?
|
||||||
|
public var accessibilityText: String?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(headline: LabelModel, body: LabelModel?) {
|
public init(headline: LabelModel, body: LabelModel?, accessibilityText: String?) {
|
||||||
self.headline = headline
|
self.headline = headline
|
||||||
self.body = body
|
self.body = body
|
||||||
|
self.accessibilityText = accessibilityText
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol
|
|||||||
case moleculeName
|
case moleculeName
|
||||||
case headline
|
case headline
|
||||||
case body
|
case body
|
||||||
|
case accessibilityText
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -55,6 +58,7 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
||||||
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
|
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
|
||||||
|
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,5 +68,6 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol
|
|||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(headline, forKey: .headline)
|
try container.encode(headline, forKey: .headline)
|
||||||
try container.encodeIfPresent(body, forKey: .body)
|
try container.encodeIfPresent(body, forKey: .body)
|
||||||
|
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user