diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 1a162287..54eb1514 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -66,6 +66,7 @@ EA985C2D296F03FE00F2FF2E /* TileletIconModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C2C296F03FE00F2FF2E /* TileletIconModels.swift */; }; EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C662970C21600F2FF2E /* VDSLayout.swift */; }; EA985C692971B90B00F2FF2E /* IconSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C682971B90B00F2FF2E /* IconSize.swift */; }; + EA985C7D297DAED300F2FF2E /* Primitive.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C7C297DAED300F2FF2E /* Primitive.swift */; }; EAA5EEB528ECBFB4003B3210 /* ImageLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEB428ECBFB4003B3210 /* ImageLabelAttribute.swift */; }; EAA5EEB728ECC03A003B3210 /* ToolTipLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEB628ECC03A003B3210 /* ToolTipLabelAttribute.swift */; }; EAA5EEB928ECD24B003B3210 /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAA5EEB828ECD24B003B3210 /* Icons.xcassets */; }; @@ -181,6 +182,7 @@ EA985C2C296F03FE00F2FF2E /* TileletIconModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletIconModels.swift; sourceTree = ""; }; EA985C662970C21600F2FF2E /* VDSLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSLayout.swift; sourceTree = ""; }; EA985C682971B90B00F2FF2E /* IconSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconSize.swift; sourceTree = ""; }; + EA985C7C297DAED300F2FF2E /* Primitive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Primitive.swift; sourceTree = ""; }; EAA5EEB428ECBFB4003B3210 /* ImageLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageLabelAttribute.swift; sourceTree = ""; }; EAA5EEB628ECC03A003B3210 /* ToolTipLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolTipLabelAttribute.swift; sourceTree = ""; }; EAA5EEB828ECD24B003B3210 /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = ""; }; @@ -400,6 +402,7 @@ EA3361AE288B26310071C351 /* FormFieldable.swift */, EA3361BE288B2EA60071C351 /* Handlerable.swift */, EA33624628931B050071C351 /* Initable.swift */, + EA985C7C297DAED300F2FF2E /* Primitive.swift */, EAF7F0A5289B0CE000B287F5 /* Resetable.swift */, EA3361C8289054C50071C351 /* Surfaceable.swift */, EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */, @@ -799,6 +802,7 @@ EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */, EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */, EAF7F0A2289AFB3900B287F5 /* Errorable.swift in Sources */, + EA985C7D297DAED300F2FF2E /* Primitive.swift in Sources */, EAB5FEF829393A7200998C17 /* ButtonGroupConstants.swift in Sources */, EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */, EA5E3058295105A40082B959 /* Tilelet.swift in Sources */, diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index cba0078d..4da338c3 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -10,7 +10,7 @@ import UIKit import Combine @objc(VDSControl) -open class Control: UIControl, Handlerable, ViewProtocol, Resettable { +open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties @@ -23,6 +23,8 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- private var initialSetupPerformed = false + open var userInfo = [String: Primitive]() + open var surface: Surface = .light { didSet { didChange() } } open var disabled: Bool = false { didSet { isEnabled = !disabled } } diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 1671b377..c00a5887 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -11,7 +11,7 @@ import Combine @objc(VDSView) -open class View: UIView, Handlerable, ViewProtocol, Resettable { +open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties @@ -24,6 +24,8 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- private var initialSetupPerformed = false + open var userInfo = [String: Primitive]() + open var surface: Surface = .light { didSet { didChange() }} open var disabled: Bool = false { didSet { isEnabled = !disabled } } diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index d2759c52..0cd56958 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -17,14 +17,14 @@ 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 } //-------------------------------------------------- - // MARK: - Private Properties + // MARK: - Public Properties //-------------------------------------------------- - private var label = Label().with { + open var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.adjustsFontSizeToFitWidth = false $0.lineBreakMode = .byTruncatingTail @@ -32,9 +32,6 @@ public class Badge: View, Accessable { $0.textStyle = .boldBodySmall } - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- open var fillColor: FillColor = .red { didSet { didChange() }} open var text: String = "" { didSet { didChange() }} diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 1bc94e2e..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, Codable, CaseIterable { +public enum ButtonSize: String, CaseIterable { case large case small } diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 0314a04f..890b8f9c 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -18,7 +18,7 @@ public protocol Buttonable: UIControl, Surfaceable, Disabling { } @objc(VDSButtonBase) -open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettable { +open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- @@ -48,6 +48,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab open var disabled: Bool = false { didSet { isEnabled = !disabled } } + open var userInfo = [String: Primitive]() + var isHighlightAnimating = false open override var isHighlighted: Bool { didSet { diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 12ab59c3..a1a6a0fd 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -73,28 +73,28 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable { $0.axis = .vertical } - private var label = Label().with { + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .boldBodyLarge } - private var childLabel = Label().with { + open var childLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodyLarge } - private var errorLabel = Label().with { + open var errorLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodyMedium } - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- - public var selectorView = UIView().with { + open var selectorView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index 6105b633..184ccf6f 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -19,15 +19,15 @@ public class Icon: View { private var widthConstraint: NSLayoutConstraint? private var heightConstraint: NSLayoutConstraint? - private var imageView = UIImageView().with { + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var imageView = UIImageView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.contentMode = .scaleAspectFill $0.clipsToBounds = true } - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- open var color: Color = .black { didSet { didChange() }} open var size: Size = .medium { didSet { didChange() }} open var name: Name? { didSet { didChange() }} 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/Label/Label.swift b/VDS/Components/Label/Label.swift index fca57836..2a4aefd4 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -11,7 +11,7 @@ import VDSColorTokens import Combine @objc(VDSLabel) -public class Label: UILabel, Handlerable, ViewProtocol, Resettable { +public class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties @@ -37,6 +37,8 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable { open var textPosition: TextPosition = .left { didSet { didChange() }} + open var userInfo = [String: Primitive]() + open override var isEnabled: Bool { get { !disabled } set { diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index 975199af..bacd5278 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -67,27 +67,27 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{ $0.isHidden = false } - private var textLabel = Label().with { + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var textLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .boldBodyLarge } - private var subTextLabel = Label().with { + open var subTextLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodyLarge } - private var subTextRightLabel = Label().with { + open var subTextRightLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .right $0.textStyle = .bodyLarge } - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- public var selectorView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 1f01e85b..08b46faf 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -80,27 +80,27 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable { $0.axis = .vertical } - private var label = Label().with { + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .boldBodyLarge } - private var childLabel = Label().with { + open var childLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodyLarge } - private var errorLabel = Label().with { + open var errorLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodyMedium } - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- public var selectorView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index e4d4b9fd..5e500b9a 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -45,26 +45,7 @@ open class EntryField: Control, Accessable { $0.distribution = .fill } }() - - internal var titleLabel = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - $0.attributes = [] - $0.textPosition = .left - $0.textStyle = .bodySmall - } - - internal var errorLabel = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - $0.textPosition = .left - $0.textStyle = .bodySmall - } - - internal var helperLabel = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - $0.textPosition = .left - $0.textStyle = .bodySmall - } - + internal var containerView: UIView = { return UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false @@ -85,13 +66,7 @@ open class EntryField: Control, Accessable { $0.translatesAutoresizingMaskIntoConstraints = false } }() - - - internal var tooltipView: UIView? - internal var icon: Icon = Icon().with { - $0.size = .small - } - + //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- @@ -123,6 +98,30 @@ open class EntryField: Control, Accessable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + open var titleLabel = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.attributes = [] + $0.textPosition = .left + $0.textStyle = .bodySmall + } + + open var errorLabel = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.textStyle = .bodySmall + } + + open var helperLabel = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + $0.textPosition = .left + $0.textStyle = .bodySmall + } + + open var tooltipView: UIView? + open var icon: Icon = Icon().with { + $0.size = .small + } + open var labelText: String? { didSet { didChange() }} open var helperText: String? { didSet { didChange() }} diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index e8ebe3f4..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, Codable, CaseIterable { + public enum BackgroundColor: String, CaseIterable { case white case black case gray case transparent } - public enum Padding: String, Codable, CaseIterable { + public enum Padding: String, CaseIterable { case padding2X case padding4X case padding6X @@ -64,7 +64,7 @@ open class TileContainer: Control { } } - public enum AspectRatio: String, Codable, CaseIterable { + 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 8ad347e8..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, Codable, CaseIterable { + public enum TextPosition: String, CaseIterable { case top case bottom } @@ -50,8 +50,20 @@ open class Tilelet: TileContainer { private var titleLockupContainerView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } - - private var titleLockup = TitleLockup().with { + + private var badgeContainerView = UIView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + } + + private let iconContainerView = UIView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.backgroundColor = .clear + } + + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var titleLockup = TitleLockup().with { let configs = [ TextStyle.DeviceSpacingConfig([.titleSmall, .boldTitleSmall], neighboring: [ @@ -113,28 +125,16 @@ open class Tilelet: TileContainer { $0.bottomTextStyleSpacingConfig = TextStyle.SpacingConfig(configs: configs) } - private var badgeContainerView = UIView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - } - - private var badge = Badge().with { + open var badge = Badge().with { $0.fillColor = .red } - private let iconContainerView = UIView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.backgroundColor = .clear - } + open var descriptiveIcon = Icon() - private var descriptiveIcon = Icon() - private var directionalIcon = Icon().with { + open var directionalIcon = Icon().with { $0.name = .rightArrow } - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- - //style private var _textWidth: CGFloat? open var textWidth: CGFloat? { get { _textWidth } diff --git a/VDS/Components/Tilelet/TileletBadgeModel.swift b/VDS/Components/Tilelet/TileletBadgeModel.swift index a9dbd875..bd7efcac 100644 --- a/VDS/Components/Tilelet/TileletBadgeModel.swift +++ b/VDS/Components/Tilelet/TileletBadgeModel.swift @@ -8,10 +8,10 @@ import Foundation extension Tilelet { - public struct BadgeModel: Codable { + public struct BadgeModel { public var text: String = "" - public var fillColor: Badge.FillColor = .red - public var surface: Surface = .light + public var fillColor: Badge.FillColor + public var surface: Surface public var numberOfLines: Int public var maxWidth: CGFloat? @@ -22,14 +22,5 @@ extension Tilelet { self.numberOfLines = numberOfLines self.maxWidth = maxWidth } - - 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 d4f8caf1..22a5a148 100644 --- a/VDS/Components/Tilelet/TileletIconModels.swift +++ b/VDS/Components/Tilelet/TileletIconModels.swift @@ -10,38 +10,25 @@ 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 struct DescriptiveIcon { + public var name: Icon.Name + public var size: Icon.Size + public var surface: Surface - public init(name: Icon.Name = .multipleDocuments, size: Icon.Size, surface: Surface) { + public init(name: Icon.Name = .multipleDocuments, size: Icon.Size = .medium, surface: Surface = .dark) { 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 struct DirectionalIcon { + public var size: Icon.Size + public var surface: Surface - public init(size: Icon.Size, surface: Surface) { + public init(size: Icon.Size = .medium, surface: Surface = .dark) { 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 - } } } diff --git a/VDS/Components/Tilelet/TileletSubTitleModel.swift b/VDS/Components/Tilelet/TileletSubTitleModel.swift index 0c9078c3..43ce158c 100644 --- a/VDS/Components/Tilelet/TileletSubTitleModel.swift +++ b/VDS/Components/Tilelet/TileletSubTitleModel.swift @@ -8,11 +8,11 @@ import Foundation extension Tilelet { - public struct SubTitleModel: Codable { + public struct SubTitleModel { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TextStyle: String, Codable, EnumSubset { + public enum TextStyle: String, EnumSubset { case bodyLarge case boldBodyLarge case bodyMedium @@ -22,12 +22,12 @@ extension Tilelet { public var defaultValue: TitleLockup.OtherTextStyle { .bodySmall } } - //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- public var text: String = "" public var textStyle: TextStyle = .bodySmall + public var textAttributes: [any LabelAttributeModel]? public var textColor: Use = .primary //-------------------------------------------------- @@ -38,6 +38,7 @@ extension Tilelet { textAttributes: [any LabelAttributeModel]? = nil, textStyle: TextStyle = .bodySmall) { self.text = text + self.textAttributes = textAttributes self.textColor = textColor self.textStyle = textStyle } @@ -50,12 +51,5 @@ extension Tilelet { textColor: textColor, textAttributes: nil) } - - public init(from decoder: Decoder) throws { - let container: KeyedDecodingContainer = try decoder.container(keyedBy: Tilelet.SubTitleModel.CodingKeys.self) - self.text = try container.decode(String.self, forKey: Tilelet.SubTitleModel.CodingKeys.text) - self.textStyle = try container.decodeIfPresent(Tilelet.SubTitleModel.TextStyle.self, forKey: Tilelet.SubTitleModel.CodingKeys.textStyle) ?? .bodySmall - self.textColor = try container.decodeIfPresent(Use.self, forKey: Tilelet.SubTitleModel.CodingKeys.textColor) ?? .primary - } } } diff --git a/VDS/Components/Tilelet/TileletTitleModel.swift b/VDS/Components/Tilelet/TileletTitleModel.swift index 404574e5..7170021d 100644 --- a/VDS/Components/Tilelet/TileletTitleModel.swift +++ b/VDS/Components/Tilelet/TileletTitleModel.swift @@ -8,11 +8,11 @@ import Foundation extension Tilelet { - public struct TitleModel: Codable { + public struct TitleModel { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - public enum TextStyle: String, EnumSubset, Codable { + public enum TextStyle: String, EnumSubset { case titleXLarge case boldTitleXLarge case titleLarge @@ -24,21 +24,24 @@ extension Tilelet { public var defaultValue: TitleLockup.TitleTextStyle { .boldTitleSmall } } - //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- public var text: String = "" + public var textAttributes: [any LabelAttributeModel]? public var textStyle: TextStyle = .boldTitleSmall //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- public init(text: String, + textAttributes: [any LabelAttributeModel]? = nil, textStyle: TextStyle = .boldTitleSmall) { self.text = text + self.textAttributes = textAttributes self.textStyle = textStyle } + //-------------------------------------------------- // MARK: - Public Functions @@ -48,11 +51,5 @@ extension Tilelet { textAttributes: nil, textStyle: textStyle.value) } - - public init(from decoder: Decoder) throws { - let container: KeyedDecodingContainer = try decoder.container(keyedBy: Tilelet.TitleModel.CodingKeys.self) - self.text = try container.decode(String.self, forKey: Tilelet.TitleModel.CodingKeys.text) - self.textStyle = try container.decodeIfPresent(Tilelet.TitleModel.TextStyle.self, forKey: Tilelet.TitleModel.CodingKeys.textStyle) ?? .boldTitleSmall - } } } 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 e490d456..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 } @@ -68,11 +68,7 @@ open class ToggleBase: Control, Accessable, DataTrackable { $0.axis = .horizontal $0.distribution = .fill } - - private var label = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - } - + private var toggleView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } @@ -121,6 +117,10 @@ open class ToggleBase: Control, Accessable, DataTrackable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + open var label = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + } + open var isOn: Bool { get { isSelected } set { 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/Primitive.swift b/VDS/Protocols/Primitive.swift new file mode 100644 index 00000000..30982c67 --- /dev/null +++ b/VDS/Protocols/Primitive.swift @@ -0,0 +1,13 @@ +public protocol Primitive {} + +extension String: Primitive {} +extension Int: Primitive {} +extension Double: Primitive {} +extension Float: Primitive {} +extension Bool: Primitive {} +extension Array: Primitive where Element: Primitive {} +extension Dictionary: Primitive where Key == String, Value: Primitive {} + +public protocol UserInfoable { + var userInfo: [String: Primitive] { get set } +} 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"