more accessibility stuff.

This commit is contained in:
Kevin G Christiano 2020-03-25 14:47:15 -04:00
parent 5c4be8c2a6
commit 7e89e58cd1
3 changed files with 29 additions and 2 deletions

View File

@ -316,6 +316,7 @@ public typealias ActionBlock = () -> ()
text = labelModel.text
hero = labelModel.hero
Label.setLabel(self, withHTML: labelModel.html)
isAccessibilityElement = hasText
let alignment = LabelAlignment(rawValue: labelModel.textAlignment ?? "")
switch alignment {
@ -426,6 +427,7 @@ public typealias ActionBlock = () -> ()
continue
}
}
attributedText = attributedString
originalAttributedString = attributedText
}

View File

@ -24,7 +24,10 @@ import UIKit
(molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData)
} else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) {
addMolecule(moleculeView)
accessibilityElements = [moleculeView]
if ((moleculeView as? Label) != nil) {
accessibilityElements = [moleculeView]
}
}
super.set(with: model, delegateObject, additionalData)
}

View File

@ -14,9 +14,31 @@ public class LabelToggleModel: MoleculeModelProtocol {
public var backgroundColor: Color?
public var label: LabelModel
public var toggle: ToggleModel
init(_ label: LabelModel, _ toggle: ToggleModel) {
self.label = label
self.toggle = toggle
}
private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
case label
case toggle
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey:.backgroundColor)
label = try typeContainer.decode(LabelModel.self, forKey:.label)
toggle = try typeContainer.decode(ToggleModel.self, forKey:.toggle)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encode(label, forKey: .label)
try container.encode(toggle, forKey: .toggle)
}
}