From b302d2ff61575b9168ec5a4da3a0bf1713a5b23f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 2 Apr 2020 19:47:52 -0400 Subject: [PATCH 01/17] april jira tasks --- MVMCoreUI.xcodeproj/project.pbxproj | 8 --- .../ActionCollapseNotificationModel.swift | 1 - MVMCoreUI/Actions/ActionOpenPanelModel.swift | 2 - MVMCoreUI/Actions/ActionTopAlertModel.swift | 2 - MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 - .../Doughnut/DoughnutChartView.swift | 4 +- .../Lists/NumberedListModel.swift | 9 ++-- .../StringAndMoleculeStack.swift | 7 +-- .../StringAndMoleculeView.swift | 3 +- .../Lists/UnOrderedListModel.swift | 7 ++- .../Atomic/Organisms/MoleculeStackModel.swift | 54 ------------------- .../Atomic/Organisms/MoleculeStackView.swift | 44 --------------- MVMCoreUI/Atomic/Organisms/Stack.swift | 13 +++-- MVMCoreUI/Atomic/Organisms/StackModel.swift | 20 ++++--- .../Atomic/Organisms/StackModelProtocol.swift | 4 +- .../Templates/MoleculeStackTemplate.swift | 2 +- .../Templates/StackPageTemplateModel.swift | 6 +-- 17 files changed, 41 insertions(+), 146 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Organisms/MoleculeStackModel.swift delete mode 100644 MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 60829e96..f3716e02 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -61,7 +61,6 @@ 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; 01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* MoleculeListItemModel.swift */; }; - 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368B23609801006832FA /* MoleculeStackModel.swift */; }; 01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; }; 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */; }; @@ -358,7 +357,6 @@ D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */; }; D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */; }; D29E28DD23D7404C00ACEA85 /* ContainerHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28DC23D7404C00ACEA85 /* ContainerHelper.swift */; }; - D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */; }; D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */; }; D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */; }; D2A514672213885800345BFB /* MoleculeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* MoleculeHeaderView.swift */; }; @@ -460,7 +458,6 @@ 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* MoleculeListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeListItemModel.swift; sourceTree = ""; }; 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackItemModel.swift; sourceTree = ""; }; - 01EB368B23609801006832FA /* MoleculeStackModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackModel.swift; sourceTree = ""; }; 01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = ""; }; 01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = ""; }; 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretLinkModel.swift; sourceTree = ""; }; @@ -761,7 +758,6 @@ D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeView.swift; sourceTree = ""; }; D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeModel.swift; sourceTree = ""; }; D29E28DC23D7404C00ACEA85 /* ContainerHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerHelper.swift; sourceTree = ""; }; - D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackView.swift; sourceTree = ""; }; D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackTemplate.swift; sourceTree = ""; }; D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackCenteredTemplate.swift; sourceTree = ""; }; D2A514662213885800345BFB /* MoleculeHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeHeaderView.swift; sourceTree = ""; }; @@ -1185,8 +1181,6 @@ D260105A23D0BB7100764D80 /* StackModelProtocol.swift */, D260106423D0CEA700764D80 /* StackModel.swift */, D260105C23D0BCD400764D80 /* Stack.swift */, - 01EB368B23609801006832FA /* MoleculeStackModel.swift */, - D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, D2A6390022CBB1820052ED1F /* Carousel.swift */, ); @@ -1977,7 +1971,6 @@ 0A21DB91235E0EDB00C160A2 /* DigitBox.swift in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */, - D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */, @@ -2003,7 +1996,6 @@ 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, - 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, 011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */, AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, diff --git a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift index 9a6e6793..1a665b80 100644 --- a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift +++ b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift @@ -13,5 +13,4 @@ import UIKit public var actionType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - public var title: String? } diff --git a/MVMCoreUI/Actions/ActionOpenPanelModel.swift b/MVMCoreUI/Actions/ActionOpenPanelModel.swift index 55fd272a..6ada6f04 100644 --- a/MVMCoreUI/Actions/ActionOpenPanelModel.swift +++ b/MVMCoreUI/Actions/ActionOpenPanelModel.swift @@ -22,8 +22,6 @@ public class ActionOpenPanelModel: ActionModelProtocol { public var panel: Panel public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - // Temporary fix till server changes - public var title: String? public init(panel: Panel) { self.panel = panel diff --git a/MVMCoreUI/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Actions/ActionTopAlertModel.swift index 628633c2..29838c76 100644 --- a/MVMCoreUI/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Actions/ActionTopAlertModel.swift @@ -14,8 +14,6 @@ import Foundation public var pageType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - // Temporary fix till server changes - public var title: String? public init(pageType: String) { self.pageType = pageType diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 7f56f142..7d35dbce 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -37,7 +37,6 @@ import Foundation /// Call to register all of the CoreUI molecules. public static func registerObjects() { // Stacks - MoleculeObjectMapping.shared()?.register(viewClass: MoleculeStackView.self, viewModelClass: MoleculeStackModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Stack.self, viewModelClass: StackModel.self) MoleculeObjectMapping.shared()?.register(viewClass: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) MoleculeObjectMapping.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift index 280385cb..bffea398 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift @@ -76,7 +76,7 @@ import Foundation for item in model.sections { stackItems.append(MoleculeStackItemModel(with: item)) } - let stack = MoleculeStackModel(molecules: stackItems) + let stack = StackModel(molecules: stackItems) stack.verticalAlignment = .fill colorLablesStack.set(with: stack, delegateObject, additionalData) } @@ -88,7 +88,7 @@ extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { } } -class ColorViewLabelsStack: MoleculeStackView { +class ColorViewLabelsStack: Stack { override func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 8a7b6125..f58a62ff 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class NumberedListModel: MoleculeStackModel { +@objcMembers public class NumberedListModel: StackModel { public override class var identifier: String { return "numberedList" } @@ -28,8 +28,7 @@ import Foundation for (index, molecule) in list.enumerated() { models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule))) } - super.init(molecules: models) - spacing = 0 + super.init(molecules: models, spacing: 0) } public override func encode(to encoder: Encoder) throws { @@ -39,9 +38,9 @@ import Foundation var models: [MoleculeModelProtocol] = [] for molecule in molecules { - models.append(molecule.molecule) + models.append((molecule as! MoleculeStackItemModel).molecule) } - try container.encodeModels(models, forKey: .list) + try container.encodeModels(molecules, forKey: .list) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift index 4ff045ce..8bd6d005 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift @@ -9,10 +9,11 @@ import UIKit // This class is only temporarily necessary. Eventually we will have initWithModel instad of just init for moleculeviews, which will remove this need. -open class StringAndMoleculeStack: MoleculeStackView { +open class StringAndMoleculeStack: Stack { override open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let model = stackModel else { return } - for stackItemModel in model.molecules { + guard let model = model as? StackModelProtocol, + let molcules = model.molecules as? [MoleculeStackItemModel] else { return } + for stackItemModel in molcules { guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel, let molecule = MoleculeObjectMapping.shared()?.createMolecule(stringAndMoleculeModel.molecule, delegateObject: delegateObject , additionalData: additionalData) else { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index 6db91703..a7c9e20d 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -10,7 +10,6 @@ import Foundation open class StringAndMoleculeView: View { var label = Label.commonLabelB2(true) - var string: String var molecule: MoleculeViewProtocol var leftWidthConstraint: NSLayoutConstraint? @@ -28,7 +27,7 @@ open class StringAndMoleculeView: View { // MARK: - Inits public init(string: String, molecule: MoleculeViewProtocol) { - self.string = string + self.label.text = string self.molecule = molecule super.init(frame: .zero) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 84d23a11..32764641 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class UnOrderedListModel: MoleculeStackModel { +@objcMembers public class UnOrderedListModel: StackModel { public override class var identifier: String { return "unOrderedList" } @@ -33,8 +33,7 @@ import Foundation for molecule in list { models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule))) } - super.init(molecules: models) - spacing = 0 + super.init(molecules: models, spacing: 0) } public override func encode(to encoder: Encoder) throws { @@ -45,7 +44,7 @@ import Foundation var models: [MoleculeModelProtocol] = [] for molecule in molecules { - models.append(molecule.molecule) + models.append((molecule as! MoleculeStackItemModel).molecule) } try container.encodeModels(models, forKey: .list) } diff --git a/MVMCoreUI/Atomic/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Atomic/Organisms/MoleculeStackModel.swift deleted file mode 100644 index 134cc701..00000000 --- a/MVMCoreUI/Atomic/Organisms/MoleculeStackModel.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// MoleculeStack.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/3/19. -// Copyright © 2019 Suresh, Kamlesh. All rights reserved. -// -// A stack that has a list molecule stack items. - -import Foundation - -@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeModelProtocol, StackModelProtocol { - public class var identifier: String { - return "stack" - } - public var backgroundColor: Color? - public var molecules: [MoleculeStackItemModel] - public var axis: NSLayoutConstraint.Axis = .vertical - public var spacing: CGFloat = 16.0 - public var useStackSpacingBeforeFirstItem = false - - public init(molecules: [MoleculeStackItemModel]) { - self.molecules = molecules - super.init() - } - - private enum CodingKeys: String, CodingKey { - case moleculeName - case molecules - case axis - case spacing - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules) - if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) { - axis = optionalAxis - } - if let spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) { - self.spacing = spacing - } - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(molecules, forKey: .molecules) - try container.encodeIfPresent(axis.rawValueString, forKey: .axis) - try container.encodeIfPresent(spacing, forKey: .spacing) - } -} diff --git a/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift deleted file mode 100644 index 0f13cde5..00000000 --- a/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift +++ /dev/null @@ -1,44 +0,0 @@ -// -// MoleculeStackView.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 2/11/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class MoleculeStackView: Stack { - open override var stackModel: MoleculeStackModel? { - get { return model as? MoleculeStackModel } - } - - /// Convenience function, adds a molecule to a MoleculeStackItem to the MoleculeStack - func setup(with views: [View], lastItem: Bool) { - var models: [MoleculeStackItemModel] = [] - for view in views { - guard let model = view.model else { return } - let stackItemModel = MoleculeStackItemModel(with: model) - let stackItem = MoleculeStackItem(andContain: view) - stackItems.append(stackItem) - models.append(stackItemModel) - } - if let stackModel = stackModel { - stackModel.molecules = models - } else { - model = MoleculeStackModel(molecules: models) - } - restack() - } - - // MARK: - Adding to stack - /// Creates all of the stackItems for the stackItemModels - override open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let stackItemModels = stackModel?.molecules else { return } - for model in stackItemModels { - if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) as? MoleculeStackItem { - stackItems.append(stackItem) - } - } - } -} diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index e957a2a6..d1c127fd 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -217,7 +217,14 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto //-------------------------------------------------- /// Can be subclassed to create views when we get stack item models and have no views yet - open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { } + open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let stackItemModels = (model as? StackModelProtocol)?.molecules else { return } + for model in stackItemModels { + if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) as? (MoleculeViewProtocol & StackModelProtocol) { + stackItems.append(stackItem) + } + } + } /// Can be subclassed to set stack items with model when we already have views open func setStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -243,10 +250,10 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto } /// Sets the stack with StackItems containing the passed in views and sets the StackModel with models. - open func set(with viewModels:[(view: UIView, model: T.AnyStackItemModel)]) { + open func set(with viewModels:[(view: UIView, model: StackItemModel)]) { guard var stackModel = self.stackModel else { return } var stackItems: [StackItem] = [] - var models: [T.AnyStackItemModel] = [] + var models: [StackItemModel] = [] for item in viewModels { stackItems.append(StackItem(andContain: item.view)) models.append(item.model) diff --git a/MVMCoreUI/Atomic/Organisms/StackModel.swift b/MVMCoreUI/Atomic/Organisms/StackModel.swift index 46f68c3b..43dd7058 100644 --- a/MVMCoreUI/Atomic/Organisms/StackModel.swift +++ b/MVMCoreUI/Atomic/Organisms/StackModel.swift @@ -8,17 +8,19 @@ import Foundation -@objcMembers public class StackModel: StackModelProtocol, MoleculeModelProtocol { +@objcMembers public class StackModel: ContainerModel, StackModelProtocol, MoleculeModelProtocol { static let defaultSpacing: CGFloat = 16.0 - public static var identifier: String = "simpleStack" + public class var identifier: String { + return "stack" + } public var backgroundColor: Color? - public var molecules: [StackItemModel] + public var molecules: [StackItemModelProtocol] public var axis: NSLayoutConstraint.Axis = .vertical public var spacing: CGFloat = StackModel.defaultSpacing public var useStackSpacingBeforeFirstItem = false - public init(molecules: [StackItemModel], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) { + public init(molecules: [StackItemModelProtocol], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) { self.molecules = molecules if let axis = axis { self.axis = axis @@ -26,6 +28,7 @@ import Foundation if let spacing = spacing { self.spacing = spacing } + super.init() } private enum CodingKeys: String, CodingKey { @@ -38,19 +41,20 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - - molecules = try typeContainer.decode([StackItemModel].self, forKey: .molecules) + molecules = try typeContainer.decodeModel(codingKey: .molecules) if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) { axis = optionalAxis } if let spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) { self.spacing = spacing } + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(molecules, forKey: .molecules) + try container.encodeModels(molecules, forKey: .molecules) try container.encodeIfPresent(axis.rawValueString, forKey: .axis) try container.encodeIfPresent(spacing, forKey: .spacing) try container.encode(moleculeName, forKey: .moleculeName) diff --git a/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift b/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift index b7385466..75c29a3e 100644 --- a/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift +++ b/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift @@ -9,9 +9,7 @@ import Foundation public protocol StackModelProtocol { - associatedtype AnyStackItemModel: StackItemModelProtocol - - var molecules: [AnyStackItemModel] { get set } + var molecules: [StackItemModelProtocol] { get set } var axis: NSLayoutConstraint.Axis { get set } var spacing: CGFloat { get set } var useStackSpacingBeforeFirstItem: Bool { get set } diff --git a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift index b26bbc8a..b095f19e 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift @@ -49,7 +49,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { return nil } - let stack = MoleculeStackView(frame: .zero) + let stack = Stack(frame: .zero) moleculeStackModel.useStackSpacingBeforeFirstItem = true moleculeStackModel.useHorizontalMargins = true stack.set(with: moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil) diff --git a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift index 2b683d98..c7b5239a 100644 --- a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift @@ -15,10 +15,10 @@ import Foundation } public var header: MoleculeModelProtocol? - public var moleculeStack: MoleculeStackModel + public var moleculeStack: StackModel public var footer: MoleculeModelProtocol? - public init(pageType: String, moleculeStack: MoleculeStackModel) { + public init(pageType: String, moleculeStack: StackModel) { self.moleculeStack = moleculeStack super.init(pageType: pageType) } @@ -31,7 +31,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeStack = try typeContainer.decode(MoleculeStackModel.self, forKey: .stack) + moleculeStack = try typeContainer.decode(StackModel.self, forKey: .stack) header = try typeContainer.decodeModelIfPresent(codingKey: .header) footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) try super.init(from: decoder) From 9e241e6d8e2a69d51e1d3bd6c68c95227272e845 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 3 Apr 2020 11:03:12 -0400 Subject: [PATCH 02/17] Molecule stack fix --- .../Atomic/Molecules/Items/StackItemModelProtocol.swift | 2 +- MVMCoreUI/Atomic/Organisms/Stack.swift | 2 +- MVMCoreUI/Atomic/Organisms/StackModel.swift | 6 +++--- MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/StackItemModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/Items/StackItemModelProtocol.swift index 170fce69..2223ed39 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/StackItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/StackItemModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol StackItemModelProtocol: MoleculeModelProtocol { +public protocol StackItemModelProtocol { var spacing: CGFloat? { get set } var percent: Int? { get set } var gone: Bool { get set } diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index d1c127fd..ab17be3b 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -220,7 +220,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let stackItemModels = (model as? StackModelProtocol)?.molecules else { return } for model in stackItemModels { - if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) as? (MoleculeViewProtocol & StackModelProtocol) { + if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) { stackItems.append(stackItem) } } diff --git a/MVMCoreUI/Atomic/Organisms/StackModel.swift b/MVMCoreUI/Atomic/Organisms/StackModel.swift index 43dd7058..cc8f7d0e 100644 --- a/MVMCoreUI/Atomic/Organisms/StackModel.swift +++ b/MVMCoreUI/Atomic/Organisms/StackModel.swift @@ -15,12 +15,12 @@ import Foundation return "stack" } public var backgroundColor: Color? - public var molecules: [StackItemModelProtocol] + public var molecules: [StackItemModelProtocol & MoleculeModelProtocol] public var axis: NSLayoutConstraint.Axis = .vertical public var spacing: CGFloat = StackModel.defaultSpacing public var useStackSpacingBeforeFirstItem = false - public init(molecules: [StackItemModelProtocol], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) { + public init(molecules: [StackItemModelProtocol & MoleculeModelProtocol], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) { self.molecules = molecules if let axis = axis { self.axis = axis @@ -41,7 +41,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeModel(codingKey: .molecules) + molecules = try typeContainer.decodeModels(codingKey: .molecules) if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) { axis = optionalAxis } diff --git a/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift b/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift index 75c29a3e..54f6c9d0 100644 --- a/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift +++ b/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol StackModelProtocol { - var molecules: [StackItemModelProtocol] { get set } + var molecules: [StackItemModelProtocol & MoleculeModelProtocol] { get set } var axis: NSLayoutConstraint.Axis { get set } var spacing: CGFloat { get set } var useStackSpacingBeforeFirstItem: Bool { get set } From 24bce846f4438d2cbce4133a1af34442202f1f62 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 3 Apr 2020 11:42:31 -0400 Subject: [PATCH 03/17] progress updates --- MVMCoreUI.xcodeproj/project.pbxproj | 24 ++++++++-------- .../Atomic/Atoms/Views/MultiProgress.swift | 14 ++++------ .../Atoms/Views/MultiProgressModel.swift | 18 ++++++------ .../Atomic/Atoms/Views/ProgressBar.swift | 9 +++--- .../Atomic/Atoms/Views/ProgressBarModel.swift | 18 ++++++------ .../Views/{GraphView.swift => Wheel.swift} | 28 +++++++++---------- ...dler.swift => WheelAnimationHandler.swift} | 6 ++-- ...leProgressModel.swift => WheelModel.swift} | 6 ++-- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 +- .../List/RightVariable/ListRVWheel.swift | 2 +- .../List/RightVariable/ListRVWheelModel.swift | 6 ++-- 11 files changed, 65 insertions(+), 68 deletions(-) rename MVMCoreUI/Atomic/Atoms/Views/{GraphView.swift => Wheel.swift} (87%) rename MVMCoreUI/Atomic/Atoms/Views/{GraphViewAnimationHandler.swift => WheelAnimationHandler.swift} (82%) rename MVMCoreUI/Atomic/Atoms/Views/{CircleProgressModel.swift => WheelModel.swift} (96%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f3716e02..33daa259 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -136,8 +136,8 @@ 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; }; 942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378D2412F5B60066E45E /* ModalMoleculeStackTemplate.swift */; }; 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */; }; - 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; - 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; + 943784F5236B77BB006A1E82 /* Wheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* Wheel.swift */; }; + 943784F6236B77BB006A1E82 /* WheelAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* WheelAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; }; 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */; }; @@ -249,7 +249,7 @@ D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837C23CCA86A00DFE4FC /* TabsListItemModel.swift */; }; D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837E23CCA96400DFE4FC /* TabsModel.swift */; }; D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */; }; - D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */; }; + D28A838323CCBD3F00DFE4FC /* WheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838223CCBD3F00DFE4FC /* WheelModel.swift */; }; D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; }; D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; }; D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */; }; @@ -525,8 +525,8 @@ 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalMoleculeListTemplate.swift; sourceTree = ""; }; 942C378D2412F5B60066E45E /* ModalMoleculeStackTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalMoleculeStackTemplate.swift; sourceTree = ""; }; 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; - 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; - 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = ""; }; + 943784F3236B77BB006A1E82 /* Wheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wheel.swift; sourceTree = ""; }; + 943784F4236B77BB006A1E82 /* WheelAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WheelAnimationHandler.swift; sourceTree = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = ""; }; 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretViewModel.swift; sourceTree = ""; }; @@ -635,7 +635,7 @@ D28A837C23CCA86A00DFE4FC /* TabsListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsListItemModel.swift; sourceTree = ""; }; D28A837E23CCA96400DFE4FC /* TabsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsModel.swift; sourceTree = ""; }; D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionListItemModel.swift; sourceTree = ""; }; - D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleProgressModel.swift; sourceTree = ""; }; + D28A838223CCBD3F00DFE4FC /* WheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WheelModel.swift; sourceTree = ""; }; D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = ""; }; D28A838823CCCFCB00DFE4FC /* LinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkModel.swift; sourceTree = ""; }; D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonModel.swift; sourceTree = ""; }; @@ -1539,9 +1539,9 @@ 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */, - D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, - 943784F3236B77BB006A1E82 /* GraphView.swift */, - 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */, + D28A838223CCBD3F00DFE4FC /* WheelModel.swift */, + 943784F3236B77BB006A1E82 /* Wheel.swift */, + 943784F4236B77BB006A1E82 /* WheelAnimationHandler.swift */, D260105223CEA61600764D80 /* ToggleModel.swift */, 0AA33B392398524F0067DD0F /* Toggle.swift */, 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */, @@ -1902,7 +1902,7 @@ 5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */, 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */, 8D070BB0241B56530099AC56 /* ListRightVariableTotalDataModel.swift in Sources */, - 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, + 943784F5236B77BB006A1E82 /* Wheel.swift in Sources */, 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */, 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, @@ -2008,7 +2008,7 @@ D2A514672213885800345BFB /* MoleculeHeaderView.swift in Sources */, D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */, 01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */, - D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, + D28A838323CCBD3F00DFE4FC /* WheelModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, @@ -2149,7 +2149,7 @@ D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, 94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */, - 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, + 943784F6236B77BB006A1E82 /* WheelAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift index 72f84f5e..adf480c2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift @@ -24,14 +24,12 @@ import UIKit } var previous: UIView? for progressObject in progressList! { - guard progressObject.progress > 0.0 else { - continue - } + guard progressObject.percent > 0.0 else { continue } let view = UIView(frame: .zero) view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) - view.backgroundColor = progressObject.progressColor.uiColor - view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress/100.0).isActive = true + view.backgroundColor = progressObject.color.uiColor + view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.percent/100.0).isActive = true view.leadingAnchor.constraint(equalTo: previous?.trailingAnchor ?? leadingAnchor).isActive = true previous = view NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: false, pinRight: false) @@ -39,9 +37,9 @@ import UIKit } } - var roundedRect: Bool = false { + var roundedCorners: Bool = false { didSet { - if roundedRect { + if roundedCorners { layer.cornerRadius = (thicknessConstraint?.constant ?? defaultHeight)/2 } else { layer.cornerRadius = 0 @@ -69,7 +67,7 @@ import UIKit guard let multiProgressModel = multiProgressModel else { return } - roundedRect = multiProgressModel.roundedRect ?? false + roundedCorners = multiProgressModel.roundedCorners ?? false thicknessConstraint?.constant = multiProgressModel.thickness ?? defaultHeight progressList = multiProgressModel.progressList diff --git a/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift index 4033fd28..fb70ffd0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift @@ -9,12 +9,12 @@ import Foundation @objcMembers public class SingleProgressBarModel: Codable { - @Percent var progress: CGFloat - var progressColor: Color + @Percent var percent: CGFloat + var color: Color - init(_ progress: CGFloat, color: Color) { - self.progress = progress - self.progressColor = color + init(_ percent: CGFloat, color: Color) { + self.percent = percent + self.color = color } } @@ -23,13 +23,13 @@ import Foundation public var progressList: [SingleProgressBarModel] public var backgroundColor: Color? public var thickness: CGFloat? - public var roundedRect: Bool? + public var roundedCorners: Bool? private enum CodingKeys: String, CodingKey { case moleculeName case progressList case thickness - case roundedRect + case roundedCorners case backgroundColor } @@ -42,7 +42,7 @@ import Foundation progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) - roundedRect = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedRect) + roundedCorners = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedCorners) } public func encode(to encoder: Encoder) throws { @@ -50,7 +50,7 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encode(progressList, forKey: .progressList) try container.encodeIfPresent(thickness, forKey: .thickness) - try container.encodeIfPresent(roundedRect, forKey: .roundedRect) + try container.encodeIfPresent(roundedCorners, forKey: .roundedCorners) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift index 1b9f1e74..edb8c1de 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift @@ -14,7 +14,7 @@ import Foundation var thickness: CGFloat = 8.0 { willSet(newValue) { heightAnchor.constraint(equalToConstant: newValue).isActive = true - if progressBarModel?.isRounded ?? false { + if progressBarModel?.roundedCorners ?? false { layer.cornerRadius = newValue/2.0 } else { progressViewStyle = .bar @@ -52,12 +52,11 @@ import Foundation //MARK: - MoleculeViewProtocol public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let progressBarModel = model as? ProgressBarModel else { - return - } + guard let progressBarModel = model as? ProgressBarModel else { return } + self.progressBarModel = progressBarModel thickness = progressBarModel.thickness ?? 8 progress = Float((progressBarModel.percent)/100.0) - progressTintColor = progressBarModel.progressColor.uiColor + progressTintColor = progressBarModel.color.uiColor if let backgroundColor = progressBarModel.backgroundColor { trackTintColor = backgroundColor.uiColor } diff --git a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift index dd53afac..7cef8936 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift @@ -11,17 +11,17 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeModelProtocol { public static var identifier: String = "progressBar" @Percent public var percent: CGFloat - public var progressColor: Color = Color(uiColor: .mfCerulean()) + public var color: Color = Color(uiColor: .mfCerulean()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) - public var isRounded: Bool? + public var roundedCorners: Bool? public var thickness: CGFloat? private enum CodingKeys: String, CodingKey { case moleculeName - case isRounded = "roundRect" + case roundedCorners case thickness case percent - case progressColor + case color case backgroundColor } @@ -32,13 +32,13 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) percent = try typeContainer.decode(CGFloat.self, forKey: .percent) - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .progressColor) { - progressColor = color + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) { + self.color = color } if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { backgroundColor = color } - isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) + roundedCorners = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedCorners) thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) } @@ -46,9 +46,9 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(percent, forKey: .percent) - try container.encode(progressColor, forKey: .progressColor) + try container.encode(color, forKey: .color) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(isRounded, forKey: .isRounded) + try container.encodeIfPresent(roundedCorners, forKey: .roundedCorners) try container.encodeIfPresent(thickness, forKey: .thickness) } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/GraphView.swift b/MVMCoreUI/Atomic/Atoms/Views/Wheel.swift similarity index 87% rename from MVMCoreUI/Atomic/Atoms/Views/GraphView.swift rename to MVMCoreUI/Atomic/Atoms/Views/Wheel.swift index 3cf22d79..da71ea0f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Wheel.swift @@ -1,5 +1,5 @@ // -// GraphView.swift +// Wheel.swift // MobileFirstFramework // // Created by Ryan on 10/24/19. @@ -8,12 +8,12 @@ import UIKit -@objcMembers open class GraphView: View, MVMCoreUIViewConstrainingProtocol { +@objcMembers open class Wheel: View, MVMCoreUIViewConstrainingProtocol { var heightConstraint: NSLayoutConstraint? var gradientLayer: CALayer? - var graphModel: CircleProgressModel? { - return model as? CircleProgressModel + var graphModel: WheelModel? { + return model as? WheelModel } // MARK: setup @@ -28,7 +28,7 @@ import UIKit override open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - guard let model = model as? CircleProgressModel else { return } + guard let model = model as? WheelModel else { return } createGraphCircle(model) rotationAnimation(model) } @@ -42,7 +42,7 @@ import UIKit } // MARK: circle - open func createGraphCircle(_ graphObject: CircleProgressModel) { + open func createGraphCircle(_ graphObject: WheelModel) { if let sublayers = layer.sublayers { for sublayer in sublayers { sublayer.removeAllAnimations() @@ -56,7 +56,7 @@ import UIKit //begin point will be at the bottom, clockwise direction let path = UIBezierPath(arcCenter: CGPoint(x: radius - , y: radius), radius: radius - graphObject.lineWidth/2.0, startAngle: CGFloat(GraphView.getPiValue(90.0)), endAngle: CGFloat(GraphView.getPiValue(90.0 + 360.0)), clockwise: true) + , y: radius), radius: radius - graphObject.lineWidth/2.0, startAngle: CGFloat(Wheel.getPiValue(90.0)), endAngle: CGFloat(Wheel.getPiValue(90.0 + 360.0)), clockwise: true) path.lineWidth = graphObject.lineWidth let circleLayer = CAShapeLayer() @@ -83,7 +83,7 @@ import UIKit | | | ------------- */ - func createGradientLayer(_ graphObject: CircleProgressModel) -> CALayer { + func createGradientLayer(_ graphObject: WheelModel) -> CALayer { let containLayer = CALayer() containLayer.frame = CGRect(x: 0, y: 0, width: graphObject.diameter, height: graphObject.diameter) let radius = graphObject.diameter / 2.0 @@ -151,18 +151,18 @@ import UIKit } //MARK: Animation - func rotationAnimation(_ object: CircleProgressModel) { + func rotationAnimation(_ object: WheelModel) { MVMCoreDispatchUtility.performBlock(onMainThread:{ let rotation = CABasicAnimation(keyPath: "transform.rotation") - let animationHandler = GraphViewAnimationHandler.shared + let animationHandler = WheelAnimationHandler.shared let startAngle = animationHandler.getAnimationStartAngle(object.duration, CACurrentMediaTime()) if startAngle == 0.0 { animationHandler.storeAnimation(object.duration, CACurrentMediaTime()) } - var fromValue = GraphView.getPiValue(0.0 + startAngle), toValue = GraphView.getPiValue(360.0 + startAngle) + var fromValue = Wheel.getPiValue(0.0 + startAngle), toValue = Wheel.getPiValue(360.0 + startAngle) if !object.clockwise { - fromValue = GraphView.getPiValue(360.0 - startAngle) - toValue = GraphView.getPiValue(0.0 - startAngle) + fromValue = Wheel.getPiValue(360.0 - startAngle) + toValue = Wheel.getPiValue(0.0 - startAngle) } rotation.fromValue = fromValue rotation.toValue = toValue @@ -180,7 +180,7 @@ import UIKit } -extension GraphView: CAAnimationDelegate { +extension Wheel: CAAnimationDelegate { public func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { if let object = graphModel { rotationAnimation(object) diff --git a/MVMCoreUI/Atomic/Atoms/Views/GraphViewAnimationHandler.swift b/MVMCoreUI/Atomic/Atoms/Views/WheelAnimationHandler.swift similarity index 82% rename from MVMCoreUI/Atomic/Atoms/Views/GraphViewAnimationHandler.swift rename to MVMCoreUI/Atomic/Atoms/Views/WheelAnimationHandler.swift index 2d7489dc..9a862cec 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/GraphViewAnimationHandler.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WheelAnimationHandler.swift @@ -1,5 +1,5 @@ // -// GraphViewAnimationHandler.swift +// WheelAnimationHandler.swift // MobileFirstFramework // // Created by Ryan on 10/29/19. @@ -8,12 +8,12 @@ import UIKit -@objcMembers open class GraphViewAnimationHandler: NSObject { +@objcMembers open class WheelAnimationHandler: NSObject { /// duration : CACurrentMediaTime() private var animations = [Double: Double]() - static let shared = GraphViewAnimationHandler() + static let shared = WheelAnimationHandler() open func storeAnimation(_ duration: Double, _ currentTime: CFTimeInterval) { guard animations[duration] == nil else { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atomic/Atoms/Views/WheelModel.swift similarity index 96% rename from MVMCoreUI/Atomic/Atoms/Views/CircleProgressModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/WheelModel.swift index 2fc67b44..85e4fffb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WheelModel.swift @@ -1,5 +1,5 @@ // -// CircleProgressModel.swift +// WheelModel.swift // MVMCoreUI // // Created by Scott Pfeil on 1/13/20. @@ -16,9 +16,9 @@ public enum GraphStyle: String, Codable { case unlimited, safetyMode } -public class CircleProgressModel: MoleculeModelProtocol { +public class WheelModel: MoleculeModelProtocol { - public static var identifier: String = "circleProgress" + public static var identifier: String = "wheel" public var style: GraphStyle = .unlimited { didSet { updateStyle() diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 7d35dbce..354bb082 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -72,7 +72,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: DashLine.self, viewModelClass: DashLineModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MFLoadImageView.self, viewModelClass: ImageViewModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Line.self, viewModelClass: LineModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: GraphView.self, viewModelClass: CircleProgressModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Wheel.self, viewModelClass: WheelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift index 8ca28609..f7c65dbe 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift @@ -8,7 +8,7 @@ import Foundation @objcMembers open class ListRVWheel: TableViewCell { - let wheel = GraphView(frame: .zero) + let wheel = Wheel(frame: .zero) let leftLabel = Label.commonLabelB1(true) let rightLabel = Label.commonLabelB2(true) var stack: Stack diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift index 89b70b0f..a5df2cfe 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift @@ -11,9 +11,9 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "listRVWheel" public var leftLabel: LabelModel public var rightLabel: LabelModel - public var wheel : CircleProgressModel + public var wheel: WheelModel - public init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: CircleProgressModel) { + public init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: WheelModel) { self.leftLabel = leftLabel self.rightLabel = rightLabel self.wheel = wheel @@ -37,7 +37,7 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - wheel = try typeContainer.decodeIfPresent(CircleProgressModel.self, forKey: .wheel) ?? CircleProgressModel() + wheel = try typeContainer.decodeIfPresent(WheelModel.self, forKey: .wheel) ?? WheelModel() try super.init(from: decoder) } From 10ed8bcb6658b0d0a757da5fcfe9d455bfca62b7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 3 Apr 2020 11:45:06 -0400 Subject: [PATCH 04/17] link color update MOBFIRST-20060 --- MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift | 2 +- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 2 +- MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift index 9fe48936..5b4e5671 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift @@ -25,7 +25,7 @@ open class ExternalLink: Link { guard let model = model as? ExternalLinkModel else { return } - exportImageView?.tintColor = model.textColor.uiColor + exportImageView?.tintColor = model.enabledColor.uiColor } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index d65ce3ce..5f5e6e12 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -52,7 +52,7 @@ import UIKit guard let model = model as? LinkModel else { return } setTitle(model.title, for: .normal) - setTitleColor(model.textColor.uiColor, for: .normal) + setTitleColor(model.enabledColor.uiColor, for: .normal) setTitleColor(model.disabledColor.uiColor, for: .disabled) isEnabled = model.enabled set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 7a4661bd..a54f23e9 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -21,7 +21,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { public var title: String public var action: ActionModelProtocol public var enabled = true - public var textColor = Color(uiColor: .mvmBlack) + public var enabledColor = Color(uiColor: .mvmBlack) public var disabledColor = Color(uiColor: .mvmCoolGray6) //-------------------------------------------------- @@ -43,7 +43,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { case title case action case enabled - case textColor + case enabledColor case disabledColor } @@ -60,8 +60,8 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled } - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) { - textColor = color + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor) { + enabledColor = color } if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) { @@ -76,7 +76,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) try container.encode(enabled, forKey: .enabled) - try container.encode(textColor, forKey: .textColor) + try container.encode(enabledColor, forKey: .enabledColor) try container.encode(disabledColor, forKey: .disabledColor) } } From 7382d9acf55674367a22d7ab1eef02c6042ece0b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 3 Apr 2020 13:44:20 -0400 Subject: [PATCH 05/17] Textfield key updates: MOBFIRST-20088 --- .../Atomic/Atoms/TextFields/EntryField.swift | 6 ++-- .../Atoms/TextFields/EntryFieldModel.swift | 36 +++++++++---------- .../Atoms/TextFields/TextEntryField.swift | 9 +---- .../TextFields/TextEntryFieldModel.swift | 4 --- 4 files changed, 20 insertions(+), 35 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift index a02f87ee..88aa1559 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift @@ -256,12 +256,12 @@ import UIKit title = model.title feedback = model.feedback errorMessage = model.errorMessage - isEnabled = model.isEnabled + isEnabled = model.enabled - if let isLocked = model.isLocked { + if let isLocked = model.locked { self.isLocked = isLocked - } else if let isSelected = model.isSelected{ + } else if let isSelected = model.selected { self.isSelected = isSelected } } diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift index 729b3516..79de359b 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol { +@objcMembers public class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties @@ -23,9 +23,9 @@ import Foundation public var title: String? public var feedback: String? public var errorMessage: String = "" - public var isEnabled: Bool = true - public var isLocked: Bool? - public var isSelected: Bool? + public var enabled: Bool = true + public var locked: Bool? + public var selected: Bool? public var text: String? public var fieldKey: String? @@ -52,14 +52,12 @@ import Foundation private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor - case title = "label" - case isEnabled + case title + case enabled case feedback - case errorMessage = "errorMsg" - case isLocked - case isSelected - case isValid - case isRequired = "required" + case errorMessage + case locked + case selected case text case fieldKey case groupName @@ -84,10 +82,9 @@ import Foundation title = try typeContainer.decodeIfPresent(String.self, forKey: .title) feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) ?? "" - isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? true - isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked) - isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) - isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid) + enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true + locked = try typeContainer.decodeIfPresent(Bool.self, forKey: .locked) + selected = try typeContainer.decodeIfPresent(Bool.self, forKey: .selected) text = try typeContainer.decodeIfPresent(String.self, forKey: .text) baseValue = text @@ -104,12 +101,11 @@ import Foundation try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(feedback, forKey: .feedback) try container.encode(errorMessage, forKey: .errorMessage) - try container.encode(isEnabled, forKey: .isEnabled) - try container.encode(isLocked, forKey: .isLocked) - try container.encode(isSelected, forKey: .isSelected) - try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(isValid, forKey: .isValid) + try container.encode(enabled, forKey: .enabled) + try container.encode(locked, forKey: .locked) + try container.encode(selected, forKey: .selected) try container.encodeIfPresent(text, forKey: .text) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) } } diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift index 2e7df5ee..a421cb46 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift @@ -308,14 +308,7 @@ import UIKit break } - if let regex = model.regex, !regex.isEmpty { - validationBlock = { enteredValue in - guard let value = enteredValue else { return false } - return MVMCoreUIUtility.validate(value, withRegularExpression: regex) - } - } else { - defaultValidationBlock() - } + defaultValidationBlock() uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift index c35d812e..0057b46a 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift @@ -27,7 +27,6 @@ public var enabledTextColor: Color? public var disabledTextColor: Color? public var type: EntryType? - public var regex: String? //-------------------------------------------------- // MARK: - Keys @@ -40,7 +39,6 @@ case enabledTextColor case disabledTextColor case type - case regex } //-------------------------------------------------- @@ -55,7 +53,6 @@ enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledTextColor) disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor) type = try typeContainer.decodeIfPresent(EntryType.self, forKey: .type) - regex = try typeContainer.decodeIfPresent(String.self, forKey: .regex) } public override func encode(to encoder: Encoder) throws { @@ -67,6 +64,5 @@ try container.encodeIfPresent(enabledTextColor, forKey: .enabledTextColor) try container.encodeIfPresent(disabledTextColor, forKey: .disabledTextColor) try container.encodeIfPresent(type, forKey: .type) - try container.encodeIfPresent(regex, forKey: .regex) } } From 817e4cb7bab3c4cc09b1ebc4049097325f122a23 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 3 Apr 2020 15:22:21 -0400 Subject: [PATCH 06/17] multi progress changes --- .../Atomic/Atoms/Views/MultiProgress.swift | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift index adf480c2..67a5f840 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift @@ -9,31 +9,38 @@ import UIKit @objcMembers open class MultiProgress: View { + private let stack = Stack() var multiProgressModel: MultiProgressBarModel? { get { return model as? MultiProgressBarModel } } - + + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.init(frame: .zero) + set(with: model, delegateObject, additionalData) + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + } + + public override init(frame: CGRect) { + super.init(frame: frame) + } + ///passing value to progressList creates corresponding progress bars var progressList: Array? { didSet { - for subview in subviews { - subview.removeFromSuperview() - } - guard (progressList?.count ?? 0) > 0 else { - return - } - var previous: UIView? + stack.removeAllItemViews() + guard (progressList?.count ?? 0) > 0 else { return } + var viewModels: [(view: UIView, model: StackItemModel)] = [] for progressObject in progressList! { guard progressObject.percent > 0.0 else { continue } - let view = UIView(frame: .zero) - view.translatesAutoresizingMaskIntoConstraints = false - addSubview(view) - view.backgroundColor = progressObject.color.uiColor - view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.percent/100.0).isActive = true - view.leadingAnchor.constraint(equalTo: previous?.trailingAnchor ?? leadingAnchor).isActive = true - previous = view - NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: false, pinRight: false) + let model = StackItemModel(spacing: 0, percent: Int(progressObject.percent), horizontalAlignment: .fill, verticalAlignment: .fill) + model.backgroundColor = progressObject.color + viewModels.append((view: StackItem(frame: .zero), model: model)) } + stack.set(with: viewModels) + stack.restack() } } @@ -55,6 +62,8 @@ import UIKit translatesAutoresizingMaskIntoConstraints = false backgroundColor = .mfLightSilver() clipsToBounds = true + addSubview(stack) + NSLayoutConstraint.constraintPinSubview(toSuperview: stack) if thicknessConstraint == nil { thicknessConstraint = heightAnchor.constraint(equalToConstant: defaultHeight) thicknessConstraint?.isActive = true From cbf0f85ea796fef35af2e8d10c8cb66aebea5f5d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 3 Apr 2020 17:00:16 -0400 Subject: [PATCH 07/17] Fix to progress bar spacing MOBFIRST-20303 Brought back molecule stack --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ .../Atomic/Atoms/Views/MultiProgress.swift | 50 ++++++++------- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 +- .../Doughnut/DoughnutChartView.swift | 2 +- .../StringAndMoleculeStack.swift | 2 +- .../Atomic/Organisms/MoleculeStackView.swift | 61 +++++++++++++++++++ MVMCoreUI/Atomic/Organisms/Stack.swift | 25 +------- 7 files changed, 98 insertions(+), 48 deletions(-) create mode 100644 MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 33daa259..ffbc8621 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -202,6 +202,7 @@ D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; + D21B7F602437C5BC00051ABF /* MoleculeStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21B7F5E2437C5BC00051ABF /* MoleculeStackView.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelToggle.swift */; }; D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224798B231450C8003FCCF9 /* HeadlineBodyToggle.swift */; }; @@ -589,6 +590,7 @@ D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; + D21B7F5E2437C5BC00051ABF /* MoleculeStackView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackView.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggle.swift; sourceTree = ""; }; D224798B231450C8003FCCF9 /* HeadlineBodyToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyToggle.swift; sourceTree = ""; }; @@ -1181,6 +1183,7 @@ D260105A23D0BB7100764D80 /* StackModelProtocol.swift */, D260106423D0CEA700764D80 /* StackModel.swift */, D260105C23D0BCD400764D80 /* Stack.swift */, + D21B7F5E2437C5BC00051ABF /* MoleculeStackView.swift */, 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, D2A6390022CBB1820052ED1F /* Carousel.swift */, ); @@ -1924,6 +1927,7 @@ D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, + D21B7F602437C5BC00051ABF /* MoleculeStackView.swift in Sources */, 0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D2E2A99423D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift index 67a5f840..6339d002 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift @@ -27,23 +27,6 @@ import UIKit super.init(frame: frame) } - ///passing value to progressList creates corresponding progress bars - var progressList: Array? { - didSet { - stack.removeAllItemViews() - guard (progressList?.count ?? 0) > 0 else { return } - var viewModels: [(view: UIView, model: StackItemModel)] = [] - for progressObject in progressList! { - guard progressObject.percent > 0.0 else { continue } - let model = StackItemModel(spacing: 0, percent: Int(progressObject.percent), horizontalAlignment: .fill, verticalAlignment: .fill) - model.backgroundColor = progressObject.color - viewModels.append((view: StackItem(frame: .zero), model: model)) - } - stack.set(with: viewModels) - stack.restack() - } - } - var roundedCorners: Bool = false { didSet { if roundedCorners { @@ -62,30 +45,51 @@ import UIKit translatesAutoresizingMaskIntoConstraints = false backgroundColor = .mfLightSilver() clipsToBounds = true + addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) + stack.backgroundColor = backgroundColor + stack.contentView.backgroundColor = .white + stack.model = StackModel(molecules: [], axis: .horizontal, spacing: 2) + stack.stackModel?.horizontalAlignment = .leading + if thicknessConstraint == nil { thicknessConstraint = heightAnchor.constraint(equalToConstant: defaultHeight) thicknessConstraint?.isActive = true } } + /// Creates the bars + open func set(with progressList: Array, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let stackModel = stack.stackModel else { return } + var views: [StackItem] = [] + var models: [StackItemModel] = [] + for progressObject in progressList { + guard progressObject.percent > 0.0 else { continue } + let model = StackItemModel(percent: Int(progressObject.percent), horizontalAlignment: .fill, verticalAlignment: .fill) + model.backgroundColor = progressObject.color + models.append(model) + views.append(StackItem()) + } + stack.stackItems = views + stackModel.molecules = models + stack.set(with: stackModel, delegateObject, additionalData) + } + //MARK: - MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - guard let multiProgressModel = multiProgressModel else { - return - } + guard let multiProgressModel = multiProgressModel else { return } roundedCorners = multiProgressModel.roundedCorners ?? false thicknessConstraint?.constant = multiProgressModel.thickness ?? defaultHeight - progressList = multiProgressModel.progressList - + stack.model?.backgroundColor = model.backgroundColor + set(with: multiProgressModel.progressList, delegateObject, additionalData) } open override func reset() { super.reset() backgroundColor = .mfLightSilver() - progressList = nil + set(with: [], nil, nil) } public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 354bb082..ee26efaa 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -37,7 +37,7 @@ import Foundation /// Call to register all of the CoreUI molecules. public static func registerObjects() { // Stacks - MoleculeObjectMapping.shared()?.register(viewClass: Stack.self, viewModelClass: StackModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: MoleculeStackView.self, viewModelClass: StackModel.self) MoleculeObjectMapping.shared()?.register(viewClass: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) MoleculeObjectMapping.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift index bffea398..36bec9a5 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift @@ -88,7 +88,7 @@ extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { } } -class ColorViewLabelsStack: Stack { +class ColorViewLabelsStack: MoleculeStackView { override func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift index 8bd6d005..c887e838 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift @@ -9,7 +9,7 @@ import UIKit // This class is only temporarily necessary. Eventually we will have initWithModel instad of just init for moleculeviews, which will remove this need. -open class StringAndMoleculeStack: Stack { +open class StringAndMoleculeStack: MoleculeStackView { override open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let model = model as? StackModelProtocol, let molcules = model.molecules as? [MoleculeStackItemModel] else { return } diff --git a/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift new file mode 100644 index 00000000..c5c993f2 --- /dev/null +++ b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift @@ -0,0 +1,61 @@ +// +// MoleculeStackView.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 2/11/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// +// This is a dynamic stack view that creates molecules if needed on set. + +import UIKit + +open class MoleculeStackView: Stack { + var previousModel: MoleculeModelProtocol? + + /// Convenience function, adds a molecule to a MoleculeStackItem to the MoleculeStack + func setup(with views: [View], lastItem: Bool) { + var models: [MoleculeStackItemModel] = [] + for view in views { + guard let model = view.model else { return } + let stackItemModel = MoleculeStackItemModel(with: model) + let stackItem = MoleculeStackItem(andContain: view) + stackItems.append(stackItem) + models.append(stackItemModel) + } + if let stackModel = stackModel { + stackModel.molecules = models + } else { + model = StackModel(molecules: models) + } + restack() + } + + + + // MARK: - Adding to stack + /// Can be subclassed to create views when we get stack item models and have no views yet + open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let stackItemModels = stackModel?.molecules else { return } + for model in stackItemModels { + if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) as? MoleculeStackItem { + stackItems.append(stackItem) + } + } + } + + open override func setStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + // If the items in the stack are different, clear them, create new ones. + if (previousModel == nil) || Self.nameForReuse(with: previousModel!, delegateObject) != Self.nameForReuse(with: model, delegateObject) { + stackItems = [] + createStackItemsFromModel(model, delegateObject, additionalData) + } else { + super.setStackItemsFromModel(model, delegateObject, additionalData) + } + } + + /// + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + previousModel = self.model + super.set(with: model, delegateObject, additionalData) + } +} diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index ab17be3b..d43719a9 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -147,18 +147,9 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - let previousModel = self.model super.set(with: model, delegateObject, additionalData) removeAllItemViews() - - // If the items in the stack are different, clear them, create new ones. - if (previousModel == nil) || Self.nameForReuse(with: previousModel!, delegateObject) != Self.nameForReuse(with: model, delegateObject) { - stackItems = [] - createStackItemsFromModel(model, delegateObject, additionalData) - } else { - setStackItemsFromModel(model, delegateObject, additionalData) - } - + setStackItemsFromModel(model, delegateObject, additionalData) restack() } @@ -216,16 +207,6 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto // MARK: - Subclassables //-------------------------------------------------- - /// Can be subclassed to create views when we get stack item models and have no views yet - open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let stackItemModels = (model as? StackModelProtocol)?.molecules else { return } - for model in stackItemModels { - if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) { - stackItems.append(stackItem) - } - } - } - /// Can be subclassed to set stack items with model when we already have views open func setStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let models = stackModel?.molecules else { return } @@ -314,7 +295,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto if let percent = model.percent { let multiplier = CGFloat(percent) / 100.0 let constant = multiplier * totalSpacing - view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: multiplier, constant: -constant).isActive = true + view.heightAnchor.constraint(equalTo: heightAnchor, multiplier: multiplier, constant: -constant).isActive = true } if lastItem { pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) @@ -333,7 +314,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto if let percent = model.percent { let multiplier = CGFloat(percent) / 100.0 let constant = multiplier * totalSpacing - view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: multiplier, constant: -constant).isActive = true + view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: multiplier, constant: -constant).isActive = true } if lastItem { pinView(contentView, toView: view, attribute: .right, relation: .equal, priority: .required, constant: 0) From 2e7dc614c50dff9919e8f9bdc2aa6cc09e0ee48c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 3 Apr 2020 18:49:02 -0400 Subject: [PATCH 08/17] Key changes --- MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift index b095f19e..b26bbc8a 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift @@ -49,7 +49,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { return nil } - let stack = Stack(frame: .zero) + let stack = MoleculeStackView(frame: .zero) moleculeStackModel.useStackSpacingBeforeFirstItem = true moleculeStackModel.useHorizontalMargins = true stack.set(with: moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil) From dc2dfe42bb86b04c975a54bcefed934df9d94185 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 6 Apr 2020 11:37:14 -0400 Subject: [PATCH 09/17] MoleculeStack --- MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift index b095f19e..b26bbc8a 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift @@ -49,7 +49,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { return nil } - let stack = Stack(frame: .zero) + let stack = MoleculeStackView(frame: .zero) moleculeStackModel.useStackSpacingBeforeFirstItem = true moleculeStackModel.useHorizontalMargins = true stack.set(with: moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil) From cce4124bad8f71451246cdbdd6ada0f84c1a89e5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Apr 2020 10:18:58 -0400 Subject: [PATCH 10/17] Encode fix --- .../VerticalCombinationViews/Lists/UnOrderedListModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 32764641..3866e918 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -44,7 +44,7 @@ import Foundation var models: [MoleculeModelProtocol] = [] for molecule in molecules { - models.append((molecule as! MoleculeStackItemModel).molecule) + models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } try container.encodeModels(models, forKey: .list) } From bf1ca8b285a5bf5cf46a18e9141124dce09891a4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Apr 2020 10:20:33 -0400 Subject: [PATCH 11/17] remove unneeded comment --- MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift index c5c993f2..3965932d 100644 --- a/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift @@ -53,7 +53,6 @@ open class MoleculeStackView: Stack { } } - /// open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { previousModel = self.model super.set(with: model, delegateObject, additionalData) From 1e86bfbc32d5dabc74f03361fd233b3356877460 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Apr 2020 14:06:27 -0400 Subject: [PATCH 12/17] reuse issue fix --- MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift index 6339d002..ceecdd9b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift @@ -61,6 +61,7 @@ import UIKit /// Creates the bars open func set(with progressList: Array, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + stack.removeAllItemViews() guard let stackModel = stack.stackModel else { return } var views: [StackItem] = [] var models: [StackItemModel] = [] @@ -89,6 +90,7 @@ import UIKit open override func reset() { super.reset() backgroundColor = .mfLightSilver() + stack.reset() set(with: [], nil, nil) } From 9e47ea8e1c374706f92b53bc951cdb1b048264ff Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Apr 2020 15:30:15 -0400 Subject: [PATCH 13/17] remove bad remove items --- MVMCoreUI/Atomic/Organisms/Stack.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index d43719a9..f539cf8b 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -148,7 +148,6 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - removeAllItemViews() setStackItemsFromModel(model, delegateObject, additionalData) restack() } From dcd6257f95db113c08ada80290e1e7fd7697578f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 15 Apr 2020 11:29:32 -0400 Subject: [PATCH 14/17] merge --- MVMCoreUI/BaseControllers/ViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index a49dfad3..677d9e31 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -236,10 +236,13 @@ import UIKit } // MARK: - View lifecycle + + /// Called only once in viewDidLoad open func initialLoad() { observeForResponseJSONUpdates() } + /// Called on screen size update. open func updateViews() { _ = formValidator?.validate() } @@ -265,8 +268,7 @@ import UIKit initialLoad() } - // Handle data for first load. Dispatched to allow subclasses to finish their view did load implementations. - self.handleNewDataAndUpdateUI() + handleNewDataAndUpdateUI() } open override func viewDidLayoutSubviews() { From d19b46d3e933d0ac50a726cca8eaecc98c7317fc Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 15 Apr 2020 12:37:05 -0400 Subject: [PATCH 15/17] corner labels defect fix --- .../Atomic/Molecules/LeftRightViews/CornerLabels.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabels.swift index c0018e9b..7eb3282b 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabels.swift @@ -164,10 +164,12 @@ import UIKit public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? CornerLabelsModel else { return } - if middleView != nil { - (middleView as? MoleculeViewProtocol)?.set(with: model, delegateObject, additionalData) - } else if let moleculeModel = model.molecule, let molecule = MoleculeObjectMapping.shared()?.createMolecule(moleculeModel, delegateObject: delegateObject, additionalData: additionalData) { - addMiddleView(molecule) + if let moleculeModel = model.molecule { + if middleView != nil { + (middleView as? MoleculeViewProtocol)?.set(with: moleculeModel, delegateObject, additionalData) + } else if let molecule = MoleculeObjectMapping.shared()?.createMolecule(moleculeModel, delegateObject: delegateObject, additionalData: additionalData) { + addMiddleView(molecule) + } } topLeftLabel.setOptional(with: model.topLeftLabel, delegateObject, additionalData) From a57f07c22b843ef1ec01e9ba35c22848a9709640 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 15 Apr 2020 17:42:57 -0400 Subject: [PATCH 16/17] remove previous items --- MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift index 3965932d..e0517d45 100644 --- a/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift @@ -46,6 +46,7 @@ open class MoleculeStackView: Stack { open override func setStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { // If the items in the stack are different, clear them, create new ones. if (previousModel == nil) || Self.nameForReuse(with: previousModel!, delegateObject) != Self.nameForReuse(with: model, delegateObject) { + removeAllItemViews() stackItems = [] createStackItemsFromModel(model, delegateObject, additionalData) } else { From 8479ed605a4694bf43902d352a425904089c160a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 15 Apr 2020 18:09:10 -0400 Subject: [PATCH 17/17] small fix encoding numbered list --- .../VerticalCombinationViews/Lists/NumberedListModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index f58a62ff..eeacb98d 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -38,9 +38,9 @@ import Foundation var models: [MoleculeModelProtocol] = [] for molecule in molecules { - models.append((molecule as! MoleculeStackItemModel).molecule) + models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } - try container.encodeModels(molecules, forKey: .list) + try container.encodeModels(models, forKey: .list) } }