From cdaa86a59e1711578c69ea9db24bbbc199413cc6 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 13 Jan 2023 14:32:02 -0600 Subject: [PATCH] refactored structs into parent Signed-off-by: Matt Bruce --- VDS/Components/Tilet/Tilet.swift | 14 ++-- VDS/Components/Tilet/TiletBadgeModel.swift | 26 +++--- VDS/Components/Tilet/TiletIconModels.swift | 39 +++++---- VDS/Components/Tilet/TiletSubTitleModel.swift | 82 ++++++++++--------- VDS/Components/Tilet/TiletTitleModel.swift | 78 +++++++++--------- 5 files changed, 124 insertions(+), 115 deletions(-) diff --git a/VDS/Components/Tilet/Tilet.swift b/VDS/Components/Tilet/Tilet.swift index 9ab7bf35..2f5afbe9 100644 --- a/VDS/Components/Tilet/Tilet.swift +++ b/VDS/Components/Tilet/Tilet.swift @@ -171,13 +171,13 @@ open class Tilet: TileContainer { open var textPostion: TextPosition = .top { didSet { didChange() }} //models - public var badgeModel: TiletBadgeModel? { didSet { didChange() }} - public var titleModel: TiletTitleModel? { didSet { didChange() }} - public var subTitleModel: TiletSubTitleModel? { didSet { didChange() }} + public var badgeModel: BadgeModel? { didSet { didChange() }} + public var titleModel: TitleModel? { didSet { didChange() }} + public var subTitleModel: SubTitleModel? { didSet { didChange() }} //only 1 Icon can be active - private var _descriptiveIconModel: TiletDescriptiveIcon? - public var descriptiveIconModel: TiletDescriptiveIcon? { + private var _descriptiveIconModel: DescriptiveIcon? + public var descriptiveIconModel: DescriptiveIcon? { get { _descriptiveIconModel } set { _descriptiveIconModel = newValue; @@ -186,8 +186,8 @@ open class Tilet: TileContainer { } } - private var _directionalIconModel: TiletDirectionalIcon? - public var directionalIconModel: TiletDirectionalIcon? { + private var _directionalIconModel: DirectionalIcon? + public var directionalIconModel: DirectionalIcon? { get { _directionalIconModel } set { _directionalIconModel = newValue; diff --git a/VDS/Components/Tilet/TiletBadgeModel.swift b/VDS/Components/Tilet/TiletBadgeModel.swift index 2ea327e5..521958a4 100644 --- a/VDS/Components/Tilet/TiletBadgeModel.swift +++ b/VDS/Components/Tilet/TiletBadgeModel.swift @@ -7,17 +7,19 @@ import Foundation -public struct TiletBadgeModel: Codable { - public var text: String = "" - public var fillColor:Badge.FillColor - public var surface: Surface - public var numberOfLines: Int - public var maxWidth: CGFloat? - public init(text: String, fillColor: Badge.FillColor = .red, surface: Surface = .light, numberOfLines: Int = 0, maxWidth: CGFloat? = nil) { - self.text = text - self.fillColor = fillColor - self.surface = surface - self.numberOfLines = numberOfLines - self.maxWidth = maxWidth +extension Tilet { + public struct BadgeModel: Codable { + public var text: String = "" + public var fillColor:Badge.FillColor + public var surface: Surface + public var numberOfLines: Int + public var maxWidth: CGFloat? + public init(text: String, fillColor: Badge.FillColor = .red, surface: Surface = .light, numberOfLines: Int = 0, maxWidth: CGFloat? = nil) { + self.text = text + self.fillColor = fillColor + self.surface = surface + self.numberOfLines = numberOfLines + self.maxWidth = maxWidth + } } } diff --git a/VDS/Components/Tilet/TiletIconModels.swift b/VDS/Components/Tilet/TiletIconModels.swift index d5347dad..58ee3057 100644 --- a/VDS/Components/Tilet/TiletIconModels.swift +++ b/VDS/Components/Tilet/TiletIconModels.swift @@ -8,24 +8,27 @@ import Foundation import UIKit -public struct TiletDescriptiveIcon: Codable { - public var name: Icon.Name = .multipleDocuments - public var size: Icon.Size = .medium - public var surface: Surface = .dark +extension Tilet { - public init(name: Icon.Name = .multipleDocuments, size: Icon.Size, surface: Surface) { - self.name = name - self.size = size - self.surface = surface - } -} - -public struct TiletDirectionalIcon: 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 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 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 + } } } diff --git a/VDS/Components/Tilet/TiletSubTitleModel.swift b/VDS/Components/Tilet/TiletSubTitleModel.swift index f39a854f..eeec0bbc 100644 --- a/VDS/Components/Tilet/TiletSubTitleModel.swift +++ b/VDS/Components/Tilet/TiletSubTitleModel.swift @@ -7,46 +7,48 @@ import Foundation -public struct TiletSubTitleModel: Codable { - //-------------------------------------------------- - // MARK: - Enums - //-------------------------------------------------- - public enum TextStyle: String, Codable, EnumSubset { - case BodyLarge - case BoldBodyLarge - case BodyMedium - case BoldBodyMedium - case BodySmall - case BoldBodySmall +extension Tilet { + public struct SubTitleModel: Codable { + //-------------------------------------------------- + // MARK: - Enums + //-------------------------------------------------- + public enum TextStyle: String, Codable, EnumSubset { + case BodyLarge + case BoldBodyLarge + case BodyMedium + case BoldBodyMedium + case BodySmall + case BoldBodySmall + + public var defaultValue: TitleLockup.OtherTextStyle { .BodySmall } + } - public var defaultValue: TitleLockup.OtherTextStyle { .BodySmall } - } - - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- - public var text: String = "" - public var textStyle: TextStyle = .BodySmall - public var textColor: Use = .primary - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - public init(text: String, - textColor: Use = .primary, - textAttributes: [any LabelAttributeModel]? = nil, - textStyle: TextStyle = .BodySmall) { - self.text = text - self.textColor = textColor - self.textStyle = textStyle - } - - //-------------------------------------------------- - // MARK: - Public Functions - //-------------------------------------------------- - public func toTitleLockupSubTitleModel() -> TitleLockup.SubTitleModel { - TitleLockup.SubTitleModel(text: text, - textColor: textColor, - textAttributes: nil) + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + public var text: String = "" + public var textStyle: TextStyle = .BodySmall + public var textColor: Use = .primary + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + public init(text: String, + textColor: Use = .primary, + textAttributes: [any LabelAttributeModel]? = nil, + textStyle: TextStyle = .BodySmall) { + self.text = text + self.textColor = textColor + self.textStyle = textStyle + } + + //-------------------------------------------------- + // MARK: - Public Functions + //-------------------------------------------------- + public func toTitleLockupSubTitleModel() -> TitleLockup.SubTitleModel { + TitleLockup.SubTitleModel(text: text, + textColor: textColor, + textAttributes: nil) + } } } diff --git a/VDS/Components/Tilet/TiletTitleModel.swift b/VDS/Components/Tilet/TiletTitleModel.swift index cafae988..5b6b830e 100644 --- a/VDS/Components/Tilet/TiletTitleModel.swift +++ b/VDS/Components/Tilet/TiletTitleModel.swift @@ -7,44 +7,46 @@ import Foundation -public struct TiletTitleModel: Codable { - //-------------------------------------------------- - // MARK: - Enums - //-------------------------------------------------- - public enum TextStyle: String, EnumSubset, Codable { - case TitleXLarge - case BoldTitleXLarge - case TitleLarge - case BoldTitleLarge - case TitleMedium - case BoldTitleMedium - case TitleSmall - case BoldTitleSmall +extension Tilet { + public struct TitleModel: Codable { + //-------------------------------------------------- + // MARK: - Enums + //-------------------------------------------------- + public enum TextStyle: String, EnumSubset, Codable { + case TitleXLarge + case BoldTitleXLarge + case TitleLarge + case BoldTitleLarge + case TitleMedium + case BoldTitleMedium + case TitleSmall + case BoldTitleSmall + + public var defaultValue: TitleLockup.TitleTextStyle { .BoldTitleSmall } + } - public var defaultValue: TitleLockup.TitleTextStyle { .BoldTitleSmall } - } - - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- - public var text: String = "" - public var textStyle: TextStyle = .BoldTitleSmall - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - public init(text: String, - textStyle: TextStyle = .BoldTitleSmall) { - self.text = text - self.textStyle = textStyle - } - - //-------------------------------------------------- - // MARK: - Public Functions - //-------------------------------------------------- - public func toTitleLockupTitleModel() -> TitleLockup.TitleModel { - TitleLockup.TitleModel(text: text, - textAttributes: nil, - textStyle: textStyle.value) + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + public var text: String = "" + public var textStyle: TextStyle = .BoldTitleSmall + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + public init(text: String, + textStyle: TextStyle = .BoldTitleSmall) { + self.text = text + self.textStyle = textStyle + } + + //-------------------------------------------------- + // MARK: - Public Functions + //-------------------------------------------------- + public func toTitleLockupTitleModel() -> TitleLockup.TitleModel { + TitleLockup.TitleModel(text: text, + textAttributes: nil, + textStyle: textStyle.value) + } } }