update view, removed some un-needed code, added other code

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-04-10 11:18:30 -05:00
parent a8dc76e3e5
commit 60d5c45a39
2 changed files with 24 additions and 57 deletions

View File

@ -22,54 +22,25 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol {
public var additionalData: [AnyHashable : Any]?
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
// public convenience required init() {
// self.init(frame: .zero)
// }
public required init() {
super.init()
}
required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
//--------------------------------------------------
// MARK: - Public
//--------------------------------------------------
open func set(){
maxWidth = viewModel.maxWidth
numberOfLines = viewModel.numberOfLines ?? 3
fillColor = viewModel.fillColor
surface = viewModel.surface ?? .light
}
public func viewModelDidUpdate() {
// backgroundColor = viewModel.backgroundColor
text = viewModel.text
maxWidth = viewModel.maxWidth
numberOfLines = viewModel.numberOfLines ?? 3
numberOfLines = viewModel.numberOfLines
fillColor = viewModel.fillColor
surface = viewModel.surface ?? .light
surface = viewModel.surface
}
public func updateView(_ size: CGFloat) {
}
// open override func setupView() {
// super.setupView()
// backgroundColor = .clear
// widthConstraint = widthAnchor.constraint(equalToConstant: 30)
// widthConstraint?.isActive = true
// heightConstraint = heightAnchor.constraint(equalTo: widthAnchor, multiplier: 1)
// heightConstraint?.isActive = true
// isAccessibilityElement = true
// updateAccessibilityLabel()
// }
public func updateView(_ size: CGFloat) {}
}
//to deal with how it's parent constrains this control
extension Badge: MVMCoreUIViewConstrainingProtocol {
public func needsToBeConstrained() -> Bool { true }
public func horizontalAlignment() -> UIStackView.Alignment { .leading }
}

View File

@ -17,33 +17,29 @@ open class BadgeModel: MoleculeModelProtocol {
//--------------------------------------------------
public static var identifier: String = "badge"
public var backgroundColor: Color?
public var maxWidth: CGFloat?
public var numberOfLines: Int?
public var fillColor = Badge.FillColor.red
public var surface: Surface?
public var text: 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 text, fillColor, surface, numberOfLines, maxWidth
}
// public convenience init() {
// self.init()
// }
required public convenience init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.init()
self.text = try container.decode(String.self, forKey: .text)
self.fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red
self.surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light
self.numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 1
self.maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth)
let container = try decoder.container(keyedBy: CodingKeys.self)
text = try container.decode(String.self, forKey: .text)
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
maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(text, forKey: .text)
try container.encode(fillColor, forKey: .fillColor)
try container.encode(surface, forKey: .surface)
try container.encode(numberOfLines, forKey: .numberOfLines)