From 21ac83af4fdd586208ce1976a640e585976fb2f8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 25 Jan 2023 11:50:11 -0600 Subject: [PATCH] removed codable Signed-off-by: Matt Bruce --- VDS/Components/Badge/Badge.swift | 2 +- VDS/Components/Buttons/Button/Button.swift | 2 +- .../Buttons/ButtonGroup/ButtonGroup.swift | 2 +- .../Buttons/TextLinkCaret/TextLinkCaret.swift | 2 +- VDS/Components/Icon/IconColor.swift | 2 +- VDS/Components/Icon/IconName.swift | 2 +- VDS/Components/Icon/IconSize.swift | 2 +- .../Attributes/UnderlineLabelAttribute.swift | 4 +-- .../TextFields/EntryField/EntryField.swift | 2 +- .../TextFields/InputField/InputField.swift | 2 +- .../TileContainer/TileContainer.swift | 6 ++--- VDS/Components/Tilelet/Tilelet.swift | 2 +- .../Tilelet/TileletBadgeModel.swift | 11 -------- .../Tilelet/TileletIconModels.swift | 25 ------------------- .../Tilelet/TileletSubTitleModel.swift | 22 +--------------- .../Tilelet/TileletTitleModel.swift | 22 +--------------- VDS/Components/TitleLockup/TitleLockup.swift | 2 +- .../TitleLockup/TitleLockupTextStyle.swift | 4 +-- VDS/Components/Toggle/Toggle.swift | 6 ++--- VDS/Extensions/VDSLayout.swift | 2 +- VDS/Protocols/Surfaceable.swift | 2 +- VDS/Protocols/Useable.swift | 2 +- VDS/Typography/Typography.swift | 8 +++--- 23 files changed, 30 insertions(+), 106 deletions(-) diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index b8d919c4..0cd56958 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -17,7 +17,7 @@ public class Badge: View, Accessable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum FillColor: String, Codable, CaseIterable { + public enum FillColor: String, CaseIterable { case red, yellow, green, orange, blue, black, white } diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 1a4bc3d4..f7274092 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -11,7 +11,7 @@ import VDSColorTokens import VDSFormControlsTokens import Combine -public enum ButtonSize: String, CaseIterable, Codable { +public enum ButtonSize: String, CaseIterable { case large case small } diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift index 6d3f2ef3..1bc28dba 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift @@ -17,7 +17,7 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum ButtonPosition: String, CaseIterable, Codable { + public enum ButtonPosition: String, CaseIterable { case left, center, right } diff --git a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift index 184737dc..7c2f9fbd 100644 --- a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift +++ b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift @@ -17,7 +17,7 @@ open class TextLinkCaret: ButtonBase { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum IconPosition: String, CaseIterable, Codable { + public enum IconPosition: String, CaseIterable { case left, right } diff --git a/VDS/Components/Icon/IconColor.swift b/VDS/Components/Icon/IconColor.swift index 10d7a174..c9d4bf0e 100644 --- a/VDS/Components/Icon/IconColor.swift +++ b/VDS/Components/Icon/IconColor.swift @@ -10,7 +10,7 @@ import VDSColorTokens import UIKit extension Icon { - public enum Color: String, CaseIterable, Codable { + public enum Color: String, CaseIterable { case black case white case red diff --git a/VDS/Components/Icon/IconName.swift b/VDS/Components/Icon/IconName.swift index a24be628..2fed2c94 100644 --- a/VDS/Components/Icon/IconName.swift +++ b/VDS/Components/Icon/IconName.swift @@ -10,7 +10,7 @@ import UIKit import VDSColorTokens extension Icon { - public struct Name: RawRepresentable, Codable { + public struct Name: RawRepresentable { public typealias RawValue = String public var rawValue: String diff --git a/VDS/Components/Icon/IconSize.swift b/VDS/Components/Icon/IconSize.swift index ca1b8548..86b865f7 100644 --- a/VDS/Components/Icon/IconSize.swift +++ b/VDS/Components/Icon/IconSize.swift @@ -8,7 +8,7 @@ import Foundation extension Icon { - public enum Size: String, CaseIterable, Codable { + public enum Size: String, CaseIterable { case xsmall case small case medium diff --git a/VDS/Components/Label/Attributes/UnderlineLabelAttribute.swift b/VDS/Components/Label/Attributes/UnderlineLabelAttribute.swift index 64a9842c..c58945a6 100644 --- a/VDS/Components/Label/Attributes/UnderlineLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/UnderlineLabelAttribute.swift @@ -64,7 +64,7 @@ extension UnderlineLabelAttribute { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum Style: String, Codable { + public enum Style: String { case none case single case thick @@ -87,7 +87,7 @@ extension UnderlineLabelAttribute { } } - public enum Pattern: String, Codable { + public enum Pattern: String { case dot case dash case dashDot diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 17104e46..5e500b9a 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -16,7 +16,7 @@ open class EntryField: Control, Accessable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum HelperTextPlacement: String, CaseIterable, Codable { + public enum HelperTextPlacement: String, CaseIterable { case bottom, right } diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index 3b498043..c4c4f120 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -16,7 +16,7 @@ public class InputField: EntryField, UITextFieldDelegate { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum FieldType: String, CaseIterable, Codable { + public enum FieldType: String, CaseIterable { case text, number, calendar, inlineAction, password, creditCard, tel, date, securityCode } diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index efccea75..c49e7235 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -34,14 +34,14 @@ open class TileContainer: Control { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum BackgroundColor: String, CaseIterable, Codable { + public enum BackgroundColor: String, CaseIterable { case white case black case gray case transparent } - public enum Padding: String, CaseIterable, Codable { + public enum Padding: String, CaseIterable { case padding2X case padding4X case padding6X @@ -64,7 +64,7 @@ open class TileContainer: Control { } } - public enum AspectRatio: String, CaseIterable, Codable { + public enum AspectRatio: String, CaseIterable { case ratio1x1 = "1:1" case ratio3x4 = "3:4" case ratio4x3 = "4:3" diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 918d5ee7..3fcddb37 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -15,7 +15,7 @@ open class Tilelet: TileContainer { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TextPosition: String, CaseIterable, Codable { + public enum TextPosition: String, CaseIterable { case top case bottom } diff --git a/VDS/Components/Tilelet/TileletBadgeModel.swift b/VDS/Components/Tilelet/TileletBadgeModel.swift index 515e6bb8..f11f6c8f 100644 --- a/VDS/Components/Tilelet/TileletBadgeModel.swift +++ b/VDS/Components/Tilelet/TileletBadgeModel.swift @@ -24,14 +24,3 @@ extension Tilelet { } } } - -extension Tilelet.BadgeModel: Codable { - public init(from decoder: Decoder) throws { - let container: KeyedDecodingContainer = try decoder.container(keyedBy: Tilelet.BadgeModel.CodingKeys.self) - self.text = try container.decode(String.self, forKey: Tilelet.BadgeModel.CodingKeys.text) - self.fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: Tilelet.BadgeModel.CodingKeys.fillColor) ?? .red - self.surface = try container.decodeIfPresent(Surface.self, forKey: Tilelet.BadgeModel.CodingKeys.surface) ?? .light - self.numberOfLines = try container.decodeIfPresent(Int.self, forKey: Tilelet.BadgeModel.CodingKeys.numberOfLines) ?? 0 - self.maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: Tilelet.BadgeModel.CodingKeys.maxWidth) - } -} diff --git a/VDS/Components/Tilelet/TileletIconModels.swift b/VDS/Components/Tilelet/TileletIconModels.swift index e3e0e587..b8b932c4 100644 --- a/VDS/Components/Tilelet/TileletIconModels.swift +++ b/VDS/Components/Tilelet/TileletIconModels.swift @@ -32,28 +32,3 @@ extension Tilelet { } } } - -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 - } -} diff --git a/VDS/Components/Tilelet/TileletSubTitleModel.swift b/VDS/Components/Tilelet/TileletSubTitleModel.swift index 6d6e1074..43ce158c 100644 --- a/VDS/Components/Tilelet/TileletSubTitleModel.swift +++ b/VDS/Components/Tilelet/TileletSubTitleModel.swift @@ -12,7 +12,7 @@ extension Tilelet { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TextStyle: String, EnumSubset, Codable { + public enum TextStyle: String, EnumSubset { case bodyLarge case boldBodyLarge case bodyMedium @@ -53,23 +53,3 @@ extension Tilelet { } } } - -extension Tilelet.SubTitleModel: Codable { - private enum CodingKeys: String, CodingKey { - case text, textStyle, textColor - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.text = try container.decode(String.self, forKey: .text) - self.textStyle = try container.decodeIfPresent(TextStyle.self, forKey: .textStyle) ?? .bodySmall - self.textColor = try container.decodeIfPresent(Use.self, forKey: .textColor) ?? .primary - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(text, forKey: .text) - try container.encode(textStyle, forKey: .textStyle) - try container.encode(textColor, forKey: .textColor) - } -} diff --git a/VDS/Components/Tilelet/TileletTitleModel.swift b/VDS/Components/Tilelet/TileletTitleModel.swift index de08c83b..7170021d 100644 --- a/VDS/Components/Tilelet/TileletTitleModel.swift +++ b/VDS/Components/Tilelet/TileletTitleModel.swift @@ -12,7 +12,7 @@ extension Tilelet { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TextStyle: String, EnumSubset, Codable { + public enum TextStyle: String, EnumSubset { case titleXLarge case boldTitleXLarge case titleLarge @@ -53,23 +53,3 @@ extension Tilelet { } } } - -extension Tilelet.TitleModel: Codable { - - private enum CodingKeys: String, CodingKey { - case text, textStyle - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.text = try container.decode(String.self, forKey: .text) - self.textStyle = try container.decodeIfPresent(TextStyle.self, forKey: .textStyle) ?? .boldTitleSmall - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(text, forKey: .text) - try container.encode(textStyle, forKey: .textStyle) - } - -} diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index 9a059d35..127cb33b 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -16,7 +16,7 @@ open class TitleLockup: View { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TextPosition: String, Codable, EnumSubset { + public enum TextPosition: String, EnumSubset { case left, center public var defaultValue: VDS.TextPosition { .left } diff --git a/VDS/Components/TitleLockup/TitleLockupTextStyle.swift b/VDS/Components/TitleLockup/TitleLockupTextStyle.swift index 8f8288d7..e8dc0319 100644 --- a/VDS/Components/TitleLockup/TitleLockupTextStyle.swift +++ b/VDS/Components/TitleLockup/TitleLockupTextStyle.swift @@ -11,7 +11,7 @@ extension TitleLockup { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TitleTextStyle: String, Codable, EnumSubset { + public enum TitleTextStyle: String, EnumSubset { case featureMedium case boldFeatureMedium @@ -34,7 +34,7 @@ extension TitleLockup { public var defaultValue: TextStyle {.boldFeatureXSmall } } - public enum OtherTextStyle: String, Codable, EnumSubset { + public enum OtherTextStyle: String, EnumSubset { case bodyLarge case boldBodyLarge case bodyMedium diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 6af7354d..b66d7bed 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -33,15 +33,15 @@ open class ToggleBase: Control, Accessable, DataTrackable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TextSize: String, Codable, CaseIterable { + public enum TextSize: String, CaseIterable { case small, large } - public enum TextWeight: String, Codable, CaseIterable { + public enum TextWeight: String, CaseIterable { case regular, bold } - public enum TextPosition: String, Codable, CaseIterable { + public enum TextPosition: String, CaseIterable { case left, right } diff --git a/VDS/Extensions/VDSLayout.swift b/VDS/Extensions/VDSLayout.swift index aa3d572a..9478e7fc 100644 --- a/VDS/Extensions/VDSLayout.swift +++ b/VDS/Extensions/VDSLayout.swift @@ -8,7 +8,7 @@ import Foundation public struct VDSLayout { - public enum Spacing: String, Codable, CaseIterable { + public enum Spacing: String, CaseIterable { case space1X case space2X case space3X diff --git a/VDS/Protocols/Surfaceable.swift b/VDS/Protocols/Surfaceable.swift index a26ddda4..916167f1 100644 --- a/VDS/Protocols/Surfaceable.swift +++ b/VDS/Protocols/Surfaceable.swift @@ -9,7 +9,7 @@ import Foundation import UIKit import VDSColorTokens -public enum Surface: String, Codable, Equatable { +public enum Surface: String, Equatable { case light, dark public var color: UIColor { return self == .dark ? VDSColor.backgroundPrimaryDark : VDSColor.backgroundSecondaryLight diff --git a/VDS/Protocols/Useable.swift b/VDS/Protocols/Useable.swift index 3f60ae18..43c4f4cc 100644 --- a/VDS/Protocols/Useable.swift +++ b/VDS/Protocols/Useable.swift @@ -9,7 +9,7 @@ import Foundation import UIKit import VDSColorTokens -public enum Use: String, Codable, Equatable { +public enum Use: String, Equatable { case primary, secondary } diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 3def20c5..1853c1f0 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -8,7 +8,7 @@ import Foundation import VDSTypographyTokens -public enum TextPosition: String, Codable, CaseIterable { +public enum TextPosition: String, CaseIterable { case left, right, center var textAlignment: NSTextAlignment { @@ -23,7 +23,7 @@ public enum TextPosition: String, Codable, CaseIterable { } } -public enum TextStyle: String, Codable, CaseIterable { +public enum TextStyle: String, CaseIterable { case featureXLarge case boldFeatureXLarge @@ -64,7 +64,7 @@ public enum TextStyle: String, Codable, CaseIterable { //MARK: FontCategory extension TextStyle { - public enum FontCategory: String, Codable, CaseIterable { + public enum FontCategory: String, CaseIterable { case feature = "Feature" case title = "Title" case body = "Body" @@ -95,7 +95,7 @@ extension TextStyle { //MARK: FontSize extension TextStyle { - public enum FontSize: String, Codable, CaseIterable { + public enum FontSize: String, CaseIterable { case xxlarge = "2XLarge" case xlarge = "XLarge" case large = "Large"