From 05069e044cb64ed9c850aeb17874a2d05f68092b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 09:55:56 -0500 Subject: [PATCH 01/16] added helper protocol Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 6 +++++- .../Atomic/Extensions/VDS-Enums+Codable.swift | 2 ++ .../Atomic/Protocols/VDS-Interpreters.swift | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index acb13d9a..a46d3b1a 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -587,6 +587,7 @@ EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; EABFC152276913E800E78B40 /* FormLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC151276913E800E78B40 /* FormLabelModel.swift */; }; + EACCF38C2ABB346700E0F104 /* VDS-Interpreters.swift in Sources */ = {isa = PBXBuildFile; fileRef = EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */; }; FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */; }; /* End PBXBuildFile section */ @@ -1174,6 +1175,7 @@ EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; EABFC151276913E800E78B40 /* FormLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabelModel.swift; sourceTree = ""; }; + EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VDS-Interpreters.swift"; sourceTree = ""; }; FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleNotEqualsModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -2415,6 +2417,7 @@ 011B58EE23A2AA850085F53C /* ModelProtocols */, 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */, EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */, + EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */, ); path = Protocols; sourceTree = ""; @@ -2972,6 +2975,7 @@ D28BA741248025A300B75CB8 /* TabBarModel.swift in Sources */, D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */, D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */, + EACCF38C2ABB346700E0F104 /* VDS-Interpreters.swift in Sources */, C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, D2FA83D22513EA6900564112 /* NotificationXButton.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 6c143d9c..3f132670 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -16,3 +16,5 @@ extension Icon.Size: Codable {} extension TileContainer.BackgroundColor: Codable {} extension TileContainer.Padding: Codable {} extension TileContainer.AspectRatio: Codable {} +extension VDS.Line.Style: Codable {} +extension VDS.Line.Orientation: Codable {} diff --git a/MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift b/MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift new file mode 100644 index 00000000..24237527 --- /dev/null +++ b/MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift @@ -0,0 +1,18 @@ +// +// VDS-Interpreters.swift +// MVMCoreUI +// +// Created by Matt Bruce on 9/20/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +import Foundation +import VDS + +public protocol Invertable { + var inverted: Bool { get set } +} + +extension Invertable { + public var surface: Surface { return inverted ? .dark : .light } +} From 470bb160d6f928337d4497bb2f96f1034a3b700f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:25:33 -0500 Subject: [PATCH 02/16] update for VDS Protocol Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift index 41349f2c..fcbd07d1 100644 --- a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift @@ -28,5 +28,9 @@ extension VDSMoleculeViewProtocol { viewModel = castedModel viewModelDidUpdate() } + + public func update(viewModel: ViewModel){ + set(with: viewModel, delegateObject, additionalData) + } } From 099fce290e81b8c2419529244d3e7ff9e10b911b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:26:31 -0500 Subject: [PATCH 03/16] updated LineModel and Line Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 125 +++++++++---------- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 87 +++---------- 2 files changed, 73 insertions(+), 139 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index e36c8d23..c527a362 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -7,116 +7,107 @@ // import UIKit +import VDS - -@objcMembers open class Line: View { +@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - var lineModel: LineModel? { - get { return model as? LineModel } - } - - //-------------------------------------------------- - // MARK: - Constraints - //-------------------------------------------------- - - public var heightConstraint: NSLayoutConstraint? - public var widthConstraint: NSLayoutConstraint? - - open func updateLineConstraints(constant: CGFloat) { - if let useVerticalLine = lineModel?.useVerticalLine, useVerticalLine { - heightConstraint?.isActive = false - widthConstraint?.isActive = true - widthConstraint?.constant = constant - } else { - widthConstraint?.isActive = false - heightConstraint?.isActive = true - heightConstraint?.constant = constant + open var line = VDS.Line() + open var viewModel: LineModel! + open var delegateObject: MVMCoreUIDelegateObject? + open var additionalData: [AnyHashable : Any]? + open var orientation: VDS.Line.Orientation = .horizontal { + didSet { + viewModel.orientation = orientation + update(viewModel: viewModel) } } //-------------------------------------------------- // MARK: - Initializer - //-------------------------------------------------- - + //-------------------------------------------------- public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) { self.init(frame: .zero) addLine(to: view, edge: edge, useMargin: useMargin) } - public init() { - super.init(frame: .zero) - model = LineModel(type: .secondary) - setStyle(.secondary) + public required init() { + super.init() + viewModel = LineModel(type: .primary) } public override init(frame: CGRect) { super.init(frame: frame) - model = LineModel(type: .secondary) - setStyle(.secondary) + viewModel = LineModel(type: .primary) } public required init?(coder: NSCoder) { super.init(coder: coder) - model = LineModel(type: .secondary) - setStyle(.secondary) + viewModel = LineModel(type: .primary) } - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func setup() { + super.setup() + addSubview(line) + line.pinToSuperView() } - + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- - - open func setStyle(_ style: LineModel.Style) { - lineModel?.type = style - backgroundColor = lineModel?.backgroundColor?.uiColor - updateLineConstraints(constant: lineModel?.thickness ?? 1) - } - open func shouldBeVisible() -> Bool { - guard let type = lineModel?.type else { return false } + guard let type = viewModel?.type else { return false } return type != .none } - //-------------------------------------------------- - // MARK: - MoleculeViewProtocol - //-------------------------------------------------- + open func setStyle(_ style: LineModel.Style) { + viewModel.type = style + update(viewModel: viewModel) + } open func addLine(to view: UIView, edge: UIRectEdge, useMargin: Bool) { view.addSubview(self) - NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: self, useMargins: useMargin, pinTop: edge != .bottom, pinBottom: edge != .top, pinLeft: edge != .right, pinRight: edge != .left).values)) + NSLayoutConstraint.activate( + Array( + NSLayoutConstraint.pinView(toSuperview: self, + useMargins: useMargin, + pinTop: edge != .bottom, + pinBottom: edge != .top, + pinLeft: edge != .right, + pinRight: edge != .left).values + ) + ) } - open override func setupView() { - super.setupView() - heightConstraint = heightAnchor.constraint(equalToConstant: 1) - heightConstraint?.isActive = true - widthConstraint = widthAnchor.constraint(equalToConstant: 1) - widthConstraint?.isActive = false + //-------------------------------------------------- + // MARK: - VDSMoleculeViewProtocol + //-------------------------------------------------- + open func viewModelDidUpdate() { + surface = viewModel.surface + line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + line.orientation = viewModel.orientation } - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - if let lineModel = model as? LineModel { - setStyle(lineModel.type) - } + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + public func updateView(_ size: CGFloat) { + setNeedsDisplay() } - - open override func reset() { - setStyle(.secondary) - } - - public override static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return (model as? LineModel)?.thickness ?? 1 + + public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 1 } } +//-------------------------------------------------- +// MARK: - MVMCoreUIViewConstrainingProtocol +//-------------------------------------------------- extension Line: MVMCoreUIViewConstrainingProtocol { open func needsToBeConstrained() -> Bool { diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index 3b4c57e9..ecb39df0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -8,8 +8,9 @@ import UIKit import VDSColorTokens +import VDS -@objcMembers public class LineModel: MoleculeModelProtocol { +@objcMembers public class LineModel: MoleculeModelProtocol, Invertable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -28,23 +29,9 @@ import VDSColorTokens case between } - /** - The style of the line: - - secondary (1 height, silver) - - primary (1 height, black) - - standard (1 height, silver) - deprecated - - thin (1 height, black) - deprecated - - medium (2 height, black) - - heavy (4 height, black) - - none (hidden) - */ public enum Style: String, Codable { case secondary case primary - case standard - case thin - case medium - case heavy case none } @@ -54,53 +41,14 @@ import VDSColorTokens public static var identifier: String = "line" public var id: String = UUID().uuidString - - public var type: Style = .secondary + public var backgroundColor: Color? + + public var type: Style = .primary public var frequency: Frequency? = .allExceptTop - - //TODO: use color insted of backgroundColor. Needs server changes - // public var color: Color? - private var _backgroundColor: Color? - public var backgroundColor: Color? { - get { - if let backgroundColor = _backgroundColor { return backgroundColor } - if inverted { - if type == .secondary || type == .standard { return Color(uiColor: VDSColor.paletteGray20) } - return Color(uiColor: VDSColor.elementsPrimaryOndark) - } - if type == .secondary || type == .standard { return Color(uiColor: VDSColor.paletteGray85) } - return Color(uiColor: VDSColor.elementsPrimaryOnlight) - } - set { - _backgroundColor = newValue - } - } - - private var _thickness: CGFloat? - public var thickness: CGFloat { - get { - if let thickness = _thickness { return thickness } - switch type { - case .heavy: - return 4 - case .medium: - return 2 - case .none: - return 0 - default: - return 1 - } - } - set { - _thickness = newValue - } - } - + public var inverted: Bool = false - // Use this to show vertical line - // Default is false - public var useVerticalLine: Bool? + public var orientation: VDS.Line.Orientation = .horizontal //-------------------------------------------------- // MARK: - Initializer @@ -108,13 +56,10 @@ import VDSColorTokens public init(type: Style) { self.type = type - self.useVerticalLine = false } public init(verticalLineOf type: Style, backgroundColor: Color? = nil) { self.type = type - self.backgroundColor = backgroundColor - self.useVerticalLine = true } //-------------------------------------------------- @@ -125,13 +70,10 @@ import VDSColorTokens case id case moleculeName case type - case backgroundColor - case backgroundColor_inverted - case color case frequency case inverted case useVerticalLine - case thickness + case orientation } //-------------------------------------------------- @@ -155,9 +97,12 @@ import VDSColorTokens self.inverted = inverted } - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) - _thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) + /// adding code to look for the old useVerticalLine or the new orientation + if let useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) { + orientation = useVerticalLine ? .vertical : .horizontal + }else if let orientation = try typeContainer.decodeIfPresent(VDS.Line.Orientation.self, forKey: .orientation) { + self.orientation = orientation + } } public func encode(to encoder: Encoder) throws { @@ -167,8 +112,6 @@ import VDSColorTokens try container.encode(type, forKey: .type) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(useVerticalLine, forKey: .useVerticalLine) - try container.encodeIfPresent(_thickness, forKey: .thickness) + try container.encodeIfPresent(orientation == .vertical, forKey: .useVerticalLine) } } From 2e03cec5be3ed5ed51c991c56823ed7f7cb0969d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:27:51 -0500 Subject: [PATCH 04/16] updated ListProgressBarThin Signed-off-by: Matt Bruce --- .../Molecules/DesignedComponents/List/ListProgressBarThin.swift | 2 +- .../DesignedComponents/List/ListProgressBarThinModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 9b85dc4f..d9875068 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -102,7 +102,7 @@ leftHeadline.styleB1(true) leftBody.styleB2(true) rightLabel.styleB2(true) - rightBar.setStyle(.medium) + rightBar.setStyle(.primary) } //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 52c175df..d6787f52 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -39,7 +39,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { override public func setDefaults() { super.setDefaults() - rightBar.type = .medium + rightBar.type = .primary if rightBar.backgroundColor == nil { rightBar.backgroundColor = Color(uiColor: .gray) From 81a5d5099fe7528dbe7974af702300d9c9bf02ba Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:28:16 -0500 Subject: [PATCH 05/16] updated ListRightVariableTotalData Signed-off-by: Matt Bruce --- .../List/RightVariable/ListRightVariableTotalData.swift | 4 ++-- .../List/RightVariable/ListRightVariableTotalDataModel.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift index a749041a..9845ea16 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift @@ -44,7 +44,7 @@ override open func setupView() { super.setupView() - bar.setStyle(.heavy) + bar.setStyle(.primary) bar.widthAnchor.constraint(equalToConstant: 20).isActive = true rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) addMolecule(stack) @@ -74,7 +74,7 @@ super.reset() leftLabel.setFontStyle(.BoldBodySmall) rightLabel.setFontStyle(.RegularBodySmall) - bar.setStyle(.heavy) + bar.setStyle(.primary) } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift index cebaeb34..53ede6e5 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift @@ -24,7 +24,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc override public func setDefaults() { super.setDefaults() rightLabel.hero = 0 - bar.type = .heavy + bar.type = .primary if bar.backgroundColor == nil { bar.backgroundColor = Color(uiColor: .mvmBlue) From aed46d592c86a8860f6d24cf716e2d0d9eaf1378 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:28:38 -0500 Subject: [PATCH 06/16] updated tabs and tabs model Signed-off-by: Matt Bruce --- .../Atomic/Molecules/HorizontalCombinationViews/TabBar.swift | 2 +- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index e49006fa..bbe17e05 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -50,7 +50,7 @@ import VDSColorTokens setItems(tabs, animated: false) selectedItem = tabs[model.selectedTab] - guard let lineModel = line.lineModel else { return } + guard let lineModel = line.viewModel else { return } lineModel.inverted = model.style == .dark line.set(with: lineModel, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index e5682e71..e6689f3d 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -174,7 +174,7 @@ import VDSColorTokens self.additionalData = additionalData selectedIndex = tabsModel?.selectedIndex ?? 0 selectionLine.backgroundColor = tabsModel?.selectedBarColor.uiColor - let lineModel = bottomLine.lineModel ?? LineModel(type: .secondary) + let lineModel = bottomLine.viewModel ?? LineModel(type: .secondary) lineModel.inverted = tabsModel?.style == .dark bottomLine.set(with: lineModel, delegateObject, additionalData) reloadData() From 5d9944b5eab6482d78026235a675a31e81738255 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:07:36 -0500 Subject: [PATCH 07/16] subclass line directly Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index c527a362..e3195aa2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -9,22 +9,15 @@ import UIKit import VDS -@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { +@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var line = VDS.Line() open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? - open var orientation: VDS.Line.Orientation = .horizontal { - didSet { - viewModel.orientation = orientation - update(viewModel: viewModel) - } - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -47,15 +40,6 @@ import VDS super.init(coder: coder) viewModel = LineModel(type: .primary) } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - open override func setup() { - super.setup() - addSubview(line) - line.pinToSuperView() - } //-------------------------------------------------- // MARK: - Methods @@ -89,8 +73,8 @@ import VDS //-------------------------------------------------- open func viewModelDidUpdate() { surface = viewModel.surface - line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary - line.orientation = viewModel.orientation + style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + orientation = viewModel.orientation } //-------------------------------------------------- From 62afe434f9a37c36fb127550b39a3862853f46df Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:07:49 -0500 Subject: [PATCH 08/16] updated to use line properties Signed-off-by: Matt Bruce --- .../UINavigationController+Extension.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index 625f0a25..d45ca632 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -81,9 +81,9 @@ public extension UINavigationController { /// Returns a ShadowImage based on the line property of NavigationItemModelProtocol func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { - guard let thickness = navigationItemModel.line?.thickness, - let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } - return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) + guard let model = navigationItemModel.line else { return nil } + let line = Line(model: model, nil, nil) + return line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)) } /// Convenience function for setting the navigation bar ui From 10370f3ac6840a89f97b158aecfe4b6691765519 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:35:46 -0500 Subject: [PATCH 09/16] Revert "subclass line directly" This reverts commit 5d9944b5eab6482d78026235a675a31e81738255. --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index e3195aa2..c527a362 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -9,15 +9,22 @@ import UIKit import VDS -@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol { +@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var line = VDS.Line() open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? - + open var orientation: VDS.Line.Orientation = .horizontal { + didSet { + viewModel.orientation = orientation + update(viewModel: viewModel) + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -40,6 +47,15 @@ import VDS super.init(coder: coder) viewModel = LineModel(type: .primary) } + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func setup() { + super.setup() + addSubview(line) + line.pinToSuperView() + } //-------------------------------------------------- // MARK: - Methods @@ -73,8 +89,8 @@ import VDS //-------------------------------------------------- open func viewModelDidUpdate() { surface = viewModel.surface - style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary - orientation = viewModel.orientation + line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + line.orientation = viewModel.orientation } //-------------------------------------------------- From b2b33db8a986517997760a7007fef6ce24a83179 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:40:56 -0500 Subject: [PATCH 10/16] Revert "Revert "subclass line directly"" This reverts commit 10370f3ac6840a89f97b158aecfe4b6691765519. --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index c527a362..e3195aa2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -9,22 +9,15 @@ import UIKit import VDS -@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { +@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var line = VDS.Line() open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? - open var orientation: VDS.Line.Orientation = .horizontal { - didSet { - viewModel.orientation = orientation - update(viewModel: viewModel) - } - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -47,15 +40,6 @@ import VDS super.init(coder: coder) viewModel = LineModel(type: .primary) } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - open override func setup() { - super.setup() - addSubview(line) - line.pinToSuperView() - } //-------------------------------------------------- // MARK: - Methods @@ -89,8 +73,8 @@ import VDS //-------------------------------------------------- open func viewModelDidUpdate() { surface = viewModel.surface - line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary - line.orientation = viewModel.orientation + style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + orientation = viewModel.orientation } //-------------------------------------------------- From 6da75b26bd94176658092e2e6baca48486ec3cd2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:51:12 -0500 Subject: [PATCH 11/16] don't call super to draw if model is set to none Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index e3195aa2..c3ce3d7f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -68,6 +68,11 @@ import VDS ) } + open override func draw(_ rect: CGRect) { + guard viewModel.type != .none else { return } + super.draw(rect) + } + //-------------------------------------------------- // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- From 2a34fa433dbeb29e0dbbfa1cd63a56bd7f981556 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:51:21 -0500 Subject: [PATCH 12/16] updated for line Signed-off-by: Matt Bruce --- .../Headers/H2/HeadersH2PricingTwoRows.swift | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index 1baf057c..f38793eb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -42,6 +42,13 @@ import Foundation return Stack.createStack(with: [headline, horizontalStack], spacing: 8) }() + + //------------------------------------------------------- + // MARK: - Constraints + //------------------------------------------------------- + public var verticalLine1HeightConstraint: NSLayoutConstraint? + public var verticalLine2HeightConstraint: NSLayoutConstraint? + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- @@ -51,11 +58,10 @@ import Foundation body.lineBreakMode = .byTruncatingTail body2.lineBreakMode = .byTruncatingTail body3.lineBreakMode = .byTruncatingTail - - verticalLine1.widthConstraint?.isActive = true - verticalLine1.backgroundColor = .mvmBlack - verticalLine2.widthConstraint?.isActive = true - verticalLine2.backgroundColor = .mvmBlack + + // setup lines + verticalLine1.orientation = .vertical + verticalLine2.orientation = .vertical addMolecule(stack) stack.restack() @@ -80,13 +86,13 @@ import Foundation } open func setLineHeight() { - verticalLine1.heightConstraint?.isActive = false - verticalLine1.heightConstraint = verticalLine1.heightAnchor.constraint(equalTo: body2.heightAnchor, multiplier: 1) - verticalLine1.heightConstraint?.isActive = true + verticalLine1HeightConstraint?.isActive = false + verticalLine1HeightConstraint = verticalLine1.heightAnchor.constraint(equalTo: body2.heightAnchor, multiplier: 1) + verticalLine1HeightConstraint?.isActive = true - verticalLine2.heightConstraint?.isActive = false - verticalLine2.heightConstraint = verticalLine2.heightAnchor.constraint(equalTo: body3.heightAnchor, multiplier: 1) - verticalLine2.heightConstraint?.isActive = true + verticalLine2HeightConstraint?.isActive = false + verticalLine2HeightConstraint = verticalLine2.heightAnchor.constraint(equalTo: body3.heightAnchor, multiplier: 1) + verticalLine2HeightConstraint?.isActive = true } //---------------------------------------------------- From 4d4f7c334d6ebc357ce6222a5578c6107d1387da Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 19:41:06 -0400 Subject: [PATCH 13/16] Code review: Fix data list items and navigation bar. --- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 24 +++++++++++---- .../List/ListProgressBarThin.swift | 9 ++++-- .../List/ListProgressBarThinModel.swift | 10 +++---- .../ListRightVariableTotalData.swift | 18 ++++++++---- .../ListRightVariableTotalDataModel.swift | 20 +++++++++---- .../UINavigationController+Extension.swift | 29 +++++++++---------- .../SubNav/SubNavManagerController.swift | 13 +++++---- 7 files changed, 77 insertions(+), 46 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index ecb39df0..a170c4b4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -10,7 +10,7 @@ import UIKit import VDSColorTokens import VDS -@objcMembers public class LineModel: MoleculeModelProtocol, Invertable { +public class LineModel: MoleculeModelProtocol, Invertable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -29,9 +29,23 @@ import VDS case between } + /** + The style of the line: + - secondary (VDS Secondary) + - primary (VDS Primary) + - standard (VDS Secondary) - deprecated + - thin (VDS Primar) - deprecated + - medium (VDS Primar) + - heavy (VDS Primar) + - none (hidden) + */ public enum Style: String, Codable { case secondary case primary + case standard + case thin + case medium + case heavy case none } @@ -43,7 +57,7 @@ import VDS public var id: String = UUID().uuidString public var backgroundColor: Color? - public var type: Style = .primary + public var type: Style = .secondary public var frequency: Frequency? = .allExceptTop public var inverted: Bool = false @@ -58,7 +72,7 @@ import VDS self.type = type } - public init(verticalLineOf type: Style, backgroundColor: Color? = nil) { + public init(verticalLineOf type: Style) { self.type = type } @@ -100,7 +114,7 @@ import VDS /// adding code to look for the old useVerticalLine or the new orientation if let useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) { orientation = useVerticalLine ? .vertical : .horizontal - }else if let orientation = try typeContainer.decodeIfPresent(VDS.Line.Orientation.self, forKey: .orientation) { + } else if let orientation = try typeContainer.decodeIfPresent(VDS.Line.Orientation.self, forKey: .orientation) { self.orientation = orientation } } @@ -112,6 +126,6 @@ import VDS try container.encode(type, forKey: .type) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(orientation == .vertical, forKey: .useVerticalLine) + try container.encode(orientation == .vertical, forKey: .useVerticalLine) } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index d9875068..e29ef00c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -7,7 +7,7 @@ // -@objcMembers open class ListProgressBarThin: TableViewCell { +open class ListProgressBarThin: TableViewCell { //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- @@ -15,7 +15,11 @@ public let progressBar = ProgressBar() public let leftHeadline = Label(fontStyle: .BoldBodySmall) public let leftBody = Label(fontStyle: .BoldBodySmall) - public let rightBar = Line() + public let rightBar: DataLine = { + var line = DataLine() + line.heightConstraint.constant = 2 + return line + }() public let rightLabel = Label(fontStyle: .BoldBodySmall) private let barStackItem: StackItem private let rightLabelStackItem: StackItem @@ -102,7 +106,6 @@ leftHeadline.styleB1(true) leftBody.styleB2(true) rightLabel.styleB2(true) - rightBar.setStyle(.primary) } //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index d6787f52..0cc5f172 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -16,14 +16,14 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { public var progressBar: ProgressBarModel public var leftHeadline: LabelModel public var leftBody: LabelModel? - public var rightBar: LineModel + public var rightBar: DataLineModel public var rightLabel: LabelModel //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, rightBar: LineModel, rightLabel: LabelModel) { + public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, rightBar: DataLineModel, rightLabel: LabelModel) { self.progressBar = progressBar self.leftHeadline = leftHeadline self.leftBody = leftBody @@ -38,9 +38,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { override public func setDefaults() { super.setDefaults() - - rightBar.type = .primary - + if rightBar.backgroundColor == nil { rightBar.backgroundColor = Color(uiColor: .gray) } @@ -74,7 +72,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar) leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) leftBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody) - rightBar = try typeContainer.decode(LineModel.self, forKey: .rightBar) + rightBar = try typeContainer.decode(DataLineModel.self, forKey: .rightBar) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift index 9845ea16..6dc1ffe2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift @@ -6,15 +6,26 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +open class DataLine: View { + + lazy var heightConstraint = heightAnchor.constraint(equalToConstant: 4) + lazy var widthConstraint = widthAnchor.constraint(equalToConstant: 20) + + open override func setupView() { + super.setupView() + heightConstraint.isActive = true + widthConstraint.isActive = true + } +} -@objcMembers open class ListRightVariableTotalData: TableViewCell { +open class ListRightVariableTotalData: TableViewCell { //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- public let leftLabel = Label(fontStyle: .BoldBodySmall) public let rightLabel = Label(fontStyle: .RegularBodySmall) - public let bar = Line() + public let bar = DataLine() //----------------------------------------------------- // MARK: - Properties @@ -44,8 +55,6 @@ override open func setupView() { super.setupView() - bar.setStyle(.primary) - bar.widthAnchor.constraint(equalToConstant: 20).isActive = true rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) addMolecule(stack) stack.restack() @@ -74,7 +83,6 @@ super.reset() leftLabel.setFontStyle(.BoldBodySmall) rightLabel.setFontStyle(.RegularBodySmall) - bar.setStyle(.primary) } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift index 53ede6e5..28a3a25c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift @@ -6,8 +6,18 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +public struct DataLineModel: Codable, MoleculeModelProtocol { + public var id: String = UUID().uuidString + public static var identifier: String = "line" + public var backgroundColor: Color? + + private enum CodingKeys: String, CodingKey { + case backgroundColor + } +} public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -15,7 +25,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc public static var identifier: String = "listRVLine" public var leftLabel: LabelModel public var rightLabel: LabelModel - public var bar: LineModel + public var bar: DataLineModel //-------------------------------------------------- // MARK: - Method @@ -24,8 +34,6 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc override public func setDefaults() { super.setDefaults() rightLabel.hero = 0 - bar.type = .primary - if bar.backgroundColor == nil { bar.backgroundColor = Color(uiColor: .mvmBlue) } @@ -35,7 +43,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc // MARK: - Initializer //-------------------------------------------------- - public init(leftLabel: LabelModel, rightlabel:LabelModel, bar: LineModel){ + public init(leftLabel: LabelModel, rightlabel:LabelModel, bar: DataLineModel) { self.leftLabel = leftLabel self.rightLabel = rightlabel self.bar = bar @@ -46,7 +54,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc // MARK: - Keys //-------------------------------------------------- - private enum CodingKeys: String, CodingKey{ + private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel case rightLabel @@ -61,7 +69,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc let typeContainer = try decoder.container(keyedBy: CodingKeys.self) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - bar = try typeContainer.decode(LineModel.self, forKey: .bar) + bar = try typeContainer.decode(DataLineModel.self, forKey: .bar) try super.init(from: decoder) } diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index ac9684ac..fb1bde79 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -82,13 +82,6 @@ public extension UINavigationController { } } - /// Returns a ShadowImage based on the line property of NavigationItemModelProtocol - func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { - guard let model = navigationItemModel.line else { return nil } - let line = Line(model: model, nil, nil) - return line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)) - } - /// Convenience function for setting the navigation bar ui @MainActor func setNavigationBarUI(with model: NavigationItemModelProtocol) { @@ -105,14 +98,7 @@ public extension UINavigationController { appearance.backgroundColor = backgroundColor appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) appearance.titlePositionAdjustment = model.titleOffset ?? .zero - if let type = model.line?.type, - type != .none, - let color = model.line?.backgroundColor { - appearance.shadowColor = color.uiColor - } else { - appearance.shadowColor = .clear - } - appearance.shadowImage = getNavigationBarShadowImage(for: model)?.withRenderingMode(.alwaysTemplate) + appearance.setShadow(for: model.line) navigationBar.standardAppearance = appearance navigationBar.scrollEdgeAppearance = appearance @@ -126,3 +112,16 @@ public extension UINavigationController { return viewController } } + +public extension UINavigationBarAppearance { + func setShadow(for model: LineModel?) { + let model = model ?? LineModel(type: .secondary) + let line = Line(model: model, nil, nil) + if model.type != .none { + shadowColor = line.lineColor + } else { + shadowColor = .clear + } + shadowImage = line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)).withRenderingMode(.alwaysTemplate) + } +} diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 458c0169..7461c93d 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -125,13 +125,14 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Hides/Shows the navigation bar for the page. open func hideNavigationBarLine(_ isHidden: Bool) { guard self == navigationController?.topViewController else { return } - var color = UIColor.clear - if !isHidden, - let backgroundColor = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line?.backgroundColor?.uiColor { - color = backgroundColor + var model: LineModel? + if isHidden { + model = LineModel(type: .none) + } else if let lineModel = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line { + model = lineModel } - navigationController?.navigationBar.standardAppearance.shadowColor = color - navigationController?.navigationBar.scrollEdgeAppearance?.shadowColor = color + navigationController?.navigationBar.standardAppearance.setShadow(for: model) + navigationController?.navigationBar.scrollEdgeAppearance?.setShadow(for: model) } open override func updateViews() { From 1da8a6db77b106baf683f625ab6e4155e7ca065f Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 20:12:36 -0400 Subject: [PATCH 14/16] Default to secondary --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 6 +++--- .../UINavigationController+Extension.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index c3ce3d7f..2d20d209 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -28,17 +28,17 @@ import VDS public required init() { super.init() - viewModel = LineModel(type: .primary) + viewModel = LineModel(type: .secondary) } public override init(frame: CGRect) { super.init(frame: frame) - viewModel = LineModel(type: .primary) + viewModel = LineModel(type: .secondary) } public required init?(coder: NSCoder) { super.init(coder: coder) - viewModel = LineModel(type: .primary) + viewModel = LineModel(type: .secondary) } //-------------------------------------------------- diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index fb1bde79..57aeb02d 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -117,7 +117,7 @@ public extension UINavigationBarAppearance { func setShadow(for model: LineModel?) { let model = model ?? LineModel(type: .secondary) let line = Line(model: model, nil, nil) - if model.type != .none { + if line.shouldBeVisible() { shadowColor = line.lineColor } else { shadowColor = .clear From e5e17a286df55c0bf4a9ef43c9ca0e3ff2ae61e5 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 20:31:25 -0400 Subject: [PATCH 15/16] fix to vertical lines --- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index a170c4b4..8a473016 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -74,6 +74,7 @@ public class LineModel: MoleculeModelProtocol, Invertable { public init(verticalLineOf type: Style) { self.type = type + orientation = .vertical } //-------------------------------------------------- From c3503edecbaf54888b915a29002f21a17ff92baa Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 20:39:50 -0400 Subject: [PATCH 16/16] Changes to ensure line does not stretch --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index 2d20d209..ba0af74f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -17,6 +17,22 @@ import VDS open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? + + open override var orientation: Line.Orientation { + didSet { + if orientation == .horizontal { + setContentHuggingPriority(.defaultLow, for: .horizontal) + setContentHuggingPriority(.required, for: .vertical) + setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + setContentCompressionResistancePriority(.required, for: .vertical) + } else { + setContentHuggingPriority(.required, for: .horizontal) + setContentHuggingPriority(.defaultLow, for: .vertical) + setContentCompressionResistancePriority(.required, for: .horizontal) + setContentCompressionResistancePriority(.defaultLow, for: .vertical) + } + } + } //-------------------------------------------------- // MARK: - Initializer