60 lines
1.8 KiB
Swift
60 lines
1.8 KiB
Swift
//
|
|
// TiletDescriptiveIconModel.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 1/11/23.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
extension Tilelet {
|
|
|
|
public struct DescriptiveIcon {
|
|
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 struct DirectionalIcon {
|
|
public var size: Icon.Size = .medium
|
|
public var surface: Surface = .dark
|
|
|
|
public init(size: Icon.Size, surface: Surface) {
|
|
self.size = size
|
|
self.surface = surface
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Tilelet.DescriptiveIcon: Codable {
|
|
private enum CodingKeys: String, CodingKey {
|
|
case name, size, surface
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
self.name = try container.decodeIfPresent(Icon.Name.self, forKey: .name) ?? .multipleDocuments
|
|
self.size = try container.decodeIfPresent(Icon.Size.self, forKey: .size) ?? .medium
|
|
self.surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .dark
|
|
}
|
|
}
|
|
|
|
extension Tilelet.DirectionalIcon: Codable {
|
|
private enum CodingKeys: String, CodingKey {
|
|
case size, surface
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
self.size = try container.decodeIfPresent(Icon.Size.self, forKey: .size) ?? .medium
|
|
self.surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .dark
|
|
}
|
|
}
|