added default values in the decoder func
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
35d1f4071d
commit
09c0a567e1
@ -20,6 +20,13 @@ extension Tilet {
|
||||
self.size = size
|
||||
self.surface = surface
|
||||
}
|
||||
|
||||
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.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
|
||||
}
|
||||
}
|
||||
|
||||
public struct DirectionalIcon: Codable {
|
||||
@ -30,5 +37,11 @@ extension Tilet {
|
||||
self.size = size
|
||||
self.surface = surface
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<Tilet.DirectionalIcon.CodingKeys> = try decoder.container(keyedBy: Tilet.DirectionalIcon.CodingKeys.self)
|
||||
self.size = try container.decodeIfPresent(Icon.Size.self, forKey: Tilet.DirectionalIcon.CodingKeys.size) ?? .medium
|
||||
self.surface = try container.decodeIfPresent(Surface.self, forKey: Tilet.DirectionalIcon.CodingKeys.surface) ?? .dark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,5 +50,12 @@ extension Tilet {
|
||||
textColor: textColor,
|
||||
textAttributes: nil)
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<Tilet.SubTitleModel.CodingKeys> = try decoder.container(keyedBy: Tilet.SubTitleModel.CodingKeys.self)
|
||||
self.text = try container.decode(String.self, forKey: Tilet.SubTitleModel.CodingKeys.text)
|
||||
self.textStyle = try container.decodeIfPresent(Tilet.SubTitleModel.TextStyle.self, forKey: Tilet.SubTitleModel.CodingKeys.textStyle) ?? .bodySmall
|
||||
self.textColor = try container.decodeIfPresent(Use.self, forKey: Tilet.SubTitleModel.CodingKeys.textColor) ?? .primary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,5 +48,11 @@ extension Tilet {
|
||||
textAttributes: nil,
|
||||
textStyle: textStyle.value)
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container: KeyedDecodingContainer<Tilet.TitleModel.CodingKeys> = try decoder.container(keyedBy: Tilet.TitleModel.CodingKeys.self)
|
||||
self.text = try container.decode(String.self, forKey: Tilet.TitleModel.CodingKeys.text)
|
||||
self.textStyle = try container.decodeIfPresent(Tilet.TitleModel.TextStyle.self, forKey: Tilet.TitleModel.CodingKeys.textStyle) ?? .boldTitleSmall
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user