From 7cb2a759491cae1d9f8d2043396d955df5f998d0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 26 Mar 2024 14:00:15 -0500 Subject: [PATCH 1/5] fixes in the enum change for tilelet Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift | 12 ++++++------ MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift index 7cc9747e..62fac7e9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift @@ -17,9 +17,9 @@ open class TileletModel: MoleculeModelProtocol { public static var identifier: String = "tilelet" public var id: String = UUID().uuidString public var backgroundColor: Color? - public var color: TileContainer.BackgroundColor - public var padding: TileContainer.Padding - public var aspectRatio: TileContainer.AspectRatio + public var color: Tilelet.BackgroundColor + public var padding: Tilelet.Padding + public var aspectRatio: Tilelet.AspectRatio public var badge: Tilelet.BadgeModel? public var title: LabelModel? public var subTitle: LabelModel? @@ -51,9 +51,9 @@ open class TileletModel: MoleculeModelProtocol { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString self.backgroundColor = try container.decodeIfPresent(Color.self, forKey: .backgroundColor) - self.color = try container.decodeIfPresent(TileContainer.BackgroundColor.self, forKey: .color) ?? TileContainer.BackgroundColor.black - self.padding = try container.decodeIfPresent(TileContainer.Padding.self, forKey: .padding) ?? TileContainer.Padding.padding4X - self.aspectRatio = try container.decodeIfPresent(TileContainer.AspectRatio.self, forKey: .aspectRatio) ?? TileContainer.AspectRatio.none + self.color = try container.decodeIfPresent(Tilelet.BackgroundColor.self, forKey: .color) ?? Tilelet.BackgroundColor.black + self.padding = try container.decodeIfPresent(Tilelet.Padding.self, forKey: .padding) ?? Tilelet.Padding.small + self.aspectRatio = try container.decodeIfPresent(Tilelet.AspectRatio.self, forKey: .aspectRatio) ?? Tilelet.AspectRatio.none self.badge = try container.decodeIfPresent(Tilelet.BadgeModel.self, forKey: .badge) self.title = try container.decodeIfPresent(LabelModel.self, forKey: .title) self.subTitle = try container.decodeIfPresent(LabelModel.self, forKey: .subTitle) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index fa55423f..9e524462 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -25,7 +25,8 @@ extension VDS.Tabs.Overflow: Codable {} extension VDS.Tabs.Size: Codable {} extension VDS.TextLink.Size: Codable {} extension VDS.TextLinkCaret.IconPosition: Codable {} -extension VDS.TileContainer.AspectRatio: Codable {} +extension VDS.TileContainerBase.AspectRatio: Codable {} +extension VDS.Tilelet.Padding: Codable {} extension VDS.TitleLockup.TextAlignment: Codable {} extension VDS.Tooltip.FillColor: Codable {} extension VDS.Tooltip.Size: Codable {} @@ -61,7 +62,7 @@ extension DecodableDefault { public typealias Surface = Wrapper } -extension VDS.TileContainer.BackgroundColor: Codable { +extension VDS.TileContainerBase.BackgroundColor: Codable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { From 645327273136fa262b2a4b17ae72bad52882bfd2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 26 Mar 2024 16:42:56 -0500 Subject: [PATCH 2/5] added 2 properties that were missed in the initial refactor Signed-off-by: Matt Bruce --- .../HorizontalCombinationViews/Tabs.swift | 4 ++++ .../HorizontalCombinationViews/TabsModel.swift | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 654e48ac..ca4ca068 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -63,6 +63,10 @@ import VDS //------------------------------------------------- open func viewModelDidUpdate() { + borderLine = viewModel.borderLine + if let minWidth = viewModel.minWidth { + self.minWidth = minWidth + } orientation = viewModel.orientation indicatorPosition = viewModel.indicatorPosition overflow = viewModel.overflow diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index 24933f45..e09761d5 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -23,6 +23,8 @@ open class TabsModel: MoleculeModelProtocol { open var overflow: Tabs.Overflow = .scroll open var fillContainer: Bool = false open var size: Tabs.Size = .medium + open var borderLine: Bool = true + open var minWidth: CGFloat? public var backgroundColor: Color? // Must be capped to 0...(tabs.count - 1) @@ -39,6 +41,8 @@ open class TabsModel: MoleculeModelProtocol { case fillContainer case overflow case size + case borderLine + case minWidth case style } @@ -75,6 +79,15 @@ open class TabsModel: MoleculeModelProtocol { if let size = try typeContainer.decodeIfPresent(VDS.Tabs.Size.self, forKey: .orientation) { self.size = size } + + if let borderLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .borderLine) { + self.borderLine = borderLine + } + + if let minWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .minWidth) { + self.minWidth = minWidth + } + } open func encode(to encoder: Encoder) throws { @@ -89,7 +102,8 @@ open class TabsModel: MoleculeModelProtocol { try container.encode(overflow, forKey: .overflow) try container.encode(size, forKey: .size) try container.encode(indicatorPosition, forKey: .indicatorPosition) - + try container.encode(borderLine, forKey: .borderLine) + try container.encodeIfPresent(minWidth, forKey: .minWidth) } } From 81623520d257d8552f019c8fdcec7ce4e5e93f3e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 26 Mar 2024 16:51:17 -0500 Subject: [PATCH 3/5] if the lineModel is nil, default to a none style. Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift index 88bb6db4..7cb4cb47 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift @@ -78,6 +78,9 @@ public class TabsListItemModel: ListItemModel, ParentMoleculeModelProtocol { tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs) molecules = try typeContainer.decodeModels2D(codingKey: .molecules) try super.init(from: decoder) + if line == nil { + self.line = LineModel(type: .none) + } } public override func encode(to encoder: Encoder) throws { From 19d7a459ed0bdc7f7e45fd153f0c165ac046dfc6 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 26 Mar 2024 16:57:55 -0500 Subject: [PATCH 4/5] moved logic to setDefaults if a line model doesn't come back. Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift index 7cb4cb47..cc957907 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift @@ -57,6 +57,9 @@ public class TabsListItemModel: ListItemModel, ParentMoleculeModelProtocol { style = nil topPadding = 8 bottomPadding = 0 + if line == nil { + self.line = LineModel(type: .none) + } } //-------------------------------------------------- @@ -78,9 +81,6 @@ public class TabsListItemModel: ListItemModel, ParentMoleculeModelProtocol { tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs) molecules = try typeContainer.decodeModels2D(codingKey: .molecules) try super.init(from: decoder) - if line == nil { - self.line = LineModel(type: .none) - } } public override func encode(to encoder: Encoder) throws { From 5d3bb712faa83ca9bd1b70fc6f2ba08665fcc74f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 26 Mar 2024 17:00:28 -0500 Subject: [PATCH 5/5] removed self Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift index cc957907..1924820b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift @@ -58,7 +58,7 @@ public class TabsListItemModel: ListItemModel, ParentMoleculeModelProtocol { topPadding = 8 bottomPadding = 0 if line == nil { - self.line = LineModel(type: .none) + line = LineModel(type: .none) } }