// // TiletDescriptiveIconModel.swift // VDS // // Created by Matt Bruce on 1/11/23. // import Foundation import UIKit extension Tilelet { public struct DescriptiveIcon: Codable { public var name: Icon.Name = .multipleDocuments public var size: Icon.Size = .medium public var surface: Surface = .dark public init(name: Icon.Name = .multipleDocuments, size: Icon.Size, surface: Surface) { self.name = name self.size = size self.surface = surface } public init(from decoder: Decoder) throws { let container: KeyedDecodingContainer = try decoder.container(keyedBy: Tilelet.DescriptiveIcon.CodingKeys.self) self.name = try container.decodeIfPresent(Icon.Name.self, forKey: Tilelet.DescriptiveIcon.CodingKeys.name) ?? .multipleDocuments self.size = try container.decodeIfPresent(Icon.Size.self, forKey: Tilelet.DescriptiveIcon.CodingKeys.size) ?? .medium self.surface = try container.decodeIfPresent(Surface.self, forKey: Tilelet.DescriptiveIcon.CodingKeys.surface) ?? .dark } } public struct DirectionalIcon: Codable { public var size: Icon.Size = .medium public var surface: Surface = .dark public init(size: Icon.Size, surface: Surface) { self.size = size self.surface = surface } public init(from decoder: Decoder) throws { let container: KeyedDecodingContainer = try decoder.container(keyedBy: Tilelet.DirectionalIcon.CodingKeys.self) self.size = try container.decodeIfPresent(Icon.Size.self, forKey: Tilelet.DirectionalIcon.CodingKeys.size) ?? .medium self.surface = try container.decodeIfPresent(Surface.self, forKey: Tilelet.DirectionalIcon.CodingKeys.surface) ?? .dark } } }