added accessibility
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
8143cc7d9e
commit
e97582ee1e
@ -14,7 +14,7 @@ import Combine
|
||||
open class Badge: VDS.Badge, VDSMoleculeViewProtocol {
|
||||
// public typealias ViewModel = type
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var viewModel: BadgeModel!
|
||||
|
||||
@ -23,7 +23,7 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol {
|
||||
public var additionalData: [AnyHashable : Any]?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public
|
||||
// MARK: - Public Methods
|
||||
//--------------------------------------------------
|
||||
|
||||
public func viewModelDidUpdate() {
|
||||
@ -35,6 +35,20 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol {
|
||||
}
|
||||
|
||||
public func updateView(_ size: CGFloat) {}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
//--------------------------------------------------
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
|
||||
if let viewModel {
|
||||
if let accessibilityText = viewModel.accessibilityText {
|
||||
self.accessibilityLabel = accessibilityText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//to deal with how it's parent constrains this control
|
||||
|
||||
@ -17,13 +17,14 @@ open class BadgeModel: MoleculeModelProtocol {
|
||||
public var id: String = UUID().uuidString
|
||||
public var backgroundColor: Color?
|
||||
public var text: String = ""
|
||||
public var accessibilityText: String?
|
||||
public var maxWidth: CGFloat?
|
||||
public var numberOfLines: Int = 1
|
||||
public var fillColor = Badge.FillColor.red
|
||||
public var surface: Surface = .light
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id, text, fillColor, surface, numberOfLines, maxWidth
|
||||
case id, text, accessibilityText, fillColor, surface, numberOfLines, maxWidth
|
||||
}
|
||||
|
||||
required public convenience init(from decoder: Decoder) throws {
|
||||
@ -31,6 +32,7 @@ open class BadgeModel: MoleculeModelProtocol {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||
text = try container.decode(String.self, forKey: .text)
|
||||
accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||
fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red
|
||||
surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light
|
||||
numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 1
|
||||
@ -41,6 +43,7 @@ open class BadgeModel: MoleculeModelProtocol {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(id, forKey: .id)
|
||||
try container.encode(text, forKey: .text)
|
||||
try container.encode(accessibilityText, forKey: .accessibilityText)
|
||||
try container.encode(fillColor, forKey: .fillColor)
|
||||
try container.encode(surface, forKey: .surface)
|
||||
try container.encode(numberOfLines, forKey: .numberOfLines)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user