48 lines
1.9 KiB
Swift
48 lines
1.9 KiB
Swift
//
|
|
// TiletDescriptiveIconModel.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 1/11/23.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
extension Tilet {
|
|
|
|
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<Tilet.DescriptiveIcon.CodingKeys> = try decoder.container(keyedBy: Tilet.DescriptiveIcon.CodingKeys.self)
|
|
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
|
|
}
|
|
}
|
|
|
|
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<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
|
|
}
|
|
}
|
|
}
|