update models for default values
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
09c0a567e1
commit
1d8e7016de
@ -10,10 +10,11 @@ import Foundation
|
||||
extension Tilet {
|
||||
public struct BadgeModel: Codable {
|
||||
public var text: String = ""
|
||||
public var fillColor:Badge.FillColor
|
||||
public var surface: Surface
|
||||
public var fillColor: Badge.FillColor = .red
|
||||
public var surface: Surface = .light
|
||||
public var numberOfLines: Int
|
||||
public var maxWidth: CGFloat?
|
||||
|
||||
public init(text: String, fillColor: Badge.FillColor = .red, surface: Surface = .light, numberOfLines: Int = 0, maxWidth: CGFloat? = nil) {
|
||||
self.text = text
|
||||
self.fillColor = fillColor
|
||||
@ -21,5 +22,14 @@ extension Tilet {
|
||||
self.numberOfLines = numberOfLines
|
||||
self.maxWidth = maxWidth
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<Tilet.BadgeModel.CodingKeys> = try decoder.container(keyedBy: Tilet.BadgeModel.CodingKeys.self)
|
||||
self.text = try container.decode(String.self, forKey: Tilet.BadgeModel.CodingKeys.text)
|
||||
self.fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: Tilet.BadgeModel.CodingKeys.fillColor) ?? .red
|
||||
self.surface = try container.decodeIfPresent(Surface.self, forKey: Tilet.BadgeModel.CodingKeys.surface) ?? .light
|
||||
self.numberOfLines = try container.decodeIfPresent(Int.self, forKey: Tilet.BadgeModel.CodingKeys.numberOfLines) ?? 0
|
||||
self.maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: Tilet.BadgeModel.CodingKeys.maxWidth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ extension Tilet {
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<Tilet.DescriptiveIcon.CodingKeys> = try decoder.container(keyedBy: Tilet.DescriptiveIcon.CodingKeys.self)
|
||||
self.name = try container.decode(Icon.Name.self, forKey: Tilet.DescriptiveIcon.CodingKeys.name)
|
||||
self.name = try container.decodeIfPresent(Icon.Name.self, forKey: Tilet.DescriptiveIcon.CodingKeys.name) ?? .multipleDocuments
|
||||
self.size = try container.decodeIfPresent(Icon.Size.self, forKey: Tilet.DescriptiveIcon.CodingKeys.size) ?? .medium
|
||||
self.surface = try container.decodeIfPresent(Surface.self, forKey: Tilet.DescriptiveIcon.CodingKeys.surface) ?? .dark
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user