From eb3b1a0e810c87eeaa4a4684977d08d98eb5cbd4 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 11 Sep 2019 11:05:57 -0400 Subject: [PATCH 001/272] initial --- MVMCoreUI.xcodeproj/project.pbxproj | 20 ++++++++ MVMCoreUI/Atoms/Views/Label.swift | 11 ++++- MVMCoreUI/Models/AttributeModel.swift | 48 +++++++++++++++++++ MVMCoreUI/Models/BaseModel.swift | 63 +++++++++++++++++++++++++ MVMCoreUI/Models/LabelModel.swift | 66 +++++++++++++++++++++++++++ 5 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 MVMCoreUI/Models/AttributeModel.swift create mode 100644 MVMCoreUI/Models/BaseModel.swift create mode 100644 MVMCoreUI/Models/LabelModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9768fcf8..e600e30f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -10,6 +10,9 @@ 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; }; 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; + 01509D98232803C900EF99AA /* BaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D97232803C900EF99AA /* BaseModel.swift */; }; + 01509D9A2328077C00EF99AA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D992328077C00EF99AA /* LabelModel.swift */; }; + 01509D9C23283F5000EF99AA /* AttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D9B23283F5000EF99AA /* AttributeModel.swift */; }; 016A1071228122180009D605 /* HeadlineBodyTextButtonSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016A1070228122180009D605 /* HeadlineBodyTextButtonSwitch.swift */; }; 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -193,6 +196,9 @@ 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; + 01509D97232803C900EF99AA /* BaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseModel.swift; sourceTree = ""; }; + 01509D992328077C00EF99AA /* LabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; + 01509D9B23283F5000EF99AA /* AttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributeModel.swift; sourceTree = ""; }; 016A1070228122180009D605 /* HeadlineBodyTextButtonSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButtonSwitch.swift; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; @@ -388,6 +394,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 01509D96232803B200EF99AA /* Models */ = { + isa = PBXGroup; + children = ( + 01509D97232803C900EF99AA /* BaseModel.swift */, + 01509D992328077C00EF99AA /* LabelModel.swift */, + 01509D9B23283F5000EF99AA /* AttributeModel.swift */, + ); + path = Models; + sourceTree = ""; + }; 01C74D87224298E2009C25A3 /* FormUIHelpers */ = { isa = PBXGroup; children = ( @@ -488,6 +504,7 @@ D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */ = { isa = PBXGroup; children = ( + 01509D96232803B200EF99AA /* Models */, 01C74D87224298E2009C25A3 /* FormUIHelpers */, D29DF31421ECECA7003B2FB9 /* SupportingFiles */, D29DF27021E79B2C003B2FB9 /* OtherHandlers */, @@ -1002,6 +1019,7 @@ D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */, + 01509D9C23283F5000EF99AA /* AttributeModel.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, @@ -1024,6 +1042,7 @@ D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, + 01509D98232803C900EF99AA /* BaseModel.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, @@ -1071,6 +1090,7 @@ D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, + 01509D9A2328077C00EF99AA /* LabelModel.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index ed99fcac..fcc3de4e 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -196,7 +196,7 @@ public typealias ActionBlock = () -> () } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { - + //LabelModel() guard let label = label else { return } label.attributedText = nil label.text = json?.optionalStringForKey(KeyText) @@ -519,6 +519,15 @@ extension Label { @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { clauses = [] + + do { + let data = try JSONSerialization.data(withJSONObject: json!, options: .prettyPrinted) + let labelModel = try JSONDecoder().decode(LabelModel.self, from: data) + print("") + } catch let error { + print(error.localizedDescription) + } + Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) originalAttributedString = attributedText } diff --git a/MVMCoreUI/Models/AttributeModel.swift b/MVMCoreUI/Models/AttributeModel.swift new file mode 100644 index 00000000..426618e0 --- /dev/null +++ b/MVMCoreUI/Models/AttributeModel.swift @@ -0,0 +1,48 @@ +// +// AttributeModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 9/10/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class AttributeModel: BaseModel { + var type: String? + var location: Int? + var length: Int? + var textColor: String? + var size: Int? + var name: String? + + private enum CodingKeys : String, CodingKey { + case type + case location + case length + case textColor + case size + case name + } + + public required init(from decoder: Decoder) throws { + try super.init(from: decoder) + let container = try decoder.container(keyedBy: CodingKeys.self) + type = try container.decode(String.self, forKey: CodingKeys.type) + location = try container.decode(Int.self, forKey: CodingKeys.location) + length = try container.decode(Int.self, forKey: CodingKeys.length) + textColor = try container.decode(String.self, forKey: CodingKeys.textColor) + size = try container.decode(Int.self, forKey: CodingKeys.size) + name = try container.decode(String.self, forKey: CodingKeys.name) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(type, forKey: .type) + try container.encode(location, forKey: .location) + try container.encode(textColor, forKey: .textColor) + try container.encode(size, forKey: .size) + try container.encode(name, forKey: .name) + } +} diff --git a/MVMCoreUI/Models/BaseModel.swift b/MVMCoreUI/Models/BaseModel.swift new file mode 100644 index 00000000..140833a5 --- /dev/null +++ b/MVMCoreUI/Models/BaseModel.swift @@ -0,0 +1,63 @@ +// +// BaseModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 9/10/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +public class BaseModel: Codable { + + public var moleculeName: String? + // public var dictionaryRepresentation: [AnyHashable: Any] + + private enum CodingKeys : String, CodingKey { + case moleculeName + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + moleculeName = try container.decode(String.self, forKey: CodingKeys.moleculeName) + } + + public func encode(to encoder: Encoder) throws { + //try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + } + +// //init +// public init(_ dictionary:[AnyHashable: Any]){ +// dictionaryRepresentation = dictionary +// } +// +// public func getString(_ key:String) -> String { +// return dictionaryRepresentation[key] as? String ?? "" +// } +// +// public func getOptionalString(_ key:String) -> String? { +// return dictionaryRepresentation[key] as? String ?? nil +// } +// +// public func dictionaryForKey(_ key : String) -> [String : Any]? { +// let dict = dictionaryRepresentation.dictionaryForKey(key) +// if dict.count > 0 { +// return dict +// } +// return nil +// } +// +// public func arrayForKey(_ key : String) -> Array>? { +// return dictionaryRepresentation.arrayForKey(key) as? Array> +// } +// +// public func convertStringToBool(_ string:String)-> Bool{ +// var converter = dictionaryRepresentation[string] as? String ?? "" +// converter = converter.lowercased() +// let convertedValue = converter == "true" || converter == "yes" +// return convertedValue +// } +} diff --git a/MVMCoreUI/Models/LabelModel.swift b/MVMCoreUI/Models/LabelModel.swift new file mode 100644 index 00000000..5aa7fffa --- /dev/null +++ b/MVMCoreUI/Models/LabelModel.swift @@ -0,0 +1,66 @@ +// +// LabelModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 9/10/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +class LabelModel: BaseModel { + + var text: String + var accessibilityText: String + var textColor: String + var backgroundColor: String + var fontStyle: String + var fontName: String + var fontSize: Int + var textAlignment: String + //var attributes: AttributeModel + var html: String + + private enum CodingKeys : String, CodingKey { + case text + case accessibilityText + case textColor + case backgroundColor + case fontStyle + case fontName + case fontSize + case textAlignment + //case attributes + case html + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + text = try container.decode(String.self, forKey: CodingKeys.text) + accessibilityText = try container.decode(String.self, forKey: CodingKeys.accessibilityText) + textColor = try container.decode(String.self, forKey: CodingKeys.textColor) + backgroundColor = try container.decode(String.self, forKey: CodingKeys.backgroundColor) + fontStyle = try container.decode(String.self, forKey: CodingKeys.backgroundColor) + fontName = try container.decode(String.self, forKey: CodingKeys.fontName) + textAlignment = try container.decode(String.self, forKey: CodingKeys.textAlignment) + //attributes = try container.decode(AttributeModel.self, forKey: CodingKeys.attributes) + html = try container.decode(String.self, forKey: CodingKeys.html) + fontSize = try container.decode(Int.self, forKey: CodingKeys.fontSize) + 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(text, forKey: .text) + try container.encode(accessibilityText, forKey: .accessibilityText) + try container.encode(textColor, forKey: .textColor) + try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encode(fontStyle, forKey: .fontStyle) + try container.encode(fontName, forKey: .fontName) + try container.encode(textAlignment, forKey: .textAlignment) + //try container.encode(attributes, forKey: .attributes) + try container.encode(html, forKey: .html) + } +} From 205c83c0972d101f772e718020bf0705d6f67c7e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 28 Oct 2019 14:47:42 -0400 Subject: [PATCH 002/272] intial draft --- MVMCoreUI.xcodeproj/project.pbxproj | 124 ++++++++++++++++-- MVMCoreUI/Atoms/Views/Label.swift | 9 -- .../MFViewController+Model.swift | 27 ++++ MVMCoreUI/BaseControllers/MFViewController.h | 6 + MVMCoreUI/BaseControllers/MFViewController.m | 3 +- MVMCoreUI/Models/AttributeModel.swift | 48 ------- MVMCoreUI/Models/BaseModel.swift | 63 --------- MVMCoreUI/Models/Decoder.swift | 45 +++++++ MVMCoreUI/Models/Encoder.swift | 27 ++++ MVMCoreUI/Models/Holder.swift | 16 +++ MVMCoreUI/Models/HolderManager.swift | 79 +++++++++++ MVMCoreUI/Models/JSON/JSON.swift | 10 ++ MVMCoreUI/Models/JSON/JSONValue.swift | 122 +++++++++++++++++ MVMCoreUI/Models/LabelModel.swift | 66 ---------- MVMCoreUI/Models/MoleculeHolder.swift | 13 ++ MVMCoreUI/Models/MoleculeProtocol.swift | 16 +++ .../Models/Molecules/ActionMapModel.swift | 19 +++ .../Models/Molecules/FormModelProtocol.swift | 15 +++ MVMCoreUI/Models/Molecules/HeaderModel.swift | 22 ++++ .../Models/Molecules/HeadlineBodyModel.swift | 21 +++ MVMCoreUI/Models/Molecules/LabelModel.swift | 21 +++ .../Models/Molecules/ListItemModel.swift | 22 ++++ .../Molecules/MoleculeStackItemModel.swift | 20 +++ .../Models/Molecules/MoleculeStackModel.swift | 22 ++++ .../Models/Molecules/SeperatorModel.swift | 20 +++ .../Models/Molecules/TextFieldModel.swift | 23 ++++ MVMCoreUI/Models/PageModel.swift | 18 +++ .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 7 + .../Molecules/ModelMoleculeViewProtocol.swift | 13 ++ .../Molecules/MoleculeViewProtocol.swift | 38 ++++++ MVMCoreUI/Molecules/StandardHeaderView.swift | 20 ++- ...MoleculeMappingObject+ModelExtension.swift | 40 ++++++ ...UIMoleculeMappingObject+ModelMapping.swift | 22 ++++ .../MVMCoreUIMoleculeMappingObject.h | 3 + .../MVMCoreUIMoleculeMappingObject.m | 3 +- .../Templates/MoleculeListTemplate.swift | 10 +- 36 files changed, 849 insertions(+), 204 deletions(-) create mode 100644 MVMCoreUI/BaseControllers/MFViewController+Model.swift delete mode 100644 MVMCoreUI/Models/AttributeModel.swift delete mode 100644 MVMCoreUI/Models/BaseModel.swift create mode 100644 MVMCoreUI/Models/Decoder.swift create mode 100644 MVMCoreUI/Models/Encoder.swift create mode 100644 MVMCoreUI/Models/Holder.swift create mode 100644 MVMCoreUI/Models/HolderManager.swift create mode 100644 MVMCoreUI/Models/JSON/JSON.swift create mode 100644 MVMCoreUI/Models/JSON/JSONValue.swift delete mode 100644 MVMCoreUI/Models/LabelModel.swift create mode 100644 MVMCoreUI/Models/MoleculeHolder.swift create mode 100644 MVMCoreUI/Models/MoleculeProtocol.swift create mode 100644 MVMCoreUI/Models/Molecules/ActionMapModel.swift create mode 100644 MVMCoreUI/Models/Molecules/FormModelProtocol.swift create mode 100644 MVMCoreUI/Models/Molecules/HeaderModel.swift create mode 100644 MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift create mode 100644 MVMCoreUI/Models/Molecules/LabelModel.swift create mode 100644 MVMCoreUI/Models/Molecules/ListItemModel.swift create mode 100644 MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift create mode 100644 MVMCoreUI/Models/Molecules/MoleculeStackModel.swift create mode 100644 MVMCoreUI/Models/Molecules/SeperatorModel.swift create mode 100644 MVMCoreUI/Models/Molecules/TextFieldModel.swift create mode 100644 MVMCoreUI/Models/PageModel.swift create mode 100644 MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift create mode 100644 MVMCoreUI/Molecules/MoleculeViewProtocol.swift create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 4c3b5900..376b136e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -10,16 +10,37 @@ 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; }; 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; - 01509D98232803C900EF99AA /* BaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D97232803C900EF99AA /* BaseModel.swift */; }; - 01509D9A2328077C00EF99AA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D992328077C00EF99AA /* LabelModel.swift */; }; - 01509D9C23283F5000EF99AA /* AttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D9B23283F5000EF99AA /* AttributeModel.swift */; }; 016A1071228122180009D605 /* HeadlineBodyTextButtonSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016A1070228122180009D605 /* HeadlineBodyTextButtonSwitch.swift */; }; + 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB392360EEB40024EF95 /* PageModel.swift */; }; + 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */; }; + 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3F23620A230024EF95 /* TextFieldModel.swift */; }; + 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */; }; + 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */; }; + 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */; }; + 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; + 017BEB7B236763000024EF95 /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* SeperatorModel.swift */; }; + 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */; }; 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; + 01EB367923609281006832FA /* JSONValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367723609281006832FA /* JSONValue.swift */; }; + 01EB367A23609281006832FA /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367823609281006832FA /* JSON.swift */; }; + 01EB367D2360929F006832FA /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367B2360929F006832FA /* Decoder.swift */; }; + 01EB367E2360929F006832FA /* Encoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367C2360929F006832FA /* Encoder.swift */; }; + 01EB3681236092AE006832FA /* Holder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367F236092AE006832FA /* Holder.swift */; }; + 01EB3682236092AE006832FA /* HolderManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3680236092AE006832FA /* HolderManager.swift */; }; + 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; + 01EB3686236097F1006832FA /* MoleculeHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3685236097F1006832FA /* MoleculeHolder.swift */; }; + 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; + 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; }; + 01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.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 */; }; + 01EB369523609801006832FA /* ActionMapModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368E23609801006832FA /* ActionMapModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8200E142280C4CF007245F4 /* ProgressBar.swift */; }; @@ -199,15 +220,36 @@ 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; - 01509D97232803C900EF99AA /* BaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseModel.swift; sourceTree = ""; }; - 01509D992328077C00EF99AA /* LabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; - 01509D9B23283F5000EF99AA /* AttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributeModel.swift; sourceTree = ""; }; 016A1070228122180009D605 /* HeadlineBodyTextButtonSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButtonSwitch.swift; sourceTree = ""; }; + 017BEB392360EEB40024EF95 /* PageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModel.swift; sourceTree = ""; }; + 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFViewController+Model.swift"; sourceTree = ""; }; + 017BEB3F23620A230024EF95 /* TextFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldModel.swift; sourceTree = ""; }; + 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormModelProtocol.swift; sourceTree = ""; }; + 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelExtension.swift"; sourceTree = ""; }; + 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeViewProtocol.swift; sourceTree = ""; }; + 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; + 017BEB7A236763000024EF95 /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; + 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelMapping.swift"; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; + 01EB367723609281006832FA /* JSONValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONValue.swift; sourceTree = ""; }; + 01EB367823609281006832FA /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = ""; }; + 01EB367B2360929F006832FA /* Decoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decoder.swift; sourceTree = ""; }; + 01EB367C2360929F006832FA /* Encoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Encoder.swift; sourceTree = ""; }; + 01EB367F236092AE006832FA /* Holder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Holder.swift; sourceTree = ""; }; + 01EB3680236092AE006832FA /* HolderManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HolderManager.swift; sourceTree = ""; }; + 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; + 01EB3685236097F1006832FA /* MoleculeHolder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeHolder.swift; sourceTree = ""; }; + 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; + 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.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 = ""; }; + 01EB368E23609801006832FA /* ActionMapModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionMapModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; B8200E142280C4CF007245F4 /* ProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; @@ -403,9 +445,15 @@ 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( - 01509D97232803C900EF99AA /* BaseModel.swift */, - 01509D992328077C00EF99AA /* LabelModel.swift */, - 01509D9B23283F5000EF99AA /* AttributeModel.swift */, + 017BEB392360EEB40024EF95 /* PageModel.swift */, + 01EB368723609801006832FA /* Molecules */, + 01EB3685236097F1006832FA /* MoleculeHolder.swift */, + 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 01EB367F236092AE006832FA /* Holder.swift */, + 01EB3680236092AE006832FA /* HolderManager.swift */, + 01EB367B2360929F006832FA /* Decoder.swift */, + 01EB367C2360929F006832FA /* Encoder.swift */, + 01EB367623609281006832FA /* JSON */, ); path = Models; sourceTree = ""; @@ -421,6 +469,32 @@ path = FormUIHelpers; sourceTree = ""; }; + 01EB367623609281006832FA /* JSON */ = { + isa = PBXGroup; + children = ( + 01EB367723609281006832FA /* JSONValue.swift */, + 01EB367823609281006832FA /* JSON.swift */, + ); + path = JSON; + sourceTree = ""; + }; + 01EB368723609801006832FA /* Molecules */ = { + isa = PBXGroup; + children = ( + 01EB368823609801006832FA /* LabelModel.swift */, + 01EB368923609801006832FA /* ListItemModel.swift */, + 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, + 01EB368B23609801006832FA /* MoleculeStackModel.swift */, + 01EB368C23609801006832FA /* HeaderModel.swift */, + 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, + 01EB368E23609801006832FA /* ActionMapModel.swift */, + 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, + 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, + 017BEB7A236763000024EF95 /* SeperatorModel.swift */, + ); + path = Molecules; + sourceTree = ""; + }; D224798823142BF2003FCCF9 /* SwitchMolecules */ = { isa = PBXGroup; children = ( @@ -581,6 +655,8 @@ D274CA322236A78900B01B62 /* StandardFooterView.swift */, D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */, + 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, + 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, ); path = Molecules; sourceTree = ""; @@ -590,6 +666,7 @@ children = ( D29DF16021E69996003B2FB9 /* MFViewController.h */, D29DF15F21E69996003B2FB9 /* MFViewController.m */, + 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */, D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */, D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */, D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */, @@ -796,6 +873,8 @@ D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */, D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, + 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, + 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */, ); path = OtherHandlers; sourceTree = ""; @@ -1022,45 +1101,56 @@ D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, + 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, + 01EB3686236097F1006832FA /* MoleculeHolder.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, + 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */, - 01509D9C23283F5000EF99AA /* AttributeModel.swift in Sources */, + 01EB3681236092AE006832FA /* Holder.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, + 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, + 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, + 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */, + 01EB367D2360929F006832FA /* Decoder.swift in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, + 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, + 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, + 01EB369023609801006832FA /* ListItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, - 01509D98232803C900EF99AA /* BaseModel.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, + 01EB367923609281006832FA /* JSONValue.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, + 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, D2E1FADD2268B25E00AEFD8C /* MoleculeTableViewCell.swift in Sources */, @@ -1068,6 +1158,8 @@ D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, + 017BEB7B236763000024EF95 /* SeperatorModel.swift in Sources */, + 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */, D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, @@ -1087,23 +1179,30 @@ DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, + 01EB367A23609281006832FA /* JSON.swift in Sources */, + 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, + 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, + 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, + 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, + 01EB3682236092AE006832FA /* HolderManager.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, - 01509D9A2328077C00EF99AA /* LabelModel.swift in Sources */, + 01EB369523609801006832FA /* ActionMapModel.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, + 01EB367E2360929F006832FA /* Encoder.swift in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, @@ -1111,6 +1210,7 @@ D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */, 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, + 01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index fcc3de4e..459b78cf 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -519,15 +519,6 @@ extension Label { @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { clauses = [] - - do { - let data = try JSONSerialization.data(withJSONObject: json!, options: .prettyPrinted) - let labelModel = try JSONDecoder().decode(LabelModel.self, from: data) - print("") - } catch let error { - print(error.localizedDescription) - } - Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) originalAttributedString = attributedText } diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift new file mode 100644 index 00000000..05c9790d --- /dev/null +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -0,0 +1,27 @@ +// +// MFViewController+Model.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +public extension MFViewController { + @objc func parsePageJSON() { + guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { + return + } + do { + let pageData = try JSONSerialization.data(withJSONObject: pageJSON) + let decoder = JSONDecoder() + let pageModel = try decoder.decode(PageModel.self, from: pageData) + self.pageModel = pageModel + } catch { + print("error: \(error)") + } + + } +} diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index c1415df4..ded7446f 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -29,16 +29,22 @@ #import #import + @class MainMenuViewController; @class MVMCoreUITabBarPageControlViewController; @class MVMAnimationManager; @class DelegateObject; +@class PageModel; @interface MFViewController : UIViewController // Stores the load object that this screen was loaded with. @property (nullable, strong, nonatomic) MVMCoreLoadObject *loadObject; +@property (nullable, strong, nonatomic) PageModel *pageModel; + +//@property (nonatomic) PageModel pageModel; + // The current selected text field. @property (nullable, weak, nonatomic) __block id selectedField; diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 256bf050..3b68ef7d 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -37,6 +37,7 @@ #import "MVMCoreUITabBarPageControlViewController.h" #import "MVMCoreUINavigationController.h" #import + @import MVMAnimationFramework; @interface MFViewController() @@ -95,7 +96,7 @@ - (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error { self.pageType = loadObject.pageType; self.loadObject = loadObject; - + [self parsePageJSON]; // Verifies all modules needed are loaded. return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error]; } diff --git a/MVMCoreUI/Models/AttributeModel.swift b/MVMCoreUI/Models/AttributeModel.swift deleted file mode 100644 index 426618e0..00000000 --- a/MVMCoreUI/Models/AttributeModel.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// AttributeModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 9/10/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class AttributeModel: BaseModel { - var type: String? - var location: Int? - var length: Int? - var textColor: String? - var size: Int? - var name: String? - - private enum CodingKeys : String, CodingKey { - case type - case location - case length - case textColor - case size - case name - } - - public required init(from decoder: Decoder) throws { - try super.init(from: decoder) - let container = try decoder.container(keyedBy: CodingKeys.self) - type = try container.decode(String.self, forKey: CodingKeys.type) - location = try container.decode(Int.self, forKey: CodingKeys.location) - length = try container.decode(Int.self, forKey: CodingKeys.length) - textColor = try container.decode(String.self, forKey: CodingKeys.textColor) - size = try container.decode(Int.self, forKey: CodingKeys.size) - name = try container.decode(String.self, forKey: CodingKeys.name) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(type, forKey: .type) - try container.encode(location, forKey: .location) - try container.encode(textColor, forKey: .textColor) - try container.encode(size, forKey: .size) - try container.encode(name, forKey: .name) - } -} diff --git a/MVMCoreUI/Models/BaseModel.swift b/MVMCoreUI/Models/BaseModel.swift deleted file mode 100644 index 140833a5..00000000 --- a/MVMCoreUI/Models/BaseModel.swift +++ /dev/null @@ -1,63 +0,0 @@ -// -// BaseModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 9/10/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - - -public class BaseModel: Codable { - - public var moleculeName: String? - // public var dictionaryRepresentation: [AnyHashable: Any] - - private enum CodingKeys : String, CodingKey { - case moleculeName - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try container.decode(String.self, forKey: CodingKeys.moleculeName) - } - - public func encode(to encoder: Encoder) throws { - //try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - } - -// //init -// public init(_ dictionary:[AnyHashable: Any]){ -// dictionaryRepresentation = dictionary -// } -// -// public func getString(_ key:String) -> String { -// return dictionaryRepresentation[key] as? String ?? "" -// } -// -// public func getOptionalString(_ key:String) -> String? { -// return dictionaryRepresentation[key] as? String ?? nil -// } -// -// public func dictionaryForKey(_ key : String) -> [String : Any]? { -// let dict = dictionaryRepresentation.dictionaryForKey(key) -// if dict.count > 0 { -// return dict -// } -// return nil -// } -// -// public func arrayForKey(_ key : String) -> Array>? { -// return dictionaryRepresentation.arrayForKey(key) as? Array> -// } -// -// public func convertStringToBool(_ string:String)-> Bool{ -// var converter = dictionaryRepresentation[string] as? String ?? "" -// converter = converter.lowercased() -// let convertedValue = converter == "true" || converter == "yes" -// return convertedValue -// } -} diff --git a/MVMCoreUI/Models/Decoder.swift b/MVMCoreUI/Models/Decoder.swift new file mode 100644 index 00000000..38fdc730 --- /dev/null +++ b/MVMCoreUI/Models/Decoder.swift @@ -0,0 +1,45 @@ +import Foundation + +public protocol AnyDecoder { + func decode(_ type: T.Type, from data: Data) throws -> T +} + +extension JSONDecoder: AnyDecoder {} +extension PropertyListDecoder: AnyDecoder {} + +extension Data { + public func decodeToObject(using decoder: AnyDecoder = JSONDecoder()) throws -> T { + return try decoder.decode(T.self, from: self) + } +} + +extension KeyedDecodingContainerProtocol { + public func decode(forKey key: Key) throws -> T { + return try decode(T.self, forKey: key) + } + + public func decode( + forKey key: Key, + default defaultExpression: @autoclosure () -> T + ) throws -> T { + return try decodeIfPresent(T.self, forKey: key) ?? defaultExpression() + } +} + +extension Decodable { + public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self { + guard let path = bundle.path(forResource: fileName, ofType: ".json") else { + throw JSONError.pathNotFound + } + + guard let jsonData = try? Data(contentsOf: URL(fileURLWithPath: path)) else { + throw JSONError.data(path: path) + } + + do { + return try jsonData.decode() + } catch { + throw JSONError.other(error: error) + } + } +} diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift new file mode 100644 index 00000000..1f55038d --- /dev/null +++ b/MVMCoreUI/Models/Encoder.swift @@ -0,0 +1,27 @@ +import Foundation + +public protocol AnyEncoder { + func encode(_ value: T) throws -> Data +} + +extension JSONEncoder: AnyEncoder {} +extension PropertyListEncoder: AnyEncoder {} + +extension Encodable { + public func encodeToData(using encoder: AnyEncoder = JSONEncoder()) throws -> Data { + return try encoder.encode(self) + } + + public func toJSON() -> JSONObject? { + guard let data = try? self.encode() else { return nil } + return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? JSONObject } + } + + public func toJSONString() -> String? { + guard let data = try? self.encode(), + let string = String(data: data, encoding: .utf8) else { + return nil + } + return string + } +} diff --git a/MVMCoreUI/Models/Holder.swift b/MVMCoreUI/Models/Holder.swift new file mode 100644 index 00000000..c8ae3f1f --- /dev/null +++ b/MVMCoreUI/Models/Holder.swift @@ -0,0 +1,16 @@ +import Foundation + +public protocol Holdable: Codable { + static var identifier: String { get set } +} + +public protocol Holder: Codable { + associatedtype HoldableType = Holdable + + static var codingKeyName: String { get } + + var name: String { get set } + var object: HoldableType { get set } + + init (name: String, object: HoldableType) +} diff --git a/MVMCoreUI/Models/HolderManager.swift b/MVMCoreUI/Models/HolderManager.swift new file mode 100644 index 00000000..44059145 --- /dev/null +++ b/MVMCoreUI/Models/HolderManager.swift @@ -0,0 +1,79 @@ +import Foundation + +public class HolderManager { + public enum Error: Swift.Error { + case codingKeyNotFound + case encoderError + case decoderError + case decoderErrorModelNotMapped + } + fileprivate typealias HoldableDecoder = (SingleValueDecodingContainer) throws -> Holdable + fileprivate typealias HoldableEncoder = (Holdable, inout SingleValueEncodingContainer) throws -> Void + fileprivate static var decoders: [String: HoldableDecoder] = [:] + fileprivate static var encoders: [String: HoldableEncoder] = [:] + + public static func register(_ type: A.Type) { + decoders[A.identifier] = { container in + try container.decode(A.self) + } + + encoders[A.identifier] = { name, container in + guard let obj = name as? A else { + throw HolderManager.Error.encoderError + } + try container.encode(obj) + } + } +} + +private struct DynamicKey: CodingKey { + var stringValue: String + init?(stringValue: String) { + self.stringValue = stringValue + } + + var intValue: Int? { return nil } + init?(intValue: Int) { return nil } +} + +//MARK: - Holder Extension +extension Holder { + + public init(from decoder: Decoder) throws { + + //get the CodingKey String name that tells the type of holdable + guard let key = DynamicKey(stringValue: Self.codingKeyName) else { + throw HolderManager.Error.decoderError + } + + //get the type + let typeContainer = try decoder.container(keyedBy: DynamicKey.self) + let type = try typeContainer.decode(String.self, forKey: key) + + //get the container to decode + let container = try decoder.singleValueContainer() + + //get the decoder for the type found + guard let decoder = HolderManager.decoders[type] else { + throw HolderManager.Error.decoderErrorModelNotMapped + } + + //decode the type and ensure it is of HoldableType + guard let obj = try decoder(container) as? HoldableType else { + throw HolderManager.Error.decoderError + } + + //instantiate Self + self = Self(name: type, object: obj) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + guard let encode = HolderManager.encoders[self.name], + let holdable = self.object as? Holdable else{ + throw HolderManager.Error.encoderError + } + try encode(holdable, &container) + } +} + diff --git a/MVMCoreUI/Models/JSON/JSON.swift b/MVMCoreUI/Models/JSON/JSON.swift new file mode 100644 index 00000000..cf584557 --- /dev/null +++ b/MVMCoreUI/Models/JSON/JSON.swift @@ -0,0 +1,10 @@ +import Foundation + +public typealias JSONArray = [[String: Any]] +public typealias JSONObject = [String: Any] + +public enum JSONError: Error { + case pathNotFound + case data(path: String) + case other(error: Error) +} diff --git a/MVMCoreUI/Models/JSON/JSONValue.swift b/MVMCoreUI/Models/JSON/JSONValue.swift new file mode 100644 index 00000000..2b51a255 --- /dev/null +++ b/MVMCoreUI/Models/JSON/JSONValue.swift @@ -0,0 +1,122 @@ +import Foundation + +public typealias JSONValueArray = [[String: JSONValue]] +public typealias JSONValueObject = [String: JSONValue] + +public enum JSONValueError: Error { + case encode +} + +extension Optional { + func or(_ other: Optional) -> Optional { + switch self { + case .none: return other + case .some: return self + } + } + + func resolve(with error: @autoclosure () -> Error) throws -> Wrapped { + switch self { + case .none: throw error() + case .some(let wrapped): return wrapped + } + } +} + +public enum JSONValue: Codable, Equatable { + case string(String) + case int(Int) + case double(Double) + case bool(Bool) + case object([String: JSONValue]) + case array([JSONValue]) + case null + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let value = ((try? container.decode(String.self)).map(JSONValue.string)) + .or((try? container.decode(Int.self)).map(JSONValue.int)) + .or((try? container.decode(Double.self)).map(JSONValue.double)) + .or((try? container.decode(Bool.self)).map(JSONValue.bool)) + .or((try? container.decode([String: JSONValue].self)).map(JSONValue.object)) + .or((try? container.decode([JSONValue].self)).map(JSONValue.array)) + + self = value ?? JSONValue.null + } + + func decode() throws -> T { + let encoded = try JSONEncoder().encode(self) + return try JSONDecoder().decode(T.self, from: encoded) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + switch self { + case .string(let string): try container.encode(string) + case .int(let int): try container.encode(int) + case .double(let double): try container.encode(double) + case .bool(let bool): try container.encode(bool) + case .object(let object): try container.encode(object) + case .array(let array): try container.encode(array) + case .null: break + } + } +} + +public func ==(lhs: JSONValue, rhs: JSONValue) -> Bool { + let ld = try? lhs.encode() + let rd = try? lhs.encode() + return ld == rd +} + +extension JSONValue: ExpressibleByStringLiteral { + public init(stringLiteral value: String) { + self = .string(value) + } +} + +extension JSONValue: ExpressibleByIntegerLiteral { + public init(integerLiteral value: Int) { + self = .int(value) + } +} + +extension JSONValue: ExpressibleByFloatLiteral { + public init(floatLiteral value: Double) { + self = .double(value) + } +} + +extension JSONValue: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Bool) { + self = .bool(value) + } +} + +extension JSONValue: ExpressibleByArrayLiteral { + public init(arrayLiteral elements: JSONValue...) { + self = .array(elements) + } +} + +extension JSONValue: ExpressibleByDictionaryLiteral { + public init(dictionaryLiteral elements: (String, JSONValue)...) { + self = .object([String: JSONValue](uniqueKeysWithValues: elements)) + } +} + +extension Dictionary where Key == String, Value == Any { + public func toJSONValue() throws -> [String:JSONValue] { + let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) + return try JSONDecoder().decode([String:JSONValue].self, from: data) + } +} + +extension Dictionary where Key == String, Value == JSONValue { + public func toJSONObject() throws -> JSONObject{ + let encoded = try JSONEncoder().encode(self) + guard let json = try JSONSerialization.jsonObject(with: encoded, options: .mutableContainers) as? JSONObject else { + throw JSONValueError.encode + } + return json + } +} diff --git a/MVMCoreUI/Models/LabelModel.swift b/MVMCoreUI/Models/LabelModel.swift deleted file mode 100644 index 5aa7fffa..00000000 --- a/MVMCoreUI/Models/LabelModel.swift +++ /dev/null @@ -1,66 +0,0 @@ -// -// LabelModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 9/10/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -class LabelModel: BaseModel { - - var text: String - var accessibilityText: String - var textColor: String - var backgroundColor: String - var fontStyle: String - var fontName: String - var fontSize: Int - var textAlignment: String - //var attributes: AttributeModel - var html: String - - private enum CodingKeys : String, CodingKey { - case text - case accessibilityText - case textColor - case backgroundColor - case fontStyle - case fontName - case fontSize - case textAlignment - //case attributes - case html - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - text = try container.decode(String.self, forKey: CodingKeys.text) - accessibilityText = try container.decode(String.self, forKey: CodingKeys.accessibilityText) - textColor = try container.decode(String.self, forKey: CodingKeys.textColor) - backgroundColor = try container.decode(String.self, forKey: CodingKeys.backgroundColor) - fontStyle = try container.decode(String.self, forKey: CodingKeys.backgroundColor) - fontName = try container.decode(String.self, forKey: CodingKeys.fontName) - textAlignment = try container.decode(String.self, forKey: CodingKeys.textAlignment) - //attributes = try container.decode(AttributeModel.self, forKey: CodingKeys.attributes) - html = try container.decode(String.self, forKey: CodingKeys.html) - fontSize = try container.decode(Int.self, forKey: CodingKeys.fontSize) - 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(text, forKey: .text) - try container.encode(accessibilityText, forKey: .accessibilityText) - try container.encode(textColor, forKey: .textColor) - try container.encode(backgroundColor, forKey: .backgroundColor) - try container.encode(fontStyle, forKey: .fontStyle) - try container.encode(fontName, forKey: .fontName) - try container.encode(textAlignment, forKey: .textAlignment) - //try container.encode(attributes, forKey: .attributes) - try container.encode(html, forKey: .html) - } -} diff --git a/MVMCoreUI/Models/MoleculeHolder.swift b/MVMCoreUI/Models/MoleculeHolder.swift new file mode 100644 index 00000000..e83889c2 --- /dev/null +++ b/MVMCoreUI/Models/MoleculeHolder.swift @@ -0,0 +1,13 @@ +import Foundation + +public class MoleculeHolder: Holder { + public static var codingKeyName: String = "moleculeName" + + public var name: String + public var object: MoleculeProtocol + + required public init(name: String, object: MoleculeProtocol) { + self.name = name + self.object = object + } +} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift new file mode 100644 index 00000000..4dcdce60 --- /dev/null +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -0,0 +1,16 @@ +import Foundation + +public protocol MoleculeProtocol: Holdable { + var moleculeName: String? {get} + var dictionary: [AnyHashable: Any]? {get} +} + +extension MoleculeProtocol { + public var moleculeName: String? { + get { return Self.identifier } + } + + public var dictionary: [AnyHashable: Any]? { + return toJSON() + } +} diff --git a/MVMCoreUI/Models/Molecules/ActionMapModel.swift b/MVMCoreUI/Models/Molecules/ActionMapModel.swift new file mode 100644 index 00000000..8e2cc133 --- /dev/null +++ b/MVMCoreUI/Models/Molecules/ActionMapModel.swift @@ -0,0 +1,19 @@ +// +// ActionMap.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class ActionMapModel: Codable { + public var actionType: String? + public var pageType: String? + + public init(actionType: String?, pageType: String?){ + self.actionType = actionType + self.pageType = pageType + } +} diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift new file mode 100644 index 00000000..7d31912a --- /dev/null +++ b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift @@ -0,0 +1,15 @@ +// +// FormModelProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol FormModelProtocol: Holdable { + var required: Bool? {get} + var fieldKey: String? {get} + var groupName: String? {get} +} diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift new file mode 100644 index 00000000..98c80e4e --- /dev/null +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -0,0 +1,22 @@ +// +// Header.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class HeaderModel: MoleculeProtocol { + public static var identifier: String = "header" + public var moleculeName: String? + public var molecule: MoleculeHolder? + public var seperator: MoleculeHolder? + + public init(molecule: MoleculeHolder?){ + self.molecule = molecule + self.moleculeName = Self.identifier + } +} + diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift new file mode 100644 index 00000000..c80991ba --- /dev/null +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -0,0 +1,21 @@ +// +// HeadlineBody.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class HeadlineBodyModel: MoleculeProtocol { + public static var identifier: String = "headlineBody" + public var moleculeName: String? + public var headline: LabelModel? + + public init(headline: LabelModel?){ + self.headline = headline + self.moleculeName = Self.identifier + } +} + diff --git a/MVMCoreUI/Models/Molecules/LabelModel.swift b/MVMCoreUI/Models/Molecules/LabelModel.swift new file mode 100644 index 00000000..61fa9fda --- /dev/null +++ b/MVMCoreUI/Models/Molecules/LabelModel.swift @@ -0,0 +1,21 @@ +// +// Label.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + + +import Foundation + +@objcMembers public class LabelModel: MoleculeProtocol { + public static var identifier: String = "label" + public var moleculeName: String? + public var text: String? + + public init(text: String?) { + self.text = text + self.moleculeName = Self.identifier + } +} diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift new file mode 100644 index 00000000..6b1ceade --- /dev/null +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -0,0 +1,22 @@ +// +// ListItem.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class ListItemModel: MoleculeProtocol { + public static var identifier: String = "listItem" + public var moleculeName: String? + public var molecule: MoleculeHolder? + public var actionMap: ActionMapModel? + + public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?){ + self.molecule = molecule + self.actionMap = actionMap + self.moleculeName = Self.identifier + } +} diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift new file mode 100644 index 00000000..cb590493 --- /dev/null +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -0,0 +1,20 @@ +// +// MoleculeStackItem.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/4/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class MoleculeStackItemModel: MoleculeProtocol { + public static var identifier: String = "moleculeStackItem" + public var moleculeName: String? + public var molecule: MoleculeHolder? + + public init(molecule: MoleculeHolder?){ + self.molecule = molecule + self.moleculeName = Self.identifier + } +} diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift new file mode 100644 index 00000000..5dfda19c --- /dev/null +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -0,0 +1,22 @@ +// +// MoleculeStack.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class MoleculeStackModel: MoleculeProtocol{ + public static var identifier: String = "moleculeStack" + public var moleculeName: String? + public var molecules: [MoleculeStackItemModel]? + public var axis: String? + + public init(axis: String?, molecules: [MoleculeStackItemModel]?){ + self.axis = axis + self.molecules = molecules + self.moleculeName = Self.identifier + } +} diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift new file mode 100644 index 00000000..f58f8da1 --- /dev/null +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -0,0 +1,20 @@ +// +// SeperatorModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/28/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class SeperatorModel: MoleculeProtocol { + public static var identifier: String = "seperator" + public var moleculeName: String? + public var type: String? + + public init(type: String?) { + self.type = type + self.moleculeName = Self.identifier + } +} diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift new file mode 100644 index 00000000..74e7cd3e --- /dev/null +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -0,0 +1,23 @@ +// +// TextFieldModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { + public static var identifier: String = "textField" + + public var editable = true + public var errorMsg: String? + public var label: String? + public var type: String? + public var regex: String? + + public var required: Bool? + public var fieldKey: String? + public var groupName: String? +} diff --git a/MVMCoreUI/Models/PageModel.swift b/MVMCoreUI/Models/PageModel.swift new file mode 100644 index 00000000..b23cade8 --- /dev/null +++ b/MVMCoreUI/Models/PageModel.swift @@ -0,0 +1,18 @@ +// +// Page.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/23/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class PageModel: Codable { + public var template: String? + public var pageType: String? + public var screenHeading: String? + public var isAtomicTabs: Bool = false + public var header: HeaderModel? + public var molecules: [ListItemModel]? +} diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index 4c69b1f7..af39df41 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -8,8 +8,10 @@ #import @import MVMCore.MVMCoreViewProtocol; +//@import MVMCoreUI.Swift; @class MVMCoreUIDelegateObject; @class MVMCoreErrorObject; +@class MoleculeProtocol; @protocol MVMCoreUIMoleculeViewProtocol @@ -18,6 +20,11 @@ @optional +// optional func setWithModel(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject, _ additionalData: [String: AnyHashable]) +//Type arguments cannot be applied to non-parameterized class 'NSObject' +//- (void)setWithModel:(nullable NSObject*)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; + + /// Called after init to provide an early setter for any molecule specific logic - (void)setAsMolecule; diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift new file mode 100644 index 00000000..98c1818c --- /dev/null +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -0,0 +1,13 @@ +// +// ModelMoleculeViewProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ModelMoleculeViewProtocol { + func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) +} diff --git a/MVMCoreUI/Molecules/MoleculeViewProtocol.swift b/MVMCoreUI/Molecules/MoleculeViewProtocol.swift new file mode 100644 index 00000000..af1d09b4 --- /dev/null +++ b/MVMCoreUI/Molecules/MoleculeViewProtocol.swift @@ -0,0 +1,38 @@ +// +// MVMCoreUIMoleculeViewProtocol1.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +import UIKit +import MVMCore.MVMCoreViewProtocol +//@import MVMCoreUI.Swift; + +@objc public protocol MoleculeViewProtocol: MVMCoreViewProtocol { + + /// Sets up the ui based on the json + @objc func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) + + /// Called after init to provide an early setter for any molecule specific logic + @objc optional func setAsMolecule() + + + /// Resets to default state before set with json is called again. + @objc optional func reset() + + + /// For the molecule list to load more efficiently. + @objc optional static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat + + + /// Allows the molecule to set its name for reuse. Default could be moleculeName. + @objc optional static func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? + + + /// Can return the required modules + @objc optional static func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? +} diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 12819313..4af65f2c 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -8,7 +8,8 @@ import UIKit -public class StandardHeaderView: ViewConstrainingView { +public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol { + var separatorView: SeparatorView? // MARK: - MVMCoreViewProtocol @@ -53,6 +54,23 @@ public class StandardHeaderView: ViewConstrainingView { separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) } } + + open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + //TODO: Need to create setWithModel in ViewConstraining View + super.setWithJSON(model?.toJSON(), delegateObject: delegateObject, additionalData: additionalData) + + // This molecule will by default handle margins. + (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false) + (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false) + + guard let headerModel = model as? HeaderModel else { + return + } + + if let seperatorModel = headerModel.seperator?.object as? SeperatorModel { + separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) + } + } open override func reset() { super.reset() diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift new file mode 100644 index 00000000..1d3316fb --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -0,0 +1,40 @@ +// +// MVMCoreUIMoleculeMappingObject+ModelExtension.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +public extension MVMCoreUIMoleculeMappingObject { + + func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { + return createMolecule(model, delegateObject, false) + } + + func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { + guard let moleculeName = model.moleculeName, + let molecule = createMolecule(forName: moleculeName) as? MVMCoreUIViewConstrainingProtocol & UIView & MVMCoreUIMoleculeViewProtocol else { + return nil + } + + let setData = {() in + if let molecule = molecule as? ModelMoleculeViewProtocol { + molecule.setWithModel(model, delegateObject, nil) + } else { + molecule.setWithJSON(model.dictionary, delegateObject: delegateObject, additionalData: nil) + } + } + + if constrainIfNeeded, molecule.needsToBeConstrained?() ?? false { + let viewConstrainingView = ViewConstrainingView(molecule: molecule, alignment: molecule.alignment?() ?? .fill) + setData() + return viewConstrainingView + } + setData() + return molecule + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift new file mode 100644 index 00000000..c30c68d6 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -0,0 +1,22 @@ +// +// MVMCoreUIMoleculeMappingObject+ModelMapping.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/28/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objc public extension MVMCoreUIMoleculeMappingObject { + @objc static func registerObjects() { + HolderManager.register(LabelModel.self) + HolderManager.register(HeaderModel.self) + HolderManager.register(HeadlineBodyModel.self) + HolderManager.register(MoleculeStackModel.self) + HolderManager.register(ListItemModel.self) + HolderManager.register(MoleculeStackItemModel.self) + HolderManager.register(TextFieldModel.self) + HolderManager.register(SeperatorModel.self) + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h index 7d85a2ea..776566c8 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h @@ -25,6 +25,9 @@ #pragma mark - Molecule Creation +/// Creates the molecule for the molecule name. +- (nullable UIView *)createMoleculeForName:(nonnull NSString *)name; + /// Creates the molecule for the molecule json. - (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 945eb7bf..614251a9 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -17,6 +17,7 @@ #import "MVMCoreUIPageControl.h" #import "MVMCoreUIViewConstrainingProtocol.h" + @implementation MVMCoreUIMoleculeMappingObject - (NSMutableDictionary *)moleculeMapping { @@ -67,8 +68,8 @@ return mapping; } - + (nullable instancetype)sharedMappingObject { + [MVMCoreUIMoleculeMappingObject registerObjects]; return [MVMCoreActionUtility initializerClassCheck:[MVMCoreUIObject sharedInstance].moleculeMap classToVerify:self]; } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 0270cb63..3b1c31ef 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -27,9 +27,13 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { } open override func viewForTop() -> UIView { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { - return super.viewForTop() +// guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), +// let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { +// return super.viewForTop() +// } + guard let moleculeModel = pageModel?.header, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return super.viewForTop() } return molecule } From 37e1cb9e36c4ac70a3ce97d3e70dfd43936aa815 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 4 Nov 2019 17:24:04 -0500 Subject: [PATCH 003/272] changes --- MVMCoreUI/Models/Decoder.swift | 6 +++--- MVMCoreUI/Models/Encoder.swift | 4 ++-- MVMCoreUI/Models/JSON/JSONValue.swift | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Models/Decoder.swift b/MVMCoreUI/Models/Decoder.swift index 38fdc730..d8f5513d 100644 --- a/MVMCoreUI/Models/Decoder.swift +++ b/MVMCoreUI/Models/Decoder.swift @@ -8,7 +8,7 @@ extension JSONDecoder: AnyDecoder {} extension PropertyListDecoder: AnyDecoder {} extension Data { - public func decodeToObject(using decoder: AnyDecoder = JSONDecoder()) throws -> T { + public func decode(using decoder: AnyDecoder = JSONDecoder()) throws -> T { return try decoder.decode(T.self, from: self) } } @@ -27,7 +27,7 @@ extension KeyedDecodingContainerProtocol { } extension Decodable { - public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self { + public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self{ guard let path = bundle.path(forResource: fileName, ofType: ".json") else { throw JSONError.pathNotFound } @@ -37,7 +37,7 @@ extension Decodable { } do { - return try jsonData.decode() + return try jsonData.decode() } catch { throw JSONError.other(error: error) } diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift index 1f55038d..93d300f1 100644 --- a/MVMCoreUI/Models/Encoder.swift +++ b/MVMCoreUI/Models/Encoder.swift @@ -8,7 +8,7 @@ extension JSONEncoder: AnyEncoder {} extension PropertyListEncoder: AnyEncoder {} extension Encodable { - public func encodeToData(using encoder: AnyEncoder = JSONEncoder()) throws -> Data { + public func encode(using encoder: AnyEncoder = JSONEncoder()) throws -> Data { return try encoder.encode(self) } @@ -19,7 +19,7 @@ extension Encodable { public func toJSONString() -> String? { guard let data = try? self.encode(), - let string = String(data: data, encoding: .utf8) else { + let string = String(data: data, encoding: .utf8) else{ return nil } return string diff --git a/MVMCoreUI/Models/JSON/JSONValue.swift b/MVMCoreUI/Models/JSON/JSONValue.swift index 2b51a255..0a9061b9 100644 --- a/MVMCoreUI/Models/JSON/JSONValue.swift +++ b/MVMCoreUI/Models/JSON/JSONValue.swift @@ -3,7 +3,7 @@ import Foundation public typealias JSONValueArray = [[String: JSONValue]] public typealias JSONValueObject = [String: JSONValue] -public enum JSONValueError: Error { +public enum JSONValueError: Error{ case encode } @@ -105,7 +105,7 @@ extension JSONValue: ExpressibleByDictionaryLiteral { } extension Dictionary where Key == String, Value == Any { - public func toJSONValue() throws -> [String:JSONValue] { + public func toJSONValue() throws -> [String:JSONValue]{ let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) return try JSONDecoder().decode([String:JSONValue].self, from: data) } From a7473e2079766675b97c509cae95385174cb7ff8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 5 Nov 2019 09:02:49 -0500 Subject: [PATCH 004/272] Minor fixes for MFViewController --- MVMCoreUI/BaseControllers/MFViewController+Model.swift | 5 ++--- MVMCoreUI/BaseControllers/MFViewController.h | 3 --- MVMCoreUI/BaseControllers/MFViewController.m | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 05c9790d..924ce4c7 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -10,7 +10,7 @@ import Foundation public extension MFViewController { - @objc func parsePageJSON() { + @objc func parsePageJSON() { guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { return } @@ -20,8 +20,7 @@ public extension MFViewController { let pageModel = try decoder.decode(PageModel.self, from: pageData) self.pageModel = pageModel } catch { - print("error: \(error)") + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") } - } } diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index ded7446f..be8c3bd2 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -29,7 +29,6 @@ #import #import - @class MainMenuViewController; @class MVMCoreUITabBarPageControlViewController; @class MVMAnimationManager; @@ -43,8 +42,6 @@ @property (nullable, strong, nonatomic) PageModel *pageModel; -//@property (nonatomic) PageModel pageModel; - // The current selected text field. @property (nullable, weak, nonatomic) __block id selectedField; diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 3b68ef7d..1cde71f2 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -37,7 +37,6 @@ #import "MVMCoreUITabBarPageControlViewController.h" #import "MVMCoreUINavigationController.h" #import - @import MVMAnimationFramework; @interface MFViewController() @@ -97,6 +96,7 @@ self.pageType = loadObject.pageType; self.loadObject = loadObject; [self parsePageJSON]; + // Verifies all modules needed are loaded. return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error]; } @@ -249,6 +249,7 @@ - (BOOL)newPageLoaded:(nonnull NSDictionary *)page { self.loadObject.pageJSON = page; + [self parsePageJSON]; return YES; } From 4a1a196854fd69719497e18621725093d89ca432 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 5 Nov 2019 12:32:32 -0500 Subject: [PATCH 005/272] typos --- MVMCoreUI.xcodeproj/project.pbxproj | 6 +++--- MVMCoreUI/Models/Decoder.swift | 2 +- MVMCoreUI/Models/Encoder.swift | 2 +- MVMCoreUI/Models/Holder.swift | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 48ba4e50..031f4ba4 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -17,7 +17,7 @@ 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; }; 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */; }; 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */; }; - 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB392360EEB40024EF95 /* PageModel.swift */; }; + 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB392360EEB40024EF95 /* PageModel.swift */; }; 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */; }; 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3F23620A230024EF95 /* TextFieldModel.swift */; }; 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */; }; @@ -237,7 +237,7 @@ 01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButtonSwitch.swift; sourceTree = ""; }; 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonLabel.swift; sourceTree = ""; }; - 017BEB392360EEB40024EF95 /* PageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModel.swift; sourceTree = ""; }; + 017BEB392360EEB40024EF95 /* PageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModel.swift; sourceTree = ""; }; 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFViewController+Model.swift"; sourceTree = ""; }; 017BEB3F23620A230024EF95 /* TextFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldModel.swift; sourceTree = ""; }; 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormModelProtocol.swift; sourceTree = ""; }; @@ -466,13 +466,13 @@ isa = PBXGroup; children = ( 017BEB392360EEB40024EF95 /* PageModel.swift */, - 01EB368723609801006832FA /* Molecules */, 01EB3685236097F1006832FA /* MoleculeHolder.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, 01EB367F236092AE006832FA /* Holder.swift */, 01EB3680236092AE006832FA /* HolderManager.swift */, 01EB367B2360929F006832FA /* Decoder.swift */, 01EB367C2360929F006832FA /* Encoder.swift */, + 01EB368723609801006832FA /* Molecules */, 01EB367623609281006832FA /* JSON */, ); path = Models; diff --git a/MVMCoreUI/Models/Decoder.swift b/MVMCoreUI/Models/Decoder.swift index d8f5513d..c04e4940 100644 --- a/MVMCoreUI/Models/Decoder.swift +++ b/MVMCoreUI/Models/Decoder.swift @@ -27,7 +27,7 @@ extension KeyedDecodingContainerProtocol { } extension Decodable { - public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self{ + public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self { guard let path = bundle.path(forResource: fileName, ofType: ".json") else { throw JSONError.pathNotFound } diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift index 93d300f1..c8c441fd 100644 --- a/MVMCoreUI/Models/Encoder.swift +++ b/MVMCoreUI/Models/Encoder.swift @@ -19,7 +19,7 @@ extension Encodable { public func toJSONString() -> String? { guard let data = try? self.encode(), - let string = String(data: data, encoding: .utf8) else{ + let string = String(data: data, encoding: .utf8) else { return nil } return string diff --git a/MVMCoreUI/Models/Holder.swift b/MVMCoreUI/Models/Holder.swift index c8ae3f1f..8bb87a58 100644 --- a/MVMCoreUI/Models/Holder.swift +++ b/MVMCoreUI/Models/Holder.swift @@ -12,5 +12,5 @@ public protocol Holder: Codable { var name: String { get set } var object: HoldableType { get set } - init (name: String, object: HoldableType) + init(name: String, object: HoldableType) } From 347ebbed8c8fbbf5c614b84da87446ecc9b2a273 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 7 Nov 2019 10:05:17 -0500 Subject: [PATCH 006/272] typo fixes --- MVMCoreUI/Atoms/Views/ViewConstrainingView.h | 2 +- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 2 +- MVMCoreUI/Models/Encoder.swift | 4 ++-- MVMCoreUI/Models/HolderManager.swift | 4 ++-- MVMCoreUI/Models/JSON/JSONValue.swift | 6 +++--- .../Models/Molecules/ActionMapModel.swift | 2 +- MVMCoreUI/Models/Molecules/HeaderModel.swift | 2 +- .../Models/Molecules/HeadlineBodyModel.swift | 2 +- MVMCoreUI/Models/Molecules/ListItemModel.swift | 2 +- .../Molecules/MoleculeStackItemModel.swift | 2 +- .../Models/Molecules/MoleculeStackModel.swift | 4 ++-- .../Models/Molecules/SeperatorModel.swift | 6 +++--- MVMCoreUI/Models/PageModel.swift | 2 +- .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 1 - MVMCoreUI/Molecules/MoleculeViewProtocol.swift | 1 - MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- ...IMoleculeMappingObject+ModelExtension.swift | 18 +++++++++--------- ...eUIMoleculeMappingObject+ModelMapping.swift | 2 +- .../MVMCoreUIMoleculeMappingObject.m | 8 +++++++- 19 files changed, 38 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h index df443afd..c10768b0 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h @@ -50,7 +50,7 @@ + (nonnull ViewConstrainingView *)viewConstrainingView:(nonnull UIView *)view; // Can be initialized with a molecule to constrain -- (nullable instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment; +- (nonnull instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment; #pragma mark - Constraining diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 66a3a83d..57e54983 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -23,7 +23,7 @@ @implementation ViewConstrainingView -- (nullable instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment { +- (nonnull instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment { if (self = [super init]) { if (!molecule.superview) { [self addConstrainedView:molecule alignment:alignment]; diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift index c8c441fd..0a236a52 100644 --- a/MVMCoreUI/Models/Encoder.swift +++ b/MVMCoreUI/Models/Encoder.swift @@ -13,12 +13,12 @@ extension Encodable { } public func toJSON() -> JSONObject? { - guard let data = try? self.encode() else { return nil } + guard let data = try? encode() else { return nil } return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? JSONObject } } public func toJSONString() -> String? { - guard let data = try? self.encode(), + guard let data = try? encode(), let string = String(data: data, encoding: .utf8) else { return nil } diff --git a/MVMCoreUI/Models/HolderManager.swift b/MVMCoreUI/Models/HolderManager.swift index 44059145..4101aa95 100644 --- a/MVMCoreUI/Models/HolderManager.swift +++ b/MVMCoreUI/Models/HolderManager.swift @@ -69,8 +69,8 @@ extension Holder { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() - guard let encode = HolderManager.encoders[self.name], - let holdable = self.object as? Holdable else{ + guard let encode = HolderManager.encoders[name], + let holdable = object as? Holdable else { throw HolderManager.Error.encoderError } try encode(holdable, &container) diff --git a/MVMCoreUI/Models/JSON/JSONValue.swift b/MVMCoreUI/Models/JSON/JSONValue.swift index 0a9061b9..38f4e613 100644 --- a/MVMCoreUI/Models/JSON/JSONValue.swift +++ b/MVMCoreUI/Models/JSON/JSONValue.swift @@ -3,7 +3,7 @@ import Foundation public typealias JSONValueArray = [[String: JSONValue]] public typealias JSONValueObject = [String: JSONValue] -public enum JSONValueError: Error{ +public enum JSONValueError: Error { case encode } @@ -105,14 +105,14 @@ extension JSONValue: ExpressibleByDictionaryLiteral { } extension Dictionary where Key == String, Value == Any { - public func toJSONValue() throws -> [String:JSONValue]{ + public func toJSONValue() throws -> [String: JSONValue] { let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) return try JSONDecoder().decode([String:JSONValue].self, from: data) } } extension Dictionary where Key == String, Value == JSONValue { - public func toJSONObject() throws -> JSONObject{ + public func toJSONObject() throws -> JSONObject { let encoded = try JSONEncoder().encode(self) guard let json = try JSONSerialization.jsonObject(with: encoded, options: .mutableContainers) as? JSONObject else { throw JSONValueError.encode diff --git a/MVMCoreUI/Models/Molecules/ActionMapModel.swift b/MVMCoreUI/Models/Molecules/ActionMapModel.swift index 8e2cc133..3f46db29 100644 --- a/MVMCoreUI/Models/Molecules/ActionMapModel.swift +++ b/MVMCoreUI/Models/Molecules/ActionMapModel.swift @@ -12,7 +12,7 @@ import Foundation public var actionType: String? public var pageType: String? - public init(actionType: String?, pageType: String?){ + public init(actionType: String?, pageType: String?) { self.actionType = actionType self.pageType = pageType } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 98c80e4e..f1224810 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -14,7 +14,7 @@ import Foundation public var molecule: MoleculeHolder? public var seperator: MoleculeHolder? - public init(molecule: MoleculeHolder?){ + public init(molecule: MoleculeHolder?) { self.molecule = molecule self.moleculeName = Self.identifier } diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift index c80991ba..557e74ba 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -13,7 +13,7 @@ import Foundation public var moleculeName: String? public var headline: LabelModel? - public init(headline: LabelModel?){ + public init(headline: LabelModel?) { self.headline = headline self.moleculeName = Self.identifier } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index 6b1ceade..a1d297fb 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -14,7 +14,7 @@ import Foundation public var molecule: MoleculeHolder? public var actionMap: ActionMapModel? - public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?){ + public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?) { self.molecule = molecule self.actionMap = actionMap self.moleculeName = Self.identifier diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index cb590493..3b60f0c1 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -13,7 +13,7 @@ import Foundation public var moleculeName: String? public var molecule: MoleculeHolder? - public init(molecule: MoleculeHolder?){ + public init(molecule: MoleculeHolder?) { self.molecule = molecule self.moleculeName = Self.identifier } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 5dfda19c..c1a223ff 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -8,13 +8,13 @@ import Foundation -@objcMembers public class MoleculeStackModel: MoleculeProtocol{ +@objcMembers public class MoleculeStackModel: MoleculeProtocol { public static var identifier: String = "moleculeStack" public var moleculeName: String? public var molecules: [MoleculeStackItemModel]? public var axis: String? - public init(axis: String?, molecules: [MoleculeStackItemModel]?){ + public init(axis: String?, molecules: [MoleculeStackItemModel]?) { self.axis = axis self.molecules = molecules self.moleculeName = Self.identifier diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift index f58f8da1..6266b03e 100644 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -1,5 +1,5 @@ // -// SeperatorModel.swift +// LineModel.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 10/28/19. @@ -8,8 +8,8 @@ import UIKit -@objcMembers public class SeperatorModel: MoleculeProtocol { - public static var identifier: String = "seperator" +@objcMembers public class LineModel: MoleculeProtocol { + public static var identifier: String = "line" public var moleculeName: String? public var type: String? diff --git a/MVMCoreUI/Models/PageModel.swift b/MVMCoreUI/Models/PageModel.swift index b23cade8..ac2a4a15 100644 --- a/MVMCoreUI/Models/PageModel.swift +++ b/MVMCoreUI/Models/PageModel.swift @@ -12,7 +12,7 @@ import UIKit public var template: String? public var pageType: String? public var screenHeading: String? - public var isAtomicTabs: Bool = false + public var isAtomicTabs: Bool? = false public var header: HeaderModel? public var molecules: [ListItemModel]? } diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index e70c750a..2c52324b 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -8,7 +8,6 @@ #import @import MVMCore.MVMCoreViewProtocol; -//@import MVMCoreUI.Swift; @class MVMCoreUIDelegateObject; @class MVMCoreErrorObject; @class MoleculeProtocol; diff --git a/MVMCoreUI/Molecules/MoleculeViewProtocol.swift b/MVMCoreUI/Molecules/MoleculeViewProtocol.swift index af1d09b4..63fff68c 100644 --- a/MVMCoreUI/Molecules/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/MoleculeViewProtocol.swift @@ -10,7 +10,6 @@ import Foundation import UIKit import MVMCore.MVMCoreViewProtocol -//@import MVMCoreUI.Swift; @objc public protocol MoleculeViewProtocol: MVMCoreViewProtocol { diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 91c3cc99..435d8e02 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -67,7 +67,7 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol return } - if let seperatorModel = headerModel.seperator?.object as? SeperatorModel { + if let seperatorModel = headerModel.seperator?.object as? LineModel { separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 1d3316fb..9fd6c0ca 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -8,7 +8,6 @@ import Foundation - public extension MVMCoreUIMoleculeMappingObject { func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { @@ -17,11 +16,11 @@ public extension MVMCoreUIMoleculeMappingObject { func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { guard let moleculeName = model.moleculeName, - let molecule = createMolecule(forName: moleculeName) as? MVMCoreUIViewConstrainingProtocol & UIView & MVMCoreUIMoleculeViewProtocol else { + let molecule = createMolecule(forName: moleculeName) else { return nil } - let setData = {() in + let setData = {(molecule: UIView & MVMCoreUIMoleculeViewProtocol) in if let molecule = molecule as? ModelMoleculeViewProtocol { molecule.setWithModel(model, delegateObject, nil) } else { @@ -29,12 +28,13 @@ public extension MVMCoreUIMoleculeMappingObject { } } - if constrainIfNeeded, molecule.needsToBeConstrained?() ?? false { - let viewConstrainingView = ViewConstrainingView(molecule: molecule, alignment: molecule.alignment?() ?? .fill) - setData() - return viewConstrainingView + if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, castMolecule.needsToBeConstrained?() ?? false { + let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill) + setData(view) + return view + } else { + setData(molecule) + return molecule } - setData() - return molecule } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index c30c68d6..c9510436 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -17,6 +17,6 @@ import Foundation HolderManager.register(ListItemModel.self) HolderManager.register(MoleculeStackItemModel.self) HolderManager.register(TextFieldModel.self) - HolderManager.register(SeperatorModel.self) + HolderManager.register(LineModel.self) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 7fcea605..28471139 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -73,10 +73,16 @@ } + (nullable instancetype)sharedMappingObject { - [MVMCoreUIMoleculeMappingObject registerObjects]; return [MVMCoreActionUtility initializerClassCheck:[MVMCoreUIObject sharedInstance].moleculeMap classToVerify:self]; } +- (instancetype)init { + if (self = [super init]) { + [MVMCoreUIMoleculeMappingObject registerObjects]; + } + return self; +} + - (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json { NSString *moleculeName = [json string:KeyMoleculeName]; if (moleculeName) { From 1a3d3eb36f7db9ac84014bd988ddaa66639e3070 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 12 Nov 2019 17:36:00 -0500 Subject: [PATCH 007/272] update with new code, move core code to mvmcore --- MVMCoreUI.xcodeproj/project.pbxproj | 60 +++------ MVMCoreUI/Models/Decoder.swift | 45 ------- MVMCoreUI/Models/Encoder.swift | 27 ---- MVMCoreUI/Models/Extensions/ModelHelper.swift | 22 ++++ MVMCoreUI/Models/Holder.swift | 16 --- MVMCoreUI/Models/HolderManager.swift | 79 ------------ MVMCoreUI/Models/JSON/JSON.swift | 10 -- MVMCoreUI/Models/JSON/JSONValue.swift | 122 ------------------ MVMCoreUI/Models/MoleculeHolder.swift | 13 -- MVMCoreUI/Models/MoleculeProtocol.swift | 2 +- .../Models/Molecules/ActionMapModel.swift | 19 --- .../Models/Molecules/FormModelProtocol.swift | 2 +- MVMCoreUI/Models/Molecules/HeaderModel.swift | 25 +++- .../{SeperatorModel.swift => LineModel.swift} | 0 .../Models/Molecules/ListItemModel.swift | 25 +++- .../Molecules/MoleculeStackItemModel.swift | 20 ++- MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- ...UIMoleculeMappingObject+ModelMapping.swift | 16 +-- 18 files changed, 111 insertions(+), 394 deletions(-) delete mode 100644 MVMCoreUI/Models/Decoder.swift delete mode 100644 MVMCoreUI/Models/Encoder.swift create mode 100644 MVMCoreUI/Models/Extensions/ModelHelper.swift delete mode 100644 MVMCoreUI/Models/Holder.swift delete mode 100644 MVMCoreUI/Models/HolderManager.swift delete mode 100644 MVMCoreUI/Models/JSON/JSON.swift delete mode 100644 MVMCoreUI/Models/JSON/JSONValue.swift delete mode 100644 MVMCoreUI/Models/MoleculeHolder.swift delete mode 100644 MVMCoreUI/Models/Molecules/ActionMapModel.swift rename MVMCoreUI/Models/Molecules/{SeperatorModel.swift => LineModel.swift} (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 26d52bb7..cc93db84 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -24,7 +24,7 @@ 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */; }; 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */; }; 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; - 017BEB7B236763000024EF95 /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* SeperatorModel.swift */; }; + 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */; }; 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -32,21 +32,13 @@ 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; - 01EB367923609281006832FA /* JSONValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367723609281006832FA /* JSONValue.swift */; }; - 01EB367A23609281006832FA /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367823609281006832FA /* JSON.swift */; }; - 01EB367D2360929F006832FA /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367B2360929F006832FA /* Decoder.swift */; }; - 01EB367E2360929F006832FA /* Encoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367C2360929F006832FA /* Encoder.swift */; }; - 01EB3681236092AE006832FA /* Holder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367F236092AE006832FA /* Holder.swift */; }; - 01EB3682236092AE006832FA /* HolderManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3680236092AE006832FA /* HolderManager.swift */; }; 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; - 01EB3686236097F1006832FA /* MoleculeHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3685236097F1006832FA /* MoleculeHolder.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; }; 01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.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 */; }; - 01EB369523609801006832FA /* ActionMapModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368E23609801006832FA /* ActionMapModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; @@ -55,6 +47,7 @@ 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; + 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; @@ -246,28 +239,20 @@ 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelExtension.swift"; sourceTree = ""; }; 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeViewProtocol.swift; sourceTree = ""; }; 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; - 017BEB7A236763000024EF95 /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; + 017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = ""; }; 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelMapping.swift"; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; - 01EB367723609281006832FA /* JSONValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONValue.swift; sourceTree = ""; }; - 01EB367823609281006832FA /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = ""; }; - 01EB367B2360929F006832FA /* Decoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decoder.swift; sourceTree = ""; }; - 01EB367C2360929F006832FA /* Encoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Encoder.swift; sourceTree = ""; }; - 01EB367F236092AE006832FA /* Holder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Holder.swift; sourceTree = ""; }; - 01EB3680236092AE006832FA /* HolderManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HolderManager.swift; sourceTree = ""; }; 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; - 01EB3685236097F1006832FA /* MoleculeHolder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeHolder.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.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 = ""; }; - 01EB368E23609801006832FA /* ActionMapModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionMapModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -276,6 +261,7 @@ 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 = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; + 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; @@ -470,14 +456,9 @@ isa = PBXGroup; children = ( 017BEB392360EEB40024EF95 /* PageModel.swift */, - 01EB3685236097F1006832FA /* MoleculeHolder.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, - 01EB367F236092AE006832FA /* Holder.swift */, - 01EB3680236092AE006832FA /* HolderManager.swift */, - 01EB367B2360929F006832FA /* Decoder.swift */, - 01EB367C2360929F006832FA /* Encoder.swift */, + 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, - 01EB367623609281006832FA /* JSON */, ); path = Models; sourceTree = ""; @@ -493,15 +474,6 @@ path = FormUIHelpers; sourceTree = ""; }; - 01EB367623609281006832FA /* JSON */ = { - isa = PBXGroup; - children = ( - 01EB367723609281006832FA /* JSONValue.swift */, - 01EB367823609281006832FA /* JSON.swift */, - ); - path = JSON; - sourceTree = ""; - }; 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( @@ -511,14 +483,21 @@ 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, - 01EB368E23609801006832FA /* ActionMapModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, - 017BEB7A236763000024EF95 /* SeperatorModel.swift */, + 017BEB7A236763000024EF95 /* LineModel.swift */, ); path = Molecules; sourceTree = ""; }; + 946EE1B5237B663A0036751F /* Extensions */ = { + isa = PBXGroup; + children = ( + 946EE1B9237B66D80036751F /* ModelHelper.swift */, + ); + path = Extensions; + sourceTree = ""; + }; D224798823142BF2003FCCF9 /* SwitchMolecules */ = { isa = PBXGroup; children = ( @@ -1153,7 +1132,6 @@ D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, - 01EB3686236097F1006832FA /* MoleculeHolder.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, @@ -1161,7 +1139,6 @@ D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */, D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, - 01EB3681236092AE006832FA /* Holder.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, @@ -1173,7 +1150,6 @@ D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */, - 01EB367D2360929F006832FA /* Decoder.swift in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, @@ -1198,7 +1174,6 @@ D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, D2B18B812360945C00A9AEDC /* View.swift in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, - 01EB367923609281006832FA /* JSONValue.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, @@ -1212,7 +1187,7 @@ D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, - 017BEB7B236763000024EF95 /* SeperatorModel.swift in Sources */, + 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */, D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, @@ -1232,7 +1207,6 @@ DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, - 01EB367A23609281006832FA /* JSON.swift in Sources */, 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, @@ -1250,13 +1224,10 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, - 01EB3682236092AE006832FA /* HolderManager.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, - 01EB369523609801006832FA /* ActionMapModel.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, - 01EB367E2360929F006832FA /* Encoder.swift in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, @@ -1276,6 +1247,7 @@ 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, + 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, ); diff --git a/MVMCoreUI/Models/Decoder.swift b/MVMCoreUI/Models/Decoder.swift deleted file mode 100644 index c04e4940..00000000 --- a/MVMCoreUI/Models/Decoder.swift +++ /dev/null @@ -1,45 +0,0 @@ -import Foundation - -public protocol AnyDecoder { - func decode(_ type: T.Type, from data: Data) throws -> T -} - -extension JSONDecoder: AnyDecoder {} -extension PropertyListDecoder: AnyDecoder {} - -extension Data { - public func decode(using decoder: AnyDecoder = JSONDecoder()) throws -> T { - return try decoder.decode(T.self, from: self) - } -} - -extension KeyedDecodingContainerProtocol { - public func decode(forKey key: Key) throws -> T { - return try decode(T.self, forKey: key) - } - - public func decode( - forKey key: Key, - default defaultExpression: @autoclosure () -> T - ) throws -> T { - return try decodeIfPresent(T.self, forKey: key) ?? defaultExpression() - } -} - -extension Decodable { - public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self { - guard let path = bundle.path(forResource: fileName, ofType: ".json") else { - throw JSONError.pathNotFound - } - - guard let jsonData = try? Data(contentsOf: URL(fileURLWithPath: path)) else { - throw JSONError.data(path: path) - } - - do { - return try jsonData.decode() - } catch { - throw JSONError.other(error: error) - } - } -} diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift deleted file mode 100644 index 0a236a52..00000000 --- a/MVMCoreUI/Models/Encoder.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation - -public protocol AnyEncoder { - func encode(_ value: T) throws -> Data -} - -extension JSONEncoder: AnyEncoder {} -extension PropertyListEncoder: AnyEncoder {} - -extension Encodable { - public func encode(using encoder: AnyEncoder = JSONEncoder()) throws -> Data { - return try encoder.encode(self) - } - - public func toJSON() -> JSONObject? { - guard let data = try? encode() else { return nil } - return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? JSONObject } - } - - public func toJSONString() -> String? { - guard let data = try? encode(), - let string = String(data: data, encoding: .utf8) else { - return nil - } - return string - } -} diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift new file mode 100644 index 00000000..1f15274f --- /dev/null +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -0,0 +1,22 @@ +// +// ModelHelper.swift +// MVMCoreUI +// +// Created by Ryan on 11/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + + +extension KeyedDecodingContainer where Key : CodingKey{ + + public func decode(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { + return try decode(codingKey: codingKey, typeCodingKey: .moleculeName) + } + + public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { + return try decodeIfPresent(codingKey: codingKey, typeCodingKey: .moleculeName) + } +} diff --git a/MVMCoreUI/Models/Holder.swift b/MVMCoreUI/Models/Holder.swift deleted file mode 100644 index 8bb87a58..00000000 --- a/MVMCoreUI/Models/Holder.swift +++ /dev/null @@ -1,16 +0,0 @@ -import Foundation - -public protocol Holdable: Codable { - static var identifier: String { get set } -} - -public protocol Holder: Codable { - associatedtype HoldableType = Holdable - - static var codingKeyName: String { get } - - var name: String { get set } - var object: HoldableType { get set } - - init(name: String, object: HoldableType) -} diff --git a/MVMCoreUI/Models/HolderManager.swift b/MVMCoreUI/Models/HolderManager.swift deleted file mode 100644 index 4101aa95..00000000 --- a/MVMCoreUI/Models/HolderManager.swift +++ /dev/null @@ -1,79 +0,0 @@ -import Foundation - -public class HolderManager { - public enum Error: Swift.Error { - case codingKeyNotFound - case encoderError - case decoderError - case decoderErrorModelNotMapped - } - fileprivate typealias HoldableDecoder = (SingleValueDecodingContainer) throws -> Holdable - fileprivate typealias HoldableEncoder = (Holdable, inout SingleValueEncodingContainer) throws -> Void - fileprivate static var decoders: [String: HoldableDecoder] = [:] - fileprivate static var encoders: [String: HoldableEncoder] = [:] - - public static func register(_ type: A.Type) { - decoders[A.identifier] = { container in - try container.decode(A.self) - } - - encoders[A.identifier] = { name, container in - guard let obj = name as? A else { - throw HolderManager.Error.encoderError - } - try container.encode(obj) - } - } -} - -private struct DynamicKey: CodingKey { - var stringValue: String - init?(stringValue: String) { - self.stringValue = stringValue - } - - var intValue: Int? { return nil } - init?(intValue: Int) { return nil } -} - -//MARK: - Holder Extension -extension Holder { - - public init(from decoder: Decoder) throws { - - //get the CodingKey String name that tells the type of holdable - guard let key = DynamicKey(stringValue: Self.codingKeyName) else { - throw HolderManager.Error.decoderError - } - - //get the type - let typeContainer = try decoder.container(keyedBy: DynamicKey.self) - let type = try typeContainer.decode(String.self, forKey: key) - - //get the container to decode - let container = try decoder.singleValueContainer() - - //get the decoder for the type found - guard let decoder = HolderManager.decoders[type] else { - throw HolderManager.Error.decoderErrorModelNotMapped - } - - //decode the type and ensure it is of HoldableType - guard let obj = try decoder(container) as? HoldableType else { - throw HolderManager.Error.decoderError - } - - //instantiate Self - self = Self(name: type, object: obj) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - guard let encode = HolderManager.encoders[name], - let holdable = object as? Holdable else { - throw HolderManager.Error.encoderError - } - try encode(holdable, &container) - } -} - diff --git a/MVMCoreUI/Models/JSON/JSON.swift b/MVMCoreUI/Models/JSON/JSON.swift deleted file mode 100644 index cf584557..00000000 --- a/MVMCoreUI/Models/JSON/JSON.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Foundation - -public typealias JSONArray = [[String: Any]] -public typealias JSONObject = [String: Any] - -public enum JSONError: Error { - case pathNotFound - case data(path: String) - case other(error: Error) -} diff --git a/MVMCoreUI/Models/JSON/JSONValue.swift b/MVMCoreUI/Models/JSON/JSONValue.swift deleted file mode 100644 index 38f4e613..00000000 --- a/MVMCoreUI/Models/JSON/JSONValue.swift +++ /dev/null @@ -1,122 +0,0 @@ -import Foundation - -public typealias JSONValueArray = [[String: JSONValue]] -public typealias JSONValueObject = [String: JSONValue] - -public enum JSONValueError: Error { - case encode -} - -extension Optional { - func or(_ other: Optional) -> Optional { - switch self { - case .none: return other - case .some: return self - } - } - - func resolve(with error: @autoclosure () -> Error) throws -> Wrapped { - switch self { - case .none: throw error() - case .some(let wrapped): return wrapped - } - } -} - -public enum JSONValue: Codable, Equatable { - case string(String) - case int(Int) - case double(Double) - case bool(Bool) - case object([String: JSONValue]) - case array([JSONValue]) - case null - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - let value = ((try? container.decode(String.self)).map(JSONValue.string)) - .or((try? container.decode(Int.self)).map(JSONValue.int)) - .or((try? container.decode(Double.self)).map(JSONValue.double)) - .or((try? container.decode(Bool.self)).map(JSONValue.bool)) - .or((try? container.decode([String: JSONValue].self)).map(JSONValue.object)) - .or((try? container.decode([JSONValue].self)).map(JSONValue.array)) - - self = value ?? JSONValue.null - } - - func decode() throws -> T { - let encoded = try JSONEncoder().encode(self) - return try JSONDecoder().decode(T.self, from: encoded) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - switch self { - case .string(let string): try container.encode(string) - case .int(let int): try container.encode(int) - case .double(let double): try container.encode(double) - case .bool(let bool): try container.encode(bool) - case .object(let object): try container.encode(object) - case .array(let array): try container.encode(array) - case .null: break - } - } -} - -public func ==(lhs: JSONValue, rhs: JSONValue) -> Bool { - let ld = try? lhs.encode() - let rd = try? lhs.encode() - return ld == rd -} - -extension JSONValue: ExpressibleByStringLiteral { - public init(stringLiteral value: String) { - self = .string(value) - } -} - -extension JSONValue: ExpressibleByIntegerLiteral { - public init(integerLiteral value: Int) { - self = .int(value) - } -} - -extension JSONValue: ExpressibleByFloatLiteral { - public init(floatLiteral value: Double) { - self = .double(value) - } -} - -extension JSONValue: ExpressibleByBooleanLiteral { - public init(booleanLiteral value: Bool) { - self = .bool(value) - } -} - -extension JSONValue: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: JSONValue...) { - self = .array(elements) - } -} - -extension JSONValue: ExpressibleByDictionaryLiteral { - public init(dictionaryLiteral elements: (String, JSONValue)...) { - self = .object([String: JSONValue](uniqueKeysWithValues: elements)) - } -} - -extension Dictionary where Key == String, Value == Any { - public func toJSONValue() throws -> [String: JSONValue] { - let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) - return try JSONDecoder().decode([String:JSONValue].self, from: data) - } -} - -extension Dictionary where Key == String, Value == JSONValue { - public func toJSONObject() throws -> JSONObject { - let encoded = try JSONEncoder().encode(self) - guard let json = try JSONSerialization.jsonObject(with: encoded, options: .mutableContainers) as? JSONObject else { - throw JSONValueError.encode - } - return json - } -} diff --git a/MVMCoreUI/Models/MoleculeHolder.swift b/MVMCoreUI/Models/MoleculeHolder.swift deleted file mode 100644 index e83889c2..00000000 --- a/MVMCoreUI/Models/MoleculeHolder.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Foundation - -public class MoleculeHolder: Holder { - public static var codingKeyName: String = "moleculeName" - - public var name: String - public var object: MoleculeProtocol - - required public init(name: String, object: MoleculeProtocol) { - self.name = name - self.object = object - } -} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index 4dcdce60..0bb23cdf 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -1,6 +1,6 @@ import Foundation -public protocol MoleculeProtocol: Holdable { +public protocol MoleculeProtocol: Model { var moleculeName: String? {get} var dictionary: [AnyHashable: Any]? {get} } diff --git a/MVMCoreUI/Models/Molecules/ActionMapModel.swift b/MVMCoreUI/Models/Molecules/ActionMapModel.swift deleted file mode 100644 index 3f46db29..00000000 --- a/MVMCoreUI/Models/Molecules/ActionMapModel.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ActionMap.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/3/19. -// Copyright © 2019 Suresh, Kamlesh. All rights reserved. -// - -import Foundation - -@objcMembers public class ActionMapModel: Codable { - public var actionType: String? - public var pageType: String? - - public init(actionType: String?, pageType: String?) { - self.actionType = actionType - self.pageType = pageType - } -} diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift index 7d31912a..4cd76354 100644 --- a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift +++ b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol FormModelProtocol: Holdable { +public protocol FormModelProtocol: Model { var required: Bool? {get} var fieldKey: String? {get} var groupName: String? {get} diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index f1224810..db794d10 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -11,12 +11,31 @@ import Foundation @objcMembers public class HeaderModel: MoleculeProtocol { public static var identifier: String = "header" public var moleculeName: String? - public var molecule: MoleculeHolder? - public var seperator: MoleculeHolder? + public var molecule: MoleculeProtocol? + public var seperator: MoleculeProtocol? - public init(molecule: MoleculeHolder?) { + public init(molecule: MoleculeProtocol?){ self.molecule = molecule self.moleculeName = Self.identifier } + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + case separator + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + } } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift similarity index 100% rename from MVMCoreUI/Models/Molecules/SeperatorModel.swift rename to MVMCoreUI/Models/Molecules/LineModel.swift diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index a1d297fb..e1f9dc68 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -11,12 +11,31 @@ import Foundation @objcMembers public class ListItemModel: MoleculeProtocol { public static var identifier: String = "listItem" public var moleculeName: String? - public var molecule: MoleculeHolder? + public var molecule: MoleculeProtocol? public var actionMap: ActionMapModel? - public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?) { + public init(molecule: MoleculeProtocol?, actionMap: ActionMapModel?) { self.molecule = molecule self.actionMap = actionMap self.moleculeName = Self.identifier } -} + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + case actionMap + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.actionMap = try typeContainer.decodeIfPresent(ActionMapModel.self, forKey: .actionMap) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeIfPresent(actionMap, forKey: .actionMap) + }} diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 3b60f0c1..1ad99dec 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -11,10 +11,26 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeProtocol { public static var identifier: String = "moleculeStackItem" public var moleculeName: String? - public var molecule: MoleculeHolder? + public var molecule: MoleculeProtocol? - public init(molecule: MoleculeHolder?) { + public init(molecule: MoleculeProtocol?) { self.molecule = molecule self.moleculeName = Self.identifier } + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 435d8e02..9b9a5ff2 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -67,7 +67,7 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol return } - if let seperatorModel = headerModel.seperator?.object as? LineModel { + if let seperatorModel = headerModel.seperator as? LineModel { separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index c9510436..b3a20c2c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -10,13 +10,13 @@ import Foundation @objc public extension MVMCoreUIMoleculeMappingObject { @objc static func registerObjects() { - HolderManager.register(LabelModel.self) - HolderManager.register(HeaderModel.self) - HolderManager.register(HeadlineBodyModel.self) - HolderManager.register(MoleculeStackModel.self) - HolderManager.register(ListItemModel.self) - HolderManager.register(MoleculeStackItemModel.self) - HolderManager.register(TextFieldModel.self) - HolderManager.register(LineModel.self) + ModelRegistry.register(LabelModel.self) + ModelRegistry.register(HeaderModel.self) + ModelRegistry.register(HeadlineBodyModel.self) + ModelRegistry.register(MoleculeStackModel.self) + ModelRegistry.register(ListItemModel.self) + ModelRegistry.register(MoleculeStackItemModel.self) + ModelRegistry.register(TextFieldModel.self) + ModelRegistry.register(LineModel.self) } } From 478498a9b66a8920419f0ed4cb5e519cd48d6c66 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 13 Nov 2019 18:02:40 -0500 Subject: [PATCH 008/272] Separate action and molecule name --- MVMCoreUI/Models/Extensions/ModelHelper.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index 1f15274f..c56a0a5a 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -11,12 +11,15 @@ import Foundation extension KeyedDecodingContainer where Key : CodingKey{ + private enum TypeCodingKey: String, CodingKey { + case moleculeName + } public func decode(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { - return try decode(codingKey: codingKey, typeCodingKey: .moleculeName) + return try decode(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { - return try decodeIfPresent(codingKey: codingKey, typeCodingKey: .moleculeName) + return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } } From bf20fb3104dd8ffcf09488b357b7b433e9746d68 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Nov 2019 15:32:35 -0500 Subject: [PATCH 009/272] fixes --- MVMCoreUI/Models/Extensions/ModelHelper.swift | 2 -- MVMCoreUI/Models/Molecules/HeaderModel.swift | 1 - MVMCoreUI/Models/Molecules/LabelModel.swift | 5 ----- .../Models/Molecules/ListItemModel.swift | 3 ++- .../Molecules/MoleculeStackItemModel.swift | 2 +- .../Models/Molecules/MoleculeStackModel.swift | 21 +++++++++++++++++++ MVMCoreUI/Models/PageModel.swift | 1 + ...MoleculeMappingObject+ModelExtension.swift | 4 +++- ...UIMoleculeMappingObject+ModelMapping.swift | 2 +- .../Templates/MoleculeStackTemplate.swift | 8 +++++-- 10 files changed, 35 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index c56a0a5a..661280a9 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -8,8 +8,6 @@ import Foundation - - extension KeyedDecodingContainer where Key : CodingKey{ private enum TypeCodingKey: String, CodingKey { case moleculeName diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index db794d10..4cbc1c82 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -29,7 +29,6 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Models/Molecules/LabelModel.swift b/MVMCoreUI/Models/Molecules/LabelModel.swift index 61fa9fda..e5de1ccf 100644 --- a/MVMCoreUI/Models/Molecules/LabelModel.swift +++ b/MVMCoreUI/Models/Molecules/LabelModel.swift @@ -13,9 +13,4 @@ import Foundation public static var identifier: String = "label" public var moleculeName: String? public var text: String? - - public init(text: String?) { - self.text = text - self.moleculeName = Self.identifier - } } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index e1f9dc68..a903299a 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -38,4 +38,5 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(actionMap, forKey: .actionMap) - }} + } +} diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 1ad99dec..5bceda3e 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeProtocol { - public static var identifier: String = "moleculeStackItem" + public static var identifier: String = "stackItem" public var moleculeName: String? public var molecule: MoleculeProtocol? diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index c1a223ff..30c15822 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -9,6 +9,7 @@ import Foundation @objcMembers public class MoleculeStackModel: MoleculeProtocol { + public static var identifier: String = "moleculeStack" public var moleculeName: String? public var molecules: [MoleculeStackItemModel]? @@ -19,4 +20,24 @@ import Foundation self.molecules = molecules self.moleculeName = Self.identifier } + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecules + case axis + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) + self.molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules) + self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(molecules, forKey: .molecules) + try container.encode(axis, forKey: .axis) + } } diff --git a/MVMCoreUI/Models/PageModel.swift b/MVMCoreUI/Models/PageModel.swift index ac2a4a15..a47c78e1 100644 --- a/MVMCoreUI/Models/PageModel.swift +++ b/MVMCoreUI/Models/PageModel.swift @@ -15,4 +15,5 @@ import UIKit public var isAtomicTabs: Bool? = false public var header: HeaderModel? public var molecules: [ListItemModel]? + public var moleculeStack: MoleculeStackModel? } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 9fd6c0ca..650264fc 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -8,6 +8,7 @@ import Foundation + public extension MVMCoreUIMoleculeMappingObject { func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { @@ -28,7 +29,8 @@ public extension MVMCoreUIMoleculeMappingObject { } } - if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, castMolecule.needsToBeConstrained?() ?? false { + if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, + castMolecule.needsToBeConstrained?() ?? false { let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill) setData(view) return view diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index b3a20c2c..67d3df02 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -14,8 +14,8 @@ import Foundation ModelRegistry.register(HeaderModel.self) ModelRegistry.register(HeadlineBodyModel.self) ModelRegistry.register(MoleculeStackModel.self) - ModelRegistry.register(ListItemModel.self) ModelRegistry.register(MoleculeStackItemModel.self) + ModelRegistry.register(ListItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(LineModel.self) } diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index d6f78b05..dad4d5ef 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -30,9 +30,13 @@ open class MoleculeStackTemplate: ThreeLayerViewController { } open override func viewForTop() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { - return nil + guard let moleculeModel = pageModel?.header, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return nil } +// guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { +// return nil +// } return molecule } From 5fd74b695f6b195138db284fa2c0a9c11e1e27cd Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 20 Nov 2019 14:58:58 -0500 Subject: [PATCH 010/272] create model for progress bar, using ModelMoleculeViewProtocol --- MVMCoreUI.xcodeproj/project.pbxproj | 10 +++- MVMCoreUI/Atoms/Views/MultiProgress.swift | 51 +++++++----------- .../Atoms/Views/MultiProgressModel.swift | 47 +++++++++++++++++ MVMCoreUI/Atoms/Views/ProgressBar.swift | 23 +++++++- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 52 +++++++++++++++++++ ...UIMoleculeMappingObject+ModelMapping.swift | 2 + 6 files changed, 151 insertions(+), 34 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/MultiProgressModel.swift create mode 100644 MVMCoreUI/Atoms/Views/ProgressBarModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index cc93db84..1b95a13c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -46,6 +46,8 @@ 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; + 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; + 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; @@ -260,6 +262,8 @@ 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.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 = ""; }; + 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; + 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; @@ -590,6 +594,7 @@ D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */ = { isa = PBXGroup; children = ( + D29DF10D21E67A70003B2FB9 /* Atoms */, 01509D96232803B200EF99AA /* Models */, D2B18B7D236090D500A9AEDC /* BaseClasses */, 01C74D87224298E2009C25A3 /* FormUIHelpers */, @@ -602,7 +607,6 @@ D22D1F582204D2590077CEC0 /* LegacyControllers */, D29DF10F21E67A7D003B2FB9 /* BaseControllers */, D29DF11E21E6851E003B2FB9 /* TopAlert */, - D29DF10D21E67A70003B2FB9 /* Atoms */, D29DF10E21E67A77003B2FB9 /* Molecules */, D22479902316A9CB003FCCF9 /* Organisms */, D29DF0DF21E418B2003B2FB9 /* Templates */, @@ -789,10 +793,12 @@ isa = PBXGroup; children = ( 01509D922327ECFB00EF99AA /* ProgressBar.swift */, + 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */, D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */, D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */, 948DB67D2326DCD90011F916 /* MultiProgress.swift */, + 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, DBC4391622442196001AB423 /* CaretView.swift */, DBC4391722442197001AB423 /* DashLine.swift */, DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, @@ -1143,6 +1149,7 @@ DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, + 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, @@ -1197,6 +1204,7 @@ 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, + 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */, D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index fe902d9f..0e911e37 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -8,35 +8,10 @@ import UIKit -@objcMembers open class ProgressBarObject { - ///from 0.0 to 1.0. input progress should be [0 100] - var progress: CGFloat = 0.0 - ///default color is cerulean - var color: UIColor = UIColor.mfCerulean() +@objcMembers open class MultiProgress: ViewConstrainingView, ModelMoleculeViewProtocol { - init(_ module: [AnyHashable: Any]?) { - progress = (module?.optionalCGFloatForKey("progress") ?? 0.0)/100 - if let colorString = module?.optionalStringForKey("progressColor") { - color = UIColor.mfGet(forHex: colorString) - } - } - - static func getProgressBarObjectList(_ list: [[AnyHashable: Any]]?) -> [ProgressBarObject]? { - guard list?.count ?? 0 > 0 else { - return nil - } - var progressList = [ProgressBarObject]() - for module in list! { - let progressObject = ProgressBarObject(module) - progressList.append(progressObject) - } - return progressList - } -} - -@objcMembers open class MultiProgress: MFView { ///passing value to progressList creates corresponding progress bars - var progressList: Array? { + var progressList: Array? { didSet { for subview in subviews { subview.removeFromSuperview() @@ -46,14 +21,18 @@ import UIKit } var previous: UIView? for progressObject in progressList! { - guard progressObject.progress > 0.0 else { + guard progressObject.progress ?? 0.0 > 0.0 else { continue } let view = MFView(frame: .zero) view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) - view.backgroundColor = progressObject.color - view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress).isActive = true + var color = UIColor.mfCerulean() + if let colorString = progressObject.color { + color = UIColor.mfGet(forHex: colorString) + } + view.backgroundColor = color + view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress ?? 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) @@ -70,6 +49,7 @@ import UIKit } } } + var thicknessConstraint: NSLayoutConstraint? let defaultHeight: CGFloat = 8 @@ -84,6 +64,16 @@ import UIKit } } + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let multiProgressModel = model as? MultiProgressBarModel else { + return + } + roundedRect = multiProgressModel.roundedRect ?? false + thicknessConstraint?.constant = multiProgressModel.thickness ?? defaultHeight + progressList = multiProgressModel.progressList + + } + open override func reset() { super.reset() backgroundColor = .mfLightSilver() @@ -94,6 +84,5 @@ import UIKit super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) thicknessConstraint?.constant = json?.optionalCGFloatForKey("thickness") ?? defaultHeight roundedRect = json?.optionalBoolForKey("roundedRect") ?? false - progressList = ProgressBarObject.getProgressBarObjectList(json?.optionalArrayForKey("progressList") as? [[AnyHashable: Any]]) } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift new file mode 100644 index 00000000..156f71a0 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -0,0 +1,47 @@ +// +// MultiProgressModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class SingleProgressBarModel: Codable { + var progress: CGFloat? + var color: String? +} + +@objcMembers public class MultiProgressBarModel: MoleculeProtocol { + public static var identifier: String = "multiProgressBar" + public var moleculeName: String + public var progressList: [SingleProgressBarModel]? + public var thickness: CGFloat? + public var roundedRect: Bool? + + enum CodingKeys: String, CodingKey { + case moleculeName + case progressList + case thickness + case roundedRect + } + + required public init(from decoder: Decoder) throws { + + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.progressList = try typeContainer.decodeIfPresent([SingleProgressBarModel].self, forKey: .progressList) + self.thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) + self.roundedRect = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedRect) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(progressList, forKey: .progressList) + try container.encodeIfPresent(thickness, forKey: .thickness) + try container.encodeIfPresent(roundedRect, forKey: .roundedRect) + } +} diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 1aecd537..45ce85d6 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers open class ProgressBar: UIProgressView, MVMCoreUIMoleculeViewProtocol, MVMCoreViewProtocol { +@objcMembers open class ProgressBar: UIProgressView, MVMCoreViewProtocol, ModelMoleculeViewProtocol, MVMCoreUIMoleculeViewProtocol { var isRounded = false var thickness: CGFloat = 8.0 { willSet(newValue) { @@ -40,12 +40,31 @@ import Foundation public func setupView() { clipsToBounds = true translatesAutoresizingMaskIntoConstraints = false - reset() + isRounded = false + thickness = 8 + progress = 0 + progressTintColor = UIColor.mfCerulean() + trackTintColor = UIColor.mfLightSilver() } public func updateView(_ size: CGFloat) { } + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + guard let progressBarModel = model as? ProgressBarModel else { + return + } + isRounded = progressBarModel.isRounded ?? false + thickness = progressBarModel.thickness ?? 8 + progress = (progressBarModel.percentage ?? 0)/100.0 + if let progressColor = progressBarModel.progressColor { + progressTintColor = UIColor.mfGet(forHex: progressColor) + } + if let backgroundColor = progressBarModel.backgroundColor { + trackTintColor = UIColor.mfGet(forHex: backgroundColor) + } + } + // MARK: - MVMCoreUIMoleculeViewProtocol public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { if let isRounded = json?.optionalBoolForKey("roundedRect") { diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift new file mode 100644 index 00000000..b48f0321 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -0,0 +1,52 @@ +// +// ProgressBarModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ProgressBarModel: MoleculeProtocol { + public static var identifier: String = "progressbar" + public var moleculeName: String + + public var isRounded: Bool? + public var thickness: CGFloat? + ///from 0 to 100 + public var percentage: Float? + public var progressColor: String? + public var backgroundColor: String? + + enum CodingKeys: String, CodingKey { + case moleculeName + case isRounded = "roundRect" + case thickness + case percentage = "percent" + case progressColor + case backgroundColor + } + + required public init(from decoder: Decoder) throws { + + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) + self.thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) + self.percentage = try typeContainer.decodeIfPresent(Float.self, forKey: .percentage) + self.progressColor = try typeContainer.decodeIfPresent(String.self, forKey: .progressColor) + self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(isRounded, forKey: .isRounded) + try container.encodeIfPresent(thickness, forKey: .thickness) + try container.encodeIfPresent(percentage, forKey: .percentage) + try container.encodeIfPresent(progressColor, forKey: .progressColor) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index 67d3df02..a4961b53 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -18,5 +18,7 @@ import Foundation ModelRegistry.register(ListItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(LineModel.self) + ModelRegistry.register(ProgressBarModel.self) + ModelRegistry.register(MultiProgressBarModel.self) } } From dde5f1d1a474760591ae632b80aec44e7a38b312 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 20 Nov 2019 15:30:42 -0500 Subject: [PATCH 011/272] add caret view model and dash line model --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++++++ MVMCoreUI/Atoms/Views/CaretView.swift | 24 ++++++++++++++++++- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 19 +++++++++++++++ MVMCoreUI/Atoms/Views/DashLine.swift | 17 ++++++++++++- MVMCoreUI/Atoms/Views/DashLineModel.swift | 18 ++++++++++++++ ...UIMoleculeMappingObject+ModelMapping.swift | 2 ++ 6 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/CaretViewModel.swift create mode 100644 MVMCoreUI/Atoms/Views/DashLineModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 1b95a13c..632682a3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.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 */; }; + 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; @@ -264,6 +266,8 @@ 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.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 = ""; }; + 944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; @@ -800,7 +804,9 @@ 948DB67D2326DCD90011F916 /* MultiProgress.swift */, 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, DBC4391622442196001AB423 /* CaretView.swift */, + 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */, DBC4391722442197001AB423 /* DashLine.swift */, + 944589202385D6E900DE9FD4 /* DashLineModel.swift */, DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17F21E69E2E003B2FB9 /* MFView.m */, @@ -1151,6 +1157,7 @@ 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */, + 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, @@ -1200,6 +1207,7 @@ D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, + 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index ec4457c2..232f4a75 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -8,7 +8,8 @@ // -open class CaretView: MFView { +open class CaretView: MFView, ModelMoleculeViewProtocol { + //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -132,4 +133,25 @@ open class CaretView: MFView { open override func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading; } + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let caretModel = model as? CaretViewModel else { + return + } + if let strokeColorHex = caretModel.strokeColor { + strokeColor = UIColor.mfGet(forHex: strokeColorHex) + } + + if let isHiddenValue = caretModel.isHidden { + isHidden = isHiddenValue + } + + if let isOpaqueValue = caretModel.isOpaque { + isOpaque = isOpaqueValue + } + + if let lineWidthValue = caretModel.lineWidth { + lineWidth = lineWidthValue + } + } } diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift new file mode 100644 index 00000000..c0f3ee8c --- /dev/null +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -0,0 +1,19 @@ +// +// CaretViewModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class CaretViewModel: MoleculeProtocol { + public static var identifier: String = "caretView" + public var moleculeName: String + + public var strokeColor: String? + public var isHidden: Bool? + public var isOpaque: Bool? + public var lineWidth: CGFloat? +} diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 512b48cd..3b0cddb2 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -10,12 +10,13 @@ import MVMCore -open class DashLine: MFView { +open class DashLine: MFView, ModelMoleculeViewProtocol { //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @objc public var dashColor: UIColor? + @objc public var dashLayer: CAShapeLayer? //------------------------------------------------------ // MARK: - Lifecycle @@ -55,6 +56,7 @@ open class DashLine: MFView { dashLayer.strokeColor = dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor dashLayer.fillColor = UIColor.clear.cgColor dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor + self.dashLayer = dashLayer } //------------------------------------------------------ @@ -82,4 +84,17 @@ open class DashLine: MFView { dashColor = UIColor.mfGet(forHex: dashColorHex) } } + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let dashLineModel = model as? DashLineModel else { + return + } + dashColor = UIColor.mfGet(forHex: dashLineModel.dashColor) + if let isHiddenValue = dashLineModel.isHidden { + isHidden = isHiddenValue + } + if let backgroundColor = dashLineModel.backgroundColor { + dashLayer?.backgroundColor = UIColor.mfGet(forHex: backgroundColor).cgColor + } + } } diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift new file mode 100644 index 00000000..8fd26fbf --- /dev/null +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -0,0 +1,18 @@ +// +// DashLineModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class DashLineModel: MoleculeProtocol { + public static var identifier: String = "dashLine" + public var moleculeName: String + + public var dashColor: String + public var isHidden: Bool? + public var backgroundColor: String? +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index a4961b53..5cf3168f 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -20,5 +20,7 @@ import Foundation ModelRegistry.register(LineModel.self) ModelRegistry.register(ProgressBarModel.self) ModelRegistry.register(MultiProgressBarModel.self) + ModelRegistry.register(CaretViewModel.self) + ModelRegistry.register(DashLineModel.self) } } From 28a04218f9afd0824d453c2cff22c9638c9ea02a Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 20 Nov 2019 15:43:26 -0500 Subject: [PATCH 012/272] create image model --- MVMCoreUI.xcodeproj/project.pbxproj | 4 +++ MVMCoreUI/Atoms/Views/ImageViewModel.swift | 21 ++++++++++++++++ MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 27 ++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 MVMCoreUI/Atoms/Views/ImageViewModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 632682a3..67dd46b8 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -50,6 +50,7 @@ 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; }; 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */; }; 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; }; + 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; @@ -268,6 +269,7 @@ 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = ""; }; 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretViewModel.swift; sourceTree = ""; }; 944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = ""; }; + 944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; @@ -816,6 +818,7 @@ D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */, D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, + 944589222385DA9500DE9FD4 /* ImageViewModel.swift */, D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */, D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, @@ -1177,6 +1180,7 @@ 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, + 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift new file mode 100644 index 00000000..7133e593 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -0,0 +1,21 @@ +// +// ImageViewModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ImageViewModel: MoleculeProtocol { + public static var identifier: String = "imageView" + public var moleculeName: String + + public var image: String + public var accessibilityText: String? + public var fallbackImage: String? + public var imageFormat: String? + public var width: CGFloat? + public var height: CGFloat? +} diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 361c0aa2..95b00cd7 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class MFLoadImageView: ViewConstrainingView { +@objcMembers open class MFLoadImageView: ViewConstrainingView, ModelMoleculeViewProtocol { public let loadingSpinner = MFLoadingSpinner(frame: .zero) public let imageView = MFTransparentGIFView(frame: .zero) public var addSizeConstraintsForAspectRatio = false @@ -209,6 +209,31 @@ import UIKit } } + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let imageModel = model as? ImageViewModel else { + return + } + if let accessibilityString = imageModel.accessibilityText { + imageView.accessibilityLabel = accessibilityString + imageView.accessibilityTraits = .staticText + imageView.isAccessibilityElement = true + } + let width = imageModel.width ?? imageWidth + let height = imageModel.height ?? imageHeight + // For smoother transitions, set constraints that we know immediately. + if let width = width, addSizeConstraintsForAspectRatio { + setWidth(width) + } + if let height = height, addSizeConstraintsForAspectRatio { + setHeight(height) + } + if shouldLoadImage(withName: imageModel.image, width: width, height: height) { + imageView.image = nil + imageView.animatedImage = nil + loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage) + } + } + // MARK: - MVMCoreUIMoleculeViewProtocol functions open override func setAsMolecule() { addSizeConstraintsForAspectRatio = true From 715b5f01674f29b1c607a6631e8efa49c2f068ae Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 20 Nov 2019 15:48:14 -0500 Subject: [PATCH 013/272] add image, move label model next to label --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 2 +- MVMCoreUI/{Models/Molecules => Atoms/Views}/LabelModel.swift | 0 .../MVMCoreUIMoleculeMappingObject+ModelMapping.swift | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) rename MVMCoreUI/{Models/Molecules => Atoms/Views}/LabelModel.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 67dd46b8..5c000157 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -487,7 +487,6 @@ 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( - 01EB368823609801006832FA /* LabelModel.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, @@ -838,6 +837,7 @@ D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, DB891E822253FA8500022516 /* Label.swift */, + 01EB368823609801006832FA /* LabelModel.swift */, 0198F7A02256A80A0066C936 /* MFRadioButton.h */, 0198F7A22256A80A0066C936 /* MFRadioButton.m */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 7133e593..2c9a6dd4 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeProtocol { - public static var identifier: String = "imageView" + public static var identifier: String = "image" public var moleculeName: String public var image: String diff --git a/MVMCoreUI/Models/Molecules/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel.swift similarity index 100% rename from MVMCoreUI/Models/Molecules/LabelModel.swift rename to MVMCoreUI/Atoms/Views/LabelModel.swift diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index 5cf3168f..1efebf77 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -22,5 +22,6 @@ import Foundation ModelRegistry.register(MultiProgressBarModel.self) ModelRegistry.register(CaretViewModel.self) ModelRegistry.register(DashLineModel.self) + ModelRegistry.register(ImageViewModel.self) } } From 7b2fc7bfba3e35fa7e59d979742ed2af999db357 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Nov 2019 11:53:26 -0500 Subject: [PATCH 014/272] some more stuff --- MVMCoreUI.xcodeproj/project.pbxproj | 28 +++++- .../MFTextField+ModelExtension.swift | 77 ++++++++++++++++ MVMCoreUI/Atoms/Views/GraphView.swift | 6 +- .../Atoms/Views/MFView+ModelExtension.swift | 23 +++++ MVMCoreUI/Atoms/Views/MFView.h | 1 + .../ViewConstrainingView+ModelExtension.swift | 88 +++++++++++++++++++ MVMCoreUI/Atoms/Views/ViewConstrainingView.h | 5 ++ MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 1 - MVMCoreUI/BaseClasses/View.swift | 11 ++- .../Models/ConstrainingMoleculeProtocol.swift | 19 ++++ MVMCoreUI/Models/MoleculeProtocol.swift | 31 +++++++ MVMCoreUI/Models/Molecules/HeaderModel.swift | 3 +- MVMCoreUI/Models/Molecules/LabelModel.swift | 1 - .../Models/Molecules/SeperatorModel.swift | 14 +++ .../Models/Molecules/TextFieldModel.swift | 2 + MVMCoreUI/Molecules/StandardHeaderView.swift | 5 +- .../MVMCoreUIMoleculeMappingObject.m | 2 +- ...ping.swift => MoleculeObjectMapping.swift} | 5 +- 18 files changed, 309 insertions(+), 13 deletions(-) create mode 100644 MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift create mode 100644 MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift create mode 100644 MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift create mode 100644 MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift create mode 100644 MVMCoreUI/Models/Molecules/SeperatorModel.swift rename MVMCoreUI/OtherHandlers/{MVMCoreUIMoleculeMappingObject+ModelMapping.swift => MoleculeObjectMapping.swift} (80%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index cc93db84..d8399580 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -12,6 +12,11 @@ 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; + 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; + 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; + 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; + 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; + 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */; }; 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */; }; 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D902327ECE600EF99AA /* CornerLabels.swift */; }; 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; }; @@ -25,7 +30,7 @@ 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */; }; 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; - 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */; }; + 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; }; 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; @@ -227,6 +232,11 @@ 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; + 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; + 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; + 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; + 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; + 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstrainingMoleculeProtocol.swift; sourceTree = ""; }; 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = ""; }; 01509D902327ECE600EF99AA /* CornerLabels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerLabels.swift; sourceTree = ""; }; 01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; @@ -240,7 +250,7 @@ 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeViewProtocol.swift; sourceTree = ""; }; 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; 017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = ""; }; - 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelMapping.swift"; sourceTree = ""; }; + 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.swift; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; @@ -457,6 +467,7 @@ children = ( 017BEB392360EEB40024EF95 /* PageModel.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, ); @@ -477,6 +488,7 @@ 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( + 012CA98823849699003F810F /* SeperatorModel.swift */, 01EB368823609801006832FA /* LabelModel.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, @@ -798,10 +810,12 @@ DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17F21E69E2E003B2FB9 /* MFView.m */, + 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, + 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */, D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */, D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, @@ -839,6 +853,7 @@ children = ( D29DF24C21E6A177003B2FB9 /* MFTextField.h */, D29DF24221E6A176003B2FB9 /* MFTextField.m */, + 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */, D29DF24421E6A176003B2FB9 /* MFTextField.xib */, D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */, D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */, @@ -888,7 +903,7 @@ D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, - 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */, + 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, ); path = OtherHandlers; sourceTree = ""; @@ -1123,7 +1138,9 @@ D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, + 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, + 012CA98923849699003F810F /* SeperatorModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, @@ -1161,6 +1178,7 @@ D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, + 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, @@ -1188,7 +1206,7 @@ D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, - 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */, + 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */, D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, @@ -1211,6 +1229,7 @@ D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, + 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, @@ -1235,6 +1254,7 @@ D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */, + 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */, 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, 01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift new file mode 100644 index 00000000..81f00282 --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift @@ -0,0 +1,77 @@ +// +// MFTextField+ModelExtension.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/19/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +enum TextType: String { + case dropDown = "dropDown" + case password = "password" + case number = "number" + case email = "email" +} +extension MFTextField: ModelMoleculeViewProtocol { + // + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + //TODO: Need to create setWithModel in ViewConstraining View + #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") + //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + setUpWithModel(model, delegateObject, additionalData) + + guard let textFieldModel = model as? TextFieldModel, + let delegateObject = delegateObject else { + return + } + + if let delegate = delegateObject.formValidationProtocol { + let formValidator = FormValidator.getFormValidatorFor(delegate: delegate) + mfTextFieldDelegate = formValidator + uiTextFieldDelegate = delegateObject.uiTextFieldDelegate + if let textField = textField { + MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) + } + } + + formText = textFieldModel.label as NSString? + text = textFieldModel.value as NSString? + enable(textFieldModel.disabled) + errMessage = textFieldModel.errorMsg + fieldKey = textFieldModel.fieldKey + groupName = textFieldModel.groupName + + + switch textFieldModel.type { + case TextType.dropDown.rawValue: + dropDownCarrotLabel?.isHidden = true + hasDropDown = true + break + case TextType.password.rawValue: + textField?.isSecureTextEntry = true + break + case TextType.number.rawValue: + textField?.keyboardType = .numberPad + break + case TextType.email.rawValue: + textField?.keyboardType = .emailAddress + break + default: + print("default") + } + + if let regex = textFieldModel.regex { + validationBlock = {(enteredValue: String?) -> Bool in + if let enteredValue = enteredValue { + return MVMCoreUIUtility.validate(enteredValue, withRegularExpression: regex) + } + return true + } + } else { + setDefaultValidationBlock() + } + } +} + diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index ebd074a0..e919e445 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -125,7 +125,11 @@ public struct GraphObject { heightConstraint?.isActive = true widthAnchor.constraint(equalTo: heightAnchor).isActive = true } - + + override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) + } + override open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) let object = GraphObject(json) diff --git a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift new file mode 100644 index 00000000..44973370 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift @@ -0,0 +1,23 @@ +// +// MFView+ModelExtension.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +extension MFView { + public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + self.model = model + if let backgroundColorString = model?.backgroundColor { + backgroundColor = UIColor.mfGet(for: backgroundColorString) + } + } +} +extension ModelMoleculeViewProtocol where Self: MFView { + func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + setUpDefaultWithModel(model, delegateObject, additionalData) + } +} diff --git a/MVMCoreUI/Atoms/Views/MFView.h b/MVMCoreUI/Atoms/Views/MFView.h index 62683433..dd8e01a8 100644 --- a/MVMCoreUI/Atoms/Views/MFView.h +++ b/MVMCoreUI/Atoms/Views/MFView.h @@ -14,6 +14,7 @@ @interface MFView : UIView @property (nullable, nonatomic, strong) NSDictionary *json; +@property (nullable, nonatomic, strong) id model; // Called in the initialization functions. Can setup ui here. - (void)setupView; diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift new file mode 100644 index 00000000..1e4cd849 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift @@ -0,0 +1,88 @@ +// +// ViewConstrainingView+ModelExtension.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +extension ViewConstrainingView { + public func setUpWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + if self.constrainedView == nil { + setUpDefaultWithModel(model, delegateObject, additionalData) + } + + if shouldSetupMoleculeFromJSON, + let moleculeObject = (model as? ConstrainingMoleculeProtocol)?.molecule { + if molecule != nil { + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeObject, delegateObject, additionalData) + } else { + if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeObject, delegateObject, true) { + addMolecule(molecule) + self.molecule = molecule + setMoleculeAccessibility() + } + } + } else { + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) + } + + if let useHorizontalMargins = model?.useHorizontalMargins { + updateViewHorizontalDefaults = useHorizontalMargins + } + if let useVerticalMargins = model?.useVerticalMargins { + updateViewVerticalDefaults = useVerticalMargins + } + + if let horizontalAlignment = model?.horizontalAlignment { + alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) + } + if let verticalAlignment = model?.verticalAlignment { + alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + } + + #warning("work on the below") + // let copyBackgroundColor = self.copyBackgroundColor?() + // if copyBackgroundColor { + // + // } + } +} + +extension ModelMoleculeViewProtocol where Self: ViewConstrainingView { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + setUpWithModel(model, delegateObject, additionalData) + } +} + +/* +- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + // Only treated as a container if we are constraining a molecule. + + NSNumber *useHorizontalMargins = [json optionalNumberForKey:@"useHorizontalMargins"]; + if (useHorizontalMargins) { + self.updateViewHorizontalDefaults = [useHorizontalMargins boolValue]; + } + NSNumber *useVerticalMargins = [json optionalNumberForKey:@"useVerticalMargins"]; + if (useVerticalMargins) { + self.updateViewVerticalDefaults = [useVerticalMargins boolValue]; + } + + // Set the alignment for the stack in the containing view. The json driven value is for the axis direction alignment. + NSString *alignment = [json string:@"horizontalAlignment"]; + if (alignment) { + [self alignHorizontal:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; + } + alignment = [json string:@"verticalAlignment"]; + if (alignment) { + [self alignVertical:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; + } + + if ([self.molecule respondsToSelector:@selector(copyBackgroundColor)] && [self.molecule performSelector:@selector(copyBackgroundColor)]) { + self.backgroundColor = self.molecule.backgroundColor; + } +} +*/ diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h index c10768b0..30f5a552 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h @@ -30,6 +30,8 @@ @property (nullable, strong, nonatomic) IBOutlet NSLayoutConstraint *topPinLow; @property (nullable, strong, nonatomic) IBOutlet NSLayoutConstraint *bottomPinLow; +@property (weak, nullable, nonatomic) UIView *constrainedView; + /// In updateView, will set horizontal padding to default. @property (nonatomic) BOOL updateViewHorizontalDefaults; @property (nonatomic) BOOL updateViewVerticalDefaults; @@ -89,6 +91,9 @@ - (void)alignBottom; - (void)alignFillVertical; +- (void)alignHorizontal:(UIStackViewAlignment)alignment; +- (void)alignVertical:(UIStackViewAlignment)alignment; + /// Convenience function for getting the alignment from a map. + (UIStackViewAlignment)getAlignmentForString:(nullable NSString *)alignmentString defaultAlignment:(UIStackViewAlignment)defaultAlignment; diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 57e54983..4983020e 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -18,7 +18,6 @@ #import "MVMCoreUIViewConstrainingProtocol.h" @interface ViewConstrainingView () -@property (weak, nullable, nonatomic) UIView *constrainedView; @end @implementation ViewConstrainingView diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index bc6e7634..de76f739 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -8,8 +8,9 @@ import UIKit -@objcMembers open class View: UIView { +@objcMembers open class View: UIView, ModelMoleculeViewProtocol { open var json: [AnyHashable: Any]? + open var model: MoleculeProtocol? private var initialSetupPerformed = false @@ -34,6 +35,13 @@ import UIKit setupView() } } + + open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + self.model = model + if let backgroundColorString = model?.backgroundColor { + backgroundColor = UIColor.mfGet(for: backgroundColorString) + } + } } extension View: MVMCoreViewProtocol { @@ -59,3 +67,4 @@ extension View: MVMCoreUIMoleculeViewProtocol { backgroundColor = .clear } } + diff --git a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift new file mode 100644 index 00000000..91d4a566 --- /dev/null +++ b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift @@ -0,0 +1,19 @@ +// +// ConstrainingMoleculeProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ConstrainingMoleculeProtocol: MoleculeProtocol { + var molecule: MoleculeProtocol? {get} +} + +extension ConstrainingMoleculeProtocol { + public var molecule: MoleculeProtocol? { + get { return nil } + } +} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index 0bb23cdf..2ddc4061 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -2,7 +2,14 @@ import Foundation public protocol MoleculeProtocol: Model { var moleculeName: String? {get} + var backgroundColor: String? {get} var dictionary: [AnyHashable: Any]? {get} + var molecule: MoleculeProtocol? {get} + + var useHorizontalMargins: Bool? {get} + var useVerticalMargins: Bool? {get} + var horizontalAlignment: String? {get} + var verticalAlignment: String? {get} } extension MoleculeProtocol { @@ -10,6 +17,30 @@ extension MoleculeProtocol { get { return Self.identifier } } + public var molecule: MoleculeProtocol? { + get { return nil } + } + + public var backgroundColor: String? { + get { return toJSON()?["backgroundColor"] as? String } + } + + public var useHorizontalMargins: Bool? { + get { return toJSON()?["useHorizontalMargins"] as? Bool } + } + + public var useVerticalMargins: Bool? { + get { return toJSON()?["useVerticalMargins"] as? Bool } + } + + public var horizontalAlignment: String? { + get { return toJSON()?["horizontalAlignment"] as? String } + } + + public var verticalAlignment: String? { + get { return toJSON()?["verticalAlignment"] as? String } + } + public var dictionary: [AnyHashable: Any]? { return toJSON() } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 4cbc1c82..0dca783c 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -8,9 +8,10 @@ import Foundation -@objcMembers public class HeaderModel: MoleculeProtocol { +@objcMembers public class HeaderModel: ConstrainingMoleculeProtocol { public static var identifier: String = "header" public var moleculeName: String? + public var backgroundColor: String? public var molecule: MoleculeProtocol? public var seperator: MoleculeProtocol? diff --git a/MVMCoreUI/Models/Molecules/LabelModel.swift b/MVMCoreUI/Models/Molecules/LabelModel.swift index e5de1ccf..0886524a 100644 --- a/MVMCoreUI/Models/Molecules/LabelModel.swift +++ b/MVMCoreUI/Models/Molecules/LabelModel.swift @@ -11,6 +11,5 @@ import Foundation @objcMembers public class LabelModel: MoleculeProtocol { public static var identifier: String = "label" - public var moleculeName: String? public var text: String? } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift new file mode 100644 index 00000000..705f904c --- /dev/null +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -0,0 +1,14 @@ +// +// SeperatorModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/19/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +class SeperatorModel: MoleculeProtocol { + public static var identifier: String = "line" + public var type: String? +} diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift index 74e7cd3e..77454895 100644 --- a/MVMCoreUI/Models/Molecules/TextFieldModel.swift +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -12,9 +12,11 @@ import UIKit public static var identifier: String = "textField" public var editable = true + public var disabled = false public var errorMsg: String? public var label: String? public var type: String? + public var value: String? public var regex: String? public var required: Bool? diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 9b9a5ff2..100173fc 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -57,7 +57,10 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { //TODO: Need to create setWithModel in ViewConstraining View - super.setWithJSON(model?.toJSON(), delegateObject: delegateObject, additionalData: additionalData) + + #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") + //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + setUpWithModel(model, delegateObject, additionalData) // This molecule will by default handle margins. (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 388ee47e..86f69f86 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -79,7 +79,7 @@ - (instancetype)init { if (self = [super init]) { - [MVMCoreUIMoleculeMappingObject registerObjects]; + [MoleculeObjectMapping registerObjects]; } return self; } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift similarity index 80% rename from MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift rename to MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 67d3df02..84e0932c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -8,8 +8,8 @@ import Foundation -@objc public extension MVMCoreUIMoleculeMappingObject { - @objc static func registerObjects() { +@objcMembers public class MoleculeObjectMapping: NSObject { + public static func registerObjects() { ModelRegistry.register(LabelModel.self) ModelRegistry.register(HeaderModel.self) ModelRegistry.register(HeadlineBodyModel.self) @@ -18,5 +18,6 @@ import Foundation ModelRegistry.register(ListItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(LineModel.self) + ModelRegistry.register(SeperatorModel.self) } } From 6303c3f92ddc042dcb34e9307af5ca2fbdf66e66 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 21 Nov 2019 13:15:27 -0500 Subject: [PATCH 015/272] update label model --- MVMCoreUI.xcodeproj/project.pbxproj | 14 ++- MVMCoreUI/Atoms/Views/Label.swift | 117 +++++++++++++++++- MVMCoreUI/Atoms/Views/LabelModel.swift | 16 --- .../LabelModel/LabelAttributeModel.swift | 64 ++++++++++ .../Atoms/Views/LabelModel/LabelModel.swift | 27 ++++ MVMCoreUI/Atoms/Views/MultiProgress.swift | 10 +- .../Atoms/Views/MultiProgressModel.swift | 8 +- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 5 +- 8 files changed, 228 insertions(+), 33 deletions(-) delete mode 100644 MVMCoreUI/Atoms/Views/LabelModel.swift create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5c000157..65ff9299 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -54,6 +54,7 @@ 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; + 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; }; D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; @@ -273,6 +274,7 @@ 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; + 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; @@ -507,6 +509,15 @@ path = Extensions; sourceTree = ""; }; + 94C2D9822386F3E30006CF46 /* LabelModel */ = { + isa = PBXGroup; + children = ( + 01EB368823609801006832FA /* LabelModel.swift */, + 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */, + ); + path = LabelModel; + sourceTree = ""; + }; D224798823142BF2003FCCF9 /* SwitchMolecules */ = { isa = PBXGroup; children = ( @@ -837,7 +848,7 @@ D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, DB891E822253FA8500022516 /* Label.swift */, - 01EB368823609801006832FA /* LabelModel.swift */, + 94C2D9822386F3E30006CF46 /* LabelModel */, 0198F7A02256A80A0066C936 /* MFRadioButton.h */, 0198F7A22256A80A0066C936 /* MFRadioButton.m */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, @@ -1210,6 +1221,7 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, + 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 6b013f82..2cd23405 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -12,7 +12,8 @@ import MVMCore public typealias ActionBlock = () -> () -@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol { +@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol, ModelMoleculeViewProtocol { + //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -212,8 +213,120 @@ public typealias ActionBlock = () -> () } } + enum LabelAlignment: String { + case center + case right + case left + } + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + clauses = [] + guard let labelModel = model as? LabelModel else { return } + attributedText = nil + text = labelModel.text + Label.setLabel(self, withHTML: labelModel.html) + let alignment = LabelAlignment(rawValue: labelModel.textAlignment ?? "") + switch alignment { + case .center: + textAlignment = .center + case .right: + textAlignment = .right + default: + textAlignment = .left + } + + + makeWholeViewClickable = labelModel.makeWholeViewClickable ?? false + if let backgroundColorHex = labelModel.backgroundColor, !backgroundColorHex.isEmpty { + backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + } + if let accessibilityText = labelModel.accessibilityText { + accessibilityLabel = accessibilityText + } + if let fontStyle = labelModel.fontStyle { + MFStyler.styleLabel(self, withStyle: fontStyle) + } else { + let fontSize = labelModel.fontSize as? CGFloat + if let fontName = labelModel.fontName { + font = MFFonts.mfFont(withName: fontName, size: fontSize ?? font.pointSize) + } else if let fontSize = fontSize { + font = font.withSize(fontSize) + } + } + + if let textColorHex = labelModel.textColor, !textColorHex.isEmpty { + textColor = UIColor.mfGet(forHex: textColorHex) + } + + if let attributes = labelModel.attributes, let labelText = text { + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor]) + for attribute in attributes { + guard let attributeStyle = attribute.type, let location = attribute.location, let length = attribute.length else { continue } + let range = NSRange(location: location, length: length) + switch attributeStyle { + case .underline: + attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range) + case .strikethrough: + attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range) + attributedString.addAttribute(.baselineOffset, value: 0, range: range) + case .color: + if let colorHex = attribute.textColor, !colorHex.isEmpty { + attributedString.removeAttribute(.foregroundColor, range: range) + attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) + } + case .image: + var fontSize = font.pointSize + if let attributeSize = attribute.size { + fontSize = attributeSize + } + let imageName = attribute.name ?? "externalLink" + let imageAttachment: NSTextAttachment + + if let url = attribute.URL { + imageAttachment = Label.getTextAttachmentFrom(url: url, dimension: fontSize, label: self) + } else { + imageAttachment = Label.getTextAttachmentImage(name: imageName, dimension: fontSize) + } + let mutableString = NSMutableAttributedString() + mutableString.append(NSAttributedString(attachment: imageAttachment)) + attributedString.insert(mutableString, at: location) + case .font: + if let fontStyle = attribute.style { + let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle) + attributedString.removeAttribute(.font, range: range) + attributedString.removeAttribute(.foregroundColor, range: range) + attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range) + } else { + let fontSize = attribute.size + var font: UIFont? + + if let fontName = attribute.name { + font = MFFonts.mfFont(withName: fontName, size: fontSize ?? self.font.pointSize) + } else if let fontSize = fontSize { + font = self.font.withSize(fontSize) + } + if let font = font { + attributedString.removeAttribute(.font, range: range) + attributedString.addAttribute(.font, value: font, range: range) + } + } + case .action: + addActionAttributes(range: range, string: attributedString) +// if let actionBlock = createActionBlockFor(actionMap: attribute, additionalData: additionalData, delegateObject: delegateObject) { +// appendActionableClause(range: range, actionBlock: actionBlock) +// } + default: + continue + } + } + } + + originalAttributedString = attributedText + hero = labelModel.hero + } + @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { - //LabelModel() + guard let label = label else { return } label.attributedText = nil label.text = json?.optionalStringForKey(KeyText) diff --git a/MVMCoreUI/Atoms/Views/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel.swift deleted file mode 100644 index e5de1ccf..00000000 --- a/MVMCoreUI/Atoms/Views/LabelModel.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// Label.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/3/19. -// Copyright © 2019 Suresh, Kamlesh. All rights reserved. -// - - -import Foundation - -@objcMembers public class LabelModel: MoleculeProtocol { - public static var identifier: String = "label" - public var moleculeName: String? - public var text: String? -} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift new file mode 100644 index 00000000..e4388ea5 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift @@ -0,0 +1,64 @@ +// +// LabelAttributeModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class LabelAttributeModel: Codable { + enum ModelType: String, Codable { + case underline + case strikethrough + case color + case image + case font + case action + } + + var type: ModelType? + var location: Int? + var length: Int? + var textColor: String? + var style: String? + var size: CGFloat? + var name: String? + var URL: String? + + enum CodingKeys: String, CodingKey { + case type + case location + case length + case textColor + case style + case size + case name + case URL + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.type = try typeContainer.decodeIfPresent(ModelType.self, forKey: .type) + self.location = try typeContainer.decodeIfPresent(Int.self, forKey: .location) + self.length = try typeContainer.decodeIfPresent(Int.self, forKey: .length) + self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) + self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) + self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name) + self.URL = try typeContainer.decodeIfPresent(String.self, forKey: .URL) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(type, forKey: .type) + try container.encodeIfPresent(location, forKey: .location) + try container.encodeIfPresent(length, forKey: .length) + try container.encodeIfPresent(textColor, forKey: .textColor) + try container.encodeIfPresent(style, forKey: .style) + try container.encodeIfPresent(size, forKey: .size) + try container.encodeIfPresent(name, forKey: .name) + try container.encodeIfPresent(URL, forKey: .URL) + } +} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift new file mode 100644 index 00000000..376166ed --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -0,0 +1,27 @@ +// +// Label.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/3/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + + +import Foundation + +@objcMembers public class LabelModel: MoleculeProtocol { + public static var identifier: String = "label" + public var moleculeName: String? + public var text: String + public var accessibilityText: String? + public var textColor: String? + public var backgroundColor: String? + public var fontStyle: String? + public var fontName: String? + public var fontSize: CGFloat? + public var textAlignment: String? + public var attributes: [LabelAttributeModel]? + public var html: String? + public var hero: Int? + public var makeWholeViewClickable: Bool? +} diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index 0e911e37..f6809e53 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -21,18 +21,14 @@ import UIKit } var previous: UIView? for progressObject in progressList! { - guard progressObject.progress ?? 0.0 > 0.0 else { + guard progressObject.progress > 0.0 else { continue } let view = MFView(frame: .zero) view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) - var color = UIColor.mfCerulean() - if let colorString = progressObject.color { - color = UIColor.mfGet(forHex: colorString) - } - view.backgroundColor = color - view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress ?? 0).isActive = true + view.backgroundColor = UIColor.mfGet(forHex: progressObject.color) + view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress).isActive = true view.leadingAnchor.constraint(equalTo: previous?.trailingAnchor ?? leadingAnchor).isActive = true previous = view NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: false, pinRight: false) diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 156f71a0..d63183e4 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -10,14 +10,14 @@ import Foundation @objcMembers public class SingleProgressBarModel: Codable { - var progress: CGFloat? - var color: String? + var progress: CGFloat + var color: String } @objcMembers public class MultiProgressBarModel: MoleculeProtocol { public static var identifier: String = "multiProgressBar" public var moleculeName: String - public var progressList: [SingleProgressBarModel]? + public var progressList: [SingleProgressBarModel] public var thickness: CGFloat? public var roundedRect: Bool? @@ -32,7 +32,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.progressList = try typeContainer.decodeIfPresent([SingleProgressBarModel].self, forKey: .progressList) + self.progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList) self.thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) self.roundedRect = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedRect) } diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index b48f0321..3450fc87 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -15,7 +15,7 @@ import Foundation public var isRounded: Bool? public var thickness: CGFloat? ///from 0 to 100 - public var percentage: Float? + public var percentage: Float public var progressColor: String? public var backgroundColor: String? @@ -29,12 +29,11 @@ import Foundation } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) self.thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) - self.percentage = try typeContainer.decodeIfPresent(Float.self, forKey: .percentage) + self.percentage = try typeContainer.decode(Float.self, forKey: .percentage) self.progressColor = try typeContainer.decodeIfPresent(String.self, forKey: .progressColor) self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) From 9ec661ae3b58dac0ecd7aa8a67a74745a14928b3 Mon Sep 17 00:00:00 2001 From: panxi Date: Fri, 22 Nov 2019 14:31:17 -0500 Subject: [PATCH 016/272] add label model --- MVMCoreUI.xcodeproj/project.pbxproj | 24 +++++++ MVMCoreUI/Atoms/Views/Label.swift | 4 +- .../LabelAttributeActionModel.swift | 23 +++++++ .../LabelModel/LabelAttributeColorModel.swift | 35 ++++++++++ .../LabelModel/LabelAttributeFontModel.swift | 33 +++++++++ .../LabelModel/LabelAttributeImageModel.swift | 42 +++++++++++ .../LabelModel/LabelAttributeModel.swift | 53 ++++---------- .../LabelAttributeStrikeThroughModel.swift | 22 ++++++ .../LabelAttributeUnderlineModel.swift | 23 +++++++ .../Atoms/Views/LabelModel/LabelModel.swift | 69 +++++++++++++++++++ ...UIMoleculeMappingObject+ModelMapping.swift | 6 ++ 11 files changed, 294 insertions(+), 40 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeColorModel.swift create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeImageModel.swift create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeStrikeThroughModel.swift create mode 100644 MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeUnderlineModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 65ff9299..e9c650c8 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -55,6 +55,12 @@ 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; }; + 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */; }; + 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */; }; + 94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */; }; + 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */; }; + 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */; }; + 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; }; D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; @@ -275,6 +281,12 @@ 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = ""; }; + 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = ""; }; + 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeStrikeThroughModel.swift; sourceTree = ""; }; + 94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeFontModel.swift; sourceTree = ""; }; + 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = ""; }; + 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; + 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; @@ -514,6 +526,12 @@ children = ( 01EB368823609801006832FA /* LabelModel.swift */, 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */, + 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */, + 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */, + 94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */, + 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */, + 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */, + 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */, ); path = LabelModel; sourceTree = ""; @@ -1150,6 +1168,7 @@ DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, + 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, @@ -1184,9 +1203,11 @@ D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, + 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, + 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, @@ -1217,6 +1238,7 @@ D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, + 94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */, 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */, D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, @@ -1251,6 +1273,7 @@ D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, + 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, @@ -1258,6 +1281,7 @@ 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, + 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 2cd23405..c442fbc1 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -260,7 +260,7 @@ public typealias ActionBlock = () -> () if let attributes = labelModel.attributes, let labelText = text { let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor]) - for attribute in attributes { + /*for attribute in attributes { guard let attributeStyle = attribute.type, let location = attribute.location, let length = attribute.length else { continue } let range = NSRange(location: location, length: length) switch attributeStyle { @@ -318,7 +318,7 @@ public typealias ActionBlock = () -> () default: continue } - } + }*/ } originalAttributedString = attributedText diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift new file mode 100644 index 00000000..eb5a3cd7 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift @@ -0,0 +1,23 @@ +// +// LabelAttributeActionModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +class LabelAttributeActionModel: LabelAttributeModel { + override public class var identifier: String { + return "action" + } + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + } +} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeColorModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeColorModel.swift new file mode 100644 index 00000000..26f1fa54 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeColorModel.swift @@ -0,0 +1,35 @@ +// +// LabelAttributeColorModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class LabelAttributeColorModel: LabelAttributeModel { + + override public class var identifier: String { + return "color" + } + + var textColor: String? + + private enum CodingKeys: String, CodingKey { + case textColor + } + + required public init(from decoder: Decoder) throws { + + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) + 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.encodeIfPresent(textColor, forKey: .textColor) + } +} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift new file mode 100644 index 00000000..992cce53 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift @@ -0,0 +1,33 @@ +// +// LabelAttributeFontModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class LabelAttributeFontModel: LabelAttributeModel { + override public class var identifier: String { + return "font" + } + + var style: String? + + private enum CodingKeys: String, CodingKey { + case style + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + 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.encodeIfPresent(style, forKey: .style) + } +} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeImageModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeImageModel.swift new file mode 100644 index 00000000..0095a589 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeImageModel.swift @@ -0,0 +1,42 @@ +// +// LabelAttributeImageModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +class LabelAttributeImageModel: LabelAttributeModel { + + override public class var identifier: String { + return "image" + } + + var size: CGFloat? + var name: String? + var URL: String? + + private enum CodingKeys: String, CodingKey { + case size + case name + case URL + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) + self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name) + self.URL = try typeContainer.decodeIfPresent(String.self, forKey: .URL) + 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.encodeIfPresent(size, forKey: .size) + try container.encodeIfPresent(name, forKey: .name) + try container.encodeIfPresent(URL, forKey: .URL) + } +} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift index e4388ea5..ae2768ab 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift @@ -8,57 +8,34 @@ import Foundation -@objcMembers open class LabelAttributeModel: Codable { - enum ModelType: String, Codable { - case underline - case strikethrough - case color - case image - case font - case action +@objcMembers open class LabelAttributeModel: Model { + + public class var identifier: String { + return "" } - var type: ModelType? - var location: Int? - var length: Int? - var textColor: String? - var style: String? - var size: CGFloat? - var name: String? - var URL: String? + var type: String + var location: Int + var length: Int - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case type case location case length - case textColor - case style - case size - case name - case URL } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.type = try typeContainer.decodeIfPresent(ModelType.self, forKey: .type) - self.location = try typeContainer.decodeIfPresent(Int.self, forKey: .location) - self.length = try typeContainer.decodeIfPresent(Int.self, forKey: .length) - self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) - self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) - self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) - self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name) - self.URL = try typeContainer.decodeIfPresent(String.self, forKey: .URL) + self.type = try typeContainer.decode(String.self, forKey: .type) + self.location = try typeContainer.decode(Int.self, forKey: .location) + self.length = try typeContainer.decode(Int.self, forKey: .length) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(type, forKey: .type) - try container.encodeIfPresent(location, forKey: .location) - try container.encodeIfPresent(length, forKey: .length) - try container.encodeIfPresent(textColor, forKey: .textColor) - try container.encodeIfPresent(style, forKey: .style) - try container.encodeIfPresent(size, forKey: .size) - try container.encodeIfPresent(name, forKey: .name) - try container.encodeIfPresent(URL, forKey: .URL) + try container.encode(type, forKey: .type) + try container.encode(location, forKey: .location) + try container.encode(length, forKey: .length) } + } diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeStrikeThroughModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeStrikeThroughModel.swift new file mode 100644 index 00000000..f69e966d --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeStrikeThroughModel.swift @@ -0,0 +1,22 @@ +// +// LabelAttributeStrikeThroughModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class LabelAttributeStrikeThroughModel: LabelAttributeModel { + override public class var identifier: String { + return "strikethrough" + } + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + } +} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeUnderlineModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeUnderlineModel.swift new file mode 100644 index 00000000..d052686d --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeUnderlineModel.swift @@ -0,0 +1,23 @@ +// +// LabelAttributeUnderlineModel.swift +// MVMCoreUI +// +// Created by Ryan on 11/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class LabelAttributeUnderlineModel: LabelAttributeModel { + override public class var identifier: String { + return "underline" + } + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + } +} diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index 376166ed..e47a395f 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -24,4 +24,73 @@ import Foundation public var html: String? public var hero: Int? public var makeWholeViewClickable: Bool? + + enum CodingKeys: String, CodingKey { + case moleculeName + case text + case accessibilityText + case textColor + case backgroundColor + case fontStyle + case fontName + case fontSize + case textAlignment + case attributes + case html + case hero + case makeWholeViewClickable + } + + enum AttributeTypeKey: String, CodingKey { + case type + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) + self.text = try typeContainer.decode(String.self, forKey: .text) + self.accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) + self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) + self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle) + self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) + self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) + self.textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment) + do { + var attributesContainer = try typeContainer.nestedUnkeyedContainer(forKey: .attributes) + var attributes = [LabelAttributeModel]() + while !attributesContainer.isAtEnd { + guard let attmodel = try attributesContainer.decodeUnKeyedIfPresent(LabelAttributeModel.self, typeCodingKey: AttributeTypeKey.type) else { + continue + } + attributes.append(attmodel) + } + self.attributes = attributes + } catch { + print("no attributes") + } + self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html) + self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) + self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encode(text, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) + try container.encodeIfPresent(textColor, forKey: .textColor) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(fontStyle, forKey: .fontStyle) + try container.encodeIfPresent(fontName, forKey: .fontName) + try container.encodeIfPresent(fontSize, forKey: .fontSize) + try container.encodeIfPresent(textAlignment, forKey: .textAlignment) +// var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes) +// try attributes?.forEach({ (attributeModel) in +// try attributeContainer.encode(attributeModel) +// }) + try container.encodeIfPresent(html, forKey: .html) + try container.encodeIfPresent(hero, forKey: .hero) + try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable) + } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index 1efebf77..0dfbae0a 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -23,5 +23,11 @@ import Foundation ModelRegistry.register(CaretViewModel.self) ModelRegistry.register(DashLineModel.self) ModelRegistry.register(ImageViewModel.self) + ModelRegistry.register(LabelAttributeFontModel.self) + ModelRegistry.register(LabelAttributeColorModel.self) + ModelRegistry.register(LabelAttributeImageModel.self) + ModelRegistry.register(LabelAttributeUnderlineModel.self) + ModelRegistry.register(LabelAttributeStrikeThroughModel.self) + ModelRegistry.register(LabelAttributeActionModel.self) } } From ea69ba67ea2ef2b5899ffc3e72e69bfbf2470c3e Mon Sep 17 00:00:00 2001 From: panxi Date: Sun, 24 Nov 2019 23:14:25 -0500 Subject: [PATCH 017/272] update array decoding method --- .../LabelModel/LabelAttributeFontModel.swift | 8 +++++ .../Atoms/Views/LabelModel/LabelModel.swift | 29 ++++++++++--------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift index 992cce53..88ae728d 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift @@ -14,14 +14,20 @@ import UIKit } var style: String? + var name: String? + var size: CGFloat? private enum CodingKeys: String, CodingKey { case style + case name + case size } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name) + self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) try super.init(from: decoder) } @@ -29,5 +35,7 @@ import UIKit try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(style, forKey: .style) + try container.encodeIfPresent(name, forKey: .name) + try container.encodeIfPresent(size, forKey: .size) } } diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index e47a395f..b4c71153 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -56,22 +56,25 @@ import Foundation self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) self.textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment) - do { - var attributesContainer = try typeContainer.nestedUnkeyedContainer(forKey: .attributes) - var attributes = [LabelAttributeModel]() - while !attributesContainer.isAtEnd { - guard let attmodel = try attributesContainer.decodeUnKeyedIfPresent(LabelAttributeModel.self, typeCodingKey: AttributeTypeKey.type) else { - continue - } - attributes.append(attmodel) - } - self.attributes = attributes - } catch { - print("no attributes") - } + self.attributes = try typeContainer.decodeArrayIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel] self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html) self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) + /*if let atts = self.attributes { + for attribute in atts { + switch attribute.type { + case "font": + let afont = attribute as? LabelAttributeFontModel + print("font length\(afont!.length), \(String(describing: afont?.name))") + case "color": + let afont = attribute as? LabelAttributeColorModel + print("font length\(afont!.length), \(String(describing: afont?.textColor))") + default: + print("attribute") + } + + } + } */ } public func encode(to encoder: Encoder) throws { From d884602d87ce55a7374b706ee6ca0aa9c2b2d73b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 25 Nov 2019 09:06:09 -0500 Subject: [PATCH 018/272] tweaks --- MVMCoreUI.xcodeproj/project.pbxproj | 3 ++- MVMCoreUI/Atoms/Views/Label.swift | 2 +- MVMCoreUI/Models/Extensions/ModelHelper.swift | 2 +- MVMCoreUI/Models/Molecules/ListItemModel.swift | 12 ++++++------ MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 21071088..688228ef 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -35,7 +35,6 @@ 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; }; - 01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.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 */; }; @@ -67,6 +66,7 @@ D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -1179,6 +1179,7 @@ D213347723843825008E41B3 /* Line.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index a653985d..2f68a8d4 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -212,7 +212,7 @@ public typealias ActionBlock = () -> () } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { - //LabelModel() + guard let label = label else { return } label.attributedText = nil label.text = json?.optionalStringForKey(KeyText) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index 661280a9..da5e0d56 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -8,7 +8,7 @@ import Foundation -extension KeyedDecodingContainer where Key : CodingKey{ +extension KeyedDecodingContainer where Key : CodingKey { private enum TypeCodingKey: String, CodingKey { case moleculeName } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index a903299a..da14a602 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -12,31 +12,31 @@ import Foundation public static var identifier: String = "listItem" public var moleculeName: String? public var molecule: MoleculeProtocol? - public var actionMap: ActionMapModel? + public var action: ActionModel? - public init(molecule: MoleculeProtocol?, actionMap: ActionMapModel?) { + public init(molecule: MoleculeProtocol?, actionMap: ActionModel?) { self.molecule = molecule - self.actionMap = actionMap + self.action = actionMap self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { case moleculeName case molecule - case actionMap + case action } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - self.actionMap = try typeContainer.decodeIfPresent(ActionMapModel.self, forKey: .actionMap) + self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) - try container.encodeIfPresent(actionMap, forKey: .actionMap) + try container.encodeIfPresent(action, forKey: .action) } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 1b754e50..400e7450 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -58,7 +58,7 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol } if let seperatorModel = headerModel.seperator as? LineModel { - separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) + line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } } From b53f7e7786196cf39c002168e7b778e61d68debc Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 26 Nov 2019 13:30:06 -0500 Subject: [PATCH 019/272] update --- MVMCoreUI/Models/Molecules/ListItemModel.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index a903299a..3e340ac8 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -12,9 +12,9 @@ import Foundation public static var identifier: String = "listItem" public var moleculeName: String? public var molecule: MoleculeProtocol? - public var actionMap: ActionMapModel? + public var actionMap: ActionModel? - public init(molecule: MoleculeProtocol?, actionMap: ActionMapModel?) { + public init(molecule: MoleculeProtocol?, actionMap: ActionModel?) { self.molecule = molecule self.actionMap = actionMap self.moleculeName = Self.identifier @@ -30,7 +30,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - self.actionMap = try typeContainer.decodeIfPresent(ActionMapModel.self, forKey: .actionMap) + self.actionMap = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .actionMap) } public func encode(to encoder: Encoder) throws { From 1a5c819a2a224803fbd4a52022467888d14bd030 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 26 Nov 2019 13:55:29 -0500 Subject: [PATCH 020/272] fix conflict --- MVMCoreUI/Molecules/StandardHeaderView.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 746d510c..e6d00efa 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -8,11 +8,7 @@ import UIKit -<<<<<<< HEAD -public class StandardHeaderView: ViewConstrainingView { -======= public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol { ->>>>>>> feature/models var line: Line? // MARK: - MVMCoreViewProtocol From 269898f56620f0d228ef7ce69f9db7b72ea52640 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 26 Nov 2019 13:57:24 -0500 Subject: [PATCH 021/272] fix conflicts --- MVMCoreUI/Atoms/Views/CaretView.swift | 24 +++++++++++++----------- MVMCoreUI/Atoms/Views/DashLine.swift | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index 08251fcb..2c4669fe 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -124,18 +124,8 @@ open class CaretView: View { lineWidth = lineWidthValue } } -} - -extension CaretView: MVMCoreUIViewConstrainingProtocol { - open func needsToBeConstrained() -> Bool { - return true - } - open func alignment() -> UIStackView.Alignment { - return UIStackView.Alignment.leading; - } - - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + override public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { guard let caretModel = model as? CaretViewModel else { return } @@ -156,3 +146,15 @@ extension CaretView: MVMCoreUIViewConstrainingProtocol { } } } + +extension CaretView: MVMCoreUIViewConstrainingProtocol { + open func needsToBeConstrained() -> Bool { + return true + } + + open func alignment() -> UIStackView.Alignment { + return UIStackView.Alignment.leading; + } + + +} diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 662027fa..937b7313 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -84,7 +84,7 @@ open class DashLine: View { } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { guard let dashLineModel = model as? DashLineModel else { return } From 1bbad6ca15cd08413da813a45664b25de0cd4dbb Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 26 Nov 2019 14:14:53 -0500 Subject: [PATCH 022/272] fix merge conflict --- MVMCoreUI/Atoms/Views/CaretView.swift | 2 - MVMCoreUI/Atoms/Views/Label.swift | 40 +++++++++---------- .../Atoms/Views/LabelModel/LabelModel.swift | 23 ++--------- 3 files changed, 22 insertions(+), 43 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index 2c4669fe..c02db833 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -155,6 +155,4 @@ extension CaretView: MVMCoreUIViewConstrainingProtocol { open func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading; } - - } diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index fb9a18a4..f7d476ec 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -259,47 +259,46 @@ public typealias ActionBlock = () -> () if let attributes = labelModel.attributes, let labelText = text { let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor]) - /*for attribute in attributes { - guard let attributeStyle = attribute.type, let location = attribute.location, let length = attribute.length else { continue } - let range = NSRange(location: location, length: length) - switch attributeStyle { - case .underline: + for attribute in attributes { + let range = NSRange(location: attribute.location, length: attribute.length) + switch attribute { + case let underLineAtt as LabelAttributeUnderlineModel: attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range) - case .strikethrough: + case let strikeAtt as LabelAttributeStrikeThroughModel: attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range) attributedString.addAttribute(.baselineOffset, value: 0, range: range) - case .color: - if let colorHex = attribute.textColor, !colorHex.isEmpty { + case let colorAtt as LabelAttributeColorModel: + if let colorHex = colorAtt.textColor, !colorHex.isEmpty { attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) } - case .image: + case let imageAtt as LabelAttributeImageModel: var fontSize = font.pointSize - if let attributeSize = attribute.size { + if let attributeSize = imageAtt.size { fontSize = attributeSize } - let imageName = attribute.name ?? "externalLink" + let imageName = imageAtt.name ?? "externalLink" let imageAttachment: NSTextAttachment - if let url = attribute.URL { + if let url = imageAtt.URL { imageAttachment = Label.getTextAttachmentFrom(url: url, dimension: fontSize, label: self) } else { imageAttachment = Label.getTextAttachmentImage(name: imageName, dimension: fontSize) } let mutableString = NSMutableAttributedString() mutableString.append(NSAttributedString(attachment: imageAttachment)) - attributedString.insert(mutableString, at: location) - case .font: - if let fontStyle = attribute.style { + attributedString.insert(mutableString, at: imageAtt.location) + case let fontAtt as LabelAttributeFontModel: + if let fontStyle = fontAtt.style { let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle) attributedString.removeAttribute(.font, range: range) attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range) } else { - let fontSize = attribute.size + let fontSize = fontAtt.size var font: UIFont? - if let fontName = attribute.name { + if let fontName = fontAtt.name { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? self.font.pointSize) } else if let fontSize = fontSize { font = self.font.withSize(fontSize) @@ -309,20 +308,17 @@ public typealias ActionBlock = () -> () attributedString.addAttribute(.font, value: font, range: range) } } - case .action: + case let actionAtt as LabelAttributeActionModel: addActionAttributes(range: range, string: attributedString) -// if let actionBlock = createActionBlockFor(actionMap: attribute, additionalData: additionalData, delegateObject: delegateObject) { -// appendActionableClause(range: range, actionBlock: actionBlock) -// } default: continue } - }*/ } originalAttributedString = attributedText hero = labelModel.hero } + } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index b4c71153..cd1c5d12 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -60,21 +60,6 @@ import Foundation self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html) self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) - /*if let atts = self.attributes { - for attribute in atts { - switch attribute.type { - case "font": - let afont = attribute as? LabelAttributeFontModel - print("font length\(afont!.length), \(String(describing: afont?.name))") - case "color": - let afont = attribute as? LabelAttributeColorModel - print("font length\(afont!.length), \(String(describing: afont?.textColor))") - default: - print("attribute") - } - - } - } */ } public func encode(to encoder: Encoder) throws { @@ -88,10 +73,10 @@ import Foundation try container.encodeIfPresent(fontName, forKey: .fontName) try container.encodeIfPresent(fontSize, forKey: .fontSize) try container.encodeIfPresent(textAlignment, forKey: .textAlignment) -// var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes) -// try attributes?.forEach({ (attributeModel) in -// try attributeContainer.encode(attributeModel) -// }) + var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes) + try attributes?.forEach({ (attributeModel) in + try attributeContainer.encode(attributeModel) + }) try container.encodeIfPresent(html, forKey: .html) try container.encodeIfPresent(hero, forKey: .hero) try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable) From 876a07650bccd02479344cdac5ea36d1092604d8 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 26 Nov 2019 14:16:12 -0500 Subject: [PATCH 023/272] remove space --- MVMCoreUI/Atoms/Views/Label.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index f7d476ec..388f40cb 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -234,7 +234,6 @@ public typealias ActionBlock = () -> () textAlignment = .left } - makeWholeViewClickable = labelModel.makeWholeViewClickable ?? false if let backgroundColorHex = labelModel.backgroundColor, !backgroundColorHex.isEmpty { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) @@ -245,7 +244,7 @@ public typealias ActionBlock = () -> () if let fontStyle = labelModel.fontStyle { MFStyler.styleLabel(self, withStyle: fontStyle) } else { - let fontSize = labelModel.fontSize as? CGFloat + let fontSize = labelModel.fontSize if let fontName = labelModel.fontName { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? font.pointSize) } else if let fontSize = fontSize { @@ -313,11 +312,10 @@ public typealias ActionBlock = () -> () default: continue } + } + originalAttributedString = attributedText + hero = labelModel.hero } - - originalAttributedString = attributedText - hero = labelModel.hero - } } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { From 5446fb0785a7b9b570768cb03d0343fc30c6b200 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 26 Nov 2019 19:20:38 -0500 Subject: [PATCH 024/272] WIP --- MVMCoreUI.xcodeproj/project.pbxproj | 58 ++++++++- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 40 ------- .../MFViewController+Model.swift | 25 ++-- .../CollectionCellMoleculeProtocol.swift | 14 +++ MVMCoreUI/Models/Extensions/ModelHelper.swift | 2 +- .../Models/Molecules/CarouselItemModel.swift | 42 +++++++ .../Models/Molecules/CarouselModel.swift | 74 ++++++++++++ .../Models/Molecules/ListItemModel.swift | 20 +++- .../Molecules/ModuleMoleculeModel.swift | 14 +++ .../Molecules/MoleculeStackItemModel.swift | 33 ++++- .../Models/Molecules/MoleculeStackModel.swift | 7 +- .../Models/Molecules/SeperatorModel.swift | 2 +- MVMCoreUI/Models/PagingMoleculeProtocol.swift | 13 ++ .../Template/ListPageTemplateModel.swift | 24 ++++ .../Models/{ => Template}/PageModel.swift | 0 .../StackCenteredPageTemplateModel.swift | 21 ++++ .../Template/StackPageTemplateModel.swift | 24 ++++ .../Template/TemplateModelProtocol.swift | 22 ++++ .../ThreeLayerPageTemplateModel.swift | 24 ++++ MVMCoreUI/Models/TemplateProtocol.swift | 29 +++++ .../Items/MoleculeCollectionViewCell.swift | 40 ++++--- .../Items/MoleculeTableViewCell.swift | 33 +++-- MVMCoreUI/Molecules/Items/TableViewCell.swift | 73 ++++++----- .../Molecules/Items/TabsTableViewCell.swift | 19 +-- .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 9 +- .../Molecules/ModelMoleculeViewProtocol.swift | 11 ++ MVMCoreUI/Molecules/ModuleMolecule.swift | 88 +++++++++----- MVMCoreUI/Molecules/Scroller.swift | 32 ++++- MVMCoreUI/Molecules/StandardHeaderView.swift | 1 - MVMCoreUI/Organisms/Carousel.swift | 101 +++++++++------- MVMCoreUI/Organisms/MoleculeStackView.swift | 77 +++++++----- ...MoleculeMappingObject+ModelExtension.swift | 10 +- .../MVMCoreUIMoleculeMappingObject.h | 8 +- .../ModelMoleculeDelegateProtocol.swift | 14 +++ .../Templates/MoleculeListTemplate.swift | 113 ++++++++++-------- .../Templates/MoleculeStackTemplate.swift | 40 +++++-- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 36 ++++-- 37 files changed, 866 insertions(+), 327 deletions(-) create mode 100644 MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift create mode 100644 MVMCoreUI/Models/Molecules/CarouselItemModel.swift create mode 100644 MVMCoreUI/Models/Molecules/CarouselModel.swift create mode 100644 MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift create mode 100644 MVMCoreUI/Models/PagingMoleculeProtocol.swift create mode 100644 MVMCoreUI/Models/Template/ListPageTemplateModel.swift rename MVMCoreUI/Models/{ => Template}/PageModel.swift (100%) create mode 100644 MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift create mode 100644 MVMCoreUI/Models/Template/StackPageTemplateModel.swift create mode 100644 MVMCoreUI/Models/Template/TemplateModelProtocol.swift create mode 100644 MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift create mode 100644 MVMCoreUI/Models/TemplateProtocol.swift create mode 100644 MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d8399580..ffa63ba7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -12,11 +12,23 @@ 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; + 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */; }; + 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */; }; + 012A88AF238C626E00FE3DA1 /* CarouselModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */; }; + 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */; }; + 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */; }; + 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */; }; + 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */; }; + 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */; }; 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */; }; + 012CA9DE2388723E003F810F /* ListPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */; }; + 012CA9E023888AC8003F810F /* StackPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */; }; + 012CA9E223888AED003F810F /* StackCenteredPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */; }; + 012CA9E423888B1B003F810F /* ThreeLayerPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9E323888B1B003F810F /* ThreeLayerPageTemplateModel.swift */; }; 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */; }; 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D902327ECE600EF99AA /* CornerLabels.swift */; }; 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; }; @@ -232,11 +244,23 @@ 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; + 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModelProtocol.swift; sourceTree = ""; }; + 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateProtocol.swift; sourceTree = ""; }; + 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselModel.swift; sourceTree = ""; }; + 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PagingMoleculeProtocol.swift; sourceTree = ""; }; + 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemModel.swift; sourceTree = ""; }; + 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionCellMoleculeProtocol.swift; sourceTree = ""; }; + 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMoleculeModel.swift; sourceTree = ""; }; + 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeDelegateProtocol.swift; sourceTree = ""; }; 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstrainingMoleculeProtocol.swift; sourceTree = ""; }; + 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPageTemplateModel.swift; sourceTree = ""; }; + 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackPageTemplateModel.swift; sourceTree = ""; }; + 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackCenteredPageTemplateModel.swift; sourceTree = ""; }; + 012CA9E323888B1B003F810F /* ThreeLayerPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerPageTemplateModel.swift; sourceTree = ""; }; 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = ""; }; 01509D902327ECE600EF99AA /* CornerLabels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerLabels.swift; sourceTree = ""; }; 01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; @@ -462,11 +486,27 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 012A889A238898C600FE3DA1 /* Template */ = { + isa = PBXGroup; + children = ( + 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, + 017BEB392360EEB40024EF95 /* PageModel.swift */, + 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */, + 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */, + 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */, + 012CA9E323888B1B003F810F /* ThreeLayerPageTemplateModel.swift */, + ); + path = Template; + sourceTree = ""; + }; 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( - 017BEB392360EEB40024EF95 /* PageModel.swift */, + 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, + 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, + 012A889A238898C600FE3DA1 /* Template */, 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, @@ -498,6 +538,9 @@ 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */, + 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, + 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, + 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */, ); path = Molecules; sourceTree = ""; @@ -900,6 +943,7 @@ D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */, D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */, + 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */, D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, @@ -1135,6 +1179,7 @@ buildActionMask = 2147483647; files = ( 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, + 012CA9E423888B1B003F810F /* ThreeLayerPageTemplateModel.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, @@ -1157,11 +1202,13 @@ D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */, D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, + 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, + 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, @@ -1173,6 +1220,7 @@ D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, + 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, @@ -1181,6 +1229,8 @@ 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, + 012A88AF238C626E00FE3DA1 /* CarouselModel.swift in Sources */, + 012CA9E023888AC8003F810F /* StackPageTemplateModel.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, @@ -1198,6 +1248,7 @@ D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, + 012CA9E223888AED003F810F /* StackCenteredPageTemplateModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, @@ -1214,12 +1265,14 @@ D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, + 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, + 012CA9DE2388723E003F810F /* ListPageTemplateModel.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, @@ -1238,6 +1291,7 @@ D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, + 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, @@ -1246,6 +1300,7 @@ D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, + 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, @@ -1260,6 +1315,7 @@ D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, + 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 4983020e..29f2c9be 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -352,46 +352,6 @@ } - (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - // Only treated as a container if we are constraining a molecule. - if (!self.constrainedView) { - [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - } - [self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - if (self.shouldSetupMoleculeFromJSON) { - NSDictionary *moleculeJSON = [json dict:KeyMolecule]; - if (self.molecule) { - [self.molecule setWithJSON:moleculeJSON delegateObject:delegateObject additionalData:additionalData]; - } else if (moleculeJSON) { - UIView *molecule = [[MVMCoreUIMoleculeMappingObject sharedMappingObject] createMoleculeForJSON:moleculeJSON delegateObject:delegateObject constrainIfNeeded:true]; - if (molecule) { - [self addMolecule:molecule]; - } - self.molecule = molecule; - [self setMoleculeAccessibility]; - } - } else { - [self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - } - - NSNumber *useHorizontalMargins = [json optionalNumberForKey:@"useHorizontalMargins"]; - if (useHorizontalMargins) { - self.updateViewHorizontalDefaults = [useHorizontalMargins boolValue]; - } - NSNumber *useVerticalMargins = [json optionalNumberForKey:@"useVerticalMargins"]; - if (useVerticalMargins) { - self.updateViewVerticalDefaults = [useVerticalMargins boolValue]; - } - - // Set the alignment for the stack in the containing view. The json driven value is for the axis direction alignment. - NSString *alignment = [json string:@"horizontalAlignment"]; - if (alignment) { - [self alignHorizontal:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; - } - alignment = [json string:@"verticalAlignment"]; - if (alignment) { - [self alignVertical:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; - } - if ([self.molecule respondsToSelector:@selector(copyBackgroundColor)] && [self.molecule performSelector:@selector(copyBackgroundColor)]) { self.backgroundColor = self.molecule.backgroundColor; } diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 924ce4c7..159a3260 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -11,16 +11,19 @@ import Foundation public extension MFViewController { @objc func parsePageJSON() { - guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { - return - } - do { - let pageData = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = JSONDecoder() - let pageModel = try decoder.decode(PageModel.self, from: pageData) - self.pageModel = pageModel - } catch { - MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - } + + (self as? TemplateProtocol)?.parseTemplateJSON() +// guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { +// return +// } +// do { +// let pageData = try JSONSerialization.data(withJSONObject: pageJSON) +// let decoder = JSONDecoder() +// +// let pageModel = try decoder.decode(PageModel.self, from: pageData) +// self.pageModel = pageModel +// } catch { +// MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") +// } } } diff --git a/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift b/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift new file mode 100644 index 00000000..a6a6d95d --- /dev/null +++ b/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift @@ -0,0 +1,14 @@ +// +// CollectionCellMoleculeProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol CollectionCellMoleculeProtocol: MoleculeProtocol { + var peakingUI: Bool? {get} + var peakingArrowColor: String? {get} +} diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index 661280a9..da5e0d56 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -8,7 +8,7 @@ import Foundation -extension KeyedDecodingContainer where Key : CodingKey{ +extension KeyedDecodingContainer where Key : CodingKey { private enum TypeCodingKey: String, CodingKey { case moleculeName } diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift new file mode 100644 index 00000000..a2359f03 --- /dev/null +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -0,0 +1,42 @@ +// +// CarouselItemModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class CarouselItemModel: MoleculeProtocol { + public static var identifier: String = "carouselItem" + public var moleculeName: String + public var backgroundColor: String? + public var molecule: MoleculeProtocol? + + public init(molecule: MoleculeProtocol?, backgroundColor: String?) { + self.molecule = molecule + self.moleculeName = Self.identifier + self.backgroundColor = backgroundColor + } + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + case backgroundColor + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + } +} diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift new file mode 100644 index 00000000..9fce489a --- /dev/null +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -0,0 +1,74 @@ +// +// CarouselModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/25/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class CarouselModel: MoleculeProtocol { + + public static var identifier: String = "carousel" + public var moleculeName: String + public var molecules: [CarouselItemModel] + + public var spacing: Float? + public var border: Bool? + public var loop: Bool? + public var height: Float? + public var itemWidthPercent: Float? + public var itemAlignment: String? + public var pagingMolecule: PagingMoleculeProtocol? + + public init(molecules: [CarouselItemModel], spacing: Float?, border: Bool?, loop: Bool?, height: Float?, itemWidthPercent: Float?, itemAlignment: String?, pagingMolecule: PagingMoleculeProtocol?){ + self.moleculeName = Self.identifier + self.molecules = molecules + self.spacing = spacing + self.border = border + self.loop = loop + self.height = height + self.itemWidthPercent = itemWidthPercent + self.itemAlignment = itemAlignment + self.pagingMolecule = pagingMolecule + } + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecules + case spacing + case border + case loop + case height + case itemWidthPercent + case itemAlignment + case pagingMolecule + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) + self.spacing = try typeContainer.decode(Float.self, forKey: .spacing) + self.border = try typeContainer.decode(Bool.self, forKey: .border) + self.loop = try typeContainer.decode(Bool.self, forKey: .loop) + self.height = try typeContainer.decode(Float.self, forKey: .height) + self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent) + self.itemAlignment = try typeContainer.decode(String.self, forKey: .itemAlignment) + self.pagingMolecule = try typeContainer.decodeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(molecules, forKey: .molecules) + try container.encode(spacing, forKey: .spacing) + try container.encode(border, forKey: .border) + try container.encode(loop, forKey: .loop) + try container.encode(height, forKey: .height) + try container.encode(itemWidthPercent, forKey: .itemWidthPercent) + try container.encode(itemAlignment, forKey: .itemAlignment) + try container.encodeIfPresent(self.pagingMolecule, forKey: .pagingMolecule) + } +} diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index a903299a..b2da3db1 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -14,16 +14,26 @@ import Foundation public var molecule: MoleculeProtocol? public var actionMap: ActionMapModel? - public init(molecule: MoleculeProtocol?, actionMap: ActionMapModel?) { + public var hideArrow: Bool? + public var separator: SeperatorModel? + public var style: String? + + public init(molecule: MoleculeProtocol?, actionMap: ActionMapModel?, hideArrow: Bool?, separator: SeperatorModel?, style: String?) { self.molecule = molecule self.actionMap = actionMap self.moleculeName = Self.identifier + self.hideArrow = hideArrow + self.separator = separator + self.style = style } enum CodingKeys: String, CodingKey { case moleculeName case molecule case actionMap + case hideArrow + case separator + case style } required public init(from decoder: Decoder) throws { @@ -31,6 +41,10 @@ import Foundation self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) self.actionMap = try typeContainer.decodeIfPresent(ActionMapModel.self, forKey: .actionMap) + + self.hideArrow = try typeContainer.decode(Bool.self, forKey: .hideArrow) + self.separator = try typeContainer.decode(SeperatorModel.self, forKey: .hideArrow) + self.style = try typeContainer.decode(String.self, forKey: .style) } public func encode(to encoder: Encoder) throws { @@ -38,5 +52,9 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(actionMap, forKey: .actionMap) + + try container.encodeIfPresent(hideArrow, forKey: .hideArrow) + try container.encodeIfPresent(separator, forKey: .separator) + try container.encodeIfPresent(style, forKey: .style) } } diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift new file mode 100644 index 00000000..15ce347f --- /dev/null +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -0,0 +1,14 @@ +// +// ModuleMoleculeModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +class ModuleMoleculeModel: MoleculeProtocol { + public static var identifier: String = "moduleMolecule" + public var moduleName: String +} diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 5bceda3e..9c75b582 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -10,27 +10,56 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeProtocol { public static var identifier: String = "stackItem" - public var moleculeName: String? + public var moleculeName: String public var molecule: MoleculeProtocol? - public init(molecule: MoleculeProtocol?) { + public var spacing: CGFloat? + public var percentage: Int? + public var verticalAlignment: String? + public var horizontalAlignment: String? + public var gone = false + + public init(molecule: MoleculeProtocol?, spacing: CGFloat?, percentage: Int?, verticalAlignment: String?, horizontalAlignment: String?, gone: Bool = false) { self.molecule = molecule self.moleculeName = Self.identifier + + self.spacing = spacing + self.percentage = percentage + self.verticalAlignment = verticalAlignment + self.horizontalAlignment = horizontalAlignment + self.gone = gone } enum CodingKeys: String, CodingKey { case moleculeName case molecule + case spacing + case percentage + case verticalAlignment + case horizontalAlignment + case gone } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + + self.spacing = try typeContainer.decode(CGFloat.self, forKey: .spacing) + self.percentage = try typeContainer.decode(Int.self, forKey: .percentage) + self.verticalAlignment = try typeContainer.decode(String.self, forKey: .verticalAlignment) + self.horizontalAlignment = try typeContainer.decode(String.self, forKey: .horizontalAlignment) + self.gone = try typeContainer.decode(Bool.self, forKey: .gone) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) + + try container.encode(spacing, forKey: .spacing) + try container.encode(percentage, forKey: .percentage) + try container.encode(verticalAlignment, forKey: .verticalAlignment) + try container.encode(horizontalAlignment, forKey: .horizontalAlignment) + try container.encode(gone, forKey: .gone) } } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 30c15822..bad35824 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -14,17 +14,20 @@ import Foundation public var moleculeName: String? public var molecules: [MoleculeStackItemModel]? public var axis: String? + public var spacing: Float? - public init(axis: String?, molecules: [MoleculeStackItemModel]?) { + public init(axis: String?, molecules: [MoleculeStackItemModel]?, spacing: Float?) { self.axis = axis self.molecules = molecules self.moleculeName = Self.identifier + self.spacing = spacing } enum CodingKeys: String, CodingKey { case moleculeName case molecules case axis + case spacing } required public init(from decoder: Decoder) throws { @@ -32,6 +35,7 @@ import Foundation self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) self.molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules) self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) + self.spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) } public func encode(to encoder: Encoder) throws { @@ -39,5 +43,6 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(molecules, forKey: .molecules) try container.encode(axis, forKey: .axis) + try container.encode(spacing, forKey: .spacing) } } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift index 705f904c..cdc1cb3c 100644 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -8,7 +8,7 @@ import UIKit -class SeperatorModel: MoleculeProtocol { +@objcMembers public class SeperatorModel: MoleculeProtocol { public static var identifier: String = "line" public var type: String? } diff --git a/MVMCoreUI/Models/PagingMoleculeProtocol.swift b/MVMCoreUI/Models/PagingMoleculeProtocol.swift new file mode 100644 index 00000000..af1ce14a --- /dev/null +++ b/MVMCoreUI/Models/PagingMoleculeProtocol.swift @@ -0,0 +1,13 @@ +// +// PagingMoleculeProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/25/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol PagingMoleculeProtocol: MoleculeProtocol { + var position: Float? {get} +} diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift new file mode 100644 index 00000000..2ad31cdc --- /dev/null +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -0,0 +1,24 @@ +// +// ListPageTemplate.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/22/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ListPageTemplateModel: TemplateModelProtocol { + + public static var identifier: String = "listTemplate" + + public var pageType: String + + public var screenHeading: String + + public var isAtomicTabs: Bool? + + public var header: MoleculeStackModel? + public var molecules: [ListItemModel]? + public var footer: MoleculeStackModel? +} diff --git a/MVMCoreUI/Models/PageModel.swift b/MVMCoreUI/Models/Template/PageModel.swift similarity index 100% rename from MVMCoreUI/Models/PageModel.swift rename to MVMCoreUI/Models/Template/PageModel.swift diff --git a/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift new file mode 100644 index 00000000..27eaa362 --- /dev/null +++ b/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift @@ -0,0 +1,21 @@ +// +// StackCenteredPageTemplate.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/22/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class StackCenteredPageTemplateModel: TemplateModelProtocol { + + public static var identifier: String = "stackCenterTemplate" + + public var pageType: String + + public var screenHeading: String + + public var isAtomicTabs: Bool? + +} diff --git a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift new file mode 100644 index 00000000..e1030f35 --- /dev/null +++ b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift @@ -0,0 +1,24 @@ +// +// StackPageTemplate.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/22/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class StackPageTemplateModel: TemplateModelProtocol { + public static var identifier: String = "moleculeStack" + + public var pageType: String + + public var screenHeading: String + + public var isAtomicTabs: Bool? + + public var header: MoleculeStackModel? + public var moleculeStack: MoleculeStackModel? + public var footer: MoleculeStackModel? +} diff --git a/MVMCoreUI/Models/Template/TemplateModelProtocol.swift b/MVMCoreUI/Models/Template/TemplateModelProtocol.swift new file mode 100644 index 00000000..3eeb9673 --- /dev/null +++ b/MVMCoreUI/Models/Template/TemplateModelProtocol.swift @@ -0,0 +1,22 @@ +// +// TemplateModelProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/22/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol TemplateModelProtocol: Model { + var template: String { get } + var pageType: String { get set } + var screenHeading: String { get set } + var isAtomicTabs: Bool? { get set } +} + +extension TemplateModelProtocol { + public var template: String { + get { return Self.identifier } + } +} diff --git a/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift new file mode 100644 index 00000000..658a021f --- /dev/null +++ b/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift @@ -0,0 +1,24 @@ +// +// ThreeLayerPageTemplateModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/22/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ThreeLayerPageTemplateModel: TemplateModelProtocol { + + public static var identifier: String = "threeLayer" + + public var pageType: String + + public var screenHeading: String + + public var isAtomicTabs: Bool? + + public var header: MoleculeStackModel? + public var middle: MoleculeStackModel? + public var footer: MoleculeStackModel? +} diff --git a/MVMCoreUI/Models/TemplateProtocol.swift b/MVMCoreUI/Models/TemplateProtocol.swift new file mode 100644 index 00000000..90e3e635 --- /dev/null +++ b/MVMCoreUI/Models/TemplateProtocol.swift @@ -0,0 +1,29 @@ +// +// ModelTemplateProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/25/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol TemplateProtocol { + var templateModel: TemplateModelProtocol? {get} + func parseTemplateJSON() + func templateData() -> Data? +} + +extension TemplateProtocol where Self: MFViewController { + public func templateData() -> Data? { + guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { + return nil + } + do { + return try JSONSerialization.data(withJSONObject: pageJSON) + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + return nil + } + } +} diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index 75249f7d..bc97be16 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -8,7 +8,8 @@ import UIKit -open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol { +open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol, ModelMoleculeViewProtocol { + open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? open var json: [AnyHashable: Any]? @@ -64,47 +65,50 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi peakingRightArrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true NSLayoutConstraint.scalingPinViewRight(toSuper: peakingRightArrow, ratio: ratio, anchor: contentView.widthAnchor) } - - public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - self.json = json - - if let useHorizontalMargins = json?.optionalBoolForKey("useHorizontalMargins") { + + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let collectionModel = model as? CollectionCellMoleculeProtocol else { + return + } + + if let useHorizontalMargins = collectionModel.useHorizontalMargins { updateViewHorizontalDefaults = useHorizontalMargins } - if let useVerticalMargins = json?.optionalBoolForKey("useVerticalMargins") { + if let useVerticalMargins = collectionModel.useVerticalMargins { updateViewVerticalDefaults = useVerticalMargins } - // Handles peaking. - allowsPeaking = json?.optionalBoolForKey("peakingUI") ?? true - if let peakingArrowColor = json?.optionalStringForKey("peakingArrowColor") { + allowsPeaking = collectionModel.peakingUI ?? false + if let peakingArrowColor = collectionModel.peakingArrowColor { let color = UIColor.mfGet(forHex: peakingArrowColor) peakingLeftArrow.tintColor = color peakingRightArrow.tintColor = color } - - if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) + + if let backgroundColorString = collectionModel.backgroundColor { + backgroundColor = UIColor.mfGet(forHex: backgroundColorString) } - - guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule) else { + + guard let moleculeModel = collectionModel.molecule else { return } + if molecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) { + if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) { contentView.insertSubview(moleculeView, at: 0) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: true).values)) molecule = moleculeView } } else { - molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) } + // This molecule will handle spacing by default. if let castView = molecule as? MVMCoreUIViewConstrainingProtocol { castView.shouldSetHorizontalMargins?(false) castView.shouldSetVerticalMargins?(false) } - accessibilityElements = molecule?.subviews } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 4769b7e5..7963b819 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -9,30 +9,27 @@ import UIKit @objcMembers open class MoleculeTableViewCell: TableViewCell { - - // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard molecule == nil, let json = json, let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule), let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) else { return } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) + + guard let model = model, + let moleculeModel = (model as? ConstrainingMoleculeProtocol)?.molecule, + let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) else { + return + } addMolecule(moleculeView) } - - public override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) else { - return 80 - } - return max(2 * PaddingDefaultVerticalSpacing3, height) - } - - public override class func name(forReuse molecule: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let molecule = molecule?.optionalDictionaryForKey(KeyMolecule) else { + + public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let moleculeModel = molecule?.molecule else { return "\(self)<>" } - let moleculeName = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) ?? "" + let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol + let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.name(forReuse: molecule, delegateObject: delegateObject) ?? moleculeModel.moleculeName ?? "" return "\(self)<\(moleculeName)>" } - + public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON) else { diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index cc531d75..7a097b5e 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -8,9 +8,11 @@ import UIKit -@objcMembers open class TableViewCell: UITableViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol { +@objcMembers open class TableViewCell: UITableViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol, ModelMoleculeViewProtocol { + open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? - open var json: [AnyHashable: Any]? + open var listItemModel: ListItemModel? + open var json: [String: Any]? // In updateView, will set padding to default. open var updateViewHorizontalDefaults = true @@ -136,46 +138,47 @@ import UIKit contentView.insetsLayoutMarginsFromSafeArea = false contentView.preservesSuperviewLayoutMargins = false } - - // MARK: - MVMCoreUIMoleculeViewProtocol - public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.json = json - - guard let json = json else { return } - - style(with: json.optionalStringForKey("style")) - - if let useHorizontalMargins = json.optionalBoolForKey("useHorizontalMargins") { + + //TODO: Model, Change to model + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let model = model as? ListItemModel else { + return + } + + self.listItemModel = model + style(with: model.style) + + if let useHorizontalMargins = model.useHorizontalMargins { updateViewHorizontalDefaults = useHorizontalMargins } - - if (json.optionalBoolForKey("useVerticalMargins") ?? true) == false { + + if (model.useVerticalMargins ?? true) == false { topMarginPadding = 0 bottomMarginPadding = 0 } - - if let backgroundColorString = json.optionalStringForKey(KeyBackgroundColor) { + + if let backgroundColorString = model.backgroundColor { backgroundColor = UIColor.mfGet(forHex: backgroundColorString) } - + // Add the caret if there is an action and it's not declared hidden. if !customAccessoryView { - if let _ = json.optionalDictionaryForKey("actionMap"), !json.boolForKey("hideArrow") { + if let _ = model.actionMap, !(model.hideArrow ?? false) { addCaretViewAccessory() } else { accessoryView = nil } } - + // override the separator - if let separator = json.optionalDictionaryForKey("separator") { + if let separator = model.separator { addSeparatorsIfNeeded() - bottomSeparatorView?.setWithJSON(separator, delegateObject: delegateObject, additionalData: additionalData) + (bottomSeparatorView as? ModelMoleculeViewProtocol)?.setWithModel(separator, nil, nil) } - - guard let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule) else { return } - molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) - + + guard let moleculeModel = model.molecule else { return } + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) + // This molecule will by default handle margins. if let castView = molecule as? MVMCoreUIViewConstrainingProtocol { castView.shouldSetHorizontalMargins?(false) @@ -189,18 +192,20 @@ import UIKit styleStandard() backgroundColor = .white } - - public class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) else { + + public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + guard let moleculeModel = molecule?.molecule, + let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type, + let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else { return 80 } return max(2 * PaddingDefaultVerticalSpacing3, height) } - - public class func name(forReuse molecule: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - return molecule?.optionalStringForKey(KeyMoleculeName) ?? "" + + + public class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { + return molecule?.moleculeName ?? "" } - // MARK: - Arrow /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { @@ -247,6 +252,7 @@ import UIKit // MARK: - MoleculeListCellProtocol /// For when the separator between cells shows using json and frequency. Default is type: standard, frequency: allExceptTop. + //TODO: Change to model public func setSeparatorWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) { addSeparatorsIfNeeded() if let json = json { @@ -263,7 +269,8 @@ import UIKit } public func didSelectCell(atIndex indexPath: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - if let actionMap = json?.optionalDictionaryForKey("actionMap") { + //TODO: Use object when handleAction is rewrote to handle action model + if let actionMap = self.listItemModel?.actionMap?.toJSON() { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift index 1a1796cd..b75f4600 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift @@ -38,12 +38,13 @@ import UIKit } // MARK: - MoleculeDelegateProtocol - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) self.delegateObject = delegateObject tabs.reloadData() } - + public override func reset() { super.reset() topMarginPadding = 8 @@ -51,17 +52,21 @@ import UIKit } } +//TODO: Models changes + extension TabsTableViewCell: TopTabbarDelegate { public func shouldSelectItem(at index: Int, topTabbar: TopTabbar) -> Bool { - if let moleculesArrays = json?.arrayForKey(KeyMolecules), let molecules = moleculesArrays[topTabbar.selectedIndex] as? [[AnyHashable: Any]] { + if let moleculesArrays = json?.arrayForKey(KeyMolecules), + let molecules = moleculesArrays[topTabbar.selectedIndex] as? [[AnyHashable: Any]] { delegateObject?.moleculeDelegate?.removeMolecules?(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) } previousTabIndex = tabs.selectedIndex return true } - + public func topTabbar(_ topTabbar: TopTabbar, didSelectItemAt index: Int) { - if let moleculesArrays = json?.arrayForKey(KeyMolecules), let molecules = moleculesArrays[index] as? [[AnyHashable: Any]] { + if let moleculesArrays = json?.arrayForKey(KeyMolecules), + let molecules = moleculesArrays[index] as? [[AnyHashable: Any]] { delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) } } @@ -71,7 +76,7 @@ extension TabsTableViewCell: TopTabbarDataSource { public func number(ofTopTabbarItems topTabbar: TopTabbar) -> Int { return json?.optionalDictionaryForKey("tabs")?.optionalArrayForKey("tabs")?.count ?? 0 } - + public func topTabbar(_ topTabbar: TopTabbar, titleForItemAt index: Int) -> String? { guard let tabs = json?.optionalDictionaryForKey("tabs")?.arrayForKey("tabs"), let label = tabs[index] as? [AnyHashable: Any], let title = label.optionalStringForKey(KeyText) else { return "Select" diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index 2c52324b..e67dc964 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -14,15 +14,10 @@ @protocol MVMCoreUIMoleculeViewProtocol -/// Sets up the ui based on the json -- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; - @optional -// optional func setWithModel(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject, _ additionalData: [String: AnyHashable]) -//Type arguments cannot be applied to non-parameterized class 'NSObject' -//- (void)setWithModel:(nullable NSObject*)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; - +/// Sets up the ui based on the json +- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; /// Called after init to provide an early setter for any molecule specific logic - (void)setAsMolecule; diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index 98c1818c..fa1b30a8 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -10,4 +10,15 @@ import Foundation public protocol ModelMoleculeViewProtocol { func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) + static func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? + static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? +} + +extension ModelMoleculeViewProtocol { + public static func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { + return nil + } + public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return nil + } } diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index 77acc007..ab252b5e 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -8,7 +8,7 @@ import UIKit -open class ModuleMolecule: ViewConstrainingView { +open class ModuleMolecule: ViewConstrainingView, ModelMoleculeViewProtocol { open var moduleMolecule: (UIView & MVMCoreUIMoleculeViewProtocol)? @@ -16,33 +16,65 @@ open class ModuleMolecule: ViewConstrainingView { super.updateView(size) moduleMolecule?.updateView(size) } - - // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { - // Critical error - return + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") + //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + setUpWithModel(model, delegateObject, additionalData) + + guard let moduleMoleculeModel = model as? ModuleMoleculeModel, + let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMoleculeModel.moduleName) else { + // Critical error + return } - if moduleMolecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: true) { - addSubview(moleculeView) - NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) - moduleMolecule = moleculeView - - isAccessibilityElement = false - if moleculeView.accessibilityElements != nil { - accessibilityElements = moleculeView.accessibilityElements - } else { - accessibilityElements = [moleculeView] - } - } - } else { - moduleMolecule?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData) - } +// if moduleMolecule == nil { +// MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(<#T##model: MoleculeProtocol##MoleculeProtocol#>, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##constrainIfNeeded: Bool##Bool#>) +// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: true) { +// addSubview(moleculeView) +// NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) +// moduleMolecule = moleculeView +// +// isAccessibilityElement = false +// if moleculeView.accessibilityElements != nil { +// accessibilityElements = moleculeView.accessibilityElements +// } else { +// accessibilityElements = [moleculeView] +// } +// } +// } else { +// moduleMolecule?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData) +// } + } + +// // MARK: - MVMCoreUIMoleculeViewProtocol +// open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { +// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) +// +// guard let moduleName = json?.optionalStringForKey("moduleName"), +// let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { +// // Critical error +// return +// } +// +// if moduleMolecule == nil { +// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: true) { +// addSubview(moleculeView) +// NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) +// moduleMolecule = moleculeView +// +// isAccessibilityElement = false +// if moleculeView.accessibilityElements != nil { +// accessibilityElements = moleculeView.accessibilityElements +// } else { +// accessibilityElements = [moleculeView] +// } +// } +// } else { +// moduleMolecule?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData) +// } +// } open override func setAsMolecule() { super.setAsMolecule() @@ -55,7 +87,8 @@ open class ModuleMolecule: ViewConstrainingView { } public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { + guard let moduleName = json?.optionalStringForKey("moduleName"), + let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { // Critical error return 0 } @@ -63,7 +96,8 @@ open class ModuleMolecule: ViewConstrainingView { } public override class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let moduleName = molecule?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { + guard let moduleName = molecule?.optionalStringForKey("moduleName"), + let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { // Critical error return "moduleMolecule<>" } diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index e4289bc3..7f179a07 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -27,19 +27,41 @@ import UIKit constraint.priority = UILayoutPriority(rawValue: 999) constraint.isActive = true } - - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - guard let json = json, let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule) else { + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + //super.setWithModel(model, delegateObject, additionalData) + #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") + //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + setUpWithModel(model, delegateObject, additionalData) + + guard let model = model, + let moleculeModel = (model as? ConstrainingMoleculeProtocol)?.molecule else { return } + if molecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) { + if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) { contentView.addSubview(moleculeView) pinView(toSuperView: moleculeView) molecule = moleculeView } } else { - molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) } } + +// open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { +// guard let json = json, let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule) else { +// return +// } +// if molecule == nil { +// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) { +// contentView.addSubview(moleculeView) +// pinView(toSuperView: moleculeView) +// molecule = moleculeView +// } +// } else { +// molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) +// } +// } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 100173fc..32b14bb2 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -56,7 +56,6 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol } open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - //TODO: Need to create setWithModel in ViewConstraining View #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index d0efcce3..116f1135 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -8,7 +8,8 @@ import UIKit -open class Carousel: ViewConstrainingView { +open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) /// The current index of the collection view. Includes dummy cells when looping. @@ -28,7 +29,7 @@ open class Carousel: ViewConstrainingView { var numberOfPages = 0 /// The json for the molecules. - var molecules: [[AnyHashable: Any]]? + var molecules: [MoleculeProtocol]? /// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%. var itemAlignment = UICollectionView.ScrollPosition.left @@ -79,25 +80,37 @@ open class Carousel: ViewConstrainingView { } // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + //TODO: Model, Change to model + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let caroselModel = model as? CarouselModel else { + return + } + + #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") + //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + setUpWithModel(caroselModel, delegateObject, additionalData) + collectionView.backgroundColor = backgroundColor collectionView.layer.borderColor = backgroundColor?.cgColor - collectionView.layer.borderWidth = (json?.boolForKey("border") ?? false) ? 1 : 0 + collectionView.layer.borderWidth = (caroselModel.border ?? false) ? 1 : 0 backgroundColor = .white - registerCells(with: json, delegateObject: delegateObject) - setupLayout(with: json) - prepareMolecules(with: json) - itemWidthPercent = (json?.optionalCGFloatForKey("itemWidthPercent") ?? 100) / 100 - setAlignment(with: json?.optionalStringForKey("itemAlignment")) - if let height = json?.optionalCGFloatForKey("height") { - collectionViewHeight?.constant = height + + registerCells(with: caroselModel, delegateObject: delegateObject) + setupLayout(with: caroselModel) + prepareMolecules(with: caroselModel) + itemWidthPercent = CGFloat((caroselModel.itemWidthPercent ?? 100) / 100) + setAlignment(with: caroselModel.itemAlignment) + + if let height = caroselModel.height { + collectionViewHeight?.constant = CGFloat(height) collectionViewHeight?.isActive = true } - setupPagingMolecule(json: json?.optionalDictionaryForKey("pagingMolecule"), delegateObject: delegateObject) + + setupPagingMolecule(caroselModel.pagingMolecule, delegateObject: delegateObject) collectionView.reloadData() } - + + open override func shouldSetHorizontalMargins(_ shouldSet: Bool) { super.shouldSetHorizontalMargins(shouldSet) updateViewHorizontalDefaults = false @@ -105,24 +118,25 @@ open class Carousel: ViewConstrainingView { // MARK: - JSON Setters /// Updates the layout being used - func setupLayout(with json:[AnyHashable: Any]?) { + + func setupLayout(with carouselModel: CarouselModel?) { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal - layout.minimumLineSpacing = json?["spacing"] as? CGFloat ?? 1 + layout.minimumLineSpacing = CGFloat(carouselModel?.spacing ?? 1) layout.minimumInteritemSpacing = 0 collectionView.collectionViewLayout = layout } - - func prepareMolecules(with json: [AnyHashable: Any]?) { - guard let newMolecules = json?.optionalArrayForKey(KeyMolecules) as? [[AnyHashable: Any]] else { + + func prepareMolecules(with carouselModel: CarouselModel?) { + guard let newMolecules = carouselModel?.molecules else { numberOfPages = 0 molecules = nil return } - + numberOfPages = newMolecules.count molecules = newMolecules - if json?.boolForKey("loop") ?? false && newMolecules.count > 2 { + if carouselModel?.loop ?? false && newMolecules.count > 2 { // Sets up the row data with buffer cells on each side (for illusion of endless scroll... also has one more buffer cell on each side in case we can peek that cell). loop = true molecules?.insert(newMolecules.last!, at: 0) @@ -132,36 +146,33 @@ open class Carousel: ViewConstrainingView { } pageIndex = 0 } - + + /// Sets up the paging molecule + open func setupPagingMolecule(_ molecule: PagingMoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) { + var pagingView: (UIView & MVMCoreUIPagingProtocol)? = nil + if let molecule = molecule { + pagingView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(molecule, delegateObject, true) as? (UIView & MVMCoreUIPagingProtocol) + } + addPaging(view: pagingView, position: (CGFloat(molecule?.position ?? 20))) + } + /// Registers the cells with the collection view - func registerCells(with json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) { - if let molecules = json?.optionalArrayForKey(KeyMolecules) as? [[AnyHashable: Any]] { - for molecule in molecules { - if let info = getMoleculeInfo(with: molecule, delegateObject: delegateObject) { - collectionView.register(info.class, forCellWithReuseIdentifier: info.identifier) - } + func registerCells(with carouselModel: CarouselModel, delegateObject: MVMCoreUIDelegateObject?) { + for molecule in carouselModel.molecules { + if let info = getMoleculeInfo(with: molecule, delegateObject: delegateObject) { + collectionView.register(info.class, forCellWithReuseIdentifier: info.identifier) } } } - - /// Sets up the paging molecule - open func setupPagingMolecule(json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) { - var pagingView: (UIView & MVMCoreUIPagingProtocol)? = nil - if let json = json { - pagingView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: json, delegateObject: delegateObject, constrainIfNeeded: true) as? (UIView & MVMCoreUIPagingProtocol) - } - addPaging(view: pagingView, position: (json?.optionalCGFloatForKey("position") ?? 20)) - } // MARK: - Convenience /// Returns the (identifier, class) of the molecule for the given map. - func getMoleculeInfo(with molecule: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: [AnyHashable: Any])? { - guard let molecule = molecule, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule), - let moleculeName = moleculeClass.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) else { - return nil + func getMoleculeInfo(with molecule: MoleculeProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? { + guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) , + let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.name(forReuse: molecule, delegateObject: delegateObject) ?? molecule.moleculeName else { + return nil } - return (moleculeName, moleculeClass, molecule) + return (moleculeName, className, molecule) } /// Sets the alignment from the string. @@ -272,9 +283,9 @@ extension Carousel: UICollectionViewDataSource { return UICollectionViewCell() } let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath) - if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol { + if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol { protocolCell.reset?() - protocolCell.setWithJSON(moleculeInfo.molecule, delegateObject: nil, additionalData: nil) + protocolCell.setWithModel(moleculeInfo.molecule, nil, nil) protocolCell.updateView(collectionView.bounds.width) } setAccessiblity(cell, index: indexPath.row) diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index cafe21b0..c47ca142 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -20,21 +20,22 @@ public class StackItem { self.view = view } - init(with view: UIView, json: [AnyHashable: Any]?) { + init(with view: UIView, stackItemModel: MoleculeStackItemModel?) { self.view = view - update(with: json) + update(with: stackItemModel) } - func update(with json: [AnyHashable: Any]?) { - gone = json?.boolForKey("gone") ?? (json == nil) - spacing = json?.optionalCGFloatForKey("spacing") - percentage = json?["percent"] as? Int - if let alignment = json?.stringOptionalWithChainOfKeysOrIndexes([KeyMolecule,"verticalAlignment"]) { + func update(with stackItemModel: MoleculeStackItemModel?) { + gone = stackItemModel?.gone ?? false + spacing = stackItemModel?.spacing + percentage = stackItemModel?.percentage + + if let alignment = stackItemModel?.verticalAlignment { verticalAlignment = ViewConstrainingView.getAlignmentFor(alignment, defaultAlignment: .fill) } else { verticalAlignment = nil } - if let alignment = json?.stringOptionalWithChainOfKeysOrIndexes([KeyMolecule,"horizontalAlignment"]) { + if let alignment = stackItemModel?.horizontalAlignment { horizontalAlignment = ViewConstrainingView.getAlignmentFor(alignment, defaultAlignment: .fill) } else { horizontalAlignment = nil @@ -42,10 +43,11 @@ public class StackItem { } } -public class MoleculeStackView: ViewConstrainingView { +public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol { var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() var items: [StackItem] = [] var useStackSpacingBeforeFirstItem = false + var moleculeStackModel: MoleculeStackModel? private var moleculesShouldSetHorizontalMargins = false private var moleculesShouldSetVerticalMargins = false @@ -144,44 +146,53 @@ public class MoleculeStackView: ViewConstrainingView { } } } - - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - let previousJSON = self.json - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + + //TODO: Model, Change to model + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let model = model as? MoleculeStackModel else { + return + } + let previousModel = self.moleculeStackModel + self.moleculeStackModel = model + + #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") + //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + setUpWithModel(model, delegateObject, additionalData) removeAllItemViews() // If the items in the stack are the same, just update previous items instead of re-allocating. var items: [StackItem]? - if MoleculeStackView.name(forReuse: previousJSON, delegateObject: delegateObject) == MoleculeStackView.name(forReuse: json, delegateObject: delegateObject) { + + if MoleculeStackView.name(forReuse: previousModel, delegateObject: delegateObject) == MoleculeStackView.name(forReuse: model, delegateObject: delegateObject) { items = self.items } self.items = [] - guard let molecules = json?.arrayForKey(KeyMolecules) as? [[String: Any]] else { + guard let molecules = model.molecules else { return } - + // Sets the stack attributes - setAxisWithJSON(json) - spacing = json?.optionalCGFloatForKey("spacing") ?? 16 - - // Adds the molecules and sets the json. - for (index, map) in molecules.enumerated() { - if let moleculeJSON = map.optionalDictionaryForKey(KeyMolecule) { + //setAxisWithJSON(json) + spacing = CGFloat(model.spacing ?? 16) + + for (index, moleculeContainer) in molecules.enumerated() { + if let stackItemModel = moleculeContainer.molecule as? MoleculeStackItemModel { var view: UIView? - if let item = items?[index] { - item.update(with: map) - view = item.view - (view as? MVMCoreUIMoleculeViewProtocol)?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: nil) - addStackItem(item, lastItem: index == molecules.count - 1) - } else if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) { - view = molecule - addStackItem(StackItem(with: molecule, json: map), lastItem: index == molecules.count - 1) - } - (view as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(moleculesShouldSetHorizontalMargins) - (view as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(moleculesShouldSetVerticalMargins) + if let item = items?[index] { + item.update(with: stackItemModel) + view = item.view + (view as? ModelMoleculeViewProtocol)?.setWithModel(stackItemModel, delegateObject, nil) + addStackItem(item, lastItem: index == molecules.count - 1) + } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(stackItemModel, delegateObject, true) { + view = moleculeView + addStackItem(StackItem(with: moleculeView, stackItemModel: stackItemModel), lastItem: index == molecules.count - 1) + } + (view as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(moleculesShouldSetHorizontalMargins) + (view as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(moleculesShouldSetVerticalMargins) } } + } public override class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 650264fc..0fb7370e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -8,9 +8,15 @@ import Foundation - public extension MVMCoreUIMoleculeMappingObject { + func getMoleculeClass(_ model: MoleculeProtocol) -> AnyClass? { + if let moleculeName = model.moleculeName { + return moleculeMapping.object(forKey: moleculeName) as? AnyClass + } + return nil + } + func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { return createMolecule(model, delegateObject, false) } @@ -25,7 +31,7 @@ public extension MVMCoreUIMoleculeMappingObject { if let molecule = molecule as? ModelMoleculeViewProtocol { molecule.setWithModel(model, delegateObject, nil) } else { - molecule.setWithJSON(model.dictionary, delegateObject: delegateObject, additionalData: nil) + molecule.setWithJSON?(model.dictionary, delegateObject: delegateObject, additionalData: nil) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h index 776566c8..6c1a84b2 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h @@ -29,10 +29,10 @@ - (nullable UIView *)createMoleculeForName:(nonnull NSString *)name; /// Creates the molecule for the molecule json. -- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject; - -/// Creates the molecule for the molecule json. Also checks if the molecule needs to be constrained for a stack/list style situation. -- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded; +//- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject; +// +///// Creates the molecule for the molecule json. Also checks if the molecule needs to be constrained for a stack/list style situation. +//- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded; #pragma mark - Convenience diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift new file mode 100644 index 00000000..2120333e --- /dev/null +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -0,0 +1,14 @@ +// +// MoleculeDelegateProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ModelMoleculeDelegateProtocol { + func addMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) +} diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index e6182bf7..0d645e35 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -8,9 +8,26 @@ import UIKit -open class MoleculeListTemplate: ThreeLayerTableViewController { - public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: [AnyHashable: Any])]? +open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol, ModelMoleculeDelegateProtocol { + + public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)]? var observer: NSKeyValueObservation? + + public var templateModel: TemplateModelProtocol? + + public func parseTemplateJSON() { + guard let templateData = templateData() else { + return + } + + do { + let decoder = JSONDecoder() + let templateModel = try decoder.decode(ListPageTemplateModel.self, from: templateData) + self.templateModel = templateModel + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + } + } open override var loadObject: MVMCoreLoadObject? { didSet { @@ -27,21 +44,17 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { } open override func viewForTop() -> UIView { -// guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), -// let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { -// return super.viewForTop() -// } - guard let moleculeModel = pageModel?.header, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { - return super.viewForTop() + guard let headerModel = (templateModel as? ListPageTemplateModel)?.header, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return super.viewForTop() } return molecule } override open func viewForBottom() -> UIView { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { - return super.viewForBottom() + guard let footerModel = (templateModel as? ListPageTemplateModel)?.footer, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return super.viewForBottom() } return molecule } @@ -64,7 +77,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { open override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { guard let moleculeInfo = moleculesInfo?[indexPath.row], - let estimatedHeight = moleculeInfo.class.estimatedHeight?(forRow: moleculeInfo.molecule, delegateObject: delegateObject() as? MVMCoreUIDelegateObject) else { + let estimatedHeight = (moleculeInfo.class as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(forRow: moleculeInfo.molecule, delegateObject: delegateObject() as? MVMCoreUIDelegateObject) else { return 0 } return estimatedHeight @@ -85,7 +98,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { } if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol { protocolCell.reset?() - protocolCell.setWithJSON(moleculeInfo.molecule, delegateObject: delegate, additionalData: nil) + (protocolCell as? ModelMoleculeViewProtocol)?.setWithModel(moleculeInfo.molecule, delegate, nil) protocolCell.updateView(tableView.bounds.width) } return cell @@ -126,56 +139,58 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { } } } - - open override func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + + public func addMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // This dispatch is needed to fix a race condition that can occur if this function is called during the table setup. - DispatchQueue.main.async { - guard let indexPath = self.tableView?.indexPath(for: sender) else { return } - var indexPaths: [IndexPath] = [] - for molecule in molecules { - if let info = self.getMoleculeInfo(with: molecule) { - self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier) - let index = indexPath.row + 1 + indexPaths.count - self.moleculesInfo?.insert(info, at: index) - indexPaths.append(IndexPath(row: index, section: 0)) - } - } - self.tableView?.insertRows(at: indexPaths, with: animation) - self.updateViewConstraints() - self.view.layoutIfNeeded() - } + DispatchQueue.main.async { + guard let indexPath = self.tableView?.indexPath(for: sender) else { return } + var indexPaths: [IndexPath] = [] + for molecule in molecules { + if let info = self.getMoleculeInfo(with: molecule) { + self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier) + let index = indexPath.row + 1 + indexPaths.count + self.moleculesInfo?.insert(info, at: index) + indexPaths.append(IndexPath(row: index, section: 0)) + } + } + self.tableView?.insertRows(at: indexPaths, with: animation) + self.updateViewConstraints() + self.view.layoutIfNeeded() + } } - - open override func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func removeMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] - for molecule in molecules { - if let removeIndex = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in - return NSDictionary(dictionary: molecule).isEqual(to: moleculeInfo.molecule) - }) { - moleculesInfo?.remove(at: removeIndex) - indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) - } - } + //TODO: cehck for molecule protocola eqality +// for molecule in molecules { +// if let removeIndex = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in +// return molecule == moleculeInfo.molecule +// }) { +// moleculesInfo?.remove(at: removeIndex) +// indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) +// } +// } self.tableView?.deleteRows(at: indexPaths, with: animation) self.updateViewConstraints() self.view.layoutIfNeeded() } + + // MARK: - Convenience /// Returns the (identifier, class) of the molecule for the given map. - func getMoleculeInfo(with molecule: [AnyHashable: Any]?) -> (identifier: String, class: AnyClass, molecule: [AnyHashable: Any])? { + func getMoleculeInfo(with molecule: MoleculeProtocol?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? { guard let molecule = molecule, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule), - let moleculeName = moleculeClass.name?(forReuse: molecule, delegateObject: delegateObject() as? MVMCoreUIDelegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) else { + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule), + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.name(forReuse: molecule, delegateObject: delegateObject() as? MVMCoreUIDelegateObject) ?? molecule.moleculeName else { return nil } return (moleculeName, moleculeClass, molecule) } /// Sets up the molecule list and ensures no errors loading all content. - func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: [AnyHashable: Any])]? { - var moleculeList: [(identifier: String, class: AnyClass, molecule: [AnyHashable: Any])] = [] - if let molecules = loadObject?.pageJSON?.optionalArrayForKey(KeyMolecules) as? [[AnyHashable: Any]] { + func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)]? { + var moleculeList: [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)] = [] + if let molecules = (templateModel as? ListPageTemplateModel)?.molecules { for molecule in molecules { if let info = getMoleculeInfo(with: molecule) { moleculeList.append(info) @@ -187,8 +202,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { /// Sets up the header, footer, molecule list and ensures no errors loading all content. func setup() { - var moleculeList: [(identifier: String, class: AnyClass, molecule: [AnyHashable: Any])] = [] - if let molecules = loadObject?.pageJSON?.optionalArrayForKey(KeyMolecules) as? [[AnyHashable: Any]] { + var moleculeList: [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)] = [] + if let molecules = loadObject?.pageJSON?.optionalArrayForKey(KeyMolecules) as? [MoleculeProtocol] { for molecule in molecules { if let info = getMoleculeInfo(with: molecule) { moleculeList.append(info) diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index dad4d5ef..dacbd2cb 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -8,8 +8,24 @@ import UIKit -open class MoleculeStackTemplate: ThreeLayerViewController { +open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { + var observer: NSKeyValueObservation? + public var templateModel: TemplateModelProtocol? + + public func parseTemplateJSON() { + guard let templateData = templateData() else { + return + } + + do { + let decoder = JSONDecoder() + let templateModel = try decoder.decode(StackPageTemplateModel.self, from: templateData) + self.templateModel = templateModel + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + } + } open override var loadObject: MVMCoreLoadObject? { didSet { @@ -30,29 +46,29 @@ open class MoleculeStackTemplate: ThreeLayerViewController { } open override func viewForTop() -> UIView? { - guard let moleculeModel = pageModel?.header, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { - return nil + guard let headerModel = (templateModel as? StackPageTemplateModel)?.header, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return nil } -// guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { -// return nil -// } return molecule } open override func viewForMiddle() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") else { - return nil + + guard let moleculeStackModel = (templateModel as? StackPageTemplateModel)?.moleculeStack else { + return nil } + let stack = MoleculeStackView(frame: .zero) stack.useStackSpacingBeforeFirstItem = true - stack.setWithJSON(moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil) + stack.setWithModel(moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil) return stack } override open func viewForBottom() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { - return nil + guard let footerModel = (templateModel as? StackPageTemplateModel)?.footer, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return nil } return molecule } diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 20475a6b..f87a1e29 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -8,7 +8,23 @@ import UIKit -@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController { +@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { + + public var templateModel: TemplateModelProtocol? + + public func parseTemplateJSON() { + guard let templateData = templateData() else { + return + } + + do { + let decoder = JSONDecoder() + let templateModel = try decoder.decode(StackPageTemplateModel.self, from: templateData) + self.templateModel = templateModel + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + } + } override open func viewDidLoad() { super.viewDidLoad() @@ -20,24 +36,28 @@ import UIKit super.newDataBuildScreen() heightConstraint?.isActive = true } - + + open override func viewForTop() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { - return nil + guard let headerModel = (templateModel as? ThreeLayerPageTemplateModel)?.header, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return nil } return molecule } open override func viewForMiddle() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("middle"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { - return nil + guard let middleModel = (templateModel as? ThreeLayerPageTemplateModel)?.middle, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(middleModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return nil } return molecule } override open func viewForBottom() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else { - return nil + guard let footerModel = (templateModel as? ThreeLayerPageTemplateModel)?.footer, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + return nil } return molecule } From 9195f96a687ab56b7d4d0a21cb1c101c8c34e3fd Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 27 Nov 2019 14:29:20 -0500 Subject: [PATCH 025/272] fixes --- MVMCoreUI/Models/Molecules/HeaderModel.swift | 9 +++- MVMCoreUI/Models/Molecules/LabelModel.swift | 2 + .../Molecules/MoleculeStackItemModel.swift | 12 +++--- .../Models/Molecules/MoleculeStackModel.swift | 4 +- .../EyebrowHeadlineBodyLink.swift | 8 ++-- MVMCoreUI/Organisms/MoleculeStackView.swift | 41 +++++++++++-------- 6 files changed, 45 insertions(+), 31 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 0dca783c..b907b353 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -15,27 +15,34 @@ import Foundation public var molecule: MoleculeProtocol? public var seperator: MoleculeProtocol? - public init(molecule: MoleculeProtocol?){ + public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: MoleculeProtocol?){ self.molecule = molecule self.moleculeName = Self.identifier + self.backgroundColor = backgroundColor + self.seperator = seperator } enum CodingKeys: String, CodingKey { case moleculeName case molecule + case backgroundColor case separator } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.seperator = try typeContainer.decodeIfPresent(codingKey: .separator) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(self.seperator, forKey: .separator) } } diff --git a/MVMCoreUI/Models/Molecules/LabelModel.swift b/MVMCoreUI/Models/Molecules/LabelModel.swift index 0886524a..859627d5 100644 --- a/MVMCoreUI/Models/Molecules/LabelModel.swift +++ b/MVMCoreUI/Models/Molecules/LabelModel.swift @@ -11,5 +11,7 @@ import Foundation @objcMembers public class LabelModel: MoleculeProtocol { public static var identifier: String = "label" + public var moleculeName: String? public var text: String? + public var spacing: Int? } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 9c75b582..ea01c844 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -17,7 +17,7 @@ import Foundation public var percentage: Int? public var verticalAlignment: String? public var horizontalAlignment: String? - public var gone = false + public var gone: Bool? = false public init(molecule: MoleculeProtocol?, spacing: CGFloat?, percentage: Int?, verticalAlignment: String?, horizontalAlignment: String?, gone: Bool = false) { self.molecule = molecule @@ -44,11 +44,11 @@ import Foundation self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - self.spacing = try typeContainer.decode(CGFloat.self, forKey: .spacing) - self.percentage = try typeContainer.decode(Int.self, forKey: .percentage) - self.verticalAlignment = try typeContainer.decode(String.self, forKey: .verticalAlignment) - self.horizontalAlignment = try typeContainer.decode(String.self, forKey: .horizontalAlignment) - self.gone = try typeContainer.decode(Bool.self, forKey: .gone) + self.spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) + self.percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage) + self.verticalAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) + self.horizontalAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) + self.gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index bad35824..088a2733 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -32,8 +32,8 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) - self.molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecules = try typeContainer.decodeIfPresent([MoleculeStackItemModel].self, forKey: .molecules) self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) self.spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index a7d96a34..c9f2299f 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -44,13 +44,13 @@ import UIKit open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) eyebrow.setWithJSON(json?.optionalDictionaryForKey("eyebrow"), delegateObject: delegateObject, additionalData: additionalData) - stack.items[0].gone = !eyebrow.hasText + stack.stackItems[0].gone = !eyebrow.hasText headline.setWithJSON(json?.optionalDictionaryForKey("headline"), delegateObject: delegateObject, additionalData: additionalData) - stack.items[1].gone = !headline.hasText + stack.stackItems[1].gone = !headline.hasText body.setWithJSON(json?.optionalDictionaryForKey("body"), delegateObject: delegateObject, additionalData: additionalData) - stack.items[2].gone = !body.hasText + stack.stackItems[2].gone = !body.hasText link.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData) - stack.items[3].gone = link.titleLabel?.text?.count ?? 0 == 0 + stack.stackItems[3].gone = link.titleLabel?.text?.count ?? 0 == 0 stack.restack() } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index c47ca142..fd6896e4 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -45,7 +45,7 @@ public class StackItem { public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol { var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() - var items: [StackItem] = [] + var stackItems: [StackItem] = [] var useStackSpacingBeforeFirstItem = false var moleculeStackModel: MoleculeStackModel? @@ -88,12 +88,12 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol /// Restacks the existing items. func restack() { - setWithStackItems(items) + setWithStackItems(stackItems) } /// Removes all stack items views from the view. func removeAllItemViews() { - for item in items { + for item in stackItems { item.view.removeFromSuperview() } } @@ -130,7 +130,7 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol public override func updateView(_ size: CGFloat) { super.updateView(size) - for item in items { + for item in stackItems { (item.view as? MVMCoreViewProtocol)?.updateView(size) } } @@ -140,7 +140,7 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol super.reset() backgroundColor = .clear updateViewHorizontalDefaults = true - for item in items { + for item in stackItems { if let view = item.view as? MVMCoreUIMoleculeViewProtocol { view.reset?() } @@ -163,10 +163,15 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol // If the items in the stack are the same, just update previous items instead of re-allocating. var items: [StackItem]? - if MoleculeStackView.name(forReuse: previousModel, delegateObject: delegateObject) == MoleculeStackView.name(forReuse: model, delegateObject: delegateObject) { - items = self.items + if let previousModel = previousModel { + let previoudReuseName = MoleculeStackView.name(forReuse: previousModel, delegateObject: delegateObject) + let currentReuseName = MoleculeStackView.name(forReuse: model, delegateObject: delegateObject) + if previoudReuseName == currentReuseName { + items = self.stackItems + } } - self.items = [] + + self.stackItems = [] guard let molecules = model.molecules else { return @@ -176,15 +181,15 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol //setAxisWithJSON(json) spacing = CGFloat(model.spacing ?? 16) - for (index, moleculeContainer) in molecules.enumerated() { - if let stackItemModel = moleculeContainer.molecule as? MoleculeStackItemModel { + for (index, stackItemModel) in molecules.enumerated() { + if let moleculeModel = stackItemModel.molecule { var view: UIView? if let item = items?[index] { item.update(with: stackItemModel) view = item.view - (view as? ModelMoleculeViewProtocol)?.setWithModel(stackItemModel, delegateObject, nil) + (view as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, nil) addStackItem(item, lastItem: index == molecules.count - 1) - } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(stackItemModel, delegateObject, true) { + } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) { view = moleculeView addStackItem(StackItem(with: moleculeView, stackItemModel: stackItemModel), lastItem: index == molecules.count - 1) } @@ -254,7 +259,7 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol /// Adds the stack item to the stack. func addStackItem(_ stackItem: StackItem, lastItem: Bool) { guard !stackItem.gone else { - items.append(stackItem) + stackItems.append(stackItem) return } let view = stackItem.view @@ -268,11 +273,11 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol view.alignHorizontal?(horizontalAlignment) view.alignVertical?(verticalAlignment) } - let first = items.first { !$0.gone } == nil + let first = stackItems.first { !$0.gone } == nil if axis == .vertical { if first { pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0) - } else if let previousView = items.last(where: { stackItem in + } else if let previousView = stackItems.last(where: { stackItem in return !stackItem.gone })?.view { _ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: true) @@ -289,7 +294,7 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol if first { // First horizontal item has no spacing by default unless told otherwise. pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0) - } else if let previousView = items.last(where: { stackItem in + } else if let previousView = stackItems.last(where: { stackItem in return !stackItem.gone })?.view { _ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: false) @@ -303,12 +308,12 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol if lastItem { pinView(contentView, toView: view, attribute: .right, relation: .equal, priority: .required, constant: 0) } - items.append(stackItem) + stackItems.append(stackItem) } func setWithStackItems(_ items: [StackItem]) { removeAllItemViews() - self.items.removeAll() + self.stackItems.removeAll() var previousPresentItem: StackItem? = nil for item in items { if !item.gone { From 0648ec0191057ae9e70f7bfa017a1e945f8c85f6 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 27 Nov 2019 17:25:23 -0500 Subject: [PATCH 026/272] fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ MVMCoreUI/Models/Molecules/FooterModel.swift | 44 +++++++++++++++++++ MVMCoreUI/Models/Molecules/HeaderModel.swift | 10 ++--- .../Models/Molecules/HeadlineBodyModel.swift | 17 +++++++ .../Models/Molecules/SeperatorModel.swift | 2 +- .../Template/StackPageTemplateModel.swift | 4 +- 6 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 MVMCoreUI/Models/Molecules/FooterModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f3d044ed..fc52bc65 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */; }; 012A88DA238ED42E00FE3DA1 /* StackPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */; }; 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */; }; + 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88EB238F084D00FE3DA1 /* FooterModel.swift */; }; 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; @@ -263,6 +264,7 @@ 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionCellMoleculeProtocol.swift; sourceTree = ""; }; 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMoleculeModel.swift; sourceTree = ""; }; 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeDelegateProtocol.swift; sourceTree = ""; }; + 012A88EB238F084D00FE3DA1 /* FooterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModel.swift; sourceTree = ""; }; 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; @@ -556,6 +558,7 @@ 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, + 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, @@ -1301,6 +1304,7 @@ D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, D213347723843825008E41B3 /* Line.swift in Sources */, + 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift new file mode 100644 index 00000000..38d55edd --- /dev/null +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -0,0 +1,44 @@ +// +// FooterModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/27/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class FooterModel: ConstrainingMoleculeProtocol { + public static var identifier: String = "footer" + public var moleculeName: String? + public var backgroundColor: String? + public var molecule: MoleculeProtocol? + + public init(molecule: MoleculeProtocol?, backgroundColor: String?){ + self.molecule = molecule + self.moleculeName = Self.identifier + self.backgroundColor = backgroundColor + } + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + case backgroundColor + case separator + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeIfPresent(self.backgroundColor, forKey: .backgroundColor) + } +} diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index b907b353..a1cd7cec 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -13,9 +13,9 @@ import Foundation public var moleculeName: String? public var backgroundColor: String? public var molecule: MoleculeProtocol? - public var seperator: MoleculeProtocol? + public var seperator: SeperatorModel? - public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: MoleculeProtocol?){ + public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: SeperatorModel?){ self.molecule = molecule self.moleculeName = Self.identifier self.backgroundColor = backgroundColor @@ -32,16 +32,16 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - self.seperator = try typeContainer.decodeIfPresent(codingKey: .separator) + self.seperator = try typeContainer.decodeIfPresent(SeperatorModel.self, forKey: .separator) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) - try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(self.backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(self.seperator, forKey: .separator) } } diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift index 557e74ba..571edd5b 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -17,5 +17,22 @@ import Foundation self.headline = headline self.moleculeName = Self.identifier } + + enum CodingKeys: String, CodingKey { + case moleculeName + case headline + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.headline, forKey: .headline) + } } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift index cdc1cb3c..55f2ae75 100644 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -10,5 +10,5 @@ import UIKit @objcMembers public class SeperatorModel: MoleculeProtocol { public static var identifier: String = "line" - public var type: String? + public var type: String } diff --git a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift index e1030f35..d05d91f3 100644 --- a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift @@ -18,7 +18,7 @@ import Foundation public var isAtomicTabs: Bool? - public var header: MoleculeStackModel? + public var header: HeaderModel? public var moleculeStack: MoleculeStackModel? - public var footer: MoleculeStackModel? + public var footer: FooterModel? } From 988e30daa9bca0163a5a234a156638aa2ea90d71 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Mon, 2 Dec 2019 11:15:50 -0500 Subject: [PATCH 027/272] Creates Link atom to replace MFTextButton --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Atoms/Buttons/Link.swift | 155 +++++++++++++++++++++++++ MVMCoreUI/Utility/MVMCoreUIConstants.h | 1 + MVMCoreUI/Utility/MVMCoreUIConstants.m | 1 + 4 files changed, 161 insertions(+) create mode 100644 MVMCoreUI/Atoms/Buttons/Link.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 391e20f5..70cbe5ff 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; + C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; }; @@ -228,6 +229,7 @@ 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; + C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = ""; }; @@ -729,6 +731,7 @@ D282AACA2243C61700C46919 /* ButtonView.swift */, D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, + C07065C32395677300FBF997 /* Link.swift */, ); path = Buttons; sourceTree = ""; @@ -1060,6 +1063,7 @@ 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, + C07065C42395677300FBF997 /* Link.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift new file mode 100644 index 00000000..a89f8e71 --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -0,0 +1,155 @@ +// +// Link.swift +// MVMCoreUI +// +// Created by Robinson, Blake on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers open class Link: MFCustomButton { + + lazy var sizeObject:MFSizeObject? = { + return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) + }() + + public override init(frame: CGRect) { + super.init(frame: frame) + self.setupView() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + self.setupView() + } + + open override func draw(_ rect: CGRect) { + guard let textRect = self.titleLabel?.frame else { return } + + let contextRef = UIGraphicsGetCurrentContext() + + //set to the same color as the text + if let color = self.titleLabel?.textColor?.cgColor { + contextRef?.setStrokeColor(color) + } + + //x should be according to the text, not the button + let x = textRect.origin.x + // line is 1 point below the text + let y = textRect.origin.y + textRect.size.height + 1 + + contextRef?.move(to: CGPoint(x: x, y: y)) + contextRef?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) + contextRef?.closePath() + contextRef?.drawPath(using: .stroke) + } + + public static func link() -> Link { + return Link.link(nil, constrainHeight: true, width: CGFloat.leastNormalMagnitude) + } + + public static func link(_ button: UIButton?, constrainHeight: Bool, width:CGFloat) -> Link { + + let link = linkHelper(button) + + //Adds the height constraint. + if let constant = link.sizeObject?.standardSize, + constrainHeight { + + let heightConstraint = NSLayoutConstraint(item: link as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) + link.addConstraint(heightConstraint) + heightConstraint.isActive = true + link.heightConstraint = heightConstraint + + } else { + link.setContentHuggingPriority(.required, for: .vertical) + } + link.updateView(width) + + return link + } + + public static func linkHelper(_ button: UIButton?) -> Link { + guard let unwrappedButton = button else { return Link(type:.custom) } + guard let link = unwrappedButton as? Link else { return Link(type:.custom) } + return link + } +} + +extension Link: MVMCoreViewProtocol { + + public func updateView(_ size: CGFloat) { + MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in + guard let self = self else { return } + + var width = size + if MVMCoreGetterUtility.fequal(a: Float(CGFloat.leastNormalMagnitude), b: Float(size)) { + width = MVMCoreUISplitViewController.getApplicationViewWidth() + } + self.titleLabel?.font = MFStyler.fontB2(forWidth: width) + guard let heightConstraint = self.heightConstraint else { return } + if !MVMCoreGetterUtility.fequal(a: 0, b: Float(heightConstraint.constant)) { + guard let sizeObject = self.sizeObject else { return } + self.heightConstraint?.constant = sizeObject.getValueBased(onSize: width) + } + }) + } + + public func setupView() { + self.translatesAutoresizingMaskIntoConstraints = false; + self.backgroundColor = .clear + self.contentMode = .redraw + self.setTitleColor(UIColor.mfTextButton(), for: .normal) + self.setTitleColor(UIColor.mfCharcoal(), for: .highlighted) + // left alignment by default + self.titleLabel?.textAlignment = .left + self.contentHorizontalAlignment = .left + } +} + +extension Link: MVMCoreUIMoleculeViewProtocol { + + public func reset() { + self.setTitleColor(UIColor.mfTextButton(), for: .normal) + } + + public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + if let unwrappedJson = json { + let color = unwrappedJson.stringForkey(KeyTextColor) + setTitleColor(UIColor.mfGet(forHex: color), for: .normal) + + setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData) + + //enabling must happen after setWithActionMap is called because + //that method enables buttons when the actionMap does not contain + //disableAction = true + if let enabled = unwrappedJson[KeyEnabled] as? Bool { + isEnabled = enabled + } + } + + if let title = self.title(for: .normal), + title.isEmpty { + self.heightConstraint?.constant = 0 + } else { + guard let standardSize = sizeObject?.standardSize else { return } + self.heightConstraint?.constant = standardSize + } + } + + public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 31 + } +} + +extension Link: MVMCoreUIViewConstrainingProtocol { + + public func needsToBeConstrained() -> Bool { + return true + } + + public func alignment() -> UIStackView.Alignment { + return .leading + } +} diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.h b/MVMCoreUI/Utility/MVMCoreUIConstants.h index 778ede4f..2cb09859 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.h +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.h @@ -22,6 +22,7 @@ extern NSString * const KeyDisableButton; extern NSString * const KeyValue; extern NSString * const KeyLabel; extern NSString * const KeyDisable; +extern NSString * const KeyEnabled; extern NSString * const KeyFieldName; extern NSString * const KeyHideMainMenu; diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.m b/MVMCoreUI/Utility/MVMCoreUIConstants.m index 26636266..0ac5fcdb 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.m +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.m @@ -21,6 +21,7 @@ NSString * const KeyDisableButton = @"disableAction"; NSString * const KeyValue = @"value"; NSString * const KeyLabel = @"label"; NSString * const KeyDisable = @"disable"; +NSString * const KeyEnabled = @"enabled"; NSString * const KeyFieldName = @"fieldName"; NSString * const KeyFieldKey = @"fieldKey"; NSString * const KeyRequired = @"required"; From d00a04831d183587c72765e17ddb7f98809cefa5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 3 Dec 2019 09:19:55 -0500 Subject: [PATCH 028/272] fixes --- .../Models/Molecules/HeadlineBodyModel.swift | 20 +++++++--- .../HeadlineBody.swift | 37 +++++++++++++------ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift index 571edd5b..f4a8a0f3 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -11,28 +11,38 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeProtocol { public static var identifier: String = "headlineBody" public var moleculeName: String? - public var headline: LabelModel? + public var style: String? + public var headline: LabelModel + public var body: LabelModel - public init(headline: LabelModel?) { - self.headline = headline + public init(style: String?, headline: LabelModel, body: LabelModel) { self.moleculeName = Self.identifier + self.style = style + self.headline = headline + self.body = body } enum CodingKeys: String, CodingKey { case moleculeName + case style case headline + case body } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) + self.headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + self.body = try typeContainer.decode(LabelModel.self, forKey: .body) + self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.headline, forKey: .headline) + try container.encode(headline, forKey: .headline) + try container.encode(body, forKey: .body) + try container.encodeIfPresent(self.style, forKey: .style) } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index d236fc37..cc313d59 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -8,7 +8,7 @@ import UIKit -open class HeadlineBody: ViewConstrainingView { +open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol { let headlineLabel = Label.commonLabelH2(true) let messageLabel = Label.commonLabelB2(true) var spaceBetweenLabelsConstant = PaddingTwo @@ -118,18 +118,31 @@ open class HeadlineBody: ViewConstrainingView { spaceBetweenLabels?.constant = 0 } } - - // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - style(with: json?.optionalStringForKey("style")) - - let headlineJSON = json?.optionalDictionaryForKey("headline") - headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) - let bodyJSON = json?.optionalDictionaryForKey("body") - messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + + setUpWithModel(model, delegateObject, additionalData) + guard let headlineBodyModel = model as? HeadlineBodyModel else { + return + } + + style(with: headlineBodyModel.style) + + headlineLabel.setWithModel(headlineBodyModel.headline, delegateObject, additionalData) + messageLabel.setWithModel(headlineBodyModel.body, delegateObject, additionalData) } +// // MARK: - MVMCoreUIMoleculeViewProtocol +// open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { +// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) +// +// style(with: json?.optionalStringForKey("style")) +// +// let headlineJSON = json?.optionalDictionaryForKey("headline") +// headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) +// +// let bodyJSON = json?.optionalDictionaryForKey("body") +// messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) +// } open override func reset() { super.reset() From 1d647ec662a51da4e80a74e263b6d9e2b5ebe27e Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Tue, 3 Dec 2019 15:21:45 -0500 Subject: [PATCH 029/272] Code standard change. Removed legacy-like methods. --- MVMCoreUI/Atoms/Buttons/Link.swift | 48 ++++++++++-------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index a89f8e71..ef4a1477 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers open class Link: MFCustomButton { - lazy var sizeObject:MFSizeObject? = { + lazy var sizeObject: MFSizeObject? = { return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) }() @@ -24,6 +24,12 @@ import UIKit self.setupView() } + public convenience init(width:CGFloat) { + self.init() + self.setupView() + self.updateView(width) + } + open override func draw(_ rect: CGRect) { guard let textRect = self.titleLabel?.frame else { return } @@ -44,37 +50,6 @@ import UIKit contextRef?.closePath() contextRef?.drawPath(using: .stroke) } - - public static func link() -> Link { - return Link.link(nil, constrainHeight: true, width: CGFloat.leastNormalMagnitude) - } - - public static func link(_ button: UIButton?, constrainHeight: Bool, width:CGFloat) -> Link { - - let link = linkHelper(button) - - //Adds the height constraint. - if let constant = link.sizeObject?.standardSize, - constrainHeight { - - let heightConstraint = NSLayoutConstraint(item: link as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) - link.addConstraint(heightConstraint) - heightConstraint.isActive = true - link.heightConstraint = heightConstraint - - } else { - link.setContentHuggingPriority(.required, for: .vertical) - } - link.updateView(width) - - return link - } - - public static func linkHelper(_ button: UIButton?) -> Link { - guard let unwrappedButton = button else { return Link(type:.custom) } - guard let link = unwrappedButton as? Link else { return Link(type:.custom) } - return link - } } extension Link: MVMCoreViewProtocol { @@ -105,6 +80,15 @@ extension Link: MVMCoreViewProtocol { // left alignment by default self.titleLabel?.textAlignment = .left self.contentHorizontalAlignment = .left + + if let constant = self.sizeObject?.standardSize { + + let heightConstraint = NSLayoutConstraint(item: self as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) + self.addConstraint(heightConstraint) + heightConstraint.isActive = true + self.heightConstraint = heightConstraint + + } } } From 7e48670179862ac05f93fcca898bc06b2e280949 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 4 Dec 2019 12:38:57 -0500 Subject: [PATCH 030/272] Adding Model for UIColor and supporting UIColor Extension. --- MVMCoreUI.xcodeproj/project.pbxproj | 18 +- MVMCoreUI/Categories/UIColor+Extension.swift | 180 ++++++++++++++++++ .../Models/ConstrainingMoleculeProtocol.swift | 2 +- MVMCoreUI/Models/MoleculeProtocol.swift | 16 +- .../Models/Molecules/FormModelProtocol.swift | 6 +- MVMCoreUI/Models/Molecules/HeaderModel.swift | 3 +- .../Models/Primitive Models/ColorModel.swift | 95 +++++++++ 7 files changed, 305 insertions(+), 15 deletions(-) create mode 100644 MVMCoreUI/Categories/UIColor+Extension.swift create mode 100644 MVMCoreUI/Models/Primitive Models/ColorModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6a7921e5..9215b753 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; + 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; + 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B35239813EE0067DD0F /* ColorModel.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -279,6 +281,8 @@ 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; + 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; + 0AA33B35239813EE0067DD0F /* ColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorModel.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 = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; @@ -488,6 +492,7 @@ 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( + 0AA33B322398134B0067DD0F /* Primitive Models */, 017BEB392360EEB40024EF95 /* PageModel.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, @@ -524,6 +529,14 @@ path = Molecules; sourceTree = ""; }; + 0AA33B322398134B0067DD0F /* Primitive Models */ = { + isa = PBXGroup; + children = ( + 0AA33B35239813EE0067DD0F /* ColorModel.swift */, + ); + path = "Primitive Models"; + sourceTree = ""; + }; 946EE1B5237B663A0036751F /* Extensions */ = { isa = PBXGroup; children = ( @@ -779,6 +792,7 @@ D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */, D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */, D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */, + 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */, ); path = Categories; sourceTree = ""; @@ -879,7 +893,7 @@ DBC4391722442197001AB423 /* DashLine.swift */, 944589202385D6E900DE9FD4 /* DashLineModel.swift */, DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, - 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, + 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */, @@ -1208,6 +1222,7 @@ 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, 012CA98923849699003F810F /* SeperatorModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, + 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, @@ -1273,6 +1288,7 @@ 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, + 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift new file mode 100644 index 00000000..56986044 --- /dev/null +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -0,0 +1,180 @@ +// +// UIColor+Extension.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + + +import UIKit + + +extension UIColor { + //-------------------------------------------------- + // MARK: - Brand + //-------------------------------------------------- + + /// HEX: #000000 + public static let mvmBlack = UIColor.black + + /// HEX: #FFFFFF + public static let mvmWhite = UIColor.white + + /// HEX: #D52B1E + public static let mvmRed = UIColor.getColor(red: 213, green: 43, blue: 30) + + /// HEX: #CC4D0F + public static let mvmOrange = UIColor.getColor(red: 204, green: 77, blue: 15) + + /// HEX: #008631 + public static let mvmGreen = UIColor.getColor(red: 0, green: 134, blue: 49) + + /// HEX: #007AB8 + public static let mvmBlue = UIColor.getColor(red: 0, green: 122, blue: 184) + + /// HEX: #007AB8 + public static let mvmBlueGradient = UIColor.getColor(red: 0, green: 122, blue: 184) + + /// HEX: #FFBC3D + public static let mvmYellow = UIColor.getColor(red: 255, green: 188, blue: 61) + + /// HEX: #F6F6F6 + public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) + + /// HEX: #D8DADA + public static let mvmCoolGray3 = UIColor.getColor(red: 216, green: 218, blue: 218) + + /// HEX: #747676 + public static let mvmCoolGray6 = UIColor.getColor(red: 116, green: 118, blue: 118) + + //-------------------------------------------------- + // MARK: - VZ UP Brand + //-------------------------------------------------- + + /// HEX: #B89B56 + public static let vzupGold = UIColor.getColor(red: 184, green: 155, blue: 68) + + /// HEX: #F9D542 + public static let vzupYellow1 = UIColor.getColor(red: 249, green: 213, blue: 66) + + /// HEX: #F4CA53 + public static let vzupYellow2 = UIColor.getColor(red: 244, green: 202, blue: 83) + + /// HEX: #CC9B2D + public static let vzupYellow3 = UIColor.getColor(red: 204, green: 155, blue: 45) + + //-------------------------------------------------- + // MARK: - Functions + //-------------------------------------------------- + + /// Convenience to get a grayscale UIColor where the same value is used for red, green, and blue. + public class func grayscale(rgb: Int, alpha: CGFloat = 1.0) -> UIColor { + + let grayscale = CGFloat(rgb) / 255.0 + return UIColor(red: grayscale, green: grayscale, blue: grayscale, alpha: alpha) + } + + /// Convenience to get a UIColor via Int. + public class func getColor(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) -> UIColor { + + return UIColor(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: alpha) + } + + /// Convenience to get a UIColor via CGFloat. + public class func getColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor { + + return UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha) + } + + /// Gets UIColor via an 8 digit hex string. + public class func getColorBy(hex: String) -> UIColor { + + var hexint: UInt32 = 0 + + let scanner = Scanner(string: hex) + scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") + scanner.scanHexInt32(&hexint) + + return UIColor(red: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, + green: (CGFloat((hexint & 0xFF00) >> 8)) / 255, + blue: (CGFloat(hexint & 0xFF)) / 255, + alpha: 1) + } + + /// Gets UIColor via an 8 digit hex string. The last two being the alpha channel. + public class func getColorWithTransparencyBy(hex: String) -> UIColor { + + var hexint: UInt32 = 0 + + let scanner = Scanner(string: hex) + scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") + scanner.scanHexInt32(&hexint) + + return UIColor(red: (CGFloat((hexint & 0xFF000000) >> 24)) / 255, + green: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, + blue: (CGFloat((hexint & 0xFF00) >> 8)) / 255, + alpha: (CGFloat(hexint & 0xFF)) / 255) + } + + public class func gradientColor(_ color: UIColor?) -> UIColor { + + var h: CGFloat = 0 + var s: CGFloat = 0 + var b: CGFloat = 0 + var a: CGFloat = 0 + + if color?.getHue(&h, saturation: &s, brightness: &b, alpha: &a) ?? false { + return UIColor(hue: h, saturation: max(s - 0.17, 0.0), brightness: min(b - 0.03, 1.0), alpha: a) + } + + return .white + } + + public class func setBackgroundColor(forNavigationBar color: UIColor, navigationBar: UINavigationBar, transparent: Bool) { + + DispatchQueue.main.async { + + let view = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 1)) + view.backgroundColor = color + + UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0) + + if let context = UIGraphicsGetCurrentContext() { + view.layer.render(in: context) + } + + let image = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext() + + if transparent { + navigationBar.setBackgroundImage(UIImage(), for: .default) + navigationBar.isTranslucent = false + } else { + navigationBar.setBackgroundImage(image, for: .default) + } + } + } + + /// - parameter color: The UIColor intended to retrieve its hex value. + public class func hexString(for color: UIColor) -> String? { + + guard let components = color.cgColor.components else { return nil } + + if color.cgColor.numberOfComponents >= 3 { + let r = Int(CGFloat(components[0]) * 255) + let g = Int(CGFloat(components[1]) * 255) + let b = Int(CGFloat(components[2]) * 255) + + // If alpha of color is less than 1.0 then alpha hex is relevant. + if color.cgColor.numberOfComponents == 4 && components[3] < 1.0 { + let a = Int(CGFloat(components[3]) * 255) + return String(format: "%02X%02X%02X%02X", r, g, b, a) + } + + return String(format: "%02X%02X%02X", r, g, b) + } + + return nil + } +} diff --git a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift index 91d4a566..5cb24c4d 100644 --- a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol ConstrainingMoleculeProtocol: MoleculeProtocol { - var molecule: MoleculeProtocol? {get} + var molecule: MoleculeProtocol? { get } } extension ConstrainingMoleculeProtocol { diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index 2ddc4061..e8120568 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -1,15 +1,15 @@ import Foundation public protocol MoleculeProtocol: Model { - var moleculeName: String? {get} - var backgroundColor: String? {get} - var dictionary: [AnyHashable: Any]? {get} - var molecule: MoleculeProtocol? {get} + var moleculeName: String? { get } + var backgroundColor: String? { get } + var dictionary: [AnyHashable: Any]? { get } + var molecule: MoleculeProtocol? { get } - var useHorizontalMargins: Bool? {get} - var useVerticalMargins: Bool? {get} - var horizontalAlignment: String? {get} - var verticalAlignment: String? {get} + var useHorizontalMargins: Bool? { get } + var useVerticalMargins: Bool? { get } + var horizontalAlignment: String? { get } + var verticalAlignment: String? { get } } extension MoleculeProtocol { diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift index 4cd76354..aa298716 100644 --- a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift +++ b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol FormModelProtocol: Model { - var required: Bool? {get} - var fieldKey: String? {get} - var groupName: String? {get} + var required: Bool? { get } + var fieldKey: String? { get } + var groupName: String? { get } } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 0dca783c..5d4129e2 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -15,7 +15,7 @@ import Foundation public var molecule: MoleculeProtocol? public var seperator: MoleculeProtocol? - public init(molecule: MoleculeProtocol?){ + public init(molecule: MoleculeProtocol?) { self.molecule = molecule self.moleculeName = Self.identifier } @@ -38,4 +38,3 @@ import Foundation try container.encodeIfPresent(self.molecule, forKey: .molecule) } } - diff --git a/MVMCoreUI/Models/Primitive Models/ColorModel.swift b/MVMCoreUI/Models/Primitive Models/ColorModel.swift new file mode 100644 index 00000000..68fb16de --- /dev/null +++ b/MVMCoreUI/Models/Primitive Models/ColorModel.swift @@ -0,0 +1,95 @@ +// +// ColorModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +/** + Allows Hex values to be modeled into a UIColor object with its surrounding metadata. + */ +open class ColorModel: Codable { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + static var identifier: String = "color" + + public let uiColor: UIColor + public var hex: String = "" + + public var red: CGFloat = 0 + public var green: CGFloat = 0 + public var blue: CGFloat = 0 + public var alpha: CGFloat = 1 + + public var hexWithHash: String { + return "#" + hex + } + + //-------------------------------------------------- + // MARK: - Class Initializer + //-------------------------------------------------- + + init(uiColor: UIColor) { + self.uiColor = uiColor + + hex = UIColor.hexString(for: uiColor) ?? "" + + if !hex.isEmpty { + determineRGBA() + } + } + + //-------------------------------------------------- + // MARK: - Codable Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + hex = try container.decode(String.self).replacingOccurrences(of: "#", with: "") + + if hex.count == 8 { + uiColor = UIColor.getColorWithTransparencyBy(hex: hex) + } else { + uiColor = UIColor.getColorBy(hex: hex) + } + + determineRGBA() + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(hexWithHash) + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + public func convertHexToFloat(start: String.Index, end: String.Index) -> CGFloat { + + return CGFloat(Int(hex[start.. Date: Wed, 4 Dec 2019 14:27:45 -0500 Subject: [PATCH 031/272] fixes --- .../MVMCoreUIMoleculeMappingObject+ModelExtension.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 0fb7370e..070c8680 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -27,7 +27,7 @@ public extension MVMCoreUIMoleculeMappingObject { return nil } - let setData = {(molecule: UIView & MVMCoreUIMoleculeViewProtocol) in + let setData = {() in if let molecule = molecule as? ModelMoleculeViewProtocol { molecule.setWithModel(model, delegateObject, nil) } else { @@ -38,10 +38,10 @@ public extension MVMCoreUIMoleculeMappingObject { if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, castMolecule.needsToBeConstrained?() ?? false { let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill) - setData(view) + setData() return view } else { - setData(molecule) + setData() return molecule } } From c627901d7475498733a7af07843eef3e4452c38f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 4 Dec 2019 15:28:22 -0500 Subject: [PATCH 032/272] updates to color model and extension. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +-- MVMCoreUI/Categories/UIColor+Extension.swift | 70 +++++++++++++------ .../{ColorModel.swift => Color.swift} | 57 ++++++++++----- 3 files changed, 92 insertions(+), 43 deletions(-) rename MVMCoreUI/Models/Primitive Models/{ColorModel.swift => Color.swift} (63%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9215b753..779cd132 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -49,7 +49,7 @@ 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; - 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B35239813EE0067DD0F /* ColorModel.swift */; }; + 0AA33B36239813EE0067DD0F /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B35239813EE0067DD0F /* Color.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -282,7 +282,7 @@ 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; - 0AA33B35239813EE0067DD0F /* ColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorModel.swift; sourceTree = ""; }; + 0AA33B35239813EE0067DD0F /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.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 = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; @@ -532,7 +532,7 @@ 0AA33B322398134B0067DD0F /* Primitive Models */ = { isa = PBXGroup; children = ( - 0AA33B35239813EE0067DD0F /* ColorModel.swift */, + 0AA33B35239813EE0067DD0F /* Color.swift */, ); path = "Primitive Models"; sourceTree = ""; @@ -1288,7 +1288,7 @@ 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, - 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */, + 0AA33B36239813EE0067DD0F /* Color.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 56986044..fab1ae6f 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -9,8 +9,27 @@ import UIKit +public typealias ColorHexTuple = (uiColor: UIColor, hex: String) extension UIColor { + + /// Dictionary to access brand approved colors by name. + public static let names: [String: ColorHexTuple] = ["black": (.mvmBlack, "#000000"), + "white": (.mvmWhite, "#FFFFFF"), + "red": (.mvmRed, "#D52B1E"), + "orange": (.mvmOrange, "#CC4D0F"), + "green": (.mvmGreen, "#008631"), + "blue": (.mvmBlue, "#007AB8"), + "blueGradient": (.mvmBlueGradient, "#007AB8"), + "yellow": (.mvmYellow, "#FFBC3D"), + "coolGray1": (.mvmCoolGray1, "#F6F6F6"), + "coolGray3": (.mvmCoolGray3, "#D8DADA"), + "coolGray6": (.mvmCoolGray6, "#747676"), + "vzupGold": (.vzupGold, "#B89B56"), + "vzupYellow1": (.vzupYellow1, "#F9D542"), + "vzupYellow2": (.vzupYellow2, "#F4CA53"), + "vzupYellow3": (.vzupYellow3, "#CC9B2D")] + //-------------------------------------------------- // MARK: - Brand //-------------------------------------------------- @@ -22,47 +41,47 @@ extension UIColor { public static let mvmWhite = UIColor.white /// HEX: #D52B1E - public static let mvmRed = UIColor.getColor(red: 213, green: 43, blue: 30) + public static let mvmRed = UIColor.color8Bits(red: 213, green: 43, blue: 30) /// HEX: #CC4D0F - public static let mvmOrange = UIColor.getColor(red: 204, green: 77, blue: 15) + public static let mvmOrange = UIColor.color8Bits(red: 204, green: 77, blue: 15) /// HEX: #008631 - public static let mvmGreen = UIColor.getColor(red: 0, green: 134, blue: 49) + public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 49) /// HEX: #007AB8 - public static let mvmBlue = UIColor.getColor(red: 0, green: 122, blue: 184) + public static let mvmBlue = UIColor.color8Bits(red: 0, green: 122, blue: 184) /// HEX: #007AB8 - public static let mvmBlueGradient = UIColor.getColor(red: 0, green: 122, blue: 184) + public static let mvmBlueGradient = UIColor.color8Bits(red: 0, green: 122, blue: 184) /// HEX: #FFBC3D - public static let mvmYellow = UIColor.getColor(red: 255, green: 188, blue: 61) + public static let mvmYellow = UIColor.color8Bits(red: 255, green: 188, blue: 61) /// HEX: #F6F6F6 public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) /// HEX: #D8DADA - public static let mvmCoolGray3 = UIColor.getColor(red: 216, green: 218, blue: 218) + public static let mvmCoolGray3 = UIColor.color8Bits(red: 216, green: 218, blue: 218) /// HEX: #747676 - public static let mvmCoolGray6 = UIColor.getColor(red: 116, green: 118, blue: 118) + public static let mvmCoolGray6 = UIColor.color8Bits(red: 116, green: 118, blue: 118) //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- /// HEX: #B89B56 - public static let vzupGold = UIColor.getColor(red: 184, green: 155, blue: 68) + public static let vzupGold = UIColor.color8Bits(red: 184, green: 155, blue: 68) /// HEX: #F9D542 - public static let vzupYellow1 = UIColor.getColor(red: 249, green: 213, blue: 66) + public static let vzupYellow1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) /// HEX: #F4CA53 - public static let vzupYellow2 = UIColor.getColor(red: 244, green: 202, blue: 83) + public static let vzupYellow2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) /// HEX: #CC9B2D - public static let vzupYellow3 = UIColor.getColor(red: 204, green: 155, blue: 45) + public static let vzupYellow3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) //-------------------------------------------------- // MARK: - Functions @@ -75,14 +94,14 @@ extension UIColor { return UIColor(red: grayscale, green: grayscale, blue: grayscale, alpha: alpha) } - /// Convenience to get a UIColor via Int. - public class func getColor(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) -> UIColor { + /// Convenience to get a UIColor. + public class func color8Bits(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) -> UIColor { return UIColor(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: alpha) } - /// Convenience to get a UIColor via CGFloat. - public class func getColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor { + /// Convenience to get a UIColor. + public class func color8Bits(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor { return UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha) } @@ -90,11 +109,11 @@ extension UIColor { /// Gets UIColor via an 8 digit hex string. public class func getColorBy(hex: String) -> UIColor { - var hexint: UInt32 = 0 + var hexint: UInt64 = 0 let scanner = Scanner(string: hex) scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") - scanner.scanHexInt32(&hexint) + scanner.scanHexInt64(&hexint) return UIColor(red: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, green: (CGFloat((hexint & 0xFF00) >> 8)) / 255, @@ -105,11 +124,11 @@ extension UIColor { /// Gets UIColor via an 8 digit hex string. The last two being the alpha channel. public class func getColorWithTransparencyBy(hex: String) -> UIColor { - var hexint: UInt32 = 0 + var hexint: UInt64 = 0 let scanner = Scanner(string: hex) scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") - scanner.scanHexInt32(&hexint) + scanner.scanHexInt64(&hexint) return UIColor(red: (CGFloat((hexint & 0xFF000000) >> 24)) / 255, green: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, @@ -177,4 +196,15 @@ extension UIColor { return nil } + + public class func getColorAndHexFromName(_ name: String) -> ColorHexTuple? { + + for row in names { + if name == row.key { + return row.value + } + } + + return nil + } } diff --git a/MVMCoreUI/Models/Primitive Models/ColorModel.swift b/MVMCoreUI/Models/Primitive Models/Color.swift similarity index 63% rename from MVMCoreUI/Models/Primitive Models/ColorModel.swift rename to MVMCoreUI/Models/Primitive Models/Color.swift index 68fb16de..cafe5915 100644 --- a/MVMCoreUI/Models/Primitive Models/ColorModel.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -1,5 +1,5 @@ // -// ColorModel.swift +// Color.swift // MVMCoreUI // // Created by Kevin Christiano on 11/26/19. @@ -8,40 +8,49 @@ import UIKit -/** - Allows Hex values to be modeled into a UIColor object with its surrounding metadata. - */ -open class ColorModel: Codable { + +public final class Color: Codable { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - static var identifier: String = "color" - public let uiColor: UIColor - public var hex: String = "" + public private(set) var hex: String = "" + public private(set) var name: String = "" - public var red: CGFloat = 0 - public var green: CGFloat = 0 - public var blue: CGFloat = 0 - public var alpha: CGFloat = 1 + // Color metadata + public private(set) var red: CGFloat = 0 + public private(set) var green: CGFloat = 0 + public private(set) var blue: CGFloat = 0 + public private(set) var alpha: CGFloat = 1 public var hexWithHash: String { return "#" + hex } //-------------------------------------------------- - // MARK: - Class Initializer + // MARK: - Error + //-------------------------------------------------- + + enum ColorError: Error { + case badName(reason: String) + } + + //-------------------------------------------------- + // MARK: - Class Initializers //-------------------------------------------------- init(uiColor: UIColor) { self.uiColor = uiColor - hex = UIColor.hexString(for: uiColor) ?? "" - - if !hex.isEmpty { - determineRGBA() - } + determineRGBA() + } + + init?(name: String) { + guard let colorTuple = UIColor.getColorAndHexFromName(name) else { return nil } + self.uiColor = colorTuple.uiColor + self.hex = colorTuple.hex + determineRGBA() } //-------------------------------------------------- @@ -50,7 +59,15 @@ open class ColorModel: Codable { required public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - hex = try container.decode(String.self).replacingOccurrences(of: "#", with: "") + let colorString = try container.decode(String.self) + + if colorString.hasPrefix("#") { + hex = colorString.replacingOccurrences(of: "#", with: "") + } else { + guard let hex = UIColor.getColorAndHexFromName(colorString)?.hex else { throw ColorError.badName(reason: "Check the spelling of your color.") } + self.hex = hex.replacingOccurrences(of: "#", with: "") + name = colorString + } if hex.count == 8 { uiColor = UIColor.getColorWithTransparencyBy(hex: hex) @@ -77,6 +94,8 @@ open class ColorModel: Codable { private func determineRGBA() { + guard !hex.isEmpty else { return } + let redStart = hex.startIndex let redEnd = hex.index(redStart, offsetBy: 2) red = convertHexToFloat(start: redStart, end: redEnd) From b7ff1354b8085724796b755f64776e4314969a91 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 4 Dec 2019 16:21:10 -0500 Subject: [PATCH 033/272] clean up --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++-- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 3 +- MVMCoreUI/Atoms/Views/DashLineModel.swift | 2 +- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 1 + .../Atoms/Views/LabelModel/LabelModel.swift | 3 +- .../Atoms/Views/MultiProgressModel.swift | 1 + .../ViewConstrainingView+ModelExtension.swift | 24 ++++++++------- .../Models/ContainerMoleculeProtocol.swift | 17 +++++++++++ MVMCoreUI/Models/MoleculeProtocol.swift | 30 ------------------- .../Models/Molecules/HeadlineBodyModel.swift | 3 +- MVMCoreUI/Models/Molecules/LineModel.swift | 5 ++-- .../Models/Molecules/ListItemModel.swift | 4 +-- .../Molecules/MoleculeStackItemModel.swift | 5 ++-- .../Models/Molecules/MoleculeStackModel.swift | 4 +-- .../Models/Molecules/SeperatorModel.swift | 1 + .../Models/Molecules/TextFieldModel.swift | 2 ++ 16 files changed, 53 insertions(+), 60 deletions(-) create mode 100644 MVMCoreUI/Models/ContainerMoleculeProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c937cee8..8e1c2a00 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; + 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; @@ -85,9 +86,9 @@ D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; - D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -247,6 +248,7 @@ 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; @@ -499,6 +501,7 @@ 0AA33B322398134B0067DD0F /* Primitive Models */, 017BEB392360EEB40024EF95 /* PageModel.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, @@ -926,7 +929,7 @@ D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, DB891E822253FA8500022516 /* Label.swift */, - 94C2D9822386F3E30006CF46 /* LabelModel */, + 94C2D9822386F3E30006CF46 /* LabelModel */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, @@ -1288,6 +1291,7 @@ D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, + 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index c0f3ee8c..481d086f 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -9,8 +9,9 @@ import Foundation @objcMembers public class CaretViewModel: MoleculeProtocol { + public static var identifier: String = "caretView" - public var moleculeName: String + public var backgroundColor: String? public var strokeColor: String? public var isHidden: Bool? diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 8fd26fbf..6fff83c7 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -11,8 +11,8 @@ import Foundation @objcMembers public class DashLineModel: MoleculeProtocol { public static var identifier: String = "dashLine" public var moleculeName: String + public var backgroundColor: String? public var dashColor: String public var isHidden: Bool? - public var backgroundColor: String? } diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 2c9a6dd4..16c32d8f 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,6 +11,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeProtocol { public static var identifier: String = "image" public var moleculeName: String + public var backgroundColor: String? public var image: String public var accessibilityText: String? diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index cd1c5d12..d2c7947f 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -12,10 +12,11 @@ import Foundation @objcMembers public class LabelModel: MoleculeProtocol { public static var identifier: String = "label" public var moleculeName: String? + public var backgroundColor: String? + public var text: String public var accessibilityText: String? public var textColor: String? - public var backgroundColor: String? public var fontStyle: String? public var fontName: String? public var fontSize: CGFloat? diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index d63183e4..25522070 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -17,6 +17,7 @@ import Foundation @objcMembers public class MultiProgressBarModel: MoleculeProtocol { public static var identifier: String = "multiProgressBar" public var moleculeName: String + public var backgroundColor: String? public var progressList: [SingleProgressBarModel] public var thickness: CGFloat? public var roundedRect: Bool? diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift index 1e4cd849..90377f84 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift @@ -30,18 +30,20 @@ extension ViewConstrainingView { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) } - if let useHorizontalMargins = model?.useHorizontalMargins { - updateViewHorizontalDefaults = useHorizontalMargins - } - if let useVerticalMargins = model?.useVerticalMargins { - updateViewVerticalDefaults = useVerticalMargins - } + if let containerMoleculeModel = model as? ContainerMoleculeProtocol { + if let useHorizontalMargins = containerMoleculeModel.useHorizontalMargins { + updateViewHorizontalDefaults = useHorizontalMargins + } + if let useVerticalMargins = containerMoleculeModel.useVerticalMargins { + updateViewVerticalDefaults = useVerticalMargins + } - if let horizontalAlignment = model?.horizontalAlignment { - alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) - } - if let verticalAlignment = model?.verticalAlignment { - alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + if let horizontalAlignment = containerMoleculeModel.horizontalAlignment { + alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) + } + if let verticalAlignment = containerMoleculeModel.verticalAlignment { + alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + } } #warning("work on the below") diff --git a/MVMCoreUI/Models/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ContainerMoleculeProtocol.swift new file mode 100644 index 00000000..be3ffa60 --- /dev/null +++ b/MVMCoreUI/Models/ContainerMoleculeProtocol.swift @@ -0,0 +1,17 @@ +// +// ContainerMoleculeProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/4/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +protocol ContainerMoleculeProtocol: MoleculeProtocol { + var molecule: MoleculeProtocol? { get } + var useHorizontalMargins: Bool? { get } + var useVerticalMargins: Bool? { get } + var horizontalAlignment: String? { get } + var verticalAlignment: String? { get } +} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index e8120568..53f0fee4 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -4,42 +4,12 @@ public protocol MoleculeProtocol: Model { var moleculeName: String? { get } var backgroundColor: String? { get } var dictionary: [AnyHashable: Any]? { get } - var molecule: MoleculeProtocol? { get } - - var useHorizontalMargins: Bool? { get } - var useVerticalMargins: Bool? { get } - var horizontalAlignment: String? { get } - var verticalAlignment: String? { get } } extension MoleculeProtocol { public var moleculeName: String? { get { return Self.identifier } } - - public var molecule: MoleculeProtocol? { - get { return nil } - } - - public var backgroundColor: String? { - get { return toJSON()?["backgroundColor"] as? String } - } - - public var useHorizontalMargins: Bool? { - get { return toJSON()?["useHorizontalMargins"] as? Bool } - } - - public var useVerticalMargins: Bool? { - get { return toJSON()?["useVerticalMargins"] as? Bool } - } - - public var horizontalAlignment: String? { - get { return toJSON()?["horizontalAlignment"] as? String } - } - - public var verticalAlignment: String? { - get { return toJSON()?["verticalAlignment"] as? String } - } public var dictionary: [AnyHashable: Any]? { return toJSON() diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift index 557e74ba..76337703 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -10,12 +10,11 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeProtocol { public static var identifier: String = "headlineBody" - public var moleculeName: String? + public var backgroundColor: String? public var headline: LabelModel? public init(headline: LabelModel?) { self.headline = headline - self.moleculeName = Self.identifier } } diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift index 6266b03e..e00ba1fc 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Models/Molecules/LineModel.swift @@ -10,11 +10,10 @@ import UIKit @objcMembers public class LineModel: MoleculeProtocol { public static var identifier: String = "line" - public var moleculeName: String? + public var backgroundColor: String? public var type: String? public init(type: String?) { - self.type = type - self.moleculeName = Self.identifier + self.type = type } } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index da14a602..cd2fa39f 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -10,14 +10,13 @@ import Foundation @objcMembers public class ListItemModel: MoleculeProtocol { public static var identifier: String = "listItem" - public var moleculeName: String? public var molecule: MoleculeProtocol? + public var backgroundColor: String? public var action: ActionModel? public init(molecule: MoleculeProtocol?, actionMap: ActionModel?) { self.molecule = molecule self.action = actionMap - self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { @@ -28,7 +27,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 5bceda3e..c1ab6b15 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -10,12 +10,12 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeProtocol { public static var identifier: String = "stackItem" - public var moleculeName: String? + public var molecule: MoleculeProtocol? + public var backgroundColor: String? public init(molecule: MoleculeProtocol?) { self.molecule = molecule - self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { case moleculeName @@ -24,7 +24,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 30c15822..1ca9b9da 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -11,14 +11,13 @@ import Foundation @objcMembers public class MoleculeStackModel: MoleculeProtocol { public static var identifier: String = "moleculeStack" - public var moleculeName: String? + public var backgroundColor: String? public var molecules: [MoleculeStackItemModel]? public var axis: String? public init(axis: String?, molecules: [MoleculeStackItemModel]?) { self.axis = axis self.molecules = molecules - self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { @@ -29,7 +28,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) self.molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules) self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift index 705f904c..4c9689fd 100644 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -10,5 +10,6 @@ import UIKit class SeperatorModel: MoleculeProtocol { public static var identifier: String = "line" + public var backgroundColor: String? public var type: String? } diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift index 77454895..f9b11d5f 100644 --- a/MVMCoreUI/Models/Molecules/TextFieldModel.swift +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -9,7 +9,9 @@ import UIKit @objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { + public static var identifier: String = "textField" + public var backgroundColor: String? public var editable = true public var disabled = false From 3a1e3356bf148c9c7d647a10ecb8e871b7ac13df Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 6 Dec 2019 14:30:19 -0500 Subject: [PATCH 034/272] module molecule --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ .../MFViewController+Model.swift | 16 +++++ .../Molecules/ModuleMoleculeModel.swift | 2 +- MVMCoreUI/Molecules/ModuleMolecule.swift | 64 +++++-------------- .../MVMCoreUIDelegateObject.swift | 3 + .../MVMCoreUIMoleculeMappingObject.h | 8 +-- .../ModuleDelegateProtocol.swift | 14 ++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 8 files changed, 60 insertions(+), 52 deletions(-) create mode 100644 MVMCoreUI/OtherHandlers/ModuleDelegateProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 88dc904d..f022ef91 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; }; + 0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */; }; 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; @@ -293,6 +294,7 @@ 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; 017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = ""; }; 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.swift; sourceTree = ""; }; + 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleDelegateProtocol.swift; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; @@ -1038,6 +1040,7 @@ D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, + 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */, ); path = OtherHandlers; sourceTree = ""; @@ -1313,6 +1316,7 @@ D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */, + 0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 159a3260..fcdde9c3 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -8,8 +8,24 @@ import Foundation +extension MFViewController: ModuleDelegateProtocol { + public func getModuleWithName(_ moleculeName: String) -> Model? { + guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName), + let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), + let modelType = ModelRegistry.getType(for: moleculeName) else { + return nil + } + do { + return try modelType.decode(jsonDict: moduleJSON) + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + } + return nil + } +} public extension MFViewController { + @objc func parsePageJSON() { (self as? TemplateProtocol)?.parseTemplateJSON() diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift index e01d3def..9b7ebf01 100644 --- a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -8,7 +8,7 @@ import Foundation -class ModuleMoleculeModel: MoleculeProtocol { +public class ModuleMoleculeModel: MoleculeProtocol { public static var identifier: String = "moduleMolecule" public var moduleName: String public var backgroundColor: String? diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index ab252b5e..2087dff5 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -10,7 +10,7 @@ import UIKit open class ModuleMolecule: ViewConstrainingView, ModelMoleculeViewProtocol { - open var moduleMolecule: (UIView & MVMCoreUIMoleculeViewProtocol)? + open var moduleMolecule: (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol)? open override func updateView(_ size: CGFloat) { super.updateView(size) @@ -23,58 +23,28 @@ open class ModuleMolecule: ViewConstrainingView, ModelMoleculeViewProtocol { setUpWithModel(model, delegateObject, additionalData) guard let moduleMoleculeModel = model as? ModuleMoleculeModel, - let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMoleculeModel.moduleName) else { + let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else { // Critical error return } -// if moduleMolecule == nil { -// MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(<#T##model: MoleculeProtocol##MoleculeProtocol#>, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##constrainIfNeeded: Bool##Bool#>) -// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: true) { -// addSubview(moleculeView) -// NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) -// moduleMolecule = moleculeView -// -// isAccessibilityElement = false -// if moleculeView.accessibilityElements != nil { -// accessibilityElements = moleculeView.accessibilityElements -// } else { -// accessibilityElements = [moleculeView] -// } -// } -// } else { -// moduleMolecule?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData) -// } + if moduleMolecule == nil { + if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moduleModel, delegateObject, true) { + addSubview(moleculeView) + NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) + moduleMolecule = moleculeView as? (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol) + isAccessibilityElement = false + if moleculeView.accessibilityElements != nil { + accessibilityElements = moleculeView.accessibilityElements + } else { + accessibilityElements = [moleculeView] + } + } + } else { + moduleMolecule?.setWithModel(model, delegateObject, additionalData) + } } - -// // MARK: - MVMCoreUIMoleculeViewProtocol -// open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { -// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) -// -// guard let moduleName = json?.optionalStringForKey("moduleName"), -// let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { -// // Critical error -// return -// } -// -// if moduleMolecule == nil { -// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: true) { -// addSubview(moleculeView) -// NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) -// moduleMolecule = moleculeView -// -// isAccessibilityElement = false -// if moleculeView.accessibilityElements != nil { -// accessibilityElements = moleculeView.accessibilityElements -// } else { -// accessibilityElements = [moleculeView] -// } -// } -// } else { -// moduleMolecule?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData) -// } -// } open override func setAsMolecule() { super.setAsMolecule() diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index c0c8211f..6a7fbc05 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -13,6 +13,7 @@ open class MVMCoreUIDelegateObject: DelegateObject { public weak var buttonDelegate: ButtonDelegateProtocol? public weak var uiTextFieldDelegate: UITextFieldDelegate? public weak var moleculeDelegate: MoleculeDelegateProtocol? + public var moduleProtocol: ModuleDelegateProtocol? open override func setAll(withDelegate delegate: Any) { super.setAll(withDelegate: delegate) @@ -20,9 +21,11 @@ open class MVMCoreUIDelegateObject: DelegateObject { buttonDelegate = delegate as? ButtonDelegateProtocol uiTextFieldDelegate = delegate as? UITextFieldDelegate moleculeDelegate = delegate as? MoleculeDelegateProtocol + moduleProtocol = delegate as? ModuleDelegateProtocol } class func delegateObject(from controller: MVMCoreViewControllerProtocol?) -> MVMCoreUIDelegateObject? { return controller?.delegateObject?() as? MVMCoreUIDelegateObject } } + diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h index 6c1a84b2..776566c8 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h @@ -29,10 +29,10 @@ - (nullable UIView *)createMoleculeForName:(nonnull NSString *)name; /// Creates the molecule for the molecule json. -//- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject; -// -///// Creates the molecule for the molecule json. Also checks if the molecule needs to be constrained for a stack/list style situation. -//- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded; +- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject; + +/// Creates the molecule for the molecule json. Also checks if the molecule needs to be constrained for a stack/list style situation. +- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded; #pragma mark - Convenience diff --git a/MVMCoreUI/OtherHandlers/ModuleDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModuleDelegateProtocol.swift new file mode 100644 index 00000000..70c271ce --- /dev/null +++ b/MVMCoreUI/OtherHandlers/ModuleDelegateProtocol.swift @@ -0,0 +1,14 @@ +// +// ModuleDelegateProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/6/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +public protocol ModuleDelegateProtocol { + func getModuleWithName(_ moleculeName: String) -> Model? +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 983fac13..f97ed9b5 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -30,5 +30,6 @@ import Foundation ModelRegistry.register(LabelAttributeUnderlineModel.self) ModelRegistry.register(LabelAttributeStrikeThroughModel.self) ModelRegistry.register(LabelAttributeActionModel.self) + ModelRegistry.register(ModuleMoleculeModel.self) } } From 16cc667b02bc6218c95e1ef32300f3df5a4efeb4 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Mon, 9 Dec 2019 14:15:55 -0500 Subject: [PATCH 035/272] Expands tappable area of Link --- MVMCoreUI/Atoms/Buttons/Link.swift | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index ef4a1477..2880fcd3 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -14,6 +14,9 @@ import UIKit return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) }() + private var additionalData: [AnyHashable: Any]? + private var delegateObject: MVMCoreUIDelegateObject? + public override init(frame: CGRect) { super.init(frame: frame) self.setupView() @@ -50,6 +53,17 @@ import UIKit contextRef?.closePath() contextRef?.drawPath(using: .stroke) } + + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + + let faultTolerance: CGFloat = 20.0 + let area = bounds.insetBy(dx: -faultTolerance, dy: -faultTolerance) + return area.contains(point) + } + + open override func touchesEnded(_ touches: Set, with event: UIEvent?) { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } } extension Link: MVMCoreViewProtocol { @@ -100,14 +114,18 @@ extension Link: MVMCoreUIMoleculeViewProtocol { public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { if let unwrappedJson = json { + actionMap = unwrappedJson + self.additionalData = additionalData + self.delegateObject = delegateObject + buttonDelegate = delegateObject?.buttonDelegate + let color = unwrappedJson.stringForkey(KeyTextColor) setTitleColor(UIColor.mfGet(forHex: color), for: .normal) - setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData) + self.titleLabel?.numberOfLines = 0 + self.titleLabel?.lineBreakMode = .byWordWrapping; + self.setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) - //enabling must happen after setWithActionMap is called because - //that method enables buttons when the actionMap does not contain - //disableAction = true if let enabled = unwrappedJson[KeyEnabled] as? Bool { isEnabled = enabled } From 7c7232fe6a2f326c761e177b5288548c0a170e1f Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 9 Dec 2019 14:36:14 -0500 Subject: [PATCH 036/272] remove PageModel --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ---- MVMCoreUI/BaseControllers/MFViewController.h | 3 --- MVMCoreUI/Models/Template/PageModel.swift | 19 ------------------- 3 files changed, 26 deletions(-) delete mode 100644 MVMCoreUI/Models/Template/PageModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f022ef91..3ae8d221 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -36,7 +36,6 @@ 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; }; 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */; }; 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */; }; - 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB392360EEB40024EF95 /* PageModel.swift */; }; 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */; }; 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3F23620A230024EF95 /* TextFieldModel.swift */; }; 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */; }; @@ -285,7 +284,6 @@ 01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButtonSwitch.swift; sourceTree = ""; }; 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonLabel.swift; sourceTree = ""; }; - 017BEB392360EEB40024EF95 /* PageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModel.swift; sourceTree = ""; }; 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFViewController+Model.swift"; sourceTree = ""; }; 017BEB3F23620A230024EF95 /* TextFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldModel.swift; sourceTree = ""; }; 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormModelProtocol.swift; sourceTree = ""; }; @@ -525,7 +523,6 @@ isa = PBXGroup; children = ( 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, - 017BEB392360EEB40024EF95 /* PageModel.swift */, 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */, 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */, 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */, @@ -1308,7 +1305,6 @@ 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, - 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index be8c3bd2..c1415df4 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -33,15 +33,12 @@ @class MVMCoreUITabBarPageControlViewController; @class MVMAnimationManager; @class DelegateObject; -@class PageModel; @interface MFViewController : UIViewController // Stores the load object that this screen was loaded with. @property (nullable, strong, nonatomic) MVMCoreLoadObject *loadObject; -@property (nullable, strong, nonatomic) PageModel *pageModel; - // The current selected text field. @property (nullable, weak, nonatomic) __block id selectedField; diff --git a/MVMCoreUI/Models/Template/PageModel.swift b/MVMCoreUI/Models/Template/PageModel.swift deleted file mode 100644 index a47c78e1..00000000 --- a/MVMCoreUI/Models/Template/PageModel.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// Page.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/23/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -@objcMembers public class PageModel: Codable { - public var template: String? - public var pageType: String? - public var screenHeading: String? - public var isAtomicTabs: Bool? = false - public var header: HeaderModel? - public var molecules: [ListItemModel]? - public var moleculeStack: MoleculeStackModel? -} From 2fa4f71d313128f6c58aa7e0d240889e15a510fa Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 9 Dec 2019 15:37:00 -0500 Subject: [PATCH 037/272] cool icon. --- MVMCoreUI/Models/Primitive Models/Color.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift index cafe5915..027b826e 100644 --- a/MVMCoreUI/Models/Primitive Models/Color.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -18,7 +18,7 @@ public final class Color: Codable { public private(set) var hex: String = "" public private(set) var name: String = "" - // Color metadata + // Color metadata 🎨 public private(set) var red: CGFloat = 0 public private(set) var green: CGFloat = 0 public private(set) var blue: CGFloat = 0 From fb2cade1574d8935a810ff78a060c8695314c038 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 12 Dec 2019 09:30:00 -0500 Subject: [PATCH 038/272] Fixed spacing before colon as per code review comment --- MVMCoreUI/Atoms/Buttons/Link.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 2880fcd3..f7dd492e 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -27,7 +27,7 @@ import UIKit self.setupView() } - public convenience init(width:CGFloat) { + public convenience init(width: CGFloat) { self.init() self.setupView() self.updateView(width) @@ -112,7 +112,7 @@ extension Link: MVMCoreUIMoleculeViewProtocol { self.setTitleColor(UIColor.mfTextButton(), for: .normal) } - public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { if let unwrappedJson = json { actionMap = unwrappedJson self.additionalData = additionalData @@ -140,7 +140,7 @@ extension Link: MVMCoreUIMoleculeViewProtocol { } } - public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public static func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 31 } } From 513583547170c5db35cc66c496fd1a1835fa6f83 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 12 Dec 2019 09:32:09 -0500 Subject: [PATCH 039/272] Removed UIColor prefix as per code review comments --- MVMCoreUI/Atoms/Buttons/Link.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index f7dd492e..b38c5f04 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -89,8 +89,8 @@ extension Link: MVMCoreViewProtocol { self.translatesAutoresizingMaskIntoConstraints = false; self.backgroundColor = .clear self.contentMode = .redraw - self.setTitleColor(UIColor.mfTextButton(), for: .normal) - self.setTitleColor(UIColor.mfCharcoal(), for: .highlighted) + self.setTitleColor(.mfTextButton(), for: .normal) + self.setTitleColor(.mfCharcoal(), for: .highlighted) // left alignment by default self.titleLabel?.textAlignment = .left self.contentHorizontalAlignment = .left @@ -109,7 +109,7 @@ extension Link: MVMCoreViewProtocol { extension Link: MVMCoreUIMoleculeViewProtocol { public func reset() { - self.setTitleColor(UIColor.mfTextButton(), for: .normal) + self.setTitleColor(.mfTextButton(), for: .normal) } public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { @@ -120,7 +120,7 @@ extension Link: MVMCoreUIMoleculeViewProtocol { buttonDelegate = delegateObject?.buttonDelegate let color = unwrappedJson.stringForkey(KeyTextColor) - setTitleColor(UIColor.mfGet(forHex: color), for: .normal) + setTitleColor(.mfGet(forHex: color), for: .normal) self.titleLabel?.numberOfLines = 0 self.titleLabel?.lineBreakMode = .byWordWrapping; From b8e0fbff75bc54256eca9d7e6e91dc8d8106bce0 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 12 Dec 2019 09:33:03 -0500 Subject: [PATCH 040/272] Removed line spaces --- MVMCoreUI/Atoms/Buttons/Link.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index b38c5f04..d3e153f8 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -96,12 +96,10 @@ extension Link: MVMCoreViewProtocol { self.contentHorizontalAlignment = .left if let constant = self.sizeObject?.standardSize { - let heightConstraint = NSLayoutConstraint(item: self as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) self.addConstraint(heightConstraint) heightConstraint.isActive = true self.heightConstraint = heightConstraint - } } } From 3001f1df781e5f056377d38ec84a0a8f88fa01d7 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 12 Dec 2019 10:00:59 -0500 Subject: [PATCH 041/272] Remove self where it is not necessary for clarity --- MVMCoreUI/Atoms/Buttons/Link.swift | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index d3e153f8..1aa7b40d 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -86,18 +86,18 @@ extension Link: MVMCoreViewProtocol { } public func setupView() { - self.translatesAutoresizingMaskIntoConstraints = false; - self.backgroundColor = .clear - self.contentMode = .redraw - self.setTitleColor(.mfTextButton(), for: .normal) - self.setTitleColor(.mfCharcoal(), for: .highlighted) + translatesAutoresizingMaskIntoConstraints = false + backgroundColor = .clear + contentMode = .redraw + setTitleColor(.mfTextButton(), for: .normal) + setTitleColor(.mfCharcoal(), for: .highlighted) // left alignment by default - self.titleLabel?.textAlignment = .left - self.contentHorizontalAlignment = .left + titleLabel?.textAlignment = .left + contentHorizontalAlignment = .left if let constant = self.sizeObject?.standardSize { let heightConstraint = NSLayoutConstraint(item: self as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) - self.addConstraint(heightConstraint) + addConstraint(heightConstraint) heightConstraint.isActive = true self.heightConstraint = heightConstraint } @@ -120,9 +120,9 @@ extension Link: MVMCoreUIMoleculeViewProtocol { let color = unwrappedJson.stringForkey(KeyTextColor) setTitleColor(.mfGet(forHex: color), for: .normal) - self.titleLabel?.numberOfLines = 0 - self.titleLabel?.lineBreakMode = .byWordWrapping; - self.setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) + titleLabel?.numberOfLines = 0 + titleLabel?.lineBreakMode = .byWordWrapping; + setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) if let enabled = unwrappedJson[KeyEnabled] as? Bool { isEnabled = enabled @@ -134,7 +134,7 @@ extension Link: MVMCoreUIMoleculeViewProtocol { self.heightConstraint?.constant = 0 } else { guard let standardSize = sizeObject?.standardSize else { return } - self.heightConstraint?.constant = standardSize + heightConstraint?.constant = standardSize } } From 3fc3b6cb0a431863a39217542beb064cb8a6e9b9 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 12 Dec 2019 10:39:21 -0500 Subject: [PATCH 042/272] Removes convenience init since updateView is called by the framework and so does not need to be part of initialization --- MVMCoreUI/Atoms/Buttons/Link.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 1aa7b40d..49292fe5 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -27,12 +27,6 @@ import UIKit self.setupView() } - public convenience init(width: CGFloat) { - self.init() - self.setupView() - self.updateView(width) - } - open override func draw(_ rect: CGRect) { guard let textRect = self.titleLabel?.frame else { return } From 9a4a5139ed56a6910ba4ec98bbe2ba0f13045368 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 12 Dec 2019 11:47:33 -0500 Subject: [PATCH 043/272] fixes --- .../Items/DropDownFilterTableViewCell.swift | 20 +++++++++---------- MVMCoreUI/Molecules/Items/TableViewCell.swift | 2 +- .../Templates/MoleculeListTemplate.swift | 16 +++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 99b14870..2f856074 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -51,16 +51,16 @@ import UIKit super.updateView(size) dropDown?.updateView(size) } - -// // MARK: - MoleculeDelegateProtocol -// public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { -// bottomSeparatorView?.style = .none -// self.delegateObject = delegateObject -// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) -// dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate -// dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate -// dropDown?.setWithJSON(json?.optionalDictionaryForKey("dropDown"), delegateObject: delegateObject, additionalData: additionalData) -// } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + bottomSeparatorView?.style = .none + self.delegateObject = delegateObject + super.setWithModel(model, delegateObject, additionalData) + + dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate + dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate + dropDown?.setWithJSON(json?.optionalDictionaryForKey("dropDown"), delegateObject: delegateObject, additionalData: additionalData) + } public override func reset() { super.reset() diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index ffaefcb5..20c48487 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -176,7 +176,7 @@ import UIKit // override the separator if let separator = model.separator { addSeparatorsIfNeeded() - (bottomSeparatorView as? ModelMoleculeViewProtocol)?.setWithModel(separator, nil, nil) + bottomSeparatorView?.setWithModel(separator, nil, nil) } guard let moleculeModel = model.molecule else { return } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index fd1885cc..534d3228 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -160,14 +160,14 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol public func removeMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality -// for molecule in molecules { -// if let removeIndex = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in -// return molecule == moleculeInfo.molecule -// }) { -// moleculesInfo?.remove(at: removeIndex) -// indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) -// } -// } + for molecule in molecules { + if let removeIndex = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in + return molecule.toJSONString() == moleculeInfo.molecule.toJSONString() + }) { + moleculesInfo?.remove(at: removeIndex) + indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) + } + } self.tableView?.deleteRows(at: indexPaths, with: animation) self.updateViewConstraints() self.view.layoutIfNeeded() From d3dbfdd9976d7b9680750ccaaa188cc45018551c Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 12 Dec 2019 15:01:54 -0500 Subject: [PATCH 044/272] changes size object to private since it shouldn't be accessed from outside the class --- MVMCoreUI/Atoms/Buttons/Link.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 49292fe5..6107fce0 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers open class Link: MFCustomButton { - lazy var sizeObject: MFSizeObject? = { + private lazy var sizeObject: MFSizeObject? = { return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) }() From 439261e4c4f6ca782c991a3f4162681a05b6ce65 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 12 Dec 2019 15:23:30 -0500 Subject: [PATCH 045/272] Make Link subclass from View instead of MFCustomButton The bounds of the Link often extend far beyond the width of the button text, which, if MFCustomButton is used, extend the tappable area far beyond the link. --- MVMCoreUI/Atoms/Buttons/Link.swift | 78 +++++++++++++++++------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 6107fce0..99a01114 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class Link: MFCustomButton { +@objcMembers open class Link: View { private lazy var sizeObject: MFSizeObject? = { return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) @@ -16,6 +16,7 @@ import UIKit private var additionalData: [AnyHashable: Any]? private var delegateObject: MVMCoreUIDelegateObject? + public let linkButton = MFCustomButton() public override init(frame: CGRect) { super.init(frame: frame) @@ -28,12 +29,12 @@ import UIKit } open override func draw(_ rect: CGRect) { - guard let textRect = self.titleLabel?.frame else { return } + guard let textRect = self.linkButton.titleLabel?.frame else { return } let contextRef = UIGraphicsGetCurrentContext() //set to the same color as the text - if let color = self.titleLabel?.textColor?.cgColor { + if let color = self.linkButton.titleLabel?.textColor?.cgColor { contextRef?.setStrokeColor(color) } @@ -49,86 +50,97 @@ import UIKit } override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { - let faultTolerance: CGFloat = 20.0 - let area = bounds.insetBy(dx: -faultTolerance, dy: -faultTolerance) + let area = linkButton.bounds.insetBy(dx: -faultTolerance, dy: -faultTolerance) return area.contains(point) } open override func touchesEnded(_ touches: Set, with event: UIEvent?) { - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + if linkButton.isEnabled { + MVMCoreActionHandler.shared()?.handleAction(with: linkButton.actionMap, additionalData: additionalData, delegateObject: delegateObject) + } } } -extension Link: MVMCoreViewProtocol { +//MARK: MVMCoreViewProtocol +extension Link { - public func updateView(_ size: CGFloat) { + public override func updateView(_ size: CGFloat) { MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in guard let self = self else { return } - var width = size if MVMCoreGetterUtility.fequal(a: Float(CGFloat.leastNormalMagnitude), b: Float(size)) { width = MVMCoreUISplitViewController.getApplicationViewWidth() } - self.titleLabel?.font = MFStyler.fontB2(forWidth: width) - guard let heightConstraint = self.heightConstraint else { return } + self.linkButton.titleLabel?.font = MFStyler.fontB2(forWidth: width) + guard let heightConstraint = self.linkButton.heightConstraint else { return } if !MVMCoreGetterUtility.fequal(a: 0, b: Float(heightConstraint.constant)) { guard let sizeObject = self.sizeObject else { return } - self.heightConstraint?.constant = sizeObject.getValueBased(onSize: width) + self.linkButton.heightConstraint?.constant = sizeObject.getValueBased(onSize: width) } }) } - public func setupView() { + public override func setupView() { + linkButton.isUserInteractionEnabled = false + linkButton.translatesAutoresizingMaskIntoConstraints = false + addSubview(linkButton) + NSLayoutConstraint.activate([ + linkButton.leadingAnchor.constraint(equalTo: leadingAnchor), + linkButton.topAnchor.constraint(equalTo: topAnchor), + trailingAnchor.constraint(greaterThanOrEqualTo: linkButton.trailingAnchor), + bottomAnchor.constraint(equalTo: linkButton.bottomAnchor) + ]) translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear contentMode = .redraw - setTitleColor(.mfTextButton(), for: .normal) - setTitleColor(.mfCharcoal(), for: .highlighted) - // left alignment by default - titleLabel?.textAlignment = .left - contentHorizontalAlignment = .left + linkButton.setTitleColor(.mfTextButton(), for: .normal) + linkButton.setTitleColor(.mfCharcoal(), for: .highlighted) + linkButton.titleLabel?.textAlignment = .left + linkButton.contentHorizontalAlignment = .left if let constant = self.sizeObject?.standardSize { let heightConstraint = NSLayoutConstraint(item: self as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) addConstraint(heightConstraint) heightConstraint.isActive = true - self.heightConstraint = heightConstraint + self.linkButton.heightConstraint = heightConstraint } } } -extension Link: MVMCoreUIMoleculeViewProtocol { +//MARK: MVMCoreUIMoleculeViewProtocol +extension Link { - public func reset() { - self.setTitleColor(.mfTextButton(), for: .normal) + public override func reset() { + self.linkButton.setTitleColor(.mfTextButton(), for: .normal) + self.linkButton.isEnabled = true } - public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { if let unwrappedJson = json { - actionMap = unwrappedJson + linkButton.actionMap = unwrappedJson self.additionalData = additionalData self.delegateObject = delegateObject - buttonDelegate = delegateObject?.buttonDelegate + linkButton.buttonDelegate = delegateObject?.buttonDelegate let color = unwrappedJson.stringForkey(KeyTextColor) - setTitleColor(.mfGet(forHex: color), for: .normal) + linkButton.setTitleColor(.mfGet(forHex: color), for: .normal) - titleLabel?.numberOfLines = 0 - titleLabel?.lineBreakMode = .byWordWrapping; - setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) + linkButton.titleLabel?.numberOfLines = 0 + linkButton.titleLabel?.lineBreakMode = .byWordWrapping; + linkButton.setTitle(linkButton.actionMap?.stringForkey(KeyTitle), for: .normal) if let enabled = unwrappedJson[KeyEnabled] as? Bool { - isEnabled = enabled + linkButton.isEnabled = enabled } } - if let title = self.title(for: .normal), + if let title = self.linkButton.title(for: .normal), title.isEmpty { - self.heightConstraint?.constant = 0 + self.linkButton.heightConstraint?.constant = 0 } else { guard let standardSize = sizeObject?.standardSize else { return } - heightConstraint?.constant = standardSize + linkButton.heightConstraint?.constant = standardSize } } From 8d811f229f6ac2b75f7bfce45a68e615b59e5043 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 12 Dec 2019 15:28:47 -0500 Subject: [PATCH 046/272] change from viewconstrainingview to view --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ MVMCoreUI/Atoms/Views/CaretView.swift | 2 ++ MVMCoreUI/Atoms/Views/CaretViewModel.swift | 4 +++- MVMCoreUI/Atoms/Views/DashLine.swift | 2 ++ MVMCoreUI/Atoms/Views/DashLineModel.swift | 8 ++++--- .../Atoms/Views/LeftRightLabelModel.swift | 19 +++++++++++++++ .../Atoms/Views/LeftRightLabelView.swift | 20 ++++++++++++++-- MVMCoreUI/Atoms/Views/MultiProgress.swift | 6 +++-- .../Atoms/Views/MultiProgressModel.swift | 4 +++- MVMCoreUI/Atoms/Views/ProgressBar.swift | 3 ++- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 4 +++- MVMCoreUI/BaseClasses/Control.swift | 7 +++++- .../SwitchMolecules/HeadlineBodySwitch.swift | 23 +++++++++++++++---- .../OtherHandlers/MoleculeObjectMapping.swift | 3 +++ 14 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3ae8d221..0ff03255 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -63,6 +63,7 @@ 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; + 9402C35023A2CEA3004B974C /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -311,6 +312,7 @@ 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; + 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.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 = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; @@ -949,6 +951,7 @@ DBC4391722442197001AB423 /* DashLine.swift */, 944589202385D6E900DE9FD4 /* DashLineModel.swift */, DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, + 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */, 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, @@ -1268,6 +1271,7 @@ files = ( 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, 012CA9E423888B1B003F810F /* ThreeLayerPageTemplateModel.swift in Sources */, + 9402C35023A2CEA3004B974C /* LeftRightLabelModel.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index c02db833..f34ab776 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -125,7 +125,9 @@ open class CaretView: View { } } + //MARK: - MVMCoreMoleculeViewProtocol override public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) guard let caretModel = model as? CaretViewModel else { return } diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index 481d086f..37d095d8 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -10,7 +10,9 @@ import Foundation @objcMembers public class CaretViewModel: MoleculeProtocol { - public static var identifier: String = "caretView" + public static var identifier: String { + get{ return "caretView" } + } public var backgroundColor: String? public var strokeColor: String? diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 937b7313..595c7605 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -84,7 +84,9 @@ open class DashLine: View { } } + //MARK: - MVMCoreMoleculeViewProtocol public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) guard let dashLineModel = model as? DashLineModel else { return } diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 6fff83c7..3ba46186 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -9,10 +9,12 @@ import Foundation @objcMembers public class DashLineModel: MoleculeProtocol { - public static var identifier: String = "dashLine" - public var moleculeName: String + public static var identifier: String { + get { return "dashLine" } + } + public var moleculeName: String = "" public var backgroundColor: String? - public var dashColor: String + public var dashColor: String = "" public var isHidden: Bool? } diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift new file mode 100644 index 00000000..ba07fc8b --- /dev/null +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -0,0 +1,19 @@ +// +// LeftRightLabelModel.swift +// MVMCoreUI +// +// Created by Ryan on 12/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class LeftRightLabelModel: MoleculeProtocol { + public var backgroundColor: String? + public var leftText: LabelModel + public var rightText: LabelModel + + public static var identifier: String { + get{ return "leftRightLabel" } + } +} diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift index a059aef5..979d2abb 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers open class LeftRightLabelView: ViewConstrainingView { +@objcMembers open class LeftRightLabelView: View { //------------------------------------------------------ // MARK: - Outlets //------------------------------------------------------ @@ -28,7 +28,7 @@ import Foundation // MARK: - Initialization //------------------------------------------------------ - public init() { + public override init() { super.init(frame: .zero) } @@ -176,4 +176,20 @@ import Foundation constrainLeftLabel() } } + + //MARK: - MVMCoreMoleculeViewProtocol + + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let leftRightLabelModel = model as? LeftRightLabelModel else { + return + } + leftTextLabel.setWithModel(leftRightLabelModel.leftText, delegateObject, additionalData) + rightTextLabel.setWithModel(leftRightLabelModel.rightText, delegateObject, additionalData) + if !leftTextLabel.hasText { + constrainRightLabel() + } else if !rightTextLabel.hasText { + constrainLeftLabel() + } + } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index 6f35bcc5..bbe8ed76 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class MultiProgress: ViewConstrainingView, ModelMoleculeViewProtocol { +@objcMembers open class MultiProgress: View { ///passing value to progressList creates corresponding progress bars var progressList: Array? { @@ -60,7 +60,9 @@ import UIKit } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + //MARK: - MVMCoreMoleculeViewProtocol + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) guard let multiProgressModel = model as? MultiProgressBarModel else { return } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 25522070..62397f69 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -15,7 +15,9 @@ import Foundation } @objcMembers public class MultiProgressBarModel: MoleculeProtocol { - public static var identifier: String = "multiProgressBar" + public static var identifier: String { + get{ return "multiProgressBar"} + } public var moleculeName: String public var backgroundColor: String? public var progressList: [SingleProgressBarModel] diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 45ce85d6..0a29d62a 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -50,13 +50,14 @@ import Foundation public func updateView(_ size: CGFloat) { } + //MARK: - MVMCoreMoleculeViewProtocol public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { guard let progressBarModel = model as? ProgressBarModel else { return } isRounded = progressBarModel.isRounded ?? false thickness = progressBarModel.thickness ?? 8 - progress = (progressBarModel.percentage ?? 0)/100.0 + progress = (progressBarModel.percentage )/100.0 if let progressColor = progressBarModel.progressColor { progressTintColor = UIColor.mfGet(forHex: progressColor) } diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 3450fc87..aa5912a7 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -9,7 +9,9 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeProtocol { - public static var identifier: String = "progressbar" + public static var identifier: String { + get { return "progressbar" } + } public var moleculeName: String public var isRounded: Bool? diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index fdf8204f..942cda65 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -8,8 +8,9 @@ import UIKit -public class Control: UIControl { +public class Control: UIControl, ModelMoleculeViewProtocol { var json: [AnyHashable: Any]? + public var model: MoleculeProtocol? private var initialSetupPerformed = false @@ -34,6 +35,10 @@ public class Control: UIControl { setupView() } } + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + self.model = model + } } extension Control: MVMCoreViewProtocol { diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 79110460..20da726b 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class HeadlineBodySwitch: ViewConstrainingView { +@objcMembers open class HeadlineBodySwitch: View { public let headlineBody = HeadlineBody(frame: .zero) public let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault() @@ -27,13 +27,27 @@ import UIKit headlineBody.styleListItem() let view = MVMCoreUICommonViewsUtility.commonView() addSubview(view) - pinView(toSuperView: view) + NSLayoutConstraint.constraintPinSubview(toSuperview: view) view.addSubview(headlineBody) view.addSubview(mvmSwitch) NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: mvmSwitch) } + + //MARK: - MVMCoreMoleculeViewProtocol + + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) +// guard let headlineModel = model as? headlinebodyswitch +// headlineBody.setWithModel(mode, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##additionalData: [String : AnyHashable]?##[String : AnyHashable]?#>) + } + + public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 30 + } + + // MARK: - MVMCoreUIMoleculeViewProtocol open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) @@ -41,12 +55,11 @@ import UIKit mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData) } - open override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + open class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 30 } - open override func setAsMolecule() { - super.setAsMolecule() + open func setAsMolecule() { headlineBody.setAsMolecule() (mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() headlineBody.styleListItem() diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index f97ed9b5..86395407 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -24,12 +24,15 @@ import Foundation ModelRegistry.register(CaretViewModel.self) ModelRegistry.register(DashLineModel.self) ModelRegistry.register(ImageViewModel.self) + //need to move labelattributemodel to different method ModelRegistry.register(LabelAttributeFontModel.self) ModelRegistry.register(LabelAttributeColorModel.self) ModelRegistry.register(LabelAttributeImageModel.self) ModelRegistry.register(LabelAttributeUnderlineModel.self) ModelRegistry.register(LabelAttributeStrikeThroughModel.self) ModelRegistry.register(LabelAttributeActionModel.self) + // ModelRegistry.register(ModuleMoleculeModel.self) + ModelRegistry.register(LeftRightLabelModel.self) } } From 52186bf0898a00240b646c7ea8a21f2af2ea79e8 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 12 Dec 2019 17:22:26 -0500 Subject: [PATCH 047/272] add protocol func into view --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- MVMCoreUI/Atoms/Views/CaretView.swift | 2 +- MVMCoreUI/Atoms/Views/DashLine.swift | 2 +- MVMCoreUI/Atoms/Views/DashLineModel.swift | 7 ++-- MVMCoreUI/BaseClasses/View.swift | 4 +++ MVMCoreUI/Molecules/HeadlineBodyButton.swift | 4 +-- .../SwitchMolecules/HeadlineBodySwitch.swift | 2 +- .../HeadlineBody.swift | 35 ++++++++++--------- .../HeadlineBodyModel.swift | 4 +-- 9 files changed, 34 insertions(+), 28 deletions(-) rename MVMCoreUI/{Models/Molecules => Molecules/VerticalCombinationViews}/HeadlineBodyModel.swift (74%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0ff03255..61ee1780 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -577,7 +577,6 @@ 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, - 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */, @@ -664,6 +663,7 @@ isa = PBXGroup; children = ( D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, + 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */, ); diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index f34ab776..3a2c5561 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -99,7 +99,7 @@ open class CaretView: View { //------------------------------------------------------ // Default values for view. - @objc open func setAsMolecule() { + @objc open override func setAsMolecule() { defaultState() } diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 595c7605..52ed9a65 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -64,7 +64,7 @@ open class DashLine: View { //------------------------------------------------------ // Default values for view. - @objc open func setAsMolecule() { + @objc open override func setAsMolecule() { backgroundColor = .clear isHidden = false } diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 3ba46186..79367f35 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -12,9 +12,12 @@ import Foundation public static var identifier: String { get { return "dashLine" } } - public var moleculeName: String = "" public var backgroundColor: String? - public var dashColor: String = "" + public var dashColor: String public var isHidden: Bool? + + public init(dashColor: String) { + self.dashColor = dashColor + } } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index de76f739..ec029b96 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -66,5 +66,9 @@ extension View: MVMCoreUIMoleculeViewProtocol { open func reset() { backgroundColor = .clear } + + open func setAsMolecule() { + + } } diff --git a/MVMCoreUI/Molecules/HeadlineBodyButton.swift b/MVMCoreUI/Molecules/HeadlineBodyButton.swift index 87efc9b6..02852d51 100644 --- a/MVMCoreUI/Molecules/HeadlineBodyButton.swift +++ b/MVMCoreUI/Molecules/HeadlineBodyButton.swift @@ -9,7 +9,7 @@ import UIKit -@objcMembers open class HeadlineBodyButton: ViewConstrainingView { +@objcMembers open class HeadlineBodyButton: View { //------------------------------------------------------ // MARK: - Outlets //------------------------------------------------------ @@ -33,7 +33,7 @@ import UIKit // MARK: - Initialization //------------------------------------------------------ - public init() { + public override init() { super.init(frame: .zero) } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 20da726b..7e5fcda8 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -59,7 +59,7 @@ import UIKit return 30 } - open func setAsMolecule() { + open override func setAsMolecule() { headlineBody.setAsMolecule() (mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() headlineBody.styleListItem() diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index cc313d59..a70b106d 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -8,7 +8,7 @@ import UIKit -open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol { +open class HeadlineBody: View { let headlineLabel = Label.commonLabelH2(true) let messageLabel = Label.commonLabelB2(true) var spaceBetweenLabelsConstant = PaddingTwo @@ -81,7 +81,7 @@ open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol { let view = MVMCoreUICommonViewsUtility.commonView() addSubview(view) - pinView(toSuperView: view) + NSLayoutConstraint.constraintPinSubview(toSuperview: view) view.addSubview(headlineLabel) view.addSubview(messageLabel) @@ -119,9 +119,9 @@ open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol { } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - setUpWithModel(model, delegateObject, additionalData) + super.setWithModel(model, delegateObject, additionalData) guard let headlineBodyModel = model as? HeadlineBodyModel else { return } @@ -131,25 +131,26 @@ open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol { headlineLabel.setWithModel(headlineBodyModel.headline, delegateObject, additionalData) messageLabel.setWithModel(headlineBodyModel.body, delegateObject, additionalData) } -// // MARK: - MVMCoreUIMoleculeViewProtocol -// open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { -// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) -// -// style(with: json?.optionalStringForKey("style")) -// -// let headlineJSON = json?.optionalDictionaryForKey("headline") -// headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) -// -// let bodyJSON = json?.optionalDictionaryForKey("body") -// messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) -// } + + // MARK: - MVMCoreUIMoleculeViewProtocol + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + + style(with: json?.optionalStringForKey("style")) + + let headlineJSON = json?.optionalDictionaryForKey("headline") + headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) + + let bodyJSON = json?.optionalDictionaryForKey("body") + messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) + } open override func reset() { super.reset() stylePageHeader() } - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 58 } } diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift similarity index 74% rename from MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift rename to MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 0e4f22f6..c6dbd059 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -15,11 +15,9 @@ import Foundation public var style: String? public var backgroundColor: String? - public init(headline: LabelModel, body: LabelModel, style: String?, backgroundColor: String?) { + public init(headline: LabelModel, body: LabelModel) { self.headline = headline self.body = body - self.style = style - self.backgroundColor = backgroundColor } } From ce1559dc15216ed3a7151af08911daff42c2e3a9 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 12 Dec 2019 17:28:02 -0500 Subject: [PATCH 048/272] add decode array method --- MVMCoreUI/Models/Extensions/ModelHelper.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index da5e0d56..b4d0b1e2 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -20,4 +20,15 @@ extension KeyedDecodingContainer where Key : CodingKey { public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } + + public func decodeArray(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol] { + guard let models = try decodeArray(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { + throw ModelRegistry.Error.decoderError + } + return models + } + + public func decodeArrayIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { + return try decodeArrayIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] + } } From 58ec1abcfed85af45484dc8f2ad4f16a66cb9deb Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 13 Dec 2019 11:07:32 -0500 Subject: [PATCH 049/272] list model protocol --- MVMCoreUI.xcodeproj/project.pbxproj | 34 ++++++++++--- .../CollectionCellMoleculeProtocol.swift | 0 .../ContainerMoleculeProtocol.swift | 0 .../FormModelProtocol.swift | 0 .../ListItemModelProtocol.swift | 14 ++++++ .../MoleculeProtocol.swift | 0 .../PagingMoleculeProtocol.swift | 0 .../TemplateModelProtocol.swift | 0 .../TemplateProtocol.swift | 0 .../Molecules/DropDownListItemModel.swift | 46 +++++++++++++++++ .../Models/Molecules/DropDownModel.swift | 17 +++++++ .../Models/Molecules/ListItemModel.swift | 9 ++-- .../Template/ListPageTemplateModel.swift | 49 +++++++++++++++++-- 13 files changed, 153 insertions(+), 16 deletions(-) rename MVMCoreUI/Models/{ => ModelProtocols}/CollectionCellMoleculeProtocol.swift (100%) rename MVMCoreUI/Models/{ => ModelProtocols}/ContainerMoleculeProtocol.swift (100%) rename MVMCoreUI/Models/{Molecules => ModelProtocols}/FormModelProtocol.swift (100%) create mode 100644 MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift rename MVMCoreUI/Models/{ => ModelProtocols}/MoleculeProtocol.swift (100%) rename MVMCoreUI/Models/{ => ModelProtocols}/PagingMoleculeProtocol.swift (100%) rename MVMCoreUI/Models/{Template => ModelProtocols}/TemplateModelProtocol.swift (100%) rename MVMCoreUI/Models/{ => ModelProtocols}/TemplateProtocol.swift (100%) create mode 100644 MVMCoreUI/Models/Molecules/DropDownListItemModel.swift create mode 100644 MVMCoreUI/Models/Molecules/DropDownModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 61ee1780..d9f4c2ff 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -12,6 +12,9 @@ 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; + 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */; }; + 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */; }; + 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F323A2CCC80085F53C /* DropDownModel.swift */; }; 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */; }; 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */; }; 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */; }; @@ -261,6 +264,9 @@ 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; + 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModelProtocol.swift; sourceTree = ""; }; + 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownListItemModel.swift; sourceTree = ""; }; + 011B58F323A2CCC80085F53C /* DropDownModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownModel.swift; sourceTree = ""; }; 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModelProtocol.swift; sourceTree = ""; }; 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateProtocol.swift; sourceTree = ""; }; 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselModel.swift; sourceTree = ""; }; @@ -521,10 +527,24 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 011B58EE23A2AA850085F53C /* ModelProtocols */ = { + isa = PBXGroup; + children = ( + 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, + 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, + 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, + 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, + 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, + 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */, + ); + path = ModelProtocols; + sourceTree = ""; + }; 012A889A238898C600FE3DA1 /* Template */ = { isa = PBXGroup; children = ( - 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */, 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */, 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */, @@ -544,12 +564,8 @@ 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( + 011B58EE23A2AA850085F53C /* ModelProtocols */, 012A88EF23985E0100FE3DA1 /* Primitive Models */, - 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, - 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, - 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, - 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, 012A889A238898C600FE3DA1 /* Template */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, @@ -573,12 +589,13 @@ children = ( 012CA98823849699003F810F /* SeperatorModel.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, + 011B58F323A2CCC80085F53C /* DropDownModel.swift */, + 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, - 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */, 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, @@ -1352,6 +1369,7 @@ 012CA9E223888AED003F810F /* StackCenteredPageTemplateModel.swift in Sources */, 012A88DA238ED42E00FE3DA1 /* StackPageTemplateModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, + 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, @@ -1364,6 +1382,7 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, + 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, @@ -1407,6 +1426,7 @@ D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, + 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift diff --git a/MVMCoreUI/Models/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ContainerMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/Molecules/FormModelProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/FormModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift new file mode 100644 index 00000000..ccd8884b --- /dev/null +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -0,0 +1,14 @@ +// +// ListItemModelProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ListItemModelProtocol: ContainerMoleculeProtocol { + var molecule: MoleculeProtocol? { get } + var separator: SeperatorModel? { get set } +} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/MoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift diff --git a/MVMCoreUI/Models/PagingMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PagingMoleculeProtocol.swift similarity index 100% rename from MVMCoreUI/Models/PagingMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/PagingMoleculeProtocol.swift diff --git a/MVMCoreUI/Models/Template/TemplateModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/Template/TemplateModelProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift diff --git a/MVMCoreUI/Models/TemplateProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift similarity index 100% rename from MVMCoreUI/Models/TemplateProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift new file mode 100644 index 00000000..c6c109fe --- /dev/null +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -0,0 +1,46 @@ +// +// DropDownListItemModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class DropDownListItemModel: ListItemModelProtocol { + public static var identifier: String = "dropDownListItem" + public var molecules: [[ListItemModel]] + public var backgroundColor: String? + public var separator: SeperatorModel? + public var dropDown: DropDownModel + + public init(molecules: [[ListItemModel]], dropDown: DropDownModel) { + self.molecules = molecules + self.dropDown = dropDown + } + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecules + case separator + case backgroundColor + case dropDown + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) + self.separator = try typeContainer.decode(SeperatorModel.self, forKey: .separator) + self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(molecules, forKey: .molecules) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(dropDown, forKey: .dropDown) + } +} diff --git a/MVMCoreUI/Models/Molecules/DropDownModel.swift b/MVMCoreUI/Models/Molecules/DropDownModel.swift new file mode 100644 index 00000000..b28eda5d --- /dev/null +++ b/MVMCoreUI/Models/Molecules/DropDownModel.swift @@ -0,0 +1,17 @@ +// +// DropDownModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class DropDownModel: MoleculeProtocol { + public static var identifier: String = "dropDownModel" + public var backgroundColor: String? + public var label: String + public var options: [String] +} diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index 9bfe704a..72556dae 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ListItemModel: ContainerMoleculeProtocol { +@objcMembers public class ListItemModel: ListItemModelProtocol { public static var identifier: String = "listItem" public var molecule: MoleculeProtocol? public var backgroundColor: String? @@ -40,9 +40,9 @@ import Foundation self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) - self.hideArrow = try typeContainer.decode(Bool.self, forKey: .hideArrow) - self.separator = try typeContainer.decode(SeperatorModel.self, forKey: .hideArrow) - self.style = try typeContainer.decode(String.self, forKey: .style) + self.hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) + self.separator = try typeContainer.decodeIfPresent(SeperatorModel.self, forKey: .separator) + self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) } public func encode(to encoder: Encoder) throws { @@ -50,5 +50,6 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(action, forKey: .action) + try container.encodeIfPresent(hideArrow, forKey: .hideArrow) } } diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift index 2ad31cdc..fa8b96a2 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -11,14 +11,53 @@ import Foundation @objcMembers public class ListPageTemplateModel: TemplateModelProtocol { public static var identifier: String = "listTemplate" - + public var pageType: String - public var screenHeading: String - public var isAtomicTabs: Bool? - public var header: MoleculeStackModel? - public var molecules: [ListItemModel]? + public var header: HeaderModel? + public var molecules: [ListItemModelProtocol] public var footer: MoleculeStackModel? + + public init(pageType: String, screenHeading: String, molecules: [ListItemModelProtocol]) { + self.pageType = pageType + self.screenHeading = screenHeading + self.molecules = molecules + } + + enum CodingKeys: String, CodingKey { + case moleculeName + case pageType + case screenHeading + case molecules + case header + case footer + case isAtomicTabs + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.pageType = try typeContainer.decode(String.self, forKey: .pageType) + self.screenHeading = try typeContainer.decode(String.self, forKey: .screenHeading) + guard let list = try typeContainer.decodeArray(codingKey: .molecules) as? [ListItemModelProtocol] else { + throw JSONError.pathNotFound + } + self.molecules = list + self.isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) + self.header = try typeContainer.decodeIfPresent(HeaderModel.self, forKey: .header) + self.footer = try typeContainer.decodeIfPresent(MoleculeStackModel.self, forKey: .footer) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(pageType, forKey: .pageType) + try container.encode(screenHeading, forKey: .screenHeading) + + try container.encodeArray(molecules, forKey: .molecules) + try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) + try container.encodeIfPresent(header, forKey: .header) + try container.encodeIfPresent(footer, forKey: .footer) + } } + From 8612b34ac7c3fabe98ebfadd4d6e1cb8d9c9c290 Mon Sep 17 00:00:00 2001 From: panxi Date: Fri, 13 Dec 2019 11:26:48 -0500 Subject: [PATCH 050/272] update listitem --- MVMCoreUI.xcodeproj/project.pbxproj | 6 +---- MVMCoreUI/Atoms/Views/DashLineModel.swift | 4 +--- .../Atoms/Views/LeftRightLabelModel.swift | 6 ++--- .../Atoms/Views/MultiProgressModel.swift | 4 +--- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 4 +--- .../ListItemModelProtocol.swift | 2 +- .../Molecules/DropDownListItemModel.swift | 4 ++-- MVMCoreUI/Models/Molecules/HeaderModel.swift | 6 ++--- MVMCoreUI/Models/Molecules/LineModel.swift | 4 ---- .../Models/Molecules/SeperatorModel.swift | 15 ------------ .../Items}/ListItemModel.swift | 24 +++++++------------ .../OtherHandlers/MoleculeObjectMapping.swift | 1 - 12 files changed, 20 insertions(+), 60 deletions(-) delete mode 100644 MVMCoreUI/Models/Molecules/SeperatorModel.swift rename MVMCoreUI/{Models/Molecules => Molecules/Items}/ListItemModel.swift (61%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d9f4c2ff..f50573f6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -27,7 +27,6 @@ 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88EB238F084D00FE3DA1 /* FooterModel.swift */; }; 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; 012A88F123985E0100FE3DA1 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88F023985E0100FE3DA1 /* Color.swift */; }; - 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; @@ -278,7 +277,6 @@ 012A88EB238F084D00FE3DA1 /* FooterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModel.swift; sourceTree = ""; }; 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; 012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; - 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; @@ -587,8 +585,6 @@ 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( - 012CA98823849699003F810F /* SeperatorModel.swift */, - 01EB368923609801006832FA /* ListItemModel.swift */, 011B58F323A2CCC80085F53C /* DropDownModel.swift */, 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, @@ -719,6 +715,7 @@ children = ( D2755D7A23689C7500485468 /* TableViewCell.swift */, 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, + 01EB368923609801006832FA /* ListItemModel.swift */, D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */, @@ -1294,7 +1291,6 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, - 012CA98923849699003F810F /* SeperatorModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 79367f35..172e5dd6 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -9,9 +9,7 @@ import Foundation @objcMembers public class DashLineModel: MoleculeProtocol { - public static var identifier: String { - get { return "dashLine" } - } + public static var identifier: String = "dashLine" public var backgroundColor: String? public var dashColor: String diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index ba07fc8b..30015d70 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -9,11 +9,9 @@ import UIKit @objcMembers public class LeftRightLabelModel: MoleculeProtocol { + public static var identifier: String = "leftRightLabel" public var backgroundColor: String? public var leftText: LabelModel public var rightText: LabelModel - - public static var identifier: String { - get{ return "leftRightLabel" } - } + } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 62397f69..25522070 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -15,9 +15,7 @@ import Foundation } @objcMembers public class MultiProgressBarModel: MoleculeProtocol { - public static var identifier: String { - get{ return "multiProgressBar"} - } + public static var identifier: String = "multiProgressBar" public var moleculeName: String public var backgroundColor: String? public var progressList: [SingleProgressBarModel] diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index aa5912a7..3450fc87 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -9,9 +9,7 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeProtocol { - public static var identifier: String { - get { return "progressbar" } - } + public static var identifier: String = "progressbar" public var moleculeName: String public var isRounded: Bool? diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index ccd8884b..59e51708 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -10,5 +10,5 @@ import Foundation public protocol ListItemModelProtocol: ContainerMoleculeProtocol { var molecule: MoleculeProtocol? { get } - var separator: SeperatorModel? { get set } + var separator: LineModel? { get set } } diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift index c6c109fe..7a7770df 100644 --- a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -12,7 +12,7 @@ import Foundation public static var identifier: String = "dropDownListItem" public var molecules: [[ListItemModel]] public var backgroundColor: String? - public var separator: SeperatorModel? + public var separator: LineModel? public var dropDown: DropDownModel public init(molecules: [[ListItemModel]], dropDown: DropDownModel) { @@ -31,7 +31,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) - self.separator = try typeContainer.decode(SeperatorModel.self, forKey: .separator) + self.separator = try typeContainer.decode(LineModel.self, forKey: .separator) self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 9016184b..adbfca47 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -13,9 +13,9 @@ import Foundation public var moleculeName: String? public var backgroundColor: String? public var molecule: MoleculeProtocol? - public var seperator: SeperatorModel? + public var seperator: LineModel? - public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: SeperatorModel?){ + public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: LineModel?){ self.molecule = molecule self.backgroundColor = backgroundColor self.seperator = seperator @@ -33,7 +33,7 @@ import Foundation self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - self.seperator = try typeContainer.decodeIfPresent(SeperatorModel.self, forKey: .separator) + self.seperator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift index e00ba1fc..c6a22c62 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Models/Molecules/LineModel.swift @@ -12,8 +12,4 @@ import UIKit public static var identifier: String = "line" public var backgroundColor: String? public var type: String? - - public init(type: String?) { - self.type = type - } } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift deleted file mode 100644 index b58c7602..00000000 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// SeperatorModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 11/19/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -@objcMembers public class SeperatorModel: MoleculeProtocol { - public static var identifier: String = "line" - public var backgroundColor: String? - public var type: String? -} diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift similarity index 61% rename from MVMCoreUI/Models/Molecules/ListItemModel.swift rename to MVMCoreUI/Molecules/Items/ListItemModel.swift index 72556dae..5ae9e7fa 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -13,19 +13,10 @@ import Foundation public var molecule: MoleculeProtocol? public var backgroundColor: String? public var action: ActionModel? - public var hideArrow: Bool? - public var separator: SeperatorModel? + public var separator: LineModel? public var style: String? - public init(molecule: MoleculeProtocol?, actionMap: ActionModel?, hideArrow: Bool?, separator: SeperatorModel?, style: String?) { - self.molecule = molecule - self.action = actionMap - self.hideArrow = hideArrow - self.separator = separator - self.style = style - } - enum CodingKeys: String, CodingKey { case moleculeName case molecule @@ -37,19 +28,20 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) - - self.hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) - self.separator = try typeContainer.decodeIfPresent(SeperatorModel.self, forKey: .separator) - self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) + separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) + style = try typeContainer.decodeIfPresent(String.self, forKey: .style) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeIfPresent(molecule, forKey: .molecule) try container.encodeIfPresent(action, forKey: .action) try container.encodeIfPresent(hideArrow, forKey: .hideArrow) + try container.encodeIfPresent(separator, forKey: .separator) + try container.encodeIfPresent(style, forKey: .style) } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 86395407..a26e2c85 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -18,7 +18,6 @@ import Foundation ModelRegistry.register(ListItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(LineModel.self) - ModelRegistry.register(SeperatorModel.self) ModelRegistry.register(ProgressBarModel.self) ModelRegistry.register(MultiProgressBarModel.self) ModelRegistry.register(CaretViewModel.self) From b6ccbecdf5ae53744d87628e785f6d30ac7154f7 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 13 Dec 2019 17:32:09 -0500 Subject: [PATCH 051/272] clean up --- .../MFViewController+Model.swift | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index fcdde9c3..afc022f8 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -9,8 +9,8 @@ import Foundation extension MFViewController: ModuleDelegateProtocol { - public func getModuleWithName(_ moleculeName: String) -> Model? { - guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName), + public func getModuleWithName(_ moduleName: String) -> Model? { + guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moduleName), let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), let modelType = ModelRegistry.getType(for: moleculeName) else { return nil @@ -25,21 +25,7 @@ extension MFViewController: ModuleDelegateProtocol { } public extension MFViewController { - @objc func parsePageJSON() { - (self as? TemplateProtocol)?.parseTemplateJSON() -// guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { -// return -// } -// do { -// let pageData = try JSONSerialization.data(withJSONObject: pageJSON) -// let decoder = JSONDecoder() -// -// let pageModel = try decoder.decode(PageModel.self, from: pageData) -// self.pageModel = pageModel -// } catch { -// MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") -// } } } From c6d5775d5704df29cd34aa784a4ee93201637e0c Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 16 Dec 2019 13:51:37 -0500 Subject: [PATCH 052/272] CaretButtonModel --- MVMCoreUI.xcodeproj/project.pbxproj | 4 +++ .../Atoms/Buttons/CaretButtonModel.swift | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f50573f6..5d073043 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -59,6 +59,7 @@ 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 /* CaretButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretButtonModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; @@ -310,6 +311,7 @@ 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 /* CaretButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretButtonModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -937,6 +939,7 @@ isa = PBXGroup; children = ( DBC4391A224421A0001AB423 /* CaretButton.swift */, + 01F2A03123A4498200D954D8 /* CaretButtonModel.swift */, D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, @@ -1364,6 +1367,7 @@ 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, 012CA9E223888AED003F810F /* StackCenteredPageTemplateModel.swift in Sources */, 012A88DA238ED42E00FE3DA1 /* StackPageTemplateModel.swift in Sources */, + 01F2A03223A4498200D954D8 /* CaretButtonModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift b/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift new file mode 100644 index 00000000..a2e42aed --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift @@ -0,0 +1,25 @@ +// +// CaretButtonModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/13/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +public class CaretButtonModel: MoleculeProtocol { + public static var identifier: String = "caretButton" + public var backgroundColor: String? + public var label: String + public var action: ActionModel + public var enabledColor: String? + public var disabledColor: String? + public var enabled: Bool? + + public init(label: String, action: ActionModel) { + self.label = label + self.action = action + } +} From 77e2269062e43f35297a03f459ecc27a8d147768 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 17 Dec 2019 09:46:47 -0500 Subject: [PATCH 053/272] Provided an alternative means to provide Codable StackView.Alignment string. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ .../UIStackViewAlignment+Extension.swift | 72 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8e1c2a00..21383a16 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -46,6 +46,7 @@ 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; + 0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; @@ -281,6 +282,7 @@ 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 = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; + 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackViewAlignment+Extension.swift"; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; @@ -860,6 +862,7 @@ D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */, D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */, 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */, + 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */, ); path = Utility; sourceTree = ""; @@ -1240,6 +1243,7 @@ D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, + 0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */, 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, diff --git a/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift b/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift new file mode 100644 index 00000000..18afca83 --- /dev/null +++ b/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift @@ -0,0 +1,72 @@ +// +// UIStackViewAlignment+Extension.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 12/16/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +/** + When using this class in codable for a String value from server. + + Example use case.... + + var alignment: UIStackView.Alignment + + enum CodingKeys: String, CodingKey { + case alignment + } + + required public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let word = try container.decode(String.self, forKey: .alignment) + alignment = UIStackView.Alignment(rawValue: word)! + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(alignment.rawValueString, forKey: .alignment) + } + */ +extension UIStackView.Alignment: RawRepresentable { + + init?(rawValue: String) { + switch rawValue { + case "fill": + self = .fill + case "leading": + self = .leading + case "firstBaseline": + self = .firstBaseline + case "center": + self = .center + case "trailing": + self = .trailing + case "lastBaseline": + self = .lastBaseline + default: + return nil + } + } + + var rawValueString: String { + switch self { + case .fill: + return "fill" + case .leading: + return "leading" + case .firstBaseline: + return "firstBaseline" + case .center: + return "center" + case .trailing: + return "trailing" + case .lastBaseline: + return "lastBaseline" + @unknown default: + return "" + } + } +} From f731b56f2ec5cd62ddadf9d2fcd0bc8d23c115e4 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Tue, 17 Dec 2019 10:23:56 -0500 Subject: [PATCH 054/272] Revert "Make Link subclass from View instead of MFCustomButton" This reverts commit 439261e4c4f6ca782c991a3f4162681a05b6ce65. --- MVMCoreUI/Atoms/Buttons/Link.swift | 78 +++++++++++++----------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 99a01114..6107fce0 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class Link: View { +@objcMembers open class Link: MFCustomButton { private lazy var sizeObject: MFSizeObject? = { return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) @@ -16,7 +16,6 @@ import UIKit private var additionalData: [AnyHashable: Any]? private var delegateObject: MVMCoreUIDelegateObject? - public let linkButton = MFCustomButton() public override init(frame: CGRect) { super.init(frame: frame) @@ -29,12 +28,12 @@ import UIKit } open override func draw(_ rect: CGRect) { - guard let textRect = self.linkButton.titleLabel?.frame else { return } + guard let textRect = self.titleLabel?.frame else { return } let contextRef = UIGraphicsGetCurrentContext() //set to the same color as the text - if let color = self.linkButton.titleLabel?.textColor?.cgColor { + if let color = self.titleLabel?.textColor?.cgColor { contextRef?.setStrokeColor(color) } @@ -50,97 +49,86 @@ import UIKit } override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + let faultTolerance: CGFloat = 20.0 - let area = linkButton.bounds.insetBy(dx: -faultTolerance, dy: -faultTolerance) + let area = bounds.insetBy(dx: -faultTolerance, dy: -faultTolerance) return area.contains(point) } open override func touchesEnded(_ touches: Set, with event: UIEvent?) { - if linkButton.isEnabled { - MVMCoreActionHandler.shared()?.handleAction(with: linkButton.actionMap, additionalData: additionalData, delegateObject: delegateObject) - } + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } -//MARK: MVMCoreViewProtocol -extension Link { +extension Link: MVMCoreViewProtocol { - public override func updateView(_ size: CGFloat) { + public func updateView(_ size: CGFloat) { MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in guard let self = self else { return } + var width = size if MVMCoreGetterUtility.fequal(a: Float(CGFloat.leastNormalMagnitude), b: Float(size)) { width = MVMCoreUISplitViewController.getApplicationViewWidth() } - self.linkButton.titleLabel?.font = MFStyler.fontB2(forWidth: width) - guard let heightConstraint = self.linkButton.heightConstraint else { return } + self.titleLabel?.font = MFStyler.fontB2(forWidth: width) + guard let heightConstraint = self.heightConstraint else { return } if !MVMCoreGetterUtility.fequal(a: 0, b: Float(heightConstraint.constant)) { guard let sizeObject = self.sizeObject else { return } - self.linkButton.heightConstraint?.constant = sizeObject.getValueBased(onSize: width) + self.heightConstraint?.constant = sizeObject.getValueBased(onSize: width) } }) } - public override func setupView() { - linkButton.isUserInteractionEnabled = false - linkButton.translatesAutoresizingMaskIntoConstraints = false - addSubview(linkButton) - NSLayoutConstraint.activate([ - linkButton.leadingAnchor.constraint(equalTo: leadingAnchor), - linkButton.topAnchor.constraint(equalTo: topAnchor), - trailingAnchor.constraint(greaterThanOrEqualTo: linkButton.trailingAnchor), - bottomAnchor.constraint(equalTo: linkButton.bottomAnchor) - ]) + public func setupView() { translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear contentMode = .redraw - linkButton.setTitleColor(.mfTextButton(), for: .normal) - linkButton.setTitleColor(.mfCharcoal(), for: .highlighted) - linkButton.titleLabel?.textAlignment = .left - linkButton.contentHorizontalAlignment = .left + setTitleColor(.mfTextButton(), for: .normal) + setTitleColor(.mfCharcoal(), for: .highlighted) + // left alignment by default + titleLabel?.textAlignment = .left + contentHorizontalAlignment = .left if let constant = self.sizeObject?.standardSize { let heightConstraint = NSLayoutConstraint(item: self as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) addConstraint(heightConstraint) heightConstraint.isActive = true - self.linkButton.heightConstraint = heightConstraint + self.heightConstraint = heightConstraint } } } -//MARK: MVMCoreUIMoleculeViewProtocol -extension Link { +extension Link: MVMCoreUIMoleculeViewProtocol { - public override func reset() { - self.linkButton.setTitleColor(.mfTextButton(), for: .normal) - self.linkButton.isEnabled = true + public func reset() { + self.setTitleColor(.mfTextButton(), for: .normal) } - public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { if let unwrappedJson = json { - linkButton.actionMap = unwrappedJson + actionMap = unwrappedJson self.additionalData = additionalData self.delegateObject = delegateObject - linkButton.buttonDelegate = delegateObject?.buttonDelegate + buttonDelegate = delegateObject?.buttonDelegate let color = unwrappedJson.stringForkey(KeyTextColor) - linkButton.setTitleColor(.mfGet(forHex: color), for: .normal) + setTitleColor(.mfGet(forHex: color), for: .normal) - linkButton.titleLabel?.numberOfLines = 0 - linkButton.titleLabel?.lineBreakMode = .byWordWrapping; - linkButton.setTitle(linkButton.actionMap?.stringForkey(KeyTitle), for: .normal) + titleLabel?.numberOfLines = 0 + titleLabel?.lineBreakMode = .byWordWrapping; + setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) if let enabled = unwrappedJson[KeyEnabled] as? Bool { - linkButton.isEnabled = enabled + isEnabled = enabled } } - if let title = self.linkButton.title(for: .normal), + if let title = self.title(for: .normal), title.isEmpty { - self.linkButton.heightConstraint?.constant = 0 + self.heightConstraint?.constant = 0 } else { guard let standardSize = sizeObject?.standardSize else { return } - linkButton.heightConstraint?.constant = standardSize + heightConstraint?.constant = standardSize } } From e41f3039e4736a8b824b2ad7c4b396e95bc825ab Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 17 Dec 2019 14:12:04 -0500 Subject: [PATCH 055/272] Name changes and cleanup --- MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift | 2 +- MVMCoreUI/Models/Extensions/ModelHelper.swift | 14 +++++++------- MVMCoreUI/Models/Molecules/HeaderModel.swift | 4 ++-- MVMCoreUI/Models/Molecules/ListItemModel.swift | 4 ++-- .../Models/Molecules/MoleculeStackItemModel.swift | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index d2c7947f..2b87186f 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -57,7 +57,7 @@ import Foundation self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) self.textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment) - self.attributes = try typeContainer.decodeArrayIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel] + self.attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel] self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html) self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index b4d0b1e2..66ed89ab 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -13,22 +13,22 @@ extension KeyedDecodingContainer where Key : CodingKey { case moleculeName } - public func decode(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { - return try decode(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) + public func decodeMolecule(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { + return try decodeModel(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } - public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { - return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) + public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { + return try decodeModelIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } - public func decodeArray(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol] { - guard let models = try decodeArray(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { + public func decodeMolecules(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol] { + guard let models = try decodeModels(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { throw ModelRegistry.Error.decoderError } return models } public func decodeArrayIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { - return try decodeArrayIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] + return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] } } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 5d4129e2..28d538a0 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -29,12 +29,12 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeModelIfPresent(self.molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index cd2fa39f..70dcf379 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -27,14 +27,14 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeModelIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(action, forKey: .action) } } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index c1ab6b15..b8d25952 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -24,12 +24,12 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeModelIfPresent(self.molecule, forKey: .molecule) } } From 1db2a5b05875eae13fa5b18cd871301904810754 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 18 Dec 2019 12:06:13 -0500 Subject: [PATCH 056/272] fixes --- .../Atoms/Buttons/CaretButtonModel.swift | 39 ++++++++++++++++--- .../MFTextField+ModelExtension.swift | 4 +- .../ContainerMoleculeProtocol.swift | 7 +--- .../ListItemModelProtocol.swift | 2 +- .../ModelProtocols/MoleculeProtocol.swift | 5 --- .../Models/Molecules/CarouselItemModel.swift | 9 +++-- .../Molecules/DropDownListItemModel.swift | 7 +++- MVMCoreUI/Models/Molecules/FooterModel.swift | 8 ++-- MVMCoreUI/Models/Molecules/HeaderModel.swift | 9 ++--- .../Models/Molecules/TextFieldModel.swift | 4 +- MVMCoreUI/Molecules/Items/ListItemModel.swift | 15 ++++--- .../Items/MoleculeCollectionViewCell.swift | 8 +--- .../Items/MoleculeTableViewCell.swift | 4 +- MVMCoreUI/Molecules/Items/TableViewCell.swift | 3 +- ...MoleculeMappingObject+ModelExtension.swift | 2 +- .../ModelMoleculeDelegateProtocol.swift | 4 +- .../Templates/MoleculeListTemplate.swift | 38 +++++++++--------- 17 files changed, 96 insertions(+), 72 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift b/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift index a2e42aed..c3946788 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift @@ -7,19 +7,48 @@ // import Foundation - +import MVMCore public class CaretButtonModel: MoleculeProtocol { public static var identifier: String = "caretButton" public var backgroundColor: String? - public var label: String - public var action: ActionModel + public var label: LabelModel + public var action: ActionProtocol public var enabledColor: String? public var disabledColor: String? public var enabled: Bool? - - public init(label: String, action: ActionModel) { + + public init(label: LabelModel, action: ActionProtocol) { self.label = label self.action = action } + + enum CodingKeys: String, CodingKey { + case backgroundColor + case label + case action + case enabledColor + case disabledColor + case enabled + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + label = try typeContainer.decode(LabelModel.self, forKey: .label) + enabledColor = try typeContainer.decodeIfPresent(String.self, forKey: .enabledColor) + disabledColor = try typeContainer.decodeIfPresent(String.self, forKey: .disabledColor) + enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) + action = try typeContainer.decode(codingKey: .action, typeCodingKey: ActionCodingKey.type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(label, forKey: .label) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(action, forKey: .action) + try container.encodeIfPresent(enabledColor, forKey: .enabledColor) + try container.encodeIfPresent(disabledColor, forKey: .disabledColor) + try container.encodeIfPresent(enabled, forKey: .enabled) + } } diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift index 81f00282..79ff851e 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift +++ b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift @@ -38,7 +38,9 @@ extension MFTextField: ModelMoleculeViewProtocol { formText = textFieldModel.label as NSString? text = textFieldModel.value as NSString? - enable(textFieldModel.disabled) + if let disabled = textFieldModel.disabled { + enable(disabled) + } errMessage = textFieldModel.errorMsg fieldKey = textFieldModel.fieldKey groupName = textFieldModel.groupName diff --git a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift index f6ff152e..81ffd123 100644 --- a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol ContainerMoleculeProtocol: MoleculeProtocol { - var molecule: MoleculeProtocol? { get } + var molecule: MoleculeProtocol { get } var useHorizontalMargins: Bool? { get } var useVerticalMargins: Bool? { get } var horizontalAlignment: String? { get } @@ -17,11 +17,6 @@ public protocol ContainerMoleculeProtocol: MoleculeProtocol { } extension ContainerMoleculeProtocol { - - public var molecule: MoleculeProtocol? { - get { return nil } - } - public var backgroundColor: String? { get { return nil } } diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 59e51708..59bec9ae 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -9,6 +9,6 @@ import Foundation public protocol ListItemModelProtocol: ContainerMoleculeProtocol { - var molecule: MoleculeProtocol? { get } + var molecule: MoleculeProtocol { get } var separator: LineModel? { get set } } diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift index 53f0fee4..581f487c 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift @@ -3,15 +3,10 @@ import Foundation public protocol MoleculeProtocol: Model { var moleculeName: String? { get } var backgroundColor: String? { get } - var dictionary: [AnyHashable: Any]? { get } } extension MoleculeProtocol { public var moleculeName: String? { get { return Self.identifier } } - - public var dictionary: [AnyHashable: Any]? { - return toJSON() - } } diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift index 58aa737f..eb9df665 100644 --- a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -11,10 +11,10 @@ import Foundation @objcMembers public class CarouselItemModel: ContainerMoleculeProtocol { public static var identifier: String = "carouselItem" - public var backgroundColor: String? + public var molecule: MoleculeProtocol - public init(backgroundColor: String?) { - self.backgroundColor = backgroundColor + public init(molecule: MoleculeProtocol) { + self.molecule = molecule } enum CodingKeys: String, CodingKey { @@ -25,13 +25,14 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) + molecule = try typeContainer.decode(codingKey: .molecule) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encode(molecule, forKey: .molecule) try container.encodeIfPresent(self.molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift index 7a7770df..70a9c662 100644 --- a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -10,17 +10,20 @@ import Foundation @objcMembers public class DropDownListItemModel: ListItemModelProtocol { public static var identifier: String = "dropDownListItem" + public var molecule: MoleculeProtocol public var molecules: [[ListItemModel]] public var backgroundColor: String? public var separator: LineModel? public var dropDown: DropDownModel - public init(molecules: [[ListItemModel]], dropDown: DropDownModel) { + public init(molecule: MoleculeProtocol, molecules: [[ListItemModel]], dropDown: DropDownModel) { + self.molecule = molecule self.molecules = molecules self.dropDown = dropDown } enum CodingKeys: String, CodingKey { + case molecule case moleculeName case molecules case separator @@ -30,6 +33,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + molecule = try typeContainer.decode(codingKey: .molecule) self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) self.separator = try typeContainer.decode(LineModel.self, forKey: .separator) self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) @@ -38,6 +42,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(molecule, forKey: .molecule) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(molecules, forKey: .molecules) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 95a45422..33751aa0 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -13,11 +13,10 @@ import Foundation public static var identifier: String = "footer" public var moleculeName: String? public var backgroundColor: String? - public var molecule: MoleculeProtocol? + public var molecule: MoleculeProtocol - public init(molecule: MoleculeProtocol?, backgroundColor: String?){ + public init(molecule: MoleculeProtocol){ self.molecule = molecule - self.backgroundColor = backgroundColor } enum CodingKeys: String, CodingKey { @@ -31,7 +30,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.molecule = try typeContainer.decode(codingKey: .molecule) } public func encode(to encoder: Encoder) throws { @@ -39,5 +38,6 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(self.backgroundColor, forKey: .backgroundColor) + try container.encode(molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index adbfca47..5212de7c 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -12,13 +12,11 @@ import Foundation public static var identifier: String = "header" public var moleculeName: String? public var backgroundColor: String? - public var molecule: MoleculeProtocol? + public var molecule: MoleculeProtocol public var seperator: LineModel? - public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: LineModel?){ + public init(molecule: MoleculeProtocol){ self.molecule = molecule - self.backgroundColor = backgroundColor - self.seperator = seperator } enum CodingKeys: String, CodingKey { @@ -32,7 +30,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.molecule = try typeContainer.decode(codingKey: .molecule) self.seperator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) } @@ -42,5 +40,6 @@ import Foundation try container.encodeIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(self.backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(self.seperator, forKey: .separator) + try container.encode(molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift index f9b11d5f..ea6f3deb 100644 --- a/MVMCoreUI/Models/Molecules/TextFieldModel.swift +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -13,8 +13,8 @@ import UIKit public static var identifier: String = "textField" public var backgroundColor: String? - public var editable = true - public var disabled = false + public var editable: Bool? + public var disabled: Bool? public var errorMsg: String? public var label: String? public var type: String? diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 5ae9e7fa..c1fd5203 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -7,16 +7,21 @@ // import Foundation +import MVMCore @objcMembers public class ListItemModel: ListItemModelProtocol { public static var identifier: String = "listItem" - public var molecule: MoleculeProtocol? + public var molecule: MoleculeProtocol public var backgroundColor: String? - public var action: ActionModel? + public var action: ActionProtocol? public var hideArrow: Bool? public var separator: LineModel? public var style: String? + public init(molecule: MoleculeProtocol) { + self.molecule = molecule + } + enum CodingKeys: String, CodingKey { case moleculeName case molecule @@ -28,8 +33,8 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) + molecule = try typeContainer.decode(codingKey: .molecule) + action = try typeContainer.decodeIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.type) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) style = try typeContainer.decodeIfPresent(String.self, forKey: .style) @@ -38,7 +43,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(molecule, forKey: .molecule) + try container.encode(molecule, forKey: .molecule) try container.encodeIfPresent(action, forKey: .action) try container.encodeIfPresent(hideArrow, forKey: .hideArrow) try container.encodeIfPresent(separator, forKey: .separator) diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index bc97be16..00b8c1ee 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -90,18 +90,14 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi backgroundColor = UIColor.mfGet(forHex: backgroundColorString) } - guard let moleculeModel = collectionModel.molecule else { - return - } - if molecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) { + if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(collectionModel.molecule, delegateObject, true) { contentView.insertSubview(moleculeView, at: 0) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: true).values)) molecule = moleculeView } } else { - (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(collectionModel.molecule, delegateObject, additionalData) } // This molecule will handle spacing by default. diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 2e45d0f1..f3674562 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -14,7 +14,7 @@ import UIKit super.setWithModel(model, delegateObject, additionalData) guard let model = model, - let moleculeModel = (model as? ContainerMoleculeProtocol)?.molecule, + let moleculeModel = (model as? ListItemModelProtocol)?.molecule, let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) else { return } @@ -22,7 +22,7 @@ import UIKit } public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let moleculeModel = (molecule as? ContainerMoleculeProtocol)?.molecule else { + guard let moleculeModel = (molecule as? ListItemModelProtocol)?.molecule else { return "\(self)<>" } let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 20c48487..216f95aa 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -179,8 +179,7 @@ import UIKit bottomSeparatorView?.setWithModel(separator, nil, nil) } - guard let moleculeModel = model.molecule else { return } - (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model.molecule, delegateObject, additionalData) // This molecule will by default handle margins. if let castView = molecule as? MVMCoreUIViewConstrainingProtocol { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 070c8680..8eda8a52 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -31,7 +31,7 @@ public extension MVMCoreUIMoleculeMappingObject { if let molecule = molecule as? ModelMoleculeViewProtocol { molecule.setWithModel(model, delegateObject, nil) } else { - molecule.setWithJSON?(model.dictionary, delegateObject: delegateObject, additionalData: nil) + molecule.setWithJSON?(model.toJSON(), delegateObject: delegateObject, additionalData: nil) } } diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index 2120333e..dd79ee3d 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -9,6 +9,6 @@ import Foundation public protocol ModelMoleculeDelegateProtocol { - func addMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) - func removeMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) + func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 534d3228..3ba28ecc 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -10,7 +10,7 @@ import UIKit open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol, ModelMoleculeDelegateProtocol { - public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)]? + public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? var observer: NSKeyValueObservation? public var templateModel: TemplateModelProtocol? @@ -139,7 +139,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public func addMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // This dispatch is needed to fix a race condition that can occur if this function is called during the table setup. DispatchQueue.main.async { guard let indexPath = self.tableView?.indexPath(for: sender) else { return } @@ -157,7 +157,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol self.view.layoutIfNeeded() } } - public func removeMolecules(_ molecules: [MoleculeProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality for molecule in molecules { @@ -172,23 +172,21 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol self.updateViewConstraints() self.view.layoutIfNeeded() } - - // MARK: - Convenience /// Returns the (identifier, class) of the molecule for the given map. - func getMoleculeInfo(with molecule: MoleculeProtocol?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? { - guard let molecule = molecule, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule), - let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.name(forReuse: molecule, delegateObject: delegateObject() as? MVMCoreUIDelegateObject) ?? molecule.moleculeName else { + func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? { + guard let listItem = listItem, + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.name(forReuse: listItem, delegateObject: delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.molecule.moleculeName else { return nil } - return (moleculeName, moleculeClass, molecule) + return (moleculeName, moleculeClass, listItem) } /// Sets up the molecule list and ensures no errors loading all content. - func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)]? { - var moleculeList: [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)] = [] + func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? { + var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)] = [] if let molecules = (templateModel as? ListPageTemplateModel)?.molecules { for molecule in molecules { if let info = getMoleculeInfo(with: molecule) { @@ -201,14 +199,14 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol /// Sets up the header, footer, molecule list and ensures no errors loading all content. func setup() { - var moleculeList: [(identifier: String, class: AnyClass, molecule: MoleculeProtocol)] = [] - if let molecules = loadObject?.pageJSON?.optionalArrayForKey(KeyMolecules) as? [MoleculeProtocol] { - for molecule in molecules { - if let info = getMoleculeInfo(with: molecule) { - moleculeList.append(info) - } - } - } + var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)] = [] + if let molecules = (templateModel as? ListPageTemplateModel)?.molecules { + for molecule in molecules { + if let info = getMoleculeInfo(with: molecule) { + moleculeList.append(info) + } + } + } moleculesInfo = moleculeList } From 46e76f0b47ef415b05584524ff60ac7dba49414e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Dec 2019 16:07:00 -0500 Subject: [PATCH 057/272] Further name changes --- MVMCoreUI/Models/Extensions/ModelHelper.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index 66ed89ab..fc0616c1 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -28,7 +28,7 @@ extension KeyedDecodingContainer where Key : CodingKey { return models } - public func decodeArrayIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { + public func decodeMoleculesIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] } } From 14c608c4a5d91ebfc70d544bc51d6bd6c1745a77 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Dec 2019 16:10:15 -0500 Subject: [PATCH 058/272] Commenting --- MVMCoreUI/Models/Extensions/ModelHelper.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index fc0616c1..7c73f264 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -13,14 +13,17 @@ extension KeyedDecodingContainer where Key : CodingKey { case moleculeName } + /// Decodes the molecule model with the given coding key based on moleculeName public func decodeMolecule(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { return try decodeModel(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } + /// Decodes the molecule model with the given coding key based on moleculeName, optional public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { return try decodeModelIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } + /// Decodes the list of molecule models with the given coding key based on moleculeName public func decodeMolecules(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol] { guard let models = try decodeModels(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { throw ModelRegistry.Error.decoderError @@ -28,6 +31,7 @@ extension KeyedDecodingContainer where Key : CodingKey { return models } + /// Decodes the list of molecule models with the given coding key based on moleculeName, optional public func decodeMoleculesIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] } From 7c17889b574ddf0d50d91b415256ee206c13b60a Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 12:23:01 -0500 Subject: [PATCH 059/272] Changed to MVMCoreUIUtility.getWidth() as per pr comments --- MVMCoreUI/Atoms/Buttons/Link.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 6107fce0..b31b2c34 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -68,7 +68,7 @@ extension Link: MVMCoreViewProtocol { var width = size if MVMCoreGetterUtility.fequal(a: Float(CGFloat.leastNormalMagnitude), b: Float(size)) { - width = MVMCoreUISplitViewController.getApplicationViewWidth() + width = MVMCoreUIUtility.getWidth() } self.titleLabel?.font = MFStyler.fontB2(forWidth: width) guard let heightConstraint = self.heightConstraint else { return } From 6e233e9babec0e320c42f301f1630e4d505fa1e0 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 12:23:18 -0500 Subject: [PATCH 060/272] Removes self where unnecessary --- MVMCoreUI/Atoms/Buttons/Link.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index b31b2c34..068227b7 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -19,21 +19,21 @@ import UIKit public override init(frame: CGRect) { super.init(frame: frame) - self.setupView() + setupView() } public required init?(coder: NSCoder) { super.init(coder: coder) - self.setupView() + setupView() } open override func draw(_ rect: CGRect) { - guard let textRect = self.titleLabel?.frame else { return } + guard let textRect = titleLabel?.frame else { return } let contextRef = UIGraphicsGetCurrentContext() //set to the same color as the text - if let color = self.titleLabel?.textColor?.cgColor { + if let color = titleLabel?.textColor?.cgColor { contextRef?.setStrokeColor(color) } @@ -89,7 +89,7 @@ extension Link: MVMCoreViewProtocol { titleLabel?.textAlignment = .left contentHorizontalAlignment = .left - if let constant = self.sizeObject?.standardSize { + if let constant = sizeObject?.standardSize { let heightConstraint = NSLayoutConstraint(item: self as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) addConstraint(heightConstraint) heightConstraint.isActive = true @@ -101,7 +101,7 @@ extension Link: MVMCoreViewProtocol { extension Link: MVMCoreUIMoleculeViewProtocol { public func reset() { - self.setTitleColor(.mfTextButton(), for: .normal) + setTitleColor(.mfTextButton(), for: .normal) } public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { @@ -123,9 +123,9 @@ extension Link: MVMCoreUIMoleculeViewProtocol { } } - if let title = self.title(for: .normal), + if let title = title(for: .normal), title.isEmpty { - self.heightConstraint?.constant = 0 + heightConstraint?.constant = 0 } else { guard let standardSize = sizeObject?.standardSize else { return } heightConstraint?.constant = standardSize From 8d417068a9f0653b5d941daddd82eb904dfdc1e0 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 13:13:57 -0500 Subject: [PATCH 061/272] Removed heightConstraint-related logic because the heightConstraint was added to increase the tappable area of Link's predecessor, MFTextButton. --- MVMCoreUI/Atoms/Buttons/Link.swift | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 068227b7..7c78e349 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -10,10 +10,6 @@ import UIKit @objcMembers open class Link: MFCustomButton { - private lazy var sizeObject: MFSizeObject? = { - return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) - }() - private var additionalData: [AnyHashable: Any]? private var delegateObject: MVMCoreUIDelegateObject? @@ -71,11 +67,6 @@ extension Link: MVMCoreViewProtocol { width = MVMCoreUIUtility.getWidth() } self.titleLabel?.font = MFStyler.fontB2(forWidth: width) - guard let heightConstraint = self.heightConstraint else { return } - if !MVMCoreGetterUtility.fequal(a: 0, b: Float(heightConstraint.constant)) { - guard let sizeObject = self.sizeObject else { return } - self.heightConstraint?.constant = sizeObject.getValueBased(onSize: width) - } }) } @@ -88,13 +79,6 @@ extension Link: MVMCoreViewProtocol { // left alignment by default titleLabel?.textAlignment = .left contentHorizontalAlignment = .left - - if let constant = sizeObject?.standardSize { - let heightConstraint = NSLayoutConstraint(item: self as Any, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: constant) - addConstraint(heightConstraint) - heightConstraint.isActive = true - self.heightConstraint = heightConstraint - } } } @@ -122,14 +106,6 @@ extension Link: MVMCoreUIMoleculeViewProtocol { isEnabled = enabled } } - - if let title = title(for: .normal), - title.isEmpty { - heightConstraint?.constant = 0 - } else { - guard let standardSize = sizeObject?.standardSize else { return } - heightConstraint?.constant = standardSize - } } public static func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { From 87613fb3752855ac7d3ceb356e65bc6502576728 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 13:38:51 -0500 Subject: [PATCH 062/272] Used guard instead of if let because some code after the if let was removed --- MVMCoreUI/Atoms/Buttons/Link.swift | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 7c78e349..9116cc51 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -89,22 +89,21 @@ extension Link: MVMCoreUIMoleculeViewProtocol { } public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - if let unwrappedJson = json { - actionMap = unwrappedJson - self.additionalData = additionalData - self.delegateObject = delegateObject - buttonDelegate = delegateObject?.buttonDelegate - - let color = unwrappedJson.stringForkey(KeyTextColor) - setTitleColor(.mfGet(forHex: color), for: .normal) - - titleLabel?.numberOfLines = 0 - titleLabel?.lineBreakMode = .byWordWrapping; - setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) - - if let enabled = unwrappedJson[KeyEnabled] as? Bool { - isEnabled = enabled - } + guard let unwrappedJson = json else { return } + actionMap = unwrappedJson + self.additionalData = additionalData + self.delegateObject = delegateObject + buttonDelegate = delegateObject?.buttonDelegate + + let color = unwrappedJson.stringForkey(KeyTextColor) + setTitleColor(.mfGet(forHex: color), for: .normal) + + titleLabel?.numberOfLines = 0 + titleLabel?.lineBreakMode = .byWordWrapping; + setTitle(unwrappedJson.stringForkey(KeyTitle), for: .normal) + + if let enabled = unwrappedJson[KeyEnabled] as? Bool { + isEnabled = enabled } } From e11f64f0a4e298bdc3117dec298994ed6429836d Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 13:41:27 -0500 Subject: [PATCH 063/272] Changed to optionalStringForKey --- MVMCoreUI/Atoms/Buttons/Link.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 9116cc51..10aae78b 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -100,7 +100,9 @@ extension Link: MVMCoreUIMoleculeViewProtocol { titleLabel?.numberOfLines = 0 titleLabel?.lineBreakMode = .byWordWrapping; - setTitle(unwrappedJson.stringForkey(KeyTitle), for: .normal) + if let title = unwrappedJson.optionalStringForKey(KeyTitle) { + setTitle(title, for: .normal) + } if let enabled = unwrappedJson[KeyEnabled] as? Bool { isEnabled = enabled From d17ab73d34f6d67bacc29b68ee341fccf89e684f Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 19 Dec 2019 14:02:52 -0500 Subject: [PATCH 064/272] update encode decode method --- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 5 +-- .../Atoms/Views/LabelModel/LabelModel.swift | 2 +- MVMCoreUI/Atoms/Views/ProgressBar.swift | 2 +- MVMCoreUI/Models/Extensions/ModelHelper.swift | 8 ++-- .../Models/Molecules/CarouselItemModel.swift | 10 ++--- .../Models/Molecules/CarouselModel.swift | 42 ++++++++----------- .../Molecules/DropDownListItemModel.swift | 4 +- MVMCoreUI/Models/Molecules/FooterModel.swift | 16 +++---- MVMCoreUI/Models/Molecules/HeaderModel.swift | 20 ++++----- .../Molecules/MoleculeStackItemModel.swift | 13 +++--- .../Models/Molecules/MoleculeStackModel.swift | 21 ++++------ .../Template/ListPageTemplateModel.swift | 2 +- MVMCoreUI/Molecules/Items/ListItemModel.swift | 5 ++- 13 files changed, 61 insertions(+), 89 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index 37d095d8..5a8998db 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -10,11 +10,8 @@ import Foundation @objcMembers public class CaretViewModel: MoleculeProtocol { - public static var identifier: String { - get{ return "caretView" } - } + public static var identifier: String = "caretView" public var backgroundColor: String? - public var strokeColor: String? public var isHidden: Bool? public var isOpaque: Bool? diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index d2c7947f..2b87186f 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -57,7 +57,7 @@ import Foundation self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) self.textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment) - self.attributes = try typeContainer.decodeArrayIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel] + self.attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes, typeCodingKey: AttributeTypeKey.type) as? [LabelAttributeModel] self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html) self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 0a29d62a..b640e4c7 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -57,7 +57,7 @@ import Foundation } isRounded = progressBarModel.isRounded ?? false thickness = progressBarModel.thickness ?? 8 - progress = (progressBarModel.percentage )/100.0 + progress = (progressBarModel.percentage)/100.0 if let progressColor = progressBarModel.progressColor { progressTintColor = UIColor.mfGet(forHex: progressColor) } diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index b4d0b1e2..fab9bd5f 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -14,21 +14,21 @@ extension KeyedDecodingContainer where Key : CodingKey { } public func decode(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { - return try decode(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) + return try decodeModel(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { - return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) + return try decodeModelIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } public func decodeArray(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol] { - guard let models = try decodeArray(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { + guard let models = try decodeModels(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { throw ModelRegistry.Error.decoderError } return models } public func decodeArrayIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { - return try decodeArrayIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] + return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] } } diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift index 58aa737f..f2392131 100644 --- a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -13,10 +13,6 @@ import Foundation public static var identifier: String = "carouselItem" public var backgroundColor: String? - public init(backgroundColor: String?) { - self.backgroundColor = backgroundColor - } - enum CodingKeys: String, CodingKey { case moleculeName case molecule @@ -25,13 +21,13 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) + backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeModelIfPresent(molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift index 60f2b27c..08bddafd 100644 --- a/MVMCoreUI/Models/Molecules/CarouselModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -21,16 +21,8 @@ import UIKit public var itemAlignment: String? public var pagingMolecule: PagingMoleculeProtocol? - public init(molecules: [CarouselItemModel], spacing: Float?, border: Bool?, loop: Bool?, height: Float?, itemWidthPercent: Float?, itemAlignment: String?, pagingMolecule: PagingMoleculeProtocol?, backgroundColor: String?){ + public init(molecules: [CarouselItemModel]){ self.molecules = molecules - self.spacing = spacing - self.border = border - self.loop = loop - self.height = height - self.itemWidthPercent = itemWidthPercent - self.itemAlignment = itemAlignment - self.pagingMolecule = pagingMolecule - self.backgroundColor = backgroundColor } enum CodingKeys: String, CodingKey { @@ -47,26 +39,26 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) - self.spacing = try typeContainer.decode(Float.self, forKey: .spacing) - self.border = try typeContainer.decode(Bool.self, forKey: .border) - self.loop = try typeContainer.decode(Bool.self, forKey: .loop) - self.height = try typeContainer.decode(Float.self, forKey: .height) - self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent) - self.itemAlignment = try typeContainer.decode(String.self, forKey: .itemAlignment) - self.pagingMolecule = try typeContainer.decodeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol + molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) + spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) + border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) + loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop) + height = try typeContainer.decodeIfPresent(Float.self, forKey: .height) + itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent) + itemAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .itemAlignment) + pagingMolecule = try typeContainer.decodeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encode(molecules, forKey: .molecules) - try container.encode(spacing, forKey: .spacing) - try container.encode(border, forKey: .border) - try container.encode(loop, forKey: .loop) - try container.encode(height, forKey: .height) - try container.encode(itemWidthPercent, forKey: .itemWidthPercent) - try container.encode(itemAlignment, forKey: .itemAlignment) - try container.encodeIfPresent(self.pagingMolecule, forKey: .pagingMolecule) + try container.encodeIfPresent(spacing, forKey: .spacing) + try container.encodeIfPresent(border, forKey: .border) + try container.encodeIfPresent(loop, forKey: .loop) + try container.encodeIfPresent(height, forKey: .height) + try container.encodeIfPresent(itemWidthPercent, forKey: .itemWidthPercent) + try container.encodeIfPresent(itemAlignment, forKey: .itemAlignment) + try container.encodeModelIfPresent(pagingMolecule, forKey: .pagingMolecule) } } diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift index 7a7770df..0bac18c6 100644 --- a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -31,14 +31,14 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) - self.separator = try typeContainer.decode(LineModel.self, forKey: .separator) + self.separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encode(molecules, forKey: .molecules) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(dropDown, forKey: .dropDown) diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 95a45422..52b21212 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -15,29 +15,23 @@ import Foundation public var backgroundColor: String? public var molecule: MoleculeProtocol? - public init(molecule: MoleculeProtocol?, backgroundColor: String?){ - self.molecule = molecule - self.backgroundColor = backgroundColor - } - enum CodingKeys: String, CodingKey { case moleculeName case molecule case backgroundColor - case separator } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) + backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encodeModelIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(self.backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index adbfca47..45f511e0 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -15,12 +15,6 @@ import Foundation public var molecule: MoleculeProtocol? public var seperator: LineModel? - public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: LineModel?){ - self.molecule = molecule - self.backgroundColor = backgroundColor - self.seperator = seperator - } - enum CodingKeys: String, CodingKey { case moleculeName case molecule @@ -30,17 +24,17 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - self.seperator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) + moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + seperator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.molecule, forKey: .molecule) - try container.encodeIfPresent(self.backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(self.seperator, forKey: .separator) + try container.encodeModelIfPresent(molecule, forKey: .molecule) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(seperator, forKey: .separator) } } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 1a7e6f73..0818630f 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -52,12 +52,11 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.molecule, forKey: .molecule) - - try container.encode(spacing, forKey: .spacing) - try container.encode(percentage, forKey: .percentage) - try container.encode(verticalAlignment, forKey: .verticalAlignment) - try container.encode(horizontalAlignment, forKey: .horizontalAlignment) - try container.encode(gone, forKey: .gone) + try container.encodeModelIfPresent(self.molecule, forKey: .molecule) + try container.encodeIfPresent(spacing, forKey: .spacing) + try container.encodeIfPresent(percentage, forKey: .percentage) + try container.encodeIfPresent(verticalAlignment, forKey: .verticalAlignment) + try container.encodeIfPresent(horizontalAlignment, forKey: .horizontalAlignment) + try container.encodeIfPresent(gone, forKey: .gone) } } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 9c462339..296c26d6 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -16,31 +16,28 @@ import Foundation public var axis: String? public var spacing: Float? - public init(axis: String?, molecules: [MoleculeStackItemModel]?, spacing: Float?) { - self.axis = axis - self.molecules = molecules - self.spacing = spacing - } - enum CodingKeys: String, CodingKey { case moleculeName case molecules case axis case spacing + case backgroundColor } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.molecules = try typeContainer.decodeIfPresent([MoleculeStackItemModel].self, forKey: .molecules) - self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) - self.spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) + molecules = try typeContainer.decodeIfPresent([MoleculeStackItemModel].self, forKey: .molecules) + axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) + spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) + backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(molecules, forKey: .molecules) - try container.encode(axis, forKey: .axis) - try container.encode(spacing, forKey: .spacing) + try container.encodeIfPresent(axis, forKey: .axis) + try container.encodeIfPresent(spacing, forKey: .spacing) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift index fa8b96a2..ffeff803 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -54,7 +54,7 @@ import Foundation try container.encode(pageType, forKey: .pageType) try container.encode(screenHeading, forKey: .screenHeading) - try container.encodeArray(molecules, forKey: .molecules) + try container.encodeModels(molecules, forKey: .molecules) try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) try container.encodeIfPresent(header, forKey: .header) try container.encodeIfPresent(footer, forKey: .footer) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 5ae9e7fa..cfb1165b 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -20,6 +20,7 @@ import Foundation enum CodingKeys: String, CodingKey { case moleculeName case molecule + case backgroundColor case action case hideArrow case separator @@ -29,6 +30,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) @@ -38,7 +40,8 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(molecule, forKey: .molecule) + try container.encodeModelIfPresent(molecule, forKey: .molecule) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(action, forKey: .action) try container.encodeIfPresent(hideArrow, forKey: .hideArrow) try container.encodeIfPresent(separator, forKey: .separator) From bf27d19ae15032208ae4b8c76916211c195eb213 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 19 Dec 2019 14:25:26 -0500 Subject: [PATCH 065/272] change float to cgfloat for nslayoutconstraint --- MVMCoreUI/Models/Molecules/CarouselModel.swift | 12 ++++++------ MVMCoreUI/Organisms/Carousel.swift | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift index 08bddafd..47e36518 100644 --- a/MVMCoreUI/Models/Molecules/CarouselModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -13,11 +13,11 @@ import UIKit public var backgroundColor: String? public var molecules: [CarouselItemModel] - public var spacing: Float? + public var spacing: CGFloat? public var border: Bool? public var loop: Bool? - public var height: Float? - public var itemWidthPercent: Float? + public var height: CGFloat? + public var itemWidthPercent: CGFloat? public var itemAlignment: String? public var pagingMolecule: PagingMoleculeProtocol? @@ -40,11 +40,11 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) - spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) + spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop) - height = try typeContainer.decodeIfPresent(Float.self, forKey: .height) - itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent) + height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height) + itemWidthPercent = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .itemWidthPercent) itemAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .itemAlignment) pagingMolecule = try typeContainer.decodeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol } diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 116f1135..6af1224b 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -98,11 +98,11 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { registerCells(with: caroselModel, delegateObject: delegateObject) setupLayout(with: caroselModel) prepareMolecules(with: caroselModel) - itemWidthPercent = CGFloat((caroselModel.itemWidthPercent ?? 100) / 100) + itemWidthPercent = (caroselModel.itemWidthPercent ?? 100) / 100 setAlignment(with: caroselModel.itemAlignment) if let height = caroselModel.height { - collectionViewHeight?.constant = CGFloat(height) + collectionViewHeight?.constant = height collectionViewHeight?.isActive = true } @@ -122,7 +122,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { func setupLayout(with carouselModel: CarouselModel?) { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal - layout.minimumLineSpacing = CGFloat(carouselModel?.spacing ?? 1) + layout.minimumLineSpacing = carouselModel?.spacing ?? 1 layout.minimumInteritemSpacing = 0 collectionView.collectionViewLayout = layout } From e36d487d326f710d7302c6d9bcb758d209ad329c Mon Sep 17 00:00:00 2001 From: panxi Date: Fri, 20 Dec 2019 15:00:42 -0500 Subject: [PATCH 066/272] change model name to containerModel to avoid compiling error --- MVMCoreUI/Containers/Container.swift | 4 +-- MVMCoreUI/Molecules/Items/StackItem.swift | 4 +-- MVMCoreUI/Molecules/ModuleMolecule.swift | 2 +- MVMCoreUI/Molecules/StandardHeaderView.swift | 38 ++++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/MVMCoreUI/Containers/Container.swift b/MVMCoreUI/Containers/Container.swift index 069cd9e3..6beb72e0 100644 --- a/MVMCoreUI/Containers/Container.swift +++ b/MVMCoreUI/Containers/Container.swift @@ -185,7 +185,7 @@ public class ContainerHelper: NSObject { } open class Container: View { - var model: ContainerModelProtocol? + var containerModel: ContainerModelProtocol? var view: UIView? let containerHelper = ContainerHelper() @@ -198,7 +198,7 @@ public extension Container { override func updateView(_ size: CGFloat) { super.updateView(size) (view as? MVMCoreViewProtocol)?.updateView(size) - MFStyler.setMarginsFor(self, size: size, defaultHorizontal: model?.useHorizontalMargins ?? true, top: model?.useHorizontalMargins ?? true ? topMarginPadding : 0, bottom: model?.useHorizontalMargins ?? true ? bottomMarginPadding : 0) + MFStyler.setMarginsFor(self, size: size, defaultHorizontal: containerModel?.useHorizontalMargins ?? true, top: containerModel?.useHorizontalMargins ?? true ? topMarginPadding : 0, bottom: containerModel?.useHorizontalMargins ?? true ? bottomMarginPadding : 0) } /// Will be called only once. diff --git a/MVMCoreUI/Molecules/Items/StackItem.swift b/MVMCoreUI/Molecules/Items/StackItem.swift index 6ee5ae88..88dd5c43 100644 --- a/MVMCoreUI/Molecules/Items/StackItem.swift +++ b/MVMCoreUI/Molecules/Items/StackItem.swift @@ -20,12 +20,12 @@ open class StackItemModel: ContainerModelProtocol { init(with view: StackItem) { self.view = view - view.model = self + view.containerModel = self } init(with view: StackItem, json: [AnyHashable: Any]?) { self.view = view - view.model = self + view.containerModel = self update(with: json) } diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index 66e18d47..18dc43fa 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -18,7 +18,7 @@ struct ModuleMoleculeModel: ContainerModelProtocol { open class ModuleMolecule: Container { public override func setupView() { super.setupView() - model = ModuleMoleculeModel() + containerModel = ModuleMoleculeModel() } // MARK: - MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index dba3fde2..8ed1a879 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -40,25 +40,25 @@ public class StandardHeaderView: MoleculeContainer { } } - open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - //TODO: Need to create setWithModel in ViewConstraining View - - #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") - //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. - setUpWithModel(model, delegateObject, additionalData) - - // This molecule will by default handle margins. - (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false) - (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false) - - guard let headerModel = model as? HeaderModel else { - return - } - - if let seperatorModel = headerModel.seperator as? LineModel { - line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) - } - } +// open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { +// //TODO: Need to create setWithModel in ViewConstraining View +// +// #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") +// //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. +// setUpWithModel(model, delegateObject, additionalData) +// +// // This molecule will by default handle margins. +// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false) +// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false) +// +// guard let headerModel = model as? HeaderModel else { +// return +// } +// +// if let seperatorModel = headerModel.seperator as? LineModel { +// line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) +// } +// } open override func reset() { super.reset() From d3e3a6809c168fe82d683d23a10c6735b10fd330 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 7 Jan 2020 11:08:00 -0500 Subject: [PATCH 067/272] container fixes for modal --- MVMCoreUI.xcodeproj/project.pbxproj | 32 ++- .../Atoms/Views/MFView+ModelExtension.swift | 1 + .../ViewConstrainingView+ModelExtension.swift | 9 +- MVMCoreUI/BaseClasses/View.swift | 5 +- MVMCoreUI/Containers/Container.swift | 33 ++- .../Models/ConstrainingMoleculeProtocol.swift | 19 -- .../Models/Container/ContainerModel.swift | 54 +++++ .../Container/ContainerModelProtocol.swift | 19 ++ .../Container/MoleculeContainerModel.swift | 34 +++ .../Models/ContainerMoleculeProtocol.swift | 17 -- MVMCoreUI/Models/Molecules/HeaderModel.swift | 37 +-- .../Models/Molecules/ListItemModel.swift | 25 +- .../Molecules/MoleculeStackItemModel.swift | 48 ++-- .../Models/Molecules/MoleculeStackModel.swift | 34 +-- .../Models/Molecules/SeperatorModel.swift | 15 -- MVMCoreUI/Molecules/Items/StackItem.swift | 79 +------ .../Molecules/ModelMoleculeViewProtocol.swift | 8 + MVMCoreUI/Molecules/ModuleMolecule.swift | 29 +-- MVMCoreUI/Molecules/MoleculeContainer.swift | 13 ++ MVMCoreUI/Molecules/StandardFooterView.swift | 12 - MVMCoreUI/Molecules/StandardHeaderView.swift | 10 +- .../EyebrowHeadlineBodyLink.swift | 41 +++- MVMCoreUI/Organisms/MoleculeStackView.swift | 214 +++++++++--------- .../MVMCoreUIMoleculeMappingObject.m | 3 +- .../OtherHandlers/MoleculeObjectMapping.swift | 1 - 25 files changed, 397 insertions(+), 395 deletions(-) delete mode 100644 MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift create mode 100644 MVMCoreUI/Models/Container/ContainerModel.swift create mode 100644 MVMCoreUI/Models/Container/ContainerModelProtocol.swift create mode 100644 MVMCoreUI/Models/Container/MoleculeContainerModel.swift delete mode 100644 MVMCoreUI/Models/ContainerMoleculeProtocol.swift delete mode 100644 MVMCoreUI/Models/Molecules/SeperatorModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index db24662f..4ff1fa87 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -12,12 +12,11 @@ 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; - 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; - 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; + 012A88EE239858E300FE3DA1 /* ContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerModel.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; - 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */; }; + 012CA9BE2385C692003F810F /* ContainerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9BD2385C692003F810F /* ContainerModelProtocol.swift */; }; 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */; }; 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D902327ECE600EF99AA /* CornerLabels.swift */; }; 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; }; @@ -234,6 +233,7 @@ D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */; }; D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */; }; + D2DEDCB423C3D22700C44CC4 /* MoleculeContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCB323C3D22700C44CC4 /* MoleculeContainerModel.swift */; }; D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; @@ -253,12 +253,11 @@ 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; - 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; + 012A88ED239858E300FE3DA1 /* ContainerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerModel.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; - 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstrainingMoleculeProtocol.swift; sourceTree = ""; }; + 012CA9BD2385C692003F810F /* ContainerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerModelProtocol.swift; sourceTree = ""; }; 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = ""; }; 01509D902327ECE600EF99AA /* CornerLabels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerLabels.swift; sourceTree = ""; }; 01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; @@ -478,6 +477,7 @@ D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scroller.swift; sourceTree = ""; }; D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTemplate.swift; sourceTree = ""; }; + D2DEDCB323C3D22700C44CC4 /* MoleculeContainerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainerModel.swift; sourceTree = ""; }; D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; @@ -508,11 +508,10 @@ 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( + D2DEDCB223C3D17600C44CC4 /* Container */, 0AA33B322398134B0067DD0F /* Primitive Models */, 017BEB392360EEB40024EF95 /* PageModel.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, - 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, ); @@ -533,7 +532,6 @@ 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( - 012CA98823849699003F810F /* SeperatorModel.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, @@ -1079,6 +1077,16 @@ path = BaseClasses; sourceTree = ""; }; + D2DEDCB223C3D17600C44CC4 /* Container */ = { + isa = PBXGroup; + children = ( + 012A88ED239858E300FE3DA1 /* ContainerModel.swift */, + 012CA9BD2385C692003F810F /* ContainerModelProtocol.swift */, + D2DEDCB323C3D22700C44CC4 /* MoleculeContainerModel.swift */, + ); + path = Container; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -1238,13 +1246,13 @@ buildActionMask = 2147483647; files = ( 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, + D2DEDCB423C3D22700C44CC4 /* MoleculeContainerModel.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, - 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */, + 012CA9BE2385C692003F810F /* ContainerModelProtocol.swift in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, - 012CA98923849699003F810F /* SeperatorModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, @@ -1308,7 +1316,7 @@ D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, - 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */, + 012A88EE239858E300FE3DA1 /* ContainerModel.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift index 44973370..bfeb7312 100644 --- a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift @@ -16,6 +16,7 @@ extension MFView { } } } + extension ModelMoleculeViewProtocol where Self: MFView { func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { setUpDefaultWithModel(model, delegateObject, additionalData) diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift index 90377f84..6a6bf03f 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift @@ -8,7 +8,6 @@ import Foundation - extension ViewConstrainingView { public func setUpWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { if self.constrainedView == nil { @@ -16,7 +15,7 @@ extension ViewConstrainingView { } if shouldSetupMoleculeFromJSON, - let moleculeObject = (model as? ConstrainingMoleculeProtocol)?.molecule { + let moleculeObject = (model as? MoleculeContainerModel)?.molecule { if molecule != nil { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeObject, delegateObject, additionalData) } else { @@ -30,7 +29,7 @@ extension ViewConstrainingView { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) } - if let containerMoleculeModel = model as? ContainerMoleculeProtocol { + if let containerMoleculeModel = model as? ContainerModelProtocol { if let useHorizontalMargins = containerMoleculeModel.useHorizontalMargins { updateViewHorizontalDefaults = useHorizontalMargins } @@ -39,10 +38,10 @@ extension ViewConstrainingView { } if let horizontalAlignment = containerMoleculeModel.horizontalAlignment { - alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) + alignHorizontal(horizontalAlignment) } if let verticalAlignment = containerMoleculeModel.verticalAlignment { - alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + alignVertical(verticalAlignment) } } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index de76f739..9b194d48 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -36,6 +36,10 @@ import UIKit } } + public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + return model?.moleculeName + } + open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { self.model = model if let backgroundColorString = model?.backgroundColor { @@ -67,4 +71,3 @@ extension View: MVMCoreUIMoleculeViewProtocol { backgroundColor = .clear } } - diff --git a/MVMCoreUI/Containers/Container.swift b/MVMCoreUI/Containers/Container.swift index 58f7c849..f3f38899 100644 --- a/MVMCoreUI/Containers/Container.swift +++ b/MVMCoreUI/Containers/Container.swift @@ -8,13 +8,6 @@ import UIKit -public protocol ContainerModelProtocol: Model { - var horizontalAlignment: UIStackView.Alignment? { get set } - var verticalAlignment: UIStackView.Alignment? { get set } - var useHorizontalMargins: Bool? { get set } - var useVerticalMargins: Bool? { get set } -} - public class ContainerHelper: NSObject { var leftConstraint: NSLayoutConstraint? var topConstraint: NSLayoutConstraint? @@ -145,15 +138,6 @@ public class ContainerHelper: NSObject { } } - func set(with model: ContainerModelProtocol) { - if let horizontalAlignment = model.horizontalAlignment { - alignHorizontal(horizontalAlignment) - } - if let verticalAlignment = model.verticalAlignment { - alignVertical(verticalAlignment) - } - } - static func getAlignment(for string: String) -> UIStackView.Alignment? { switch string { case "leading": @@ -184,6 +168,19 @@ public class ContainerHelper: NSObject { } } + func updateViewMargins(_ view: UIView, model: ContainerModelProtocol?, size: CGFloat) { + MFStyler.setMarginsFor(view, size: size, defaultHorizontal: model?.useHorizontalMargins ?? false, top: (model?.useVerticalMargins ?? false) ? (model?.topMarginPadding ?? 0) : 0, bottom: (model?.useVerticalMargins ?? false) ? (model?.bottomMarginPadding ?? 0) : 0) + } + + func set(with model: ContainerModelProtocol) { + if let horizontalAlignment = model.horizontalAlignment { + alignHorizontal(horizontalAlignment) + } + if let verticalAlignment = model.verticalAlignment { + alignVertical(verticalAlignment) + } + } + func set(with JSON: [AnyHashable: Any]?, for contained: UIView) { if let horizontalAlignmentString = JSON?.optionalStringForKey("horizontalAlignment"), let alignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() { alignHorizontal(alignment) @@ -205,8 +202,6 @@ open class Container: View { var containerModel: ContainerModelProtocol? { get { return model as? ContainerModelProtocol } } - var topMarginPadding: CGFloat = 0 - var bottomMarginPadding: CGFloat = 0 override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { super.setWithModel(model, delegateObject, additionalData) @@ -220,7 +215,7 @@ public extension Container { override func updateView(_ size: CGFloat) { super.updateView(size) (view as? MVMCoreViewProtocol)?.updateView(size) - MFStyler.setMarginsFor(self, size: size, defaultHorizontal: containerModel?.useHorizontalMargins ?? true, top: containerModel?.useHorizontalMargins ?? true ? topMarginPadding : 0, bottom: containerModel?.useHorizontalMargins ?? true ? bottomMarginPadding : 0) + containerHelper.updateViewMargins(self, model: containerModel, size: size) } /// Will be called only once. diff --git a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift deleted file mode 100644 index 5cb24c4d..00000000 --- a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ConstrainingMoleculeProtocol.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 11/20/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -public protocol ConstrainingMoleculeProtocol: MoleculeProtocol { - var molecule: MoleculeProtocol? { get } -} - -extension ConstrainingMoleculeProtocol { - public var molecule: MoleculeProtocol? { - get { return nil } - } -} diff --git a/MVMCoreUI/Models/Container/ContainerModel.swift b/MVMCoreUI/Models/Container/ContainerModel.swift new file mode 100644 index 00000000..9930ab5c --- /dev/null +++ b/MVMCoreUI/Models/Container/ContainerModel.swift @@ -0,0 +1,54 @@ +// +// ContainerModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/4/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ContainerModel: ContainerModelProtocol, Codable { + public var horizontalAlignment: UIStackView.Alignment? + public var verticalAlignment: UIStackView.Alignment? + public var useHorizontalMargins: Bool? + + public var useVerticalMargins: Bool? + public var topMarginPadding: CGFloat? + public var bottomMarginPadding: CGFloat? + + enum CodingKeys: String, CodingKey { + case verticalAlignment + case horizontalAlignment + case useHorizontalMargins + case useVerticalMargins + case topMarginPadding + case bottomMarginPadding + } + + public init() {} + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) { + verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString) + } + if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) { + horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) + } + useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins) + useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins) + topMarginPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .topMarginPadding) + bottomMarginPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .bottomMarginPadding) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment) + try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment) + try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins) + try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins) + try container.encodeIfPresent(topMarginPadding, forKey: .topMarginPadding) + try container.encodeIfPresent(bottomMarginPadding, forKey: .bottomMarginPadding) + } +} diff --git a/MVMCoreUI/Models/Container/ContainerModelProtocol.swift b/MVMCoreUI/Models/Container/ContainerModelProtocol.swift new file mode 100644 index 00000000..304a4811 --- /dev/null +++ b/MVMCoreUI/Models/Container/ContainerModelProtocol.swift @@ -0,0 +1,19 @@ +// +// ContainerModelProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ContainerModelProtocol { + var horizontalAlignment: UIStackView.Alignment? { get set } + var verticalAlignment: UIStackView.Alignment? { get set } + var useHorizontalMargins: Bool? { get set } + + var useVerticalMargins: Bool? { get set } + var topMarginPadding: CGFloat? { get set } + var bottomMarginPadding: CGFloat? { get set } +} diff --git a/MVMCoreUI/Models/Container/MoleculeContainerModel.swift b/MVMCoreUI/Models/Container/MoleculeContainerModel.swift new file mode 100644 index 00000000..c29fcd2a --- /dev/null +++ b/MVMCoreUI/Models/Container/MoleculeContainerModel.swift @@ -0,0 +1,34 @@ +// +// MoleculeContainerModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class MoleculeContainerModel: ContainerModel { + public var molecule: MoleculeProtocol + + enum MoleculeContainerCodingKeys: String, CodingKey { + case molecule + } + + public init(with moleculeModel: MoleculeProtocol) { + molecule = moleculeModel + super.init() + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: MoleculeContainerCodingKeys.self) + molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: MoleculeContainerCodingKeys.self) + try container.encodeModel(molecule, forKey: .molecule) + } +} diff --git a/MVMCoreUI/Models/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ContainerMoleculeProtocol.swift deleted file mode 100644 index be3ffa60..00000000 --- a/MVMCoreUI/Models/ContainerMoleculeProtocol.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// ContainerMoleculeProtocol.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 12/4/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -protocol ContainerMoleculeProtocol: MoleculeProtocol { - var molecule: MoleculeProtocol? { get } - var useHorizontalMargins: Bool? { get } - var useVerticalMargins: Bool? { get } - var horizontalAlignment: String? { get } - var verticalAlignment: String? { get } -} diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 28d538a0..c28d7080 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -8,33 +8,36 @@ import Foundation -@objcMembers public class HeaderModel: ConstrainingMoleculeProtocol { +@objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "header" public var moleculeName: String? public var backgroundColor: String? - public var molecule: MoleculeProtocol? - public var seperator: MoleculeProtocol? - - public init(molecule: MoleculeProtocol?) { - self.molecule = molecule - self.moleculeName = Self.identifier - } + public var line: LineModel? - enum CodingKeys: String, CodingKey { + enum HeaderCodingKeys: String, CodingKey { case moleculeName - case molecule - case separator + case line } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) + moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + + // Default Values + if topMarginPadding == nil { + topMarginPadding = PaddingDefaultVerticalSpacing + } + if bottomMarginPadding == nil { + bottomMarginPadding = PaddingDefaultVerticalSpacing + } } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: HeaderCodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeModelIfPresent(self.molecule, forKey: .molecule) + try container.encode(line, forKey: .line) } } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index 70dcf379..80263c9f 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -8,33 +8,30 @@ import Foundation -@objcMembers public class ListItemModel: MoleculeProtocol { +@objcMembers public class ListItemModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "listItem" - public var molecule: MoleculeProtocol? public var backgroundColor: String? public var action: ActionModel? + public var line: LineModel? - public init(molecule: MoleculeProtocol?, actionMap: ActionModel?) { - self.molecule = molecule - self.action = actionMap - } - - enum CodingKeys: String, CodingKey { + enum ListItemCodingKeys: String, CodingKey { case moleculeName - case molecule case action + case line } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self) self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: ListItemCodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeModelIfPresent(self.molecule, forKey: .molecule) try container.encodeIfPresent(action, forKey: .action) + try container.encodeIfPresent(line, forKey: .line) } } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index b8d25952..a0e7825c 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -8,28 +8,38 @@ import Foundation -@objcMembers public class MoleculeStackItemModel: MoleculeProtocol { +@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "stackItem" - - public var molecule: MoleculeProtocol? public var backgroundColor: String? - - public init(molecule: MoleculeProtocol?) { - self.molecule = molecule - } - enum CodingKeys: String, CodingKey { - case moleculeName - case molecule - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) + public var spacing: CGFloat? + public var percentage: Int? = 0 + public var gone: Bool = false + + enum MoleculeStackItemCodingKeys: String, CodingKey { + case spacing + case percentage + case gone } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeModelIfPresent(self.molecule, forKey: .molecule) + public override init(with moleculeModel: MoleculeProtocol) { + super.init(with: moleculeModel) + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self) + spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) + percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage) + if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) { + self.gone = gone + } + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self) + try container.encodeIfPresent(spacing, forKey: .spacing) + try container.encodeIfPresent(percentage, forKey: .percentage) + try container.encode(gone, forKey: .gone) } } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 777fcbb1..530c7393 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -8,23 +8,19 @@ import Foundation -@objcMembers public class MoleculeStackModel: ContainerModelProtocol, MoleculeProtocol { +@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol { public static var identifier: String = "moleculeStack" public var backgroundColor: String? - public var molecules: [StackItemModel] - public var axis: NSLayoutConstraint.Axis? = .vertical - public var spacing: CGFloat? - - public var horizontalAlignment: UIStackView.Alignment? - public var verticalAlignment: UIStackView.Alignment? - public var useHorizontalMargins: Bool? - public var useVerticalMargins: Bool? + public var molecules: [MoleculeStackItemModel] + public var axis: NSLayoutConstraint.Axis = .vertical + public var spacing: CGFloat = 16.0 - public init(molecules: [StackItemModel]) { + public init(molecules: [MoleculeStackItemModel]) { self.molecules = molecules + super.init() } - enum CodingKeys: String, CodingKey { + enum StackCodingKeys: String, CodingKey { case moleculeName case molecules case axis @@ -32,19 +28,23 @@ import Foundation } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [StackItemModel] + let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self) + molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [MoleculeStackItemModel] if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) { axis = optionalAxis } - spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) + 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 { - var container = encoder.container(keyedBy: CodingKeys.self) + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: StackCodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(molecules, forKey: .molecules) - try container.encodeIfPresent(axis?.rawValueString, forKey: .axis) + try container.encodeIfPresent(axis.rawValueString, forKey: .axis) try container.encodeIfPresent(spacing, forKey: .spacing) } } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift deleted file mode 100644 index 4c9689fd..00000000 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// SeperatorModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 11/19/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -class SeperatorModel: MoleculeProtocol { - public static var identifier: String = "line" - public var backgroundColor: String? - public var type: String? -} diff --git a/MVMCoreUI/Molecules/Items/StackItem.swift b/MVMCoreUI/Molecules/Items/StackItem.swift index f976667d..e121a1ee 100644 --- a/MVMCoreUI/Molecules/Items/StackItem.swift +++ b/MVMCoreUI/Molecules/Items/StackItem.swift @@ -8,81 +8,8 @@ import UIKit -open class StackItemModel: ContainerModelProtocol, MoleculeProtocol { - public static var identifier: String = "stackItem" - public var backgroundColor: String? - public var view: StackItem? - - public var molecule: MoleculeProtocol - public var spacing: CGFloat? = 16 - public var percentage: Int? = 0 - public var verticalAlignment: UIStackView.Alignment? - public var horizontalAlignment: UIStackView.Alignment? - public var useHorizontalMargins: Bool? = false - public var useVerticalMargins: Bool? = false - public var gone: Bool? = false - - enum CodingKeys: String, CodingKey { - case molecule - case spacing - case percentage - case verticalAlignment - case horizontalAlignment - case useHorizontalMargins - case useVerticalMargins - case gone - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) - spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) - percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage) - if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) { - verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString) - } - if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) { - horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) - } - useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins) - useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins) - gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModel(molecule, forKey: .molecule) - try container.encodeIfPresent(spacing, forKey: .spacing) - try container.encodeIfPresent(percentage, forKey: .percentage) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment) - try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins) - try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins) - try container.encodeIfPresent(gone, forKey: .gone) - } - - func update(with json: [AnyHashable: Any]?) { - gone = json?.boolForKey("gone") ?? (json == nil) - spacing = json?.optionalCGFloatForKey("spacing") - percentage = json?["percent"] as? Int - if let horizontalAlignmentString = json?.optionalStringForKey("horizontalAlignment") { - horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) - } else { - horizontalAlignment = nil - } - - if let verticalAlignmentString = json?.optionalStringForKey("verticalAlignment") { - verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString) - } else { - verticalAlignment = nil - } - - useHorizontalMargins = json?.optionalBoolForKey("useHorizontalMargins") ?? false - useVerticalMargins = json?.optionalBoolForKey("useVerticalMargins") ?? false - } -} - open class StackItem: MoleculeContainer { - - + var stackItemModel: MoleculeStackItemModel? { + get { return model as? MoleculeStackItemModel } + } } diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index 98c1818c..6668d2be 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -10,4 +10,12 @@ import Foundation public protocol ModelMoleculeViewProtocol { func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) + + func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? +} + +extension ModelMoleculeViewProtocol { + public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + return nil + } } diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index 51d9a53a..e6ef0048 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -8,54 +8,33 @@ import UIKit -open class ModuleMoleculeModel: ContainerModelProtocol { +open class ModuleMoleculeModel: MoleculeProtocol { + public var backgroundColor: String? public static var identifier: String = "moduleMolecule" - - public var molecule: MoleculeProtocol? public var moduleName: String - public var horizontalAlignment: UIStackView.Alignment? = .fill - public var verticalAlignment: UIStackView.Alignment? = .fill - public var useHorizontalMargins: Bool? = false - public var useVerticalMargins: Bool? = false enum CodingKeys: String, CodingKey { - case molecule case moduleName - case horizontalAlignment - case verticalAlignment - case useHorizontalMargins - case useVerticalMargins } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) moduleName = try typeContainer.decode(String.self, forKey:.moduleName) - if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) { - verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString) - } - if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) { - horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) - } - useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins) - useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moduleName, forKey: .moduleName) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment) - try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins) - try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins) } } open class ModuleMolecule: Container { var moduleMoleculeModel: ModuleMoleculeModel? { get { return model as? ModuleMoleculeModel } + } + public override func setupView() { super.setupView() - containerModel = ModuleMoleculeModel() } open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { diff --git a/MVMCoreUI/Molecules/MoleculeContainer.swift b/MVMCoreUI/Molecules/MoleculeContainer.swift index 14a5bb4a..0eea4414 100644 --- a/MVMCoreUI/Molecules/MoleculeContainer.swift +++ b/MVMCoreUI/Molecules/MoleculeContainer.swift @@ -24,4 +24,17 @@ open class MoleculeContainer: Container { } super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + if let casteModel = model as? MoleculeContainerModel { + if view != nil { + (view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData) + } else { + if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(casteModel.molecule, delegateObject) { + addAndContain(molecule) + } + } + } + super.setWithModel(model, delegateObject, additionalData) + } } diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/StandardFooterView.swift index a83611cc..e433ec88 100644 --- a/MVMCoreUI/Molecules/StandardFooterView.swift +++ b/MVMCoreUI/Molecules/StandardFooterView.swift @@ -9,22 +9,10 @@ import UIKit open class StandardFooterView: MoleculeContainer { - open override func setupView() { - super.setupView() - topMarginPadding = PaddingDefaultVerticalSpacing - bottomMarginPadding = PaddingDefaultVerticalSpacing - } - public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { if let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) { return height + PaddingDefaultVerticalSpacing + PaddingDefaultVerticalSpacing } return 42 } - - open override func reset() { - super.reset() - topMarginPadding = PaddingDefaultVerticalSpacing - bottomMarginPadding = PaddingDefaultVerticalSpacing - } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index cf44ef6a..c0994282 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -11,6 +11,10 @@ import UIKit public class StandardHeaderView: MoleculeContainer { var line: Line? + var headerModel: HeaderModel? { + get { return model as? HeaderModel } + } + // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) @@ -19,8 +23,6 @@ public class StandardHeaderView: MoleculeContainer { public override func setupView() { super.setupView() - topMarginPadding = PaddingDefaultVerticalSpacing - bottomMarginPadding = PaddingDefaultVerticalSpacing guard line == nil else { return } let line = Line() @@ -47,7 +49,7 @@ public class StandardHeaderView: MoleculeContainer { return } - if let seperatorModel = headerModel.seperator as? LineModel { + if let seperatorModel = headerModel.line { line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } } @@ -75,8 +77,6 @@ public class StandardHeaderView: MoleculeContainer { open override func reset() { super.reset() line?.style = .heavy - topMarginPadding = PaddingDefaultVerticalSpacing - bottomMarginPadding = PaddingDefaultVerticalSpacing } public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 869bd23a..152411ea 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -8,12 +8,25 @@ import UIKit +struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { + static var identifier: String = "eyebrowHeadlineBodyLink" + var backgroundColor: String? + + public var eyeBrow: LabelModel? + public var headline: LabelModel? + public var body: LabelModel? + public var link: LineModel? +} + @objcMembers open class EyebrowHeadlineBodyLink: ViewConstrainingView { let stack = MoleculeStackView(frame: .zero) let eyebrow = Label.commonLabelB3(true) let headline = Label.commonLabelB1(true) let body = Label.commonLabelB2(true) let link = MFTextButton(nil, constrainHeight: false, forWidth: MVMCoreUIUtility.getWidth()) + var casteModel: EyebrowHeadlineBodyLinkModel? { + get { return model as? EyebrowHeadlineBodyLinkModel } + } // MARK: - MFViewProtocol open override func setupView() { @@ -21,17 +34,21 @@ import UIKit guard stack.superview == nil else { return } - stack.spacing = 0 - addSubview(stack) - pinView(toSuperView: stack) - stack.addStackItem(StackItemModel(with: StackItem(andContain: eyebrow)), lastItem: false) - stack.addStackItem(StackItemModel(with: StackItem(andContain: headline)), lastItem: false) - stack.addStackItem(StackItemModel(with: StackItem(andContain: body)), lastItem: false) + let eyebrowStackItem = MoleculeStackItemModel(with: casteModel!.eyeBrow!) + let headlineStackItem = MoleculeStackItemModel(with: casteModel!.headline!) + let bodyStackItem = MoleculeStackItemModel(with: casteModel!.body!) + let linkStackItem = MoleculeStackItemModel(with: casteModel!.link!) // To visually take into account the extra padding in the intrinsic content of a button. - let stackItem = StackItemModel(with: StackItem(andContain: link)) - stackItem.spacing = -6 - stack.addStackItem(stackItem, lastItem: true) + linkStackItem.spacing = -6 + + let stackModel = MoleculeStackModel(molecules: [eyebrowStackItem,headlineStackItem,bodyStackItem,linkStackItem]) + stackModel.spacing = 0 + stack.model = stackModel + stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)] + + addSubview(stack) + pinView(toSuperView: stack) } open override func updateView(_ size: CGFloat) { @@ -42,7 +59,7 @@ import UIKit // MARK: - MVMCoreUIMoleculeViewProtocol open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - eyebrow.setWithJSON(json?.optionalDictionaryForKey("eyebrow"), delegateObject: delegateObject, additionalData: additionalData) + /*eyebrow.setWithJSON(json?.optionalDictionaryForKey("eyebrow"), delegateObject: delegateObject, additionalData: additionalData) stack.items[0].gone = !eyebrow.hasText headline.setWithJSON(json?.optionalDictionaryForKey("headline"), delegateObject: delegateObject, additionalData: additionalData) stack.items[1].gone = !headline.hasText @@ -50,13 +67,13 @@ import UIKit stack.items[2].gone = !body.hasText link.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData) stack.items[3].gone = link.titleLabel?.text?.count ?? 0 == 0 - stack.restack() + stack.restack()*/ } open override func reset() { super.reset() stack.reset() - stack.spacing = 0 + stack.stackModel?.spacing = 0 eyebrow.styleB3(true) headline.styleB1(true) body.styleB2(true) diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 31177540..3845ecdb 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -14,6 +14,7 @@ open class MoleculeStackView: Container { var stackModel: MoleculeStackModel? { get { return model as? MoleculeStackModel } } + var stackItems: [StackItem] = [] var moleculesShouldSetHorizontalMargins = false var moleculesShouldSetVerticalMargins = false @@ -27,15 +28,21 @@ open class MoleculeStackView: Container { /// Restacks the existing items. func restack() { - guard let stackItems = stackModel?.molecules else { return } - setWithStackItems(stackItems) + removeAllItemViews() + let stackItems = self.stackItems + self.stackItems = [] + let lastItem = stackItems.last(where: { (item) -> Bool in + return !item.stackItemModel!.gone + }) + for item in stackItems { + addStackItem(item, lastItem: item === lastItem) + } } /// Removes all stack items views from the view. func removeAllItemViews() { - guard let stackItems = stackModel?.molecules else { return } for item in stackItems { - item.view?.removeFromSuperview() + item.removeFromSuperview() } } @@ -76,9 +83,8 @@ open class MoleculeStackView: Container { super.updateView(size) directionalLayoutMargins.leading = 0 directionalLayoutMargins.trailing = 0 - guard let stackItems = stackModel?.molecules else { return } for item in stackItems { - item.view?.updateView(size) + item.updateView(size) } } @@ -86,64 +92,58 @@ open class MoleculeStackView: Container { public override func reset() { super.reset() backgroundColor = .clear - guard let stackItems = stackModel?.molecules else { return } for item in stackItems { - item.view?.reset() + item.reset() } } public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + let previousModel = stackModel super.setWithModel(model, delegateObject, additionalData) + removeAllItemViews() + + // If the items in the stack are different, clear them, create new ones. + if (previousModel == nil) || nameForReuse(previousModel, delegateObject) != nameForReuse(model, delegateObject) { + stackItems = [] + createStackItemsFromModel(with: delegateObject) + } else if let models = stackModel?.molecules { + for (index, element) in models.enumerated() { + stackItems[index].setWithModel(element, delegateObject, additionalData) + } + } + restack() stackModel?.useHorizontalMargins = moleculesShouldSetHorizontalMargins stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins } - + + public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + // This will aggregate names of molecules to make an id. + guard let model = model as? MoleculeStackModel else { + return "stack<>" + } + var name = "stack<" + for case let item in model.molecules { + if let moleculeName = item.molecule.moleculeName { + if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol, let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { + name.append(nameForReuse + ",") + } else { + name.append(moleculeName + ",") + } + } + } + name.append(">") + return name + } + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { if model == nil { - model = MoleculeStackModel(molecules: []) - } - - let previousJSON = self.json - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - removeAllItemViews() - - // If the items in the stack are the same, just update previous items instead of re-allocating. - var items: [StackItemModel]? - if MoleculeStackView.name(forReuse: previousJSON, delegateObject: delegateObject) == MoleculeStackView.name(forReuse: json, delegateObject: delegateObject) { - items = stackModel?.molecules - } - stackModel?.molecules = [] - - guard let molecules = json?.arrayForKey(KeyMolecules) as? [[String: Any]] else { - return - } - - // Sets the stack attributes - stackModel?.axis - setAxisWithJSON(json) - spacing = json?.optionalCGFloatForKey("spacing") ?? 16 - - // Adds the molecules and sets the json. - for (index, map) in molecules.enumerated() { - var view: UIView? - var stackItemModel: StackItemModel - if let item = items?[index] { - stackItemModel = item - item.update(with: map) - view = item.view - (view as? MVMCoreUIMoleculeViewProtocol)?.setWithJSON(map, delegateObject: delegateObject, additionalData: nil) - addStackItem(item, lastItem: index == molecules.count - 1) - } else { - let stackItem = StackItem() - stackItem.setWithJSON(map, delegateObject: delegateObject, additionalData: additionalData) - view = stackItem - stackItemModel = StackItemModel(with: stackItem, json: map) - addStackItem(stackItemModel, lastItem: index == molecules.count - 1) - } - - stackItemModel.useHorizontalMargins = moleculesShouldSetHorizontalMargins - stackItemModel.useVerticalMargins = moleculesShouldSetVerticalMargins + let data = try! JSONSerialization.data(withJSONObject: json!) + let decoder = JSONDecoder() + let model = try! decoder.decode(MoleculeStackModel.self, from: data) + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + } else { + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) } } @@ -198,78 +198,76 @@ open class MoleculeStackView: Container { } // MARK: - Adding to stack - /// Adds the view to the stack. - func addView(_ view: UIView, lastItem: Bool) { - addStackItem(StackItemModel(with: StackItem(andContain: view)), lastItem: lastItem) + /// Creates all of the stackItems for the stackItemModels + func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { + guard let stackItemModels = stackModel?.molecules else { return } + for model in stackItemModels { + if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? StackItem { + stackItems.append(stackItem) + } + } } - /// Adds the stack item to the stack. - func addStackItem(_ stackItem: StackItemModel, lastItem: Bool) { - guard !stackItem.gone else { - items.append(stackItem) + /// Adds the view to the stack. + func addView(_ view: View, lastItem: Bool) { + guard let model = view.model else { return } + let stackItem = StackItem(andContain: view) + stackItem.model = MoleculeStackItemModel(with: model) + addStackItem(stackItem, lastItem: lastItem) + } + + /// Adds the stack item view + private func addStackItem(_ stackItem: StackItem, lastItem: Bool) { + let stackModel = self.stackModel! + let model = stackItem.stackItemModel! + guard !model.gone else { + // Gone views do not show return } - let view = stackItem.view - contentView.addSubview(view) - view.translatesAutoresizingMaskIntoConstraints = false + contentView.addSubview(stackItem) + stackItem.translatesAutoresizingMaskIntoConstraints = false - let spacing = stackItem.spacing ?? self.spacing - let verticalAlignment = stackItem.verticalAlignment ?? (stackItem.percentage == nil && axis == .vertical ? .fill : (axis == .vertical ? .leading : .center)) - let horizontalAlignment = stackItem.horizontalAlignment ?? (view.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (axis == .vertical || stackItem.percentage == nil ? .fill : .leading) - view.containerHelper.alignHorizontal(horizontalAlignment) - view.containerHelper.alignVertical(verticalAlignment) + let spacing = model.spacing ?? stackModel.spacing + let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percentage == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center)) + let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percentage == nil ? .fill : .leading) + stackItem.containerHelper.alignHorizontal(horizontalAlignment) + stackItem.containerHelper.alignVertical(verticalAlignment) - let first = items.first { !$0.gone } == nil - if axis == .vertical { + let first = stackItems.first { !($0.stackItemModel?.gone ?? false) } == nil + if stackModel.axis == .vertical { if first { - pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0) - } else if let previousView = items.last(where: { stackItem in - return !stackItem.gone - })?.view { - view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true + pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) + } else if let previousView = stackItems.last(where: { item in + return !item.stackItemModel!.gone + }) { + stackItem.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true } - pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) - pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0) - if let percent = stackItem.percentage { - view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true + pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) + pinView(contentView, toView: stackItem, attribute: .trailing, relation: .equal, priority: .required, constant: 0) + if let percent = model.percentage { + stackItem.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true } if lastItem { - pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) + pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0) } } else { if first { // First horizontal item has no spacing by default unless told otherwise. - pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0) - } else if let previousView = items.last(where: { stackItem in - return !stackItem.gone - })?.view { - view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true + pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) + } else if let previousView = stackItems.last(where: { item in + return !item.stackItemModel!.gone + }) { + stackItem.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true } - pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) - pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) - if let percent = stackItem.percentage { - view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true + pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) + pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0) + if let percent = model.percentage { + stackItem.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true + } + if lastItem { + pinView(contentView, toView: stackItem, attribute: .right, relation: .equal, priority: .required, constant: 0) } } - if lastItem { - pinView(contentView, toView: view, attribute: .right, relation: .equal, priority: .required, constant: 0) - } - items.append(stackItem) - } - - func setWithStackItems(_ items: [StackItemModel]) { - removeAllItemViews() - self.items.removeAll() - var previousPresentItem: StackItemModel? = nil - for item in items { - if !item.gone { - previousPresentItem = item - } - addStackItem(item, lastItem: false) - } - if let lastView = previousPresentItem?.view { - let attribute: NSLayoutConstraint.Attribute = axis == .vertical ? .bottom : .right - pinView(contentView, toView: lastView, attribute: attribute, relation: .equal, priority: .required, constant: 0) - } + stackItems.append(stackItem) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 378332b6..c656ab2f 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -67,7 +67,8 @@ @"tabsListItem": TabsTableViewCell.class, @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, - @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class + @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, + @"stackItem": StackItem.class } mutableCopy]; }); return mapping; diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 983fac13..ac96c44f 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -18,7 +18,6 @@ import Foundation ModelRegistry.register(ListItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(LineModel.self) - ModelRegistry.register(SeperatorModel.self) ModelRegistry.register(ProgressBarModel.self) ModelRegistry.register(MultiProgressBarModel.self) ModelRegistry.register(CaretViewModel.self) From 2abd6a866a6502d98e31e30e64f7a0b171aa7ec9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Jan 2020 09:28:54 -0500 Subject: [PATCH 068/272] Explaining use case of Color. --- MVMCoreUI/Models/Primitive Models/Color.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift index 027b826e..55740fa0 100644 --- a/MVMCoreUI/Models/Primitive Models/Color.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -8,7 +8,19 @@ import UIKit - +/* + Use case: + For the Codable model define a variable such as + + var color: UIColor + + In the decode initializer: + color = try typeContainer.decode(Color.self, forKey: .color).uiColor + + In the encode initializer: + try container.encodeIfPresent(Color(uiColor: color), forKey: .color) + + */ public final class Color: Codable { //-------------------------------------------------- // MARK: - Properties From 2d0377acfc102dcb78367d1b8dd18f92ebb725d5 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Jan 2020 09:30:55 -0500 Subject: [PATCH 069/272] small format. --- MVMCoreUI/Models/Primitive Models/Color.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift index 55740fa0..31206a5e 100644 --- a/MVMCoreUI/Models/Primitive Models/Color.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -10,8 +10,7 @@ import UIKit /* Use case: - For the Codable model define a variable such as - + For the Codable model define a variable such as: var color: UIColor In the decode initializer: From 84462a197eca263e11f3ddb4cba59e2c3d384051 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Jan 2020 09:37:47 -0500 Subject: [PATCH 070/272] changed comment. --- MVMCoreUI/Models/Primitive Models/Color.swift | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift index 31206a5e..e4c0e4fa 100644 --- a/MVMCoreUI/Models/Primitive Models/Color.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -9,16 +9,9 @@ import UIKit /* - Use case: - For the Codable model define a variable such as: - var color: UIColor - - In the decode initializer: - color = try typeContainer.decode(Color.self, forKey: .color).uiColor - - In the encode initializer: - try container.encodeIfPresent(Color(uiColor: color), forKey: .color) - + UIColor is not supported by Codable. This Color class + effectively turns UIColor into a primitive class like + Int and String and can be used the same. */ public final class Color: Codable { //-------------------------------------------------- From b620a533d52b4d69a1a3a6ea56de398914193b81 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Jan 2020 11:22:34 -0500 Subject: [PATCH 071/272] Color CaretLink model change name --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++--- ...ButtonModel.swift => CaretLinkModel.swift} | 30 ++++++++++------- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 2 +- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 33 +++++++++++-------- .../ModelProtocols/MoleculeProtocol.swift | 2 +- 5 files changed, 43 insertions(+), 32 deletions(-) rename MVMCoreUI/Atoms/Buttons/{CaretButtonModel.swift => CaretLinkModel.swift} (59%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 18eaaf7b..8363aad1 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -66,7 +66,7 @@ 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 /* CaretButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretButtonModel.swift */; }; + 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; 0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; }; @@ -326,7 +326,7 @@ 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 /* CaretButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretButtonModel.swift; sourceTree = ""; }; + 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretLinkModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackViewAlignment+Extension.swift"; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; @@ -983,7 +983,7 @@ isa = PBXGroup; children = ( DBC4391A224421A0001AB423 /* CaretButton.swift */, - 01F2A03123A4498200D954D8 /* CaretButtonModel.swift */, + 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */, D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, @@ -1418,7 +1418,7 @@ 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, 012CA9E223888AED003F810F /* (null) in Sources */, 012A88DA238ED42E00FE3DA1 /* (null) in Sources */, - 01F2A03223A4498200D954D8 /* CaretButtonModel.swift in Sources */, + 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift similarity index 59% rename from MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift rename to MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index cf21a19b..0cd9c252 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -1,5 +1,5 @@ // -// CaretButtonModel.swift +// CaretLinkModel.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 12/13/19. @@ -9,14 +9,14 @@ import Foundation import MVMCore -public class CaretButtonModel: MoleculeProtocol { - public static var identifier: String = "caretButton" +public class CaretLinkModel: MoleculeProtocol { + public static var identifier: String = "caretLink" public var backgroundColor: String? public var label: LabelModel public var action: ActionProtocol - public var enabledColor: String? - public var disabledColor: String? - public var enabled: Bool? + public var enabledColor: UIColor = .black + public var disabledColor: UIColor = .mfSilver() + public var enabled: Bool = true public init(label: LabelModel, action: ActionProtocol) { self.label = label @@ -36,9 +36,15 @@ public class CaretButtonModel: MoleculeProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) label = try typeContainer.decode(LabelModel.self, forKey: .label) - enabledColor = try typeContainer.decodeIfPresent(String.self, forKey: .enabledColor) - disabledColor = try typeContainer.decodeIfPresent(String.self, forKey: .disabledColor) - enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor { + enabledColor = color + } + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor)?.uiColor { + disabledColor = color + } + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + self.enabled = enabled + } action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type) } @@ -47,8 +53,8 @@ public class CaretButtonModel: MoleculeProtocol { try container.encode(label, forKey: .label) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) - try container.encodeIfPresent(enabledColor, forKey: .enabledColor) - try container.encodeIfPresent(disabledColor, forKey: .disabledColor) - try container.encodeIfPresent(enabled, forKey: .enabled) + try container.encode(Color(uiColor: enabledColor), forKey: .enabledColor) + try container.encode(Color(uiColor: disabledColor), forKey: .disabledColor) + try container.encode(enabled, forKey: .enabled) } } diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index 5a8998db..8d2bc16c 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class CaretViewModel: MoleculeProtocol { public static var identifier: String = "caretView" - public var backgroundColor: String? + public var backgroundColor: Color? public var strokeColor: String? public var isHidden: Bool? public var isOpaque: Bool? diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 3450fc87..784b938c 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -10,33 +10,38 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeProtocol { public static var identifier: String = "progressbar" - public var moleculeName: String public var isRounded: Bool? public var thickness: CGFloat? ///from 0 to 100 - public var percentage: Float - public var progressColor: String? - public var backgroundColor: String? + public var percent: CGFloat + public var progressColor: Color = Color(uiColor: .mfCerulean()) + public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) enum CodingKeys: String, CodingKey { case moleculeName case isRounded = "roundRect" case thickness - case percentage = "percent" + case percent case progressColor case backgroundColor } + init(_ percent: CGFloat) { + self.percent = percent + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) - self.thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) - self.percentage = try typeContainer.decode(Float.self, forKey: .percentage) - self.progressColor = try typeContainer.decodeIfPresent(String.self, forKey: .progressColor) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) - + isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) + thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) + 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: .backgroundColor) { + backgroundColor = color + } } public func encode(to encoder: Encoder) throws { @@ -44,8 +49,8 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(isRounded, forKey: .isRounded) try container.encodeIfPresent(thickness, forKey: .thickness) - try container.encodeIfPresent(percentage, forKey: .percentage) - try container.encodeIfPresent(progressColor, forKey: .progressColor) + try container.encode(percent, forKey: .percent) + try container.encode(progressColor, forKey: .progressColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift index e05f16b6..b8117e60 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift @@ -2,7 +2,7 @@ import Foundation public protocol MoleculeProtocol: Model { var moleculeName: String? { get } - var backgroundColor: String? { get set} + var backgroundColor: Color? { get set} } extension MoleculeProtocol { From 2e514a7de589d0aeb2aab424f4e4b1f6eef19a0b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Jan 2020 13:22:45 -0500 Subject: [PATCH 072/272] Colors --- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 4 ++-- MVMCoreUI/Atoms/Views/DashLine.swift | 4 ++-- MVMCoreUI/Atoms/Views/DashLineModel.swift | 6 +++--- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 2 +- MVMCoreUI/Atoms/Views/Label.swift | 4 ++-- MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift | 4 ++-- MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift | 2 +- MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift | 4 ++-- MVMCoreUI/Atoms/Views/MultiProgressModel.swift | 2 +- MVMCoreUI/Atoms/Views/ProgressBar.swift | 8 +++----- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 2 +- MVMCoreUI/BaseClasses/View.swift | 4 ++-- .../Models/ModelProtocols/ContainerMoleculeProtocol.swift | 2 +- MVMCoreUI/Models/Molecules/CarouselItemModel.swift | 4 ++-- MVMCoreUI/Models/Molecules/CarouselModel.swift | 4 ++-- MVMCoreUI/Models/Molecules/DropDownListItemModel.swift | 4 ++-- MVMCoreUI/Models/Molecules/DropDownModel.swift | 2 +- MVMCoreUI/Models/Molecules/FooterModel.swift | 4 ++-- MVMCoreUI/Models/Molecules/HeaderModel.swift | 2 +- MVMCoreUI/Models/Molecules/LineModel.swift | 2 +- MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift | 2 +- MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift | 2 +- MVMCoreUI/Models/Molecules/MoleculeStackModel.swift | 2 +- MVMCoreUI/Models/Molecules/TextFieldModel.swift | 2 +- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 +- .../Molecules/Items/MoleculeCollectionViewCell.swift | 4 ++-- MVMCoreUI/Molecules/Items/TableViewCell.swift | 4 ++-- .../EyebrowHeadlineBodyLink.swift | 2 +- .../VerticalCombinationViews/HeadlineBodyModel.swift | 2 +- 29 files changed, 45 insertions(+), 47 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 0cd9c252..4d3c6223 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -11,7 +11,7 @@ import MVMCore public class CaretLinkModel: MoleculeProtocol { public static var identifier: String = "caretLink" - public var backgroundColor: String? + public var backgroundColor: Color? public var label: LabelModel public var action: ActionProtocol public var enabledColor: UIColor = .black @@ -34,7 +34,7 @@ public class CaretLinkModel: MoleculeProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) label = try typeContainer.decode(LabelModel.self, forKey: .label) if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor { enabledColor = color diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 52ed9a65..48decdf9 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -90,12 +90,12 @@ open class DashLine: View { guard let dashLineModel = model as? DashLineModel else { return } - dashColor = UIColor.mfGet(forHex: dashLineModel.dashColor) + dashColor = dashLineModel.dashColor.uiColor if let isHiddenValue = dashLineModel.isHidden { isHidden = isHiddenValue } if let backgroundColor = dashLineModel.backgroundColor { - dashLayer?.backgroundColor = UIColor.mfGet(forHex: backgroundColor).cgColor + dashLayer?.backgroundColor = backgroundColor.uiColor.cgColor } } } diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 172e5dd6..06d85f08 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -10,12 +10,12 @@ import Foundation @objcMembers public class DashLineModel: MoleculeProtocol { public static var identifier: String = "dashLine" - public var backgroundColor: String? + public var backgroundColor: Color? - public var dashColor: String + public var dashColor: Color public var isHidden: Bool? - public init(dashColor: String) { + public init(dashColor: Color) { self.dashColor = dashColor } } diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 16c32d8f..a65c946a 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeProtocol { public static var identifier: String = "image" public var moleculeName: String - public var backgroundColor: String? + public var backgroundColor: Color? public var image: String public var accessibilityText: String? diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index b37e74fb..b4b4e36a 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -235,8 +235,8 @@ public typealias ActionBlock = () -> () } makeWholeViewClickable = labelModel.makeWholeViewClickable ?? false - if let backgroundColorHex = labelModel.backgroundColor, !backgroundColorHex.isEmpty { - backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + if let backgroundColor = labelModel.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } if let accessibilityText = labelModel.accessibilityText { accessibilityLabel = accessibilityText diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index 2b87186f..90c694a0 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -12,7 +12,7 @@ import Foundation @objcMembers public class LabelModel: MoleculeProtocol { public static var identifier: String = "label" public var moleculeName: String? - public var backgroundColor: String? + public var backgroundColor: Color? public var text: String public var accessibilityText: String? @@ -52,7 +52,7 @@ import Foundation self.text = try typeContainer.decode(String.self, forKey: .text) self.accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle) self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index 30015d70..e006afc9 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers public class LeftRightLabelModel: MoleculeProtocol { public static var identifier: String = "leftRightLabel" - public var backgroundColor: String? + public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel diff --git a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift index bfeb7312..df6b09a5 100644 --- a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift @@ -11,8 +11,8 @@ import Foundation extension MFView { public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { self.model = model - if let backgroundColorString = model?.backgroundColor { - backgroundColor = UIColor.mfGet(for: backgroundColorString) + if let backgroundColor = model?.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 25522070..9d1f11fd 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -17,7 +17,7 @@ import Foundation @objcMembers public class MultiProgressBarModel: MoleculeProtocol { public static var identifier: String = "multiProgressBar" public var moleculeName: String - public var backgroundColor: String? + public var backgroundColor: Color? public var progressList: [SingleProgressBarModel] public var thickness: CGFloat? public var roundedRect: Bool? diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 90d63dfb..8a3b0bb0 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -57,12 +57,10 @@ import Foundation } isRounded = progressBarModel.isRounded ?? false thickness = progressBarModel.thickness ?? 8 - progress = (progressBarModel.percentage)/100.0 - if let progressColor = progressBarModel.progressColor { - progressTintColor = UIColor.mfGet(forHex: progressColor) - } + progress = Float((progressBarModel.percent)/100.0) + progressTintColor = progressBarModel.progressColor.uiColor if let backgroundColor = progressBarModel.backgroundColor { - trackTintColor = UIColor.mfGet(forHex: backgroundColor) + trackTintColor = backgroundColor.uiColor } } diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 784b938c..47fabb6a 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -14,7 +14,7 @@ import Foundation public var isRounded: Bool? public var thickness: CGFloat? ///from 0 to 100 - public var percent: CGFloat + @Clamping(range: 0...100) public var percent: CGFloat public var progressColor: Color = Color(uiColor: .mfCerulean()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 8ae6dfa7..0cb1088d 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -42,8 +42,8 @@ import UIKit open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { self.model = model - if let backgroundColorString = model?.backgroundColor { - backgroundColor = UIColor.mfGet(for: backgroundColorString) + if let backgroundColor = model?.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } } } diff --git a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift index 81ffd123..9a303bdf 100644 --- a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift @@ -17,7 +17,7 @@ public protocol ContainerMoleculeProtocol: MoleculeProtocol { } extension ContainerMoleculeProtocol { - public var backgroundColor: String? { + public var backgroundColor: Color? { get { return nil } } diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift index 3339ed09..1ccf898f 100644 --- a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -12,7 +12,7 @@ import Foundation @objcMembers public class CarouselItemModel: ContainerMoleculeProtocol { public static var identifier: String = "carouselItem" public var molecule: MoleculeProtocol - public var backgroundColor: String? + public var backgroundColor: Color? public init(molecule: MoleculeProtocol) { self.molecule = molecule @@ -27,7 +27,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecule = try typeContainer.decodeMolecule(codingKey: .molecule) - backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift index 56bec824..9b55f97a 100644 --- a/MVMCoreUI/Models/Molecules/CarouselModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers public class CarouselModel: MoleculeProtocol { public static var identifier: String = "carousel" - public var backgroundColor: String? + public var backgroundColor: Color? public var molecules: [CarouselItemModel] public var spacing: Float? @@ -41,7 +41,7 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.spacing = try typeContainer.decode(Float.self, forKey: .spacing) self.border = try typeContainer.decode(Bool.self, forKey: .border) self.loop = try typeContainer.decode(Bool.self, forKey: .loop) diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift index 9e447713..260e7063 100644 --- a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -12,7 +12,7 @@ import Foundation public static var identifier: String = "dropDownListItem" public var molecule: MoleculeProtocol public var molecules: [[ListItemModel]] - public var backgroundColor: String? + public var backgroundColor: Color? public var separator: LineModel? public var dropDown: DropDownModel @@ -36,7 +36,7 @@ import Foundation molecule = try typeContainer.decodeMolecule(codingKey: .molecule) self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) self.separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) } diff --git a/MVMCoreUI/Models/Molecules/DropDownModel.swift b/MVMCoreUI/Models/Molecules/DropDownModel.swift index b28eda5d..c0320737 100644 --- a/MVMCoreUI/Models/Molecules/DropDownModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class DropDownModel: MoleculeProtocol { public static var identifier: String = "dropDownModel" - public var backgroundColor: String? + public var backgroundColor: Color? public var label: String public var options: [String] } diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 83043f81..93f0a4e3 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -12,7 +12,7 @@ import Foundation @objcMembers public class FooterModel: ContainerMoleculeProtocol { public static var identifier: String = "footer" public var moleculeName: String? - public var backgroundColor: String? + public var backgroundColor: Color? public var molecule: MoleculeProtocol public init(molecule: MoleculeProtocol){ @@ -28,7 +28,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor) + self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule) } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index c28d7080..2f824773 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "header" public var moleculeName: String? - public var backgroundColor: String? + public var backgroundColor: Color? public var line: LineModel? enum HeaderCodingKeys: String, CodingKey { diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift index c6a22c62..66010536 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Models/Molecules/LineModel.swift @@ -10,6 +10,6 @@ import UIKit @objcMembers public class LineModel: MoleculeProtocol { public static var identifier: String = "line" - public var backgroundColor: String? + public var backgroundColor: Color? public var type: String? } diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift index 6e170b03..35702824 100644 --- a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -9,7 +9,7 @@ import Foundation open class ModuleMoleculeModel: MoleculeProtocol { - public var backgroundColor: String? + public var backgroundColor: Color? public static var identifier: String = "moduleMolecule" public var moduleName: String diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index a0e7825c..106ea6e5 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "stackItem" - public var backgroundColor: String? + public var backgroundColor: Color? public var spacing: CGFloat? public var percentage: Int? = 0 public var gone: Bool = false diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 530c7393..f8012a30 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol { public static var identifier: String = "moleculeStack" - public var backgroundColor: String? + public var backgroundColor: Color? public var molecules: [MoleculeStackItemModel] public var axis: NSLayoutConstraint.Axis = .vertical public var spacing: CGFloat = 16.0 diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift index ea6f3deb..3a76bbb3 100644 --- a/MVMCoreUI/Models/Molecules/TextFieldModel.swift +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -11,7 +11,7 @@ import UIKit @objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { public static var identifier: String = "textField" - public var backgroundColor: String? + public var backgroundColor: Color? public var editable: Bool? public var disabled: Bool? diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 1311e69f..bdff2842 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -12,7 +12,7 @@ import MVMCore @objcMembers public class ListItemModel: ListItemModelProtocol { public static var identifier: String = "listItem" public var molecule: MoleculeProtocol - public var backgroundColor: String? + public var backgroundColor: Color? public var action: ActionProtocol? public var hideArrow: Bool? public var separator: LineModel? diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index d532147c..b976ca64 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -87,8 +87,8 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi peakingRightArrow.tintColor = color } - if let backgroundColorString = collectionModel.backgroundColor { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) + if let backgroundColor = collectionModel.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } if molecule == nil { diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 60af3f68..d74f0ee5 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -163,8 +163,8 @@ import UIKit bottomMarginPadding = 0 } - if let backgroundColorString = model.backgroundColor { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) + if let backgroundColor = model.backgroundColor { + self.backgroundColor = backgroundColor.uiColor } // Add the caret if there is an action and it's not declared hidden. diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 975c4851..706e4712 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -10,7 +10,7 @@ import UIKit struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { static var identifier: String = "eyebrowHeadlineBodyLink" - var backgroundColor: String? + var backgroundColor: Color? public var eyeBrow: LabelModel? public var headline: LabelModel? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index c6dbd059..6ce51d3e 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -13,7 +13,7 @@ import Foundation public var headline: LabelModel public var body: LabelModel public var style: String? - public var backgroundColor: String? + public var backgroundColor: Color? public init(headline: LabelModel, body: LabelModel) { self.headline = headline From d4c9753041d85f732c15a08289017153105a3bb3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Jan 2020 14:27:10 -0500 Subject: [PATCH 073/272] Percent --- MVMCoreUI/Atoms/Views/MultiProgress.swift | 2 +- MVMCoreUI/Atoms/Views/MultiProgressModel.swift | 10 +++++++--- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 16 +++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index bbe8ed76..aceaf775 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -27,7 +27,7 @@ import UIKit let view = UIView(frame: .zero) view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) - view.backgroundColor = UIColor.mfGet(forHex: progressObject.color) + view.backgroundColor = progressObject.color.uiColor view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress).isActive = true view.leadingAnchor.constraint(equalTo: previous?.trailingAnchor ?? leadingAnchor).isActive = true previous = view diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 9d1f11fd..98bb09cf 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -8,10 +8,14 @@ import Foundation - @objcMembers public class SingleProgressBarModel: Codable { - var progress: CGFloat - var color: String + @Percent var progress: CGFloat + var color: Color + + init(_ progress: CGFloat, color: Color) { + self.progress = progress + self.color = color + } } @objcMembers public class MultiProgressBarModel: MoleculeProtocol { diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 47fabb6a..1e0bfeb1 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -10,13 +10,11 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeProtocol { public static var identifier: String = "progressbar" - - public var isRounded: Bool? - public var thickness: CGFloat? - ///from 0 to 100 - @Clamping(range: 0...100) public var percent: CGFloat + @Percent public var percent: CGFloat public var progressColor: Color = Color(uiColor: .mfCerulean()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) + public var isRounded: Bool? + public var thickness: CGFloat? enum CodingKeys: String, CodingKey { case moleculeName @@ -33,8 +31,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) - thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) percent = try typeContainer.decode(CGFloat.self, forKey: .percent) if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .progressColor) { progressColor = color @@ -42,15 +38,17 @@ import Foundation if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { backgroundColor = color } + isRounded = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRounded) + thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(isRounded, forKey: .isRounded) - try container.encodeIfPresent(thickness, forKey: .thickness) try container.encode(percent, forKey: .percent) try container.encode(progressColor, forKey: .progressColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(isRounded, forKey: .isRounded) + try container.encodeIfPresent(thickness, forKey: .thickness) } } From b3f10ec1c62851b4190baf9817f211b90b222dbd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Jan 2020 16:25:35 -0500 Subject: [PATCH 074/272] Fix stack --- MVMCoreUI/Organisms/MoleculeStackView.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index eb0317cd..05e10c0d 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -81,8 +81,6 @@ open class MoleculeStackView: Container { public override func updateView(_ size: CGFloat) { super.updateView(size) - directionalLayoutMargins.leading = 0 - directionalLayoutMargins.trailing = 0 for item in stackItems { item.updateView(size) } From b97416e7d6d2b11e7569a8e3eff8a015bf2fce3b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Jan 2020 16:45:42 -0500 Subject: [PATCH 075/272] Multip progress --- MVMCoreUI/Atoms/Views/MultiProgressModel.swift | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 98bb09cf..da2b8f69 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -20,33 +20,31 @@ import Foundation @objcMembers public class MultiProgressBarModel: MoleculeProtocol { public static var identifier: String = "multiProgressBar" - public var moleculeName: String - public var backgroundColor: Color? public var progressList: [SingleProgressBarModel] + public var backgroundColor: Color? public var thickness: CGFloat? public var roundedRect: Bool? enum CodingKeys: String, CodingKey { - case moleculeName case progressList case thickness case roundedRect + case backgroundColor } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList) - self.thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) - self.roundedRect = try typeContainer.decodeIfPresent(Bool.self, forKey: .roundedRect) + 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) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(progressList, forKey: .progressList) + try container.encode(progressList, forKey: .progressList) try container.encodeIfPresent(thickness, forKey: .thickness) try container.encodeIfPresent(roundedRect, forKey: .roundedRect) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } From 54d0ea3e5c46b661a135425562853173e2ff591f Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 8 Jan 2020 16:50:47 -0500 Subject: [PATCH 076/272] ModuleMolecule fixes --- .../Molecules/ModelMoleculeViewProtocol.swift | 4 ++ MVMCoreUI/Molecules/ModuleMolecule.swift | 66 ++++++++++--------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index 0d9f2906..a1828fa7 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -12,6 +12,7 @@ public protocol ModelMoleculeViewProtocol { func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? + static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? } extension ModelMoleculeViewProtocol { @@ -21,4 +22,7 @@ extension ModelMoleculeViewProtocol { public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } + public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + return nil + } } diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index fa82cb89..f5d580de 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -47,36 +47,40 @@ open class ModuleMolecule: Container { } } - #warning("Kamlesh: uncomment below code") - //TODO: Kamlesh: uncomment below code + public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { -// public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { -// guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { -// // Critical error -// return 0 -// } -// return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.estimatedHeight?(forRow: module, delegateObject: delegateObject) ?? 0 -// } -// -// public override class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { -// guard let moduleName = molecule?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { -// // Critical error -// return "moduleMolecule<>" -// } -// return "moduleMolecule<" + (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.name?(forReuse: module, delegateObject: delegateObject) ?? module.stringForkey(KeyMoleculeName)) + ">" -// } -// -// public override class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { -// let moduleName = json?.optionalStringForKey("moduleName") -// if moduleName == nil || delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) == nil { -// if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { -// error?.pointee = errorObject -// MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) -// } -// } -// if let moduleName = moduleName { -// return [moduleName] -// } -// return nil -// } + guard let moduleMolecule = molecule as? ModuleMoleculeModel, + let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, + let height = classType.estimatedHeight(forRow: moduleModel, delegateObject: delegateObject)else { + // Critical error + return 0 + } + return height + } + + public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let moduleMolecule = model as? ModuleMoleculeModel, + let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol, + let name = classType.nameForReuse(moduleModel, delegateObject) else { + // Critical error + return "moduleMolecule<>" + } + return name + } + + //TODO: Scottt please check this. + public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + + guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName, + let _ = delegateObject?.moduleProtocol?.getModuleWithName(moduleName) else { + if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { + error?.pointee = errorObject + MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + } + return nil + } + return [moduleName] + } } From f40335ce193f09f4b9fddeecc1b5c39a484b0f99 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 10:46:00 -0500 Subject: [PATCH 077/272] progress, multi progress, caret --- MVMCoreUI/Atoms/Views/CaretView.swift | 39 ++++--------------- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 30 +++++++++++++- MVMCoreUI/Atoms/Views/MultiProgress.swift | 14 ++++--- .../Atoms/Views/MultiProgressModel.swift | 4 ++ MVMCoreUI/Atoms/Views/ProgressBar.swift | 26 +++---------- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 2 +- .../Molecules/ModelMoleculeViewProtocol.swift | 7 ++++ MVMCoreUI/Organisms/MoleculeStackView.swift | 1 - .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 9 files changed, 62 insertions(+), 62 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index fb9689e5..4a0b9c36 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -102,27 +102,10 @@ open class CaretView: View { @objc open override func setAsMolecule() { defaultState() } - - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - // Configure class properties with JSON values - guard let dictionary = json else { return } - - if let strokeColorHex = dictionary["strokeColor"] as? String { - strokeColor = UIColor.mfGet(forHex: strokeColorHex) - } - - if let isHiddenValue = dictionary[KeyIsHidden] as? Bool { - isHidden = isHiddenValue - } - - if let isOpaqueValue = dictionary[KeyIsOpaque] as? Bool { - isOpaque = isOpaqueValue - } - - if let lineWidthValue = dictionary["lineWidth"] as? CGFloat { - lineWidth = lineWidthValue - } + + public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: CaretViewModel.self) else { return } + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) } //MARK: - MVMCoreMoleculeViewProtocol @@ -131,17 +114,9 @@ open class CaretView: View { guard let caretModel = model as? CaretViewModel else { return } - if let strokeColorHex = caretModel.strokeColor { - strokeColor = UIColor.mfGet(forHex: strokeColorHex) - } - - if let isHiddenValue = caretModel.isHidden { - isHidden = isHiddenValue - } - - if let isOpaqueValue = caretModel.isOpaque { - isOpaque = isOpaqueValue - } + strokeColor = caretModel.strokeColor.uiColor + isHidden = caretModel.isHidden ?? false + isOpaque = caretModel.isOpaque ?? false if let lineWidthValue = caretModel.lineWidth { lineWidth = lineWidthValue diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index 8d2bc16c..f26a150f 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -12,8 +12,36 @@ import Foundation public static var identifier: String = "caretView" public var backgroundColor: Color? - public var strokeColor: String? + public var strokeColor: Color = Color(uiColor: .black) public var isHidden: Bool? public var isOpaque: Bool? public var lineWidth: CGFloat? + + enum CodingKeys: String, CodingKey { + case backgroundColor + case strokeColor + case isHidden + case isOpaque + case lineWidth + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let strokeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .strokeColor) { + self.strokeColor = strokeColor + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + isHidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .isHidden) + isOpaque = try typeContainer.decodeIfPresent(Bool.self, forKey: .isOpaque) + lineWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .lineWidth) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(strokeColor, forKey: .strokeColor) + try container.encodeIfPresent(isHidden, forKey: .isHidden) + try container.encodeIfPresent(isOpaque, forKey: .isOpaque) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(lineWidth, forKey: .lineWidth) + } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index aceaf775..29fbf465 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -9,7 +9,10 @@ import UIKit @objcMembers open class MultiProgress: View { - + var multiProgressModel: MultiProgressBarModel? { + get { return model as? MultiProgressBarModel } + } + ///passing value to progressList creates corresponding progress bars var progressList: Array? { didSet { @@ -63,7 +66,7 @@ import UIKit //MARK: - MVMCoreMoleculeViewProtocol public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { super.setWithModel(model, delegateObject, additionalData) - guard let multiProgressModel = model as? MultiProgressBarModel else { + guard let multiProgressModel = multiProgressModel else { return } roundedRect = multiProgressModel.roundedRect ?? false @@ -78,9 +81,8 @@ import UIKit progressList = nil } - override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - thicknessConstraint?.constant = json?.optionalCGFloatForKey("thickness") ?? defaultHeight - roundedRect = json?.optionalBoolForKey("roundedRect") ?? false + public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: MultiProgressBarModel.self) else { return } + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index da2b8f69..b0251ff6 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -32,6 +32,10 @@ import Foundation case backgroundColor } + public init(_ progressList: [SingleProgressBarModel]) { + self.progressList = progressList + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList) diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 8a3b0bb0..dff5bfc4 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -9,11 +9,12 @@ import Foundation @objcMembers open class ProgressBar: UIProgressView, MVMCoreViewProtocol, ModelMoleculeViewProtocol, MVMCoreUIMoleculeViewProtocol { - var isRounded = false + var progressBarModel: ProgressBarModel? + var thickness: CGFloat = 8.0 { willSet(newValue) { heightAnchor.constraint(equalToConstant: newValue).isActive = true - if isRounded { + if progressBarModel?.isRounded ?? false { layer.cornerRadius = newValue/2.0 } else { progressViewStyle = .bar @@ -40,7 +41,6 @@ import Foundation public func setupView() { clipsToBounds = true translatesAutoresizingMaskIntoConstraints = false - isRounded = false thickness = 8 progress = 0 progressTintColor = UIColor.mfCerulean() @@ -55,7 +55,6 @@ import Foundation guard let progressBarModel = model as? ProgressBarModel else { return } - isRounded = progressBarModel.isRounded ?? false thickness = progressBarModel.thickness ?? 8 progress = Float((progressBarModel.percent)/100.0) progressTintColor = progressBarModel.progressColor.uiColor @@ -66,26 +65,11 @@ import Foundation // MARK: - MVMCoreUIMoleculeViewProtocol public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - if let isRounded = json?.optionalBoolForKey("roundedRect") { - self.isRounded = isRounded - } - if let thickness = json?.optionalCGFloatForKey("thickness") { - self.thickness = thickness - } - // as? Float returns nil, apple defect. - if let percentage = json?["percent"] as? CGFloat { - progress = Float(percentage/100.0) - } - if let progressColor = json?.optionalStringForKey("progressColor") { - progressTintColor = UIColor.mfGet(forHex: progressColor) - } - if let backgroundColor = json?.optionalStringForKey("backgroundColor") { - trackTintColor = UIColor.mfGet(forHex: backgroundColor) - } + guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: ProgressBarModel.self) else { return } + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) } public func reset() { - isRounded = false thickness = 8 progress = 0 progressTintColor = UIColor.mfCerulean() diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 1e0bfeb1..1850c411 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -25,7 +25,7 @@ import Foundation case backgroundColor } - init(_ percent: CGFloat) { + public init(_ percent: CGFloat) { self.percent = percent } diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index a1828fa7..8b06ab0e 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -25,4 +25,11 @@ extension ModelMoleculeViewProtocol { public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } + + // Temporary + public static func decodeJSONToModel(json: [AnyHashable: Any], type: T.Type) throws -> T where T : Decodable { + let data = try JSONSerialization.data(withJSONObject: json) + let decoder = JSONDecoder() + return try decoder.decode(type, from: data) + } } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 05e10c0d..8dd43193 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -143,7 +143,6 @@ open class MoleculeStackView: Container { } else { setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) } - } public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index d66c1558..2b9b78a5 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -33,5 +33,6 @@ import Foundation // //ModelRegistry.register(ModuleMoleculeModel.self) ModelRegistry.register(LeftRightLabelModel.self) + ModelRegistry.register(CaretViewModel.self) } } From d651fb5783519e7160ecd3dae332cea44c55828f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 11:00:00 -0500 Subject: [PATCH 078/272] Dash line color require for model, optional for server --- MVMCoreUI/Atoms/Views/DashLine.swift | 26 ++++++++--------------- MVMCoreUI/Atoms/Views/DashLineModel.swift | 24 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 48decdf9..89541b0c 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -15,8 +15,11 @@ open class DashLine: View { // MARK: - Properties //------------------------------------------------------ - @objc public var dashColor: UIColor? - @objc public var dashLayer: CAShapeLayer? + var dashModel: DashLineModel? { + get { return model as? DashLineModel } + } + + @objc private var dashLayer: CAShapeLayer? //------------------------------------------------------ // MARK: - Lifecycle @@ -53,7 +56,7 @@ open class DashLine: View { dashLayer.lineCap = .round dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)] dashLayer.path = path.cgPath - dashLayer.strokeColor = dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor + dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? UIColor.mfLighterGray().cgColor dashLayer.fillColor = UIColor.clear.cgColor dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor self.dashLayer = dashLayer @@ -70,27 +73,16 @@ open class DashLine: View { } open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - // Configure class properties with JSON values - guard let jsonDictionary = json else { return } - - if let isHiddenValue = jsonDictionary[KeyIsHidden] as? Bool { - isHidden = isHiddenValue - } - - if let dashColorHex = jsonDictionary["dashColor"] as? String { - dashColor = UIColor.mfGet(forHex: dashColorHex) - } + guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: DashLineModel.self) else { return } + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) } //MARK: - MVMCoreMoleculeViewProtocol public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { super.setWithModel(model, delegateObject, additionalData) - guard let dashLineModel = model as? DashLineModel else { + guard let dashLineModel = dashModel else { return } - dashColor = dashLineModel.dashColor.uiColor if let isHiddenValue = dashLineModel.isHidden { isHidden = isHiddenValue } diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 06d85f08..ec6b8a15 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -12,10 +12,32 @@ import Foundation public static var identifier: String = "dashLine" public var backgroundColor: Color? - public var dashColor: Color + public var dashColor: Color = Color(uiColor: .mfLighterGray()) public var isHidden: Bool? public init(dashColor: Color) { self.dashColor = dashColor } + + enum CodingKeys: String, CodingKey { + case backgroundColor + case dashColor + case isHidden + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let dashColor = try typeContainer.decodeIfPresent(Color.self, forKey: .dashColor) { + self.dashColor = dashColor + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + isHidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .isHidden) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(dashColor, forKey: .dashColor) + try container.encodeIfPresent(isHidden, forKey: .isHidden) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + } } From 3e8b69a0bc76c53a4fad50e5badd1770bf89c6c6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 11:38:32 -0500 Subject: [PATCH 079/272] Line and image update --- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 1 - .../Atoms/Views/LeftRightLabelModel.swift | 1 - MVMCoreUI/Atoms/Views/Line.swift | 68 +++++++++---------- .../Containers/NavigationController.swift | 2 +- MVMCoreUI/Models/Molecules/LineModel.swift | 38 ++++++++++- .../Items/DropDownFilterTableViewCell.swift | 4 +- MVMCoreUI/Molecules/Items/TableViewCell.swift | 24 +++---- MVMCoreUI/Molecules/StandardHeaderView.swift | 4 +- 8 files changed, 88 insertions(+), 54 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index a65c946a..0944c36e 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -10,7 +10,6 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeProtocol { public static var identifier: String = "image" - public var moleculeName: String public var backgroundColor: Color? public var image: String diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index e006afc9..5e091446 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -13,5 +13,4 @@ import UIKit public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel - } diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atoms/Views/Line.swift index d5f4f4b6..7b80d59a 100644 --- a/MVMCoreUI/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atoms/Views/Line.swift @@ -9,42 +9,35 @@ import UIKit @objcMembers open class Line: View { + var lineModel: LineModel? { + get { return model as? LineModel } + } public var heightConstraint: NSLayoutConstraint? - public enum Style: String, Codable { - case standard - case thin - case medium - case heavy - case none - } - - public var style = Style.standard { - didSet { - switch style { - case .standard: - heightConstraint?.constant = 1 - backgroundColor = .mfSilver() - case .thin: - heightConstraint?.constant = 1 - backgroundColor = .black - case .medium: - heightConstraint?.constant = 2 - backgroundColor = .black - case .heavy: - heightConstraint?.constant = 4 - backgroundColor = .black - case .none: - heightConstraint?.constant = 0 - } + open func setStyle(_ style: LineModel.Style) { + switch style { + case .standard: + heightConstraint?.constant = 1 + backgroundColor = .mfSilver() + case .thin: + heightConstraint?.constant = 1 + backgroundColor = .black + case .medium: + heightConstraint?.constant = 2 + backgroundColor = .black + case .heavy: + heightConstraint?.constant = 4 + backgroundColor = .black + case .none: + heightConstraint?.constant = 0 } } // MARK: - Helpers open func shouldBeVisible() -> Bool { - guard let type = json?.optionalStringForKey(KeyType) else { return false } - return type != "none" + guard let type = lineModel?.type else { return false } + return type != .none } public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) { @@ -56,26 +49,33 @@ import UIKit // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() - backgroundColor = .black heightConstraint = heightAnchor.constraint(equalToConstant: 1) heightConstraint?.isActive = true + setStyle(.standard) } // MARK: - MVMCoreUIMoleculeViewProtocol open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { // If no type, default to standard. - if let typeString = json?.optionalStringForKey(KeyType), let type = Style.init(rawValue: typeString) { - style = type + if let typeString = json?.optionalStringForKey(KeyType), let type = LineModel.Style.init(rawValue: typeString) { + setStyle(type) } else { - style = .standard + setStyle(.standard) } super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + if let lineModel = model as? LineModel { + setStyle(lineModel.type ?? .standard) + } + super.setWithModel(model, delegateObject, additionalData) + } + open override func reset() { - style = .standard + setStyle(.standard) } open func copyBackgroundColor() -> Bool { @@ -83,7 +83,7 @@ import UIKit } public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let type = json?.optionalStringForKey(KeyType), let style = Style(rawValue: type) else { return 1 } + guard let type = json?.optionalStringForKey(KeyType), let style = LineModel.Style(rawValue: type) else { return 1 } switch style { case .none: return 0 diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 353ea861..623b2f47 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -29,7 +29,7 @@ import UIKit let navigationController = self.init() style(navigationController.navigationBar) navigationController.separatorView = Line(pinTo: navigationController.navigationBar, edge: .bottom, useMargin: false) - navigationController.separatorView?.style = .standard + navigationController.separatorView?.setStyle(.standard) MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift index 66010536..88e09be0 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Models/Molecules/LineModel.swift @@ -9,7 +9,43 @@ import UIKit @objcMembers public class LineModel: MoleculeProtocol { + + /* + The frequency of the line in a moleculeList. + all (between all cells, above top, below bottom) + allExceptTop (between all cells, below bottom) + allExceptBottom (between all cells, above top) + between (between all cells) + */ + public enum Frequency: String, Codable { + case all + case allExceptTop + case allExceptBottom + case between + } + + /* + The style of the line. + standard (1 height, silver) + thin (1 height, black) + medium (2 height, black) + heavy (4 height, black) + none (hidden) + */ + public enum Style: String, Codable { + case standard + case thin + case medium + case heavy + case none + } + public static var identifier: String = "line" + public var type: Style? = .standard + public var frequency: Frequency? = .allExceptTop public var backgroundColor: Color? - public var type: String? + + public init(type: Style) { + self.type = type + } } diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 2f856074..a9d9c360 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -53,7 +53,7 @@ import UIKit } public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - bottomSeparatorView?.style = .none + bottomSeparatorView?.setStyle(.none) self.delegateObject = delegateObject super.setWithModel(model, delegateObject, additionalData) @@ -65,6 +65,6 @@ import UIKit public override func reset() { super.reset() bottomMarginPadding = 0 - bottomSeparatorView?.style = .none + bottomSeparatorView?.setStyle(.none) } } diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index d74f0ee5..ba017c4e 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -62,29 +62,29 @@ import UIKit open func styleStandard() { topMarginPadding = 24 bottomMarginPadding = 24 - topSeparatorView?.style = .none - bottomSeparatorView?.style = .standard + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.standard) } open func styleHeader() { topMarginPadding = 48 bottomMarginPadding = 16 - topSeparatorView?.style = .none - bottomSeparatorView?.style = .thin + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.thin) } open func styleFooter() { topMarginPadding = 24 bottomMarginPadding = 0 - topSeparatorView?.style = .none - bottomSeparatorView?.style = .none + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.none) } open func styleNone() { topMarginPadding = 0 bottomMarginPadding = 0 - topSeparatorView?.style = .none - bottomSeparatorView?.style = .none + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.none) } /// Adds the molecule to the view. @@ -264,8 +264,8 @@ import UIKit setSeparatorFrequency(separatorFrequency, indexPath: indexPath) } } else { - topSeparatorView?.style = .standard - bottomSeparatorView?.style = .standard + topSeparatorView?.setStyle(.standard) + bottomSeparatorView?.setStyle(.standard) setSeparatorFrequency(TableViewCell.SeparatorFrequency.allExceptTop, indexPath: indexPath) } } @@ -285,7 +285,7 @@ import UIKit open func addSeparatorsIfNeeded() { if topSeparatorView == nil { let line = Line() - line.style = .none + line.setStyle(.none) addSubview(line) NSLayoutConstraint.pinViewTop(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true @@ -294,7 +294,7 @@ import UIKit } if bottomSeparatorView == nil { let line = Line() - line.style = .none + line.setStyle(.none) addSubview(line) NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 686aac3b..eeb46a6a 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -26,7 +26,7 @@ public class StandardHeaderView: MoleculeContainer { guard line == nil else { return } let line = Line() - line.style = .heavy + line.setStyle(.heavy) addSubview(line) NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true @@ -56,7 +56,7 @@ public class StandardHeaderView: MoleculeContainer { open override func reset() { super.reset() - line?.style = .heavy + line?.setStyle(.heavy) } public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { From 2365a2fab4022e8895f4c19d43db1ebd91849f81 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 9 Jan 2020 13:45:17 -0500 Subject: [PATCH 080/272] fixes --- MVMCoreUI/Molecules/ModuleMolecule.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index f5d580de..107dc3f9 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -20,8 +20,7 @@ open class ModuleMolecule: Container { } public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { - #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") - //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + super.setWithModel(model, delegateObject, additionalData) guard let moduleMoleculeModel = model as? ModuleMoleculeModel, let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else { From 78461d0557c0d7cdf25ab3d952bc74e3bb3a8f37 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 13:48:35 -0500 Subject: [PATCH 081/272] CaretLink --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ MVMCoreUI/Atoms/Buttons/CaretButton.swift | 16 ++++++++++++- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 12 +++++----- .../Buttons/MFCustomButton+ActionModel.swift | 23 +++++++++++++++++++ .../MVMCoreUIMoleculeMappingObject.m | 2 +- .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 6 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8363aad1..80ff4c39 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -122,6 +122,7 @@ D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */; }; D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; }; D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; }; + D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */; }; D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -381,6 +382,7 @@ D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFLoadImageView.swift; sourceTree = ""; }; D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = ""; }; D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = ""; }; + D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFCustomButton+ActionModel.swift"; sourceTree = ""; }; D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; @@ -988,6 +990,7 @@ D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, + D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */, D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, D282AACA2243C61700C46919 /* ButtonView.swift */, @@ -1395,6 +1398,7 @@ D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, D213347723843825008E41B3 /* Line.swift in Sources */, + D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */, 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 6c9de088..b3ff5409 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -8,7 +8,7 @@ // -open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol { +open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, ModelMoleculeViewProtocol { //------------------------------------------------------ // MARK: - Constants @@ -132,6 +132,20 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI } } + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + guard let caretLinkModel = model as? CaretLinkModel else { return } + if let color = caretLinkModel.backgroundColor { + backgroundColor = color.uiColor + } + enabledColor = caretLinkModel.enabledColor.uiColor + if let color = caretLinkModel.disabledColor { + disabledColor = color.uiColor + } + isEnabled = caretLinkModel.enabled + set(with: caretLinkModel.action, delegateObject: delegateObject, additionalData: additionalData) + setTitle(caretLinkModel.label.text, for: .normal) + } + public func needsToBeConstrained() -> Bool { return true } diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 4d3c6223..3cc77a54 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -14,8 +14,8 @@ public class CaretLinkModel: MoleculeProtocol { public var backgroundColor: Color? public var label: LabelModel public var action: ActionProtocol - public var enabledColor: UIColor = .black - public var disabledColor: UIColor = .mfSilver() + public var enabledColor: Color = Color(uiColor: .black) + public var disabledColor: Color? = Color(uiColor: .mfSilver()) public var enabled: Bool = true public init(label: LabelModel, action: ActionProtocol) { @@ -36,10 +36,10 @@ public class CaretLinkModel: MoleculeProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) label = try typeContainer.decode(LabelModel.self, forKey: .label) - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor { + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor) { enabledColor = color } - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor)?.uiColor { + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) { disabledColor = color } if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { @@ -53,8 +53,8 @@ public class CaretLinkModel: MoleculeProtocol { try container.encode(label, forKey: .label) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) - try container.encode(Color(uiColor: enabledColor), forKey: .enabledColor) - try container.encode(Color(uiColor: disabledColor), forKey: .disabledColor) + try container.encode(enabled, forKey: .enabledColor) + try container.encodeIfPresent(disabledColor, forKey: .disabledColor) try container.encode(enabled, forKey: .enabled) } } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift new file mode 100644 index 00000000..b967db48 --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift @@ -0,0 +1,23 @@ +// +// MFCustomButton+ActionModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/9/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public extension MFCustomButton { + func set(with action: ActionProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + buttonDelegate = delegateObject?.buttonDelegate + add({ [weak self] sender in + guard let self = self else { return } + if let data = try? action.encode(using: JSONEncoder()), + let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any], + delegateObject?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + }, for: .touchUpInside) + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index c656ab2f..3a8b7622 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -35,7 +35,7 @@ @"twoButtonView": TwoButtonView.class, @"footer": StandardFooterView.class, @"caretView": CaretView.class, - @"caretButton": CaretButton.class, + @"caretLink": CaretButton.class, @"textField": MFTextField.class, @"dropDown": DropDown.class, @"digitTextField": MFDigitTextField.class, diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 2b9b78a5..4eb9e4a8 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -34,5 +34,6 @@ import Foundation //ModelRegistry.register(ModuleMoleculeModel.self) ModelRegistry.register(LeftRightLabelModel.self) ModelRegistry.register(CaretViewModel.self) + ModelRegistry.register(CaretLinkModel.self) } } From f6c3a02f0e1a730de2e0e3bfc9154e0a45ff4966 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 14:20:58 -0500 Subject: [PATCH 082/272] remove old extension --- MVMCoreUI.xcodeproj/project.pbxproj | 4 - .../MFTextField+ModelExtension.swift | 2 +- .../ViewConstrainingView+ModelExtension.swift | 89 ------------------- MVMCoreUI/Molecules/Scroller.swift | 3 +- MVMCoreUI/Organisms/Carousel.swift | 2 +- 5 files changed, 3 insertions(+), 97 deletions(-) delete mode 100644 MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 80ff4c39..25fd66ea 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -28,7 +28,6 @@ 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; 012A88F123985E0100FE3DA1 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88F023985E0100FE3DA1 /* Color.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; - 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; 012CA9DE2388723E003F810F /* (null) in Sources */ = {isa = PBXBuildFile; }; 012CA9E223888AED003F810F /* (null) in Sources */ = {isa = PBXBuildFile; }; @@ -292,7 +291,6 @@ 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; 012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; - 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeContainerModel.swift; sourceTree = ""; }; 014AA72223C501E2006F3E93 /* ContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerModel.swift; sourceTree = ""; }; @@ -1019,7 +1017,6 @@ 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, - 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */, D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */, D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, 944589222385DA9500DE9FD4 /* ImageViewModel.swift */, @@ -1497,7 +1494,6 @@ D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */, - 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */, 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift index 79ff851e..9944e22d 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift +++ b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift @@ -20,7 +20,7 @@ extension MFTextField: ModelMoleculeViewProtocol { //TODO: Need to create setWithModel in ViewConstraining View #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. - setUpWithModel(model, delegateObject, additionalData) + setUpDefaultWithModel(model, delegateObject, additionalData) guard let textFieldModel = model as? TextFieldModel, let delegateObject = delegateObject else { diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift deleted file mode 100644 index bd6312f2..00000000 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift +++ /dev/null @@ -1,89 +0,0 @@ -// -// ViewConstrainingView+ModelExtension.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 11/20/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -extension ViewConstrainingView { - public func setUpWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { - if self.constrainedView == nil { - setUpDefaultWithModel(model, delegateObject, additionalData) - } - - if shouldSetupMoleculeFromJSON, - let moleculeObject = (model as? ContainerMoleculeProtocol)?.molecule { - if molecule != nil { - (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeObject, delegateObject, additionalData) - } else { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeObject, delegateObject, true) { - addMolecule(molecule) - self.molecule = molecule - setMoleculeAccessibility() - } - } - } else { - (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) - } - - if let containerMoleculeModel = model as? ContainerModelProtocol { - if let useHorizontalMargins = containerMoleculeModel.useHorizontalMargins { - updateViewHorizontalDefaults = useHorizontalMargins - } - if let useVerticalMargins = containerMoleculeModel.useVerticalMargins { - updateViewVerticalDefaults = useVerticalMargins - } - - if let horizontalAlignment = containerMoleculeModel.horizontalAlignment { - alignHorizontal(horizontalAlignment) - } - if let verticalAlignment = containerMoleculeModel.verticalAlignment { - alignVertical(verticalAlignment) - } - } - - #warning("work on the below") - // let copyBackgroundColor = self.copyBackgroundColor?() - // if copyBackgroundColor { - // - // } - } -} - -extension ModelMoleculeViewProtocol where Self: ViewConstrainingView { - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { - setUpWithModel(model, delegateObject, additionalData) - } -} - -/* -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - // Only treated as a container if we are constraining a molecule. - - NSNumber *useHorizontalMargins = [json optionalNumberForKey:@"useHorizontalMargins"]; - if (useHorizontalMargins) { - self.updateViewHorizontalDefaults = [useHorizontalMargins boolValue]; - } - NSNumber *useVerticalMargins = [json optionalNumberForKey:@"useVerticalMargins"]; - if (useVerticalMargins) { - self.updateViewVerticalDefaults = [useVerticalMargins boolValue]; - } - - // Set the alignment for the stack in the containing view. The json driven value is for the axis direction alignment. - NSString *alignment = [json string:@"horizontalAlignment"]; - if (alignment) { - [self alignHorizontal:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; - } - alignment = [json string:@"verticalAlignment"]; - if (alignment) { - [self alignVertical:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; - } - - if ([self.molecule respondsToSelector:@selector(copyBackgroundColor)] && [self.molecule performSelector:@selector(copyBackgroundColor)]) { - self.backgroundColor = self.molecule.backgroundColor; - } -} -*/ diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index 1ce3ceb2..01477158 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -29,10 +29,9 @@ import UIKit } public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - //super.setWithModel(model, delegateObject, additionalData) #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. - setUpWithModel(model, delegateObject, additionalData) + setUpDefaultWithModel(model, delegateObject, additionalData) guard let model = model, let moleculeModel = (model as? ContainerMoleculeProtocol)?.molecule else { diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 50ca800a..ef19f1a3 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -88,7 +88,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. - setUpWithModel(caroselModel, delegateObject, additionalData) + setUpDefaultWithModel(model, delegateObject, additionalData) collectionView.backgroundColor = backgroundColor collectionView.layer.borderColor = backgroundColor?.cgColor From b3b37db8489ed06076a6860f9cbdfc5f3db8cf0a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 14:26:26 -0500 Subject: [PATCH 083/272] remove deprecated --- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 4 ++-- .../MVMCoreUIMoleculeMappingObject+ModelExtension.swift | 2 +- MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 2 +- MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h | 3 --- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 29f2c9be..54a12612 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -342,8 +342,8 @@ self.updateViewVerticalDefaults = NO; self.topMarginPadding = PaddingDefaultVerticalSpacing3; self.bottomMarginPadding = PaddingDefaultVerticalSpacing3; - if ([self.molecule respondsToSelector:@selector(alignment)]) { - [self alignHorizontal:[(UIView *)self.molecule alignment]]; + if ([self.molecule respondsToSelector:@selector(horizontalAlignment)]) { + [self alignHorizontal:[(UIView *)self.molecule horizontalAlignment]]; } [self alignVertical:UIStackViewAlignmentFill]; if ([self.molecule respondsToSelector:@selector(reset)]) { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 8eda8a52..45ce1bab 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -37,7 +37,7 @@ public extension MVMCoreUIMoleculeMappingObject { if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, castMolecule.needsToBeConstrained?() ?? false { - let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill) + let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.horizontalAlignment?() ?? .fill) setData() return view } else { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 3a8b7622..e32f8962 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -121,7 +121,7 @@ // Check if we need to constrain this view. UIView *castMolecule = [molecule conformsToProtocol:@protocol(MVMCoreUIViewConstrainingProtocol)] ? (UIView *)molecule : nil; if (constrainIfNeeded && [castMolecule respondsToSelector:@selector(needsToBeConstrained)] && [castMolecule needsToBeConstrained]) { - molecule = [[ViewConstrainingView alloc] initWithMolecule:molecule alignment:[castMolecule respondsToSelector:@selector(alignment)] ? [castMolecule alignment] : UIStackViewAlignmentFill]; + molecule = [[ViewConstrainingView alloc] initWithMolecule:molecule alignment:[castMolecule respondsToSelector:@selector(horizontalAlignment)] ? [castMolecule horizontalAlignment] : UIStackViewAlignmentFill]; } [molecule setWithJSON:json delegateObject:delegateObject additionalData:nil]; return molecule; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h b/MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h index a2ac2340..12aaacdb 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h @@ -15,9 +15,6 @@ /// Notifies the creator that the view may not be suitable to be shown on its own and it needs to be added to a view to help with layout. - (BOOL)needsToBeConstrained; -/// The alignment if constrained. -- (UIStackViewAlignment)alignment __deprecated; - /// The alignment if constrained. - (UIStackViewAlignment)horizontalAlignment; From 40def6e19b22706962f0e52b80290d483f9766c0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 14:30:25 -0500 Subject: [PATCH 084/272] control default --- MVMCoreUI/BaseClasses/Control.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index e425a29b..a633f4e1 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -51,6 +51,9 @@ import UIKit public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { self.model = model + if let backgroundColor = model?.backgroundColor { + self.backgroundColor = backgroundColor.uiColor + } } //-------------------------------------------------- From c8f8f8136db192845610902396e834d138f12113 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 9 Jan 2020 15:11:03 -0500 Subject: [PATCH 085/272] model changes --- MVMCoreUI/Models/Molecules/DropDownModel.swift | 5 +++++ MVMCoreUI/Models/Molecules/FooterModel.swift | 2 -- MVMCoreUI/Models/Molecules/HeaderModel.swift | 4 ++-- MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift | 4 ++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/DropDownModel.swift b/MVMCoreUI/Models/Molecules/DropDownModel.swift index c0320737..95caa2b6 100644 --- a/MVMCoreUI/Models/Molecules/DropDownModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownModel.swift @@ -14,4 +14,9 @@ import Foundation public var backgroundColor: Color? public var label: String public var options: [String] + + public init(label: String, options: [String]) { + self.label = label + self.options = options + } } diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 93f0a4e3..025538e6 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -11,7 +11,6 @@ import Foundation @objcMembers public class FooterModel: ContainerMoleculeProtocol { public static var identifier: String = "footer" - public var moleculeName: String? public var backgroundColor: Color? public var molecule: MoleculeProtocol @@ -27,7 +26,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule) } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 2f824773..1e4ab9f2 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -10,19 +10,18 @@ import Foundation @objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "header" - public var moleculeName: String? public var backgroundColor: Color? public var line: LineModel? enum HeaderCodingKeys: String, CodingKey { case moleculeName case line + case backgroundColor } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) - moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) // Default Values @@ -39,5 +38,6 @@ import Foundation var container = encoder.container(keyedBy: HeaderCodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(line, forKey: .line) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift index 35702824..56259942 100644 --- a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -17,6 +17,10 @@ open class ModuleMoleculeModel: MoleculeProtocol { case moduleName } + public init(_ moduleName: String) { + self.moduleName = moduleName + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) moduleName = try typeContainer.decode(String.self, forKey:.moduleName) From 0e6a2202ea0afe79300d8a5d68acbafb762bc4b7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 15:51:42 -0500 Subject: [PATCH 086/272] Remove old file --- .../ContainerMoleculeProtocol.swift | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift deleted file mode 100644 index 9a303bdf..00000000 --- a/MVMCoreUI/Models/ModelProtocols/ContainerMoleculeProtocol.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// ContainerMoleculeProtocol.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 12/4/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -public protocol ContainerMoleculeProtocol: MoleculeProtocol { - var molecule: MoleculeProtocol { get } - var useHorizontalMargins: Bool? { get } - var useVerticalMargins: Bool? { get } - var horizontalAlignment: String? { get } - var verticalAlignment: String? { get } -} - -extension ContainerMoleculeProtocol { - public var backgroundColor: Color? { - get { return nil } - } - - public var useHorizontalMargins: Bool? { - get { return nil } - } - - public var useVerticalMargins: Bool? { - get { return nil } - } - - public var horizontalAlignment: String? { - get { return nil } - } - - public var verticalAlignment: String? { - get { return nil } - } -} - From 391e3a635de0b1a7f49f657875ee286de1044955 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 15:53:42 -0500 Subject: [PATCH 087/272] remove file --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 25fd66ea..9643a16f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ 012A88DA238ED42E00FE3DA1 /* (null) in Sources */ = {isa = PBXBuildFile; }; 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */; }; 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88EB238F084D00FE3DA1 /* FooterModel.swift */; }; - 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; 012A88F123985E0100FE3DA1 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88F023985E0100FE3DA1 /* Color.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; @@ -288,7 +287,6 @@ 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMoleculeModel.swift; sourceTree = ""; }; 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeDelegateProtocol.swift; sourceTree = ""; }; 012A88EB238F084D00FE3DA1 /* FooterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModel.swift; sourceTree = ""; }; - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; 012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; @@ -556,7 +554,6 @@ 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */, ); path = ModelProtocols; @@ -1411,7 +1408,6 @@ 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, - 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, From 8d2348fe633f8557096f6c20ad5e809ad9797ff6 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 9 Jan 2020 15:59:56 -0500 Subject: [PATCH 088/272] swiftify MoleculeDelegateProtocol --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ----- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 2 +- .../MFViewController+Model.swift | 11 +++++- MVMCoreUI/BaseControllers/MFViewController.h | 3 +- MVMCoreUI/BaseControllers/MFViewController.m | 9 ----- MVMCoreUI/MVMCoreUI.h | 1 - .../AccordionMoleculeTableViewCell.swift | 4 +-- .../Items/DropDownFilterTableViewCell.swift | 4 +-- .../Molecules/Items/TabsTableViewCell.swift | 4 +-- MVMCoreUI/Molecules/ModuleMolecule.swift | 8 ++--- .../MVMCoreUIDelegateObject.swift | 6 ++-- .../ModelMoleculeDelegateProtocol.swift | 34 ++++++++++++++++++- .../Templates/MoleculeListTemplate.swift | 4 +-- 13 files changed, 59 insertions(+), 39 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 25fd66ea..15675325 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -52,7 +52,6 @@ 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; }; - 0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */; }; 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; @@ -123,7 +122,6 @@ D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; }; D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */; }; D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -312,7 +310,6 @@ 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; 017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = ""; }; 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.swift; sourceTree = ""; }; - 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleDelegateProtocol.swift; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; @@ -382,7 +379,6 @@ D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = ""; }; D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFCustomButton+ActionModel.swift"; sourceTree = ""; }; D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; - D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -1095,13 +1091,11 @@ D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */, D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */, D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, - D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */, 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */, D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, - 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */, ); path = OtherHandlers; sourceTree = ""; @@ -1231,7 +1225,6 @@ D29DF12D21E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h in Headers */, D29DF24E21E6A177003B2FB9 /* MFDigitTextField.h in Headers */, D29770F321F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h in Headers */, - D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */, D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */, D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */, D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */, @@ -1380,7 +1373,6 @@ D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */, - 0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 95b00cd7..17515e71 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -289,7 +289,7 @@ import UIKit self?.addConstraints(width: width, height: height, size: image?.size) self?.loadingSpinnerHeightConstraint?.constant = 0 if layoutWillChange { - self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated?(self!) + self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!) } completionHandler(image,data,isFallbackImage) })} diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index afc022f8..264592c0 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -8,7 +8,14 @@ import Foundation -extension MFViewController: ModuleDelegateProtocol { +extension MFViewController: MoleculeDelegateProtocol { + public func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? { + guard let name = name else { + return nil + } + return loadObject?.modulesJSON?.optionalDictionaryForKey(name) + } + public func getModuleWithName(_ moduleName: String) -> Model? { guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moduleName), let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), @@ -29,3 +36,5 @@ public extension MFViewController { (self as? TemplateProtocol)?.parseTemplateJSON() } } + +//MoleculeDelegateProtocol diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index c1415df4..cd96a07f 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -27,14 +27,13 @@ #import #import #import -#import @class MainMenuViewController; @class MVMCoreUITabBarPageControlViewController; @class MVMAnimationManager; @class DelegateObject; -@interface MFViewController : UIViewController +@interface MFViewController : UIViewController // Stores the load object that this screen was loaded with. @property (nullable, strong, nonatomic) MVMCoreLoadObject *loadObject; diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 153af17f..1d97efd9 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -834,15 +834,6 @@ } } -#pragma mark - MoleculeDelegateProtocol - -- (NSDictionary *)getModuleWithName:(NSString *)name { - if (!name) { - return nil; - } - return [self.loadObject.modulesJSON dict:name]; -} - #pragma mark - adobe analytics - (nullable NSArray *)additionalActionsToTrackWithMainActionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 795298b3..ff9b4087 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -20,7 +20,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import -#import #import #import diff --git a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift index 075d33f1..d6a5e05d 100644 --- a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -34,9 +34,9 @@ import UIKit } if accordionButton.isSelected { - delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: .automatic) + delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: .automatic) } else { - delegateObject?.moleculeDelegate?.removeMolecules?(molecules, sender: self, animation: .automatic) + delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: .automatic) } if (json?.boolForKey("hideSeparatorWhenExpanded") ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index a9d9c360..a2ca4383 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -39,10 +39,10 @@ import UIKit if self.previousIndex != NSNotFound { let previousMolecules = moleculesArrays[self.previousIndex] - self.delegateObject?.moleculeDelegate?.removeMolecules?(previousMolecules, sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(previousMolecules, sender: self, animation: .fade) } let molecules = moleculesArrays[index] - self.delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: .fade) self.previousIndex = index } } diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift index b75f4600..d9626ae0 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift @@ -58,7 +58,7 @@ extension TabsTableViewCell: TopTabbarDelegate { public func shouldSelectItem(at index: Int, topTabbar: TopTabbar) -> Bool { if let moleculesArrays = json?.arrayForKey(KeyMolecules), let molecules = moleculesArrays[topTabbar.selectedIndex] as? [[AnyHashable: Any]] { - delegateObject?.moleculeDelegate?.removeMolecules?(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) + delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) } previousTabIndex = tabs.selectedIndex return true @@ -67,7 +67,7 @@ extension TabsTableViewCell: TopTabbarDelegate { public func topTabbar(_ topTabbar: TopTabbar, didSelectItemAt index: Int) { if let moleculesArrays = json?.arrayForKey(KeyMolecules), let molecules = moleculesArrays[index] as? [[AnyHashable: Any]] { - delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) + delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) } } } diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index 107dc3f9..863df271 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -23,7 +23,7 @@ open class ModuleMolecule: Container { super.setWithModel(model, delegateObject, additionalData) guard let moduleMoleculeModel = model as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else { + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else { // Critical error return } @@ -49,7 +49,7 @@ open class ModuleMolecule: Container { public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let moduleMolecule = molecule as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, let height = classType.estimatedHeight(forRow: moduleModel, delegateObject: delegateObject)else { // Critical error @@ -60,7 +60,7 @@ open class ModuleMolecule: Container { public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moduleMolecule = model as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol, let name = classType.nameForReuse(moduleModel, delegateObject) else { // Critical error @@ -73,7 +73,7 @@ open class ModuleMolecule: Container { public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName, - let _ = delegateObject?.moduleProtocol?.getModuleWithName(moduleName) else { + let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { error?.pointee = errorObject MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index 6a7fbc05..f64162db 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -12,16 +12,14 @@ open class MVMCoreUIDelegateObject: DelegateObject { public weak var formValidationProtocol: FormValidationProtocol? public weak var buttonDelegate: ButtonDelegateProtocol? public weak var uiTextFieldDelegate: UITextFieldDelegate? - public weak var moleculeDelegate: MoleculeDelegateProtocol? - public var moduleProtocol: ModuleDelegateProtocol? - + public var moleculeDelegate: MoleculeDelegateProtocol? + open override func setAll(withDelegate delegate: Any) { super.setAll(withDelegate: delegate) formValidationProtocol = delegate as? FormValidationProtocol buttonDelegate = delegate as? ButtonDelegateProtocol uiTextFieldDelegate = delegate as? UITextFieldDelegate moleculeDelegate = delegate as? MoleculeDelegateProtocol - moduleProtocol = delegate as? ModuleDelegateProtocol } class func delegateObject(from controller: MVMCoreViewControllerProtocol?) -> MVMCoreUIDelegateObject? { diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index dd79ee3d..1ea4df38 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -8,7 +8,39 @@ import Foundation -public protocol ModelMoleculeDelegateProtocol { +public protocol MoleculeDelegateProtocol { + + /// returns a module for the corresponding module name. + func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? + func getModuleWithName(_ moleculeName: String) -> Model? + + /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. + func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) //optional + + /// Asks the delegate to add or remove molecules. + //optional + func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) + + //optional func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) } + +extension MoleculeDelegateProtocol { + public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + // Do Nothing + } + public func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothpublic ing + } + public func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothing + } + public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothpublic ing + } + public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothing + } +} diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 94c0d009..ecd55350 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -8,7 +8,7 @@ import UIKit -open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol, ModelMoleculeDelegateProtocol { +open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol { public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? var observer: NSKeyValueObservation? @@ -129,7 +129,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } // MARK: - MoleculeDelegateProtocol - open override func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { if let tableView = tableView { let point = molecule.convert(molecule.bounds.origin, to: tableView) if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { From a7072fe1a0260c033ad2eff9197faf13d2bceba3 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 9 Jan 2020 16:01:27 -0500 Subject: [PATCH 089/272] remove template --- MVMCoreUI.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 15675325..ace76ad4 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -558,13 +558,6 @@ path = ModelProtocols; sourceTree = ""; }; - 012A889A238898C600FE3DA1 /* Template */ = { - isa = PBXGroup; - children = ( - ); - path = Template; - sourceTree = ""; - }; 012A88EF23985E0100FE3DA1 /* Primitive Models */ = { isa = PBXGroup; children = ( @@ -601,7 +594,6 @@ 014AA72023C501E2006F3E93 /* Container */, 011B58EE23A2AA850085F53C /* ModelProtocols */, 012A88EF23985E0100FE3DA1 /* Primitive Models */, - 012A889A238898C600FE3DA1 /* Template */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, ); From 7fb22648c08d732fa3547ae4843490c65de995f1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 16:27:02 -0500 Subject: [PATCH 090/272] Container updates --- .../CollectionCellMoleculeProtocol.swift | 4 +-- .../ListItemModelProtocol.swift | 4 +-- .../Models/Molecules/CarouselItemModel.swift | 32 +++++++++---------- .../Molecules/DropDownListItemModel.swift | 26 +++++++-------- MVMCoreUI/Molecules/Items/ListItemModel.swift | 31 +++++++----------- .../Items/MoleculeCollectionViewCell.swift | 4 +-- .../Items/MoleculeTableViewCell.swift | 9 ++++++ MVMCoreUI/Molecules/Items/TableViewCell.swift | 13 ++------ MVMCoreUI/Molecules/Scroller.swift | 2 +- 9 files changed, 57 insertions(+), 68 deletions(-) diff --git a/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift index e18c8907..3dbdc694 100644 --- a/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol CollectionCellMoleculeProtocol: ContainerMoleculeProtocol { +public protocol CollectionCellMoleculeProtocol: ContainerModelProtocol, MoleculeProtocol { var peakingUI: Bool? {get} - var peakingArrowColor: String? {get} + var peakingArrowColor: Color? {get} } diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 59bec9ae..53bf51ea 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol ListItemModelProtocol: ContainerMoleculeProtocol { +public protocol ListItemModelProtocol: ContainerModelProtocol, Model { var molecule: MoleculeProtocol { get } - var separator: LineModel? { get set } + var line: LineModel? { get set } } diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift index 1ccf898f..e86b89c3 100644 --- a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -9,31 +9,31 @@ import Foundation -@objcMembers public class CarouselItemModel: ContainerMoleculeProtocol { +@objcMembers public class CarouselItemModel: MoleculeContainerModel, CollectionCellMoleculeProtocol { public static var identifier: String = "carouselItem" - public var molecule: MoleculeProtocol public var backgroundColor: Color? - - public init(molecule: MoleculeProtocol) { - self.molecule = molecule - } - - enum CodingKeys: String, CodingKey { - case moleculeName - case molecule + public var peakingUI: Bool? + public var peakingArrowColor: Color? + + enum CarouselItemCodingKeys: String, CodingKey { case backgroundColor + case peakingUI + case peakingArrowColor } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + let typeContainer = try decoder.container(keyedBy: CarouselItemCodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI) + peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CarouselItemCodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeModelIfPresent(molecule, forKey: .molecule) + try container.encodeIfPresent(peakingUI, forKey: .peakingUI) + try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) } } diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift index 260e7063..1ef1ca1f 100644 --- a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift @@ -8,42 +8,38 @@ import Foundation -@objcMembers public class DropDownListItemModel: ListItemModelProtocol { +@objcMembers public class DropDownListItemModel: MoleculeContainerModel, ListItemModelProtocol { public static var identifier: String = "dropDownListItem" - public var molecule: MoleculeProtocol public var molecules: [[ListItemModel]] public var backgroundColor: Color? - public var separator: LineModel? + public var line: LineModel? public var dropDown: DropDownModel public init(molecule: MoleculeProtocol, molecules: [[ListItemModel]], dropDown: DropDownModel) { - self.molecule = molecule self.molecules = molecules self.dropDown = dropDown + super.init(with: molecule) } - enum CodingKeys: String, CodingKey { - case molecule - case moleculeName + enum DropDownCodingKeys: String, CodingKey { case molecules - case separator + case line case backgroundColor case dropDown } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + let typeContainer = try decoder.container(keyedBy: DropDownCodingKeys.self) self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) - self.separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) + self.line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModel(molecule, forKey: .molecule) - try container.encode(moleculeName, forKey: .moleculeName) + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: DropDownCodingKeys.self) try container.encode(molecules, forKey: .molecules) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(dropDown, forKey: .dropDown) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index bdff2842..bef2cb84 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -9,46 +9,39 @@ import Foundation import MVMCore -@objcMembers public class ListItemModel: ListItemModelProtocol { +@objcMembers public class ListItemModel: MoleculeContainerModel, ListItemModelProtocol { public static var identifier: String = "listItem" - public var molecule: MoleculeProtocol public var backgroundColor: Color? public var action: ActionProtocol? public var hideArrow: Bool? - public var separator: LineModel? + public var line: LineModel? public var style: String? - public init(molecule: MoleculeProtocol) { - self.molecule = molecule - } - - enum CodingKeys: String, CodingKey { - case moleculeName - case molecule + enum ListItemCodingKeys: String, CodingKey { case backgroundColor case action case hideArrow - case separator + case line case style } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.type) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) - separator = try typeContainer.decodeIfPresent(LineModel.self, forKey: .separator) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeModelIfPresent(molecule, forKey: .molecule) + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: ListItemCodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeIfPresent(hideArrow, forKey: .hideArrow) - try container.encodeIfPresent(separator, forKey: .separator) + try container.encodeIfPresent(line, forKey: .line) try container.encodeIfPresent(style, forKey: .style) } } diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index b976ca64..1603c876 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -69,7 +69,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - guard let collectionModel = model as? CollectionCellMoleculeProtocol else { + guard let collectionModel = model as? CarouselItemModel else { return } @@ -82,7 +82,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi // Handles peaking. allowsPeaking = collectionModel.peakingUI ?? false if let peakingArrowColor = collectionModel.peakingArrowColor { - let color = UIColor.mfGet(forHex: peakingArrowColor) + let color = peakingArrowColor.uiColor peakingLeftArrow.tintColor = color peakingRightArrow.tintColor = color } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 9bfab3f3..40222f03 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -38,4 +38,13 @@ import UIKit } return theClass.requiredModules?(moleculeJSON, delegateObject: delegateObject, error: error) } + + public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + guard let moleculeModel = (molecule as? MoleculeContainerModel)?.molecule, + let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type, + let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else { + return 80 + } + return max(2 * PaddingDefaultVerticalSpacing3, height) + } } diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index ba017c4e..9fbad78b 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -177,7 +177,7 @@ import UIKit } // override the separator - if let separator = model.separator { + if let separator = model.line { addSeparatorsIfNeeded() bottomSeparatorView?.setWithModel(separator, nil, nil) } @@ -193,19 +193,10 @@ import UIKit backgroundColor = .white } - public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let moleculeModel = (molecule as? ContainerMoleculeProtocol)?.molecule, - let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type, - let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else { - return 80 - } - return max(2 * PaddingDefaultVerticalSpacing3, height) - } - - public class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { return molecule?.moleculeName ?? "" } + // MARK: - Arrow /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index 01477158..4be1025a 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -34,7 +34,7 @@ import UIKit setUpDefaultWithModel(model, delegateObject, additionalData) guard let model = model, - let moleculeModel = (model as? ContainerMoleculeProtocol)?.molecule else { + let moleculeModel = (model as? MoleculeContainerModel)?.molecule else { return } From 826cb7f28469af1d336c342472c864d6666b8dae Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 16:28:00 -0500 Subject: [PATCH 091/272] container change footer --- MVMCoreUI/Models/Molecules/FooterModel.swift | 28 +++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 93f0a4e3..757e2fd5 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -9,33 +9,23 @@ import Foundation -@objcMembers public class FooterModel: ContainerMoleculeProtocol { +@objcMembers public class FooterModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "footer" - public var moleculeName: String? public var backgroundColor: Color? - public var molecule: MoleculeProtocol - public init(molecule: MoleculeProtocol){ - self.molecule = molecule - } - - enum CodingKeys: String, CodingKey { - case moleculeName - case molecule + enum FooterCodingKeys: String, CodingKey { case backgroundColor } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(self.backgroundColor, forKey: .backgroundColor) - try container.encodeModel(self.molecule, forKey: .moleculeName) + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: FooterCodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } From 629f30e07344d600481be1f4b107ba66fe88edb8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Jan 2020 16:38:14 -0500 Subject: [PATCH 092/272] container updates --- MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift | 2 +- MVMCoreUI/Molecules/Items/TableViewCell.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 53bf51ea..a77f9374 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol ListItemModelProtocol: ContainerModelProtocol, Model { +public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeProtocol { var molecule: MoleculeProtocol { get } var line: LineModel? { get set } } diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index bf616419..ee6e79dd 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -78,8 +78,8 @@ import UIKit open func styleShortDivider() { topMarginPadding = 32 bottomMarginPadding = 16 - topSeparatorView?.style = .none - bottomSeparatorView?.style = .thin + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.thin) } open func styleFooter() { From 99a258c0f8d5c3a74ecac715d2a0b0ae80acb70b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Jan 2020 08:57:56 -0500 Subject: [PATCH 093/272] Template associated type testing --- MVMCoreUI.xcodeproj/project.pbxproj | 20 +++++++----- .../ModelProtocols/PageModelProtocol.swift | 15 +++++++++ .../TemplateModelProtocol.swift | 5 +-- .../ModelProtocols/TemplateProtocol.swift | 32 +++++++++++++------ .../Template/ListPageTemplateModel.swift | 2 +- .../StackCenteredPageTemplateModel.swift | 2 +- .../Template/StackPageTemplateModel.swift | 2 +- .../ThreeLayerPageTemplateModel.swift | 3 +- .../Templates/MoleculeListTemplate.swift | 26 +++++---------- .../Templates/MoleculeStackTemplate.swift | 22 +++---------- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 22 +++---------- 11 files changed, 70 insertions(+), 81 deletions(-) create mode 100644 MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ba0db1dd..7769203b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -119,6 +119,7 @@ D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; }; D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; }; D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */; }; + D28A837923C7D5BC00DFE4FC /* PageModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */; }; D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; @@ -374,6 +375,7 @@ D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = ""; }; D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = ""; }; D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFCustomButton+ActionModel.swift"; sourceTree = ""; }; + D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModelProtocol.swift; sourceTree = ""; }; D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; @@ -548,6 +550,7 @@ 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, + D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */, 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */, ); path = ModelProtocols; @@ -624,6 +627,14 @@ path = Molecules; sourceTree = ""; }; + 0A5D59C323AD488600EFD9E9 /* Protocols */ = { + isa = PBXGroup; + children = ( + 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, + ); + path = Protocols; + sourceTree = ""; + }; 946EE1B5237B663A0036751F /* Extensions */ = { isa = PBXGroup; children = ( @@ -654,14 +665,6 @@ name = "Recovered References"; sourceTree = ""; }; - 0A5D59C323AD488600EFD9E9 /* Protocols */ = { - isa = PBXGroup; - children = ( - 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, - ); - path = Protocols; - sourceTree = ""; - }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -1411,6 +1414,7 @@ D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, + D28A837923C7D5BC00DFE4FC /* PageModelProtocol.swift in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift new file mode 100644 index 00000000..8c6d1557 --- /dev/null +++ b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift @@ -0,0 +1,15 @@ +// +// PageModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/9/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol PageModelProtocol: Model { + var pageType: String { get set } + var screenHeading: String? { get set } + var isAtomicTabs: Bool? { get set } +} diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift index 3eeb9673..66472da6 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift @@ -8,11 +8,8 @@ import Foundation -public protocol TemplateModelProtocol: Model { +public protocol TemplateModelProtocol: PageModelProtocol { var template: String { get } - var pageType: String { get set } - var screenHeading: String { get set } - var isAtomicTabs: Bool? { get set } } extension TemplateModelProtocol { diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift index 90e3e635..c6fd38cd 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift @@ -9,21 +9,33 @@ import Foundation public protocol TemplateProtocol { - var templateModel: TemplateModelProtocol? {get} - func parseTemplateJSON() - func templateData() -> Data? + associatedtype TemplateModel: TemplateModelProtocol + var templateModel: TemplateModel? { get set } } -extension TemplateProtocol where Self: MFViewController { - public func templateData() -> Data? { - guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { - return nil - } +public extension TemplateProtocol { + +} + +public extension TemplateProtocol where Self: MFViewController { + mutating func parseTemplateJSON() { + guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { return } do { - return try JSONSerialization.data(withJSONObject: pageJSON) + let data = try JSONSerialization.data(withJSONObject: pageJSON) + let decoder = JSONDecoder() + let templateModel = try decoder.decode(TemplateModel.self, from: data) + self.templateModel = templateModel } catch { MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - return nil } } } + +class Testing: MFViewController, TemplateProtocol { + typealias TemplateModel = StackPageTemplateModel + var templateModel: StackPageTemplateModel? + + public func parsePageJSON() { + parseTemplateJSON() + } +} diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift index 587cf6a5..c457969a 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -13,7 +13,7 @@ import Foundation public static var identifier: String = "listTemplate" public var pageType: String - public var screenHeading: String + public var screenHeading: String? public var isAtomicTabs: Bool? public var header: HeaderModel? diff --git a/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift index 27eaa362..804103c4 100644 --- a/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift @@ -14,7 +14,7 @@ import Foundation public var pageType: String - public var screenHeading: String + public var screenHeading: String? public var isAtomicTabs: Bool? diff --git a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift index d05d91f3..0d8bef77 100644 --- a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift @@ -14,7 +14,7 @@ import Foundation public var pageType: String - public var screenHeading: String + public var screenHeading: String? public var isAtomicTabs: Bool? diff --git a/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift index 658a021f..b4604fbc 100644 --- a/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift @@ -9,12 +9,11 @@ import Foundation @objcMembers public class ThreeLayerPageTemplateModel: TemplateModelProtocol { - public static var identifier: String = "threeLayer" public var pageType: String - public var screenHeading: String + public var screenHeading: String? public var isAtomicTabs: Bool? diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index ecd55350..c78fe19c 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -13,20 +13,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? var observer: NSKeyValueObservation? - public var templateModel: TemplateModelProtocol? - - public func parseTemplateJSON() { - guard let templateData = templateData() else { - return - } - - do { - let decoder = JSONDecoder() - let templateModel = try decoder.decode(ListPageTemplateModel.self, from: templateData) - self.templateModel = templateModel - } catch { - MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - } + public var templateModel: ListPageTemplateModel? + + public func parsePageJSON() { + parseTemplateJSON() } open override var loadObject: MVMCoreLoadObject? { @@ -44,7 +34,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } open override func viewForTop() -> UIView { - guard let headerModel = (templateModel as? ListPageTemplateModel)?.header, + guard let headerModel = templateModel?.header, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { return super.viewForTop() } @@ -52,7 +42,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } override open func viewForBottom() -> UIView { - guard let footerModel = (templateModel as? ListPageTemplateModel)?.footer, + guard let footerModel = templateModel?.footer, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { return super.viewForBottom() } @@ -187,7 +177,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol /// Sets up the molecule list and ensures no errors loading all content. func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? { var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)] = [] - if let molecules = (templateModel as? ListPageTemplateModel)?.molecules { + if let molecules = templateModel?.molecules { for molecule in molecules { if let info = getMoleculeInfo(with: molecule) { moleculeList.append(info) @@ -200,7 +190,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol /// Sets up the header, footer, molecule list and ensures no errors loading all content. func setup() { var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)] = [] - if let molecules = (templateModel as? ListPageTemplateModel)?.molecules { + if let molecules = templateModel?.molecules { for molecule in molecules { if let info = getMoleculeInfo(with: molecule) { moleculeList.append(info) diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 9ee96d04..7c75a555 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -11,21 +11,7 @@ import UIKit open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { var observer: NSKeyValueObservation? - public var templateModel: TemplateModelProtocol? - - public func parseTemplateJSON() { - guard let templateData = templateData() else { - return - } - - do { - let decoder = JSONDecoder() - let templateModel = try decoder.decode(StackPageTemplateModel.self, from: templateData) - self.templateModel = templateModel - } catch { - MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - } - } + public var templateModel: StackPageTemplateModel? open override var loadObject: MVMCoreLoadObject? { didSet { @@ -46,7 +32,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { } open override func viewForTop() -> UIView? { - guard let headerModel = (templateModel as? StackPageTemplateModel)?.header, + guard let headerModel = templateModel?.header, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { return nil } @@ -55,7 +41,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { open override func viewForMiddle() -> UIView? { - guard let moleculeStackModel = (templateModel as? StackPageTemplateModel)?.moleculeStack else { + guard let moleculeStackModel = templateModel?.moleculeStack else { return nil } @@ -67,7 +53,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { } override open func viewForBottom() -> UIView? { - guard let footerModel = (templateModel as? StackPageTemplateModel)?.footer, + guard let footerModel = templateModel?.footer, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { return nil } diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index f87a1e29..c6ceb97c 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -10,21 +10,7 @@ import UIKit @objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { - public var templateModel: TemplateModelProtocol? - - public func parseTemplateJSON() { - guard let templateData = templateData() else { - return - } - - do { - let decoder = JSONDecoder() - let templateModel = try decoder.decode(StackPageTemplateModel.self, from: templateData) - self.templateModel = templateModel - } catch { - MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - } - } + public var templateModel: ThreeLayerPageTemplateModel? override open func viewDidLoad() { super.viewDidLoad() @@ -39,7 +25,7 @@ import UIKit open override func viewForTop() -> UIView? { - guard let headerModel = (templateModel as? ThreeLayerPageTemplateModel)?.header, + guard let headerModel = templateModel?.header, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { return nil } @@ -47,7 +33,7 @@ import UIKit } open override func viewForMiddle() -> UIView? { - guard let middleModel = (templateModel as? ThreeLayerPageTemplateModel)?.middle, + guard let middleModel = templateModel?.middle, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(middleModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { return nil } @@ -55,7 +41,7 @@ import UIKit } override open func viewForBottom() -> UIView? { - guard let footerModel = (templateModel as? ThreeLayerPageTemplateModel)?.footer, + guard let footerModel = templateModel?.footer, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { return nil } From 90d7b188d19ca86ec13aa7c2ac7e5397cb15d0a4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Jan 2020 09:55:42 -0500 Subject: [PATCH 094/272] each template must parse themselves... --- .../MFViewController+Model.swift | 3 --- .../ModelProtocols/TemplateProtocol.swift | 19 +++---------------- .../Templates/MoleculeListTemplate.swift | 3 +-- .../Templates/MoleculeStackTemplate.swift | 3 +++ MVMCoreUI/Templates/ThreeLayerTemplate.swift | 5 ++++- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 264592c0..b3ff4ec6 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -33,8 +33,5 @@ extension MFViewController: MoleculeDelegateProtocol { public extension MFViewController { @objc func parsePageJSON() { - (self as? TemplateProtocol)?.parseTemplateJSON() } } - -//MoleculeDelegateProtocol diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift index c6fd38cd..8293f18b 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift @@ -8,18 +8,14 @@ import Foundation -public protocol TemplateProtocol { +public protocol TemplateProtocol: class { associatedtype TemplateModel: TemplateModelProtocol var templateModel: TemplateModel? { get set } } -public extension TemplateProtocol { - -} - public extension TemplateProtocol where Self: MFViewController { - mutating func parseTemplateJSON() { - guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else { return } + func parseTemplateJSON() { + guard let pageJSON = self.loadObject?.pageJSON as? [String: AnyHashable] else { return } do { let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() @@ -30,12 +26,3 @@ public extension TemplateProtocol where Self: MFViewController { } } } - -class Testing: MFViewController, TemplateProtocol { - typealias TemplateModel = StackPageTemplateModel - var templateModel: StackPageTemplateModel? - - public func parsePageJSON() { - parseTemplateJSON() - } -} diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index c78fe19c..7b572c44 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -14,8 +14,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol var observer: NSKeyValueObservation? public var templateModel: ListPageTemplateModel? - - public func parsePageJSON() { + public override func parsePageJSON() { parseTemplateJSON() } diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 7c75a555..3dc9a58c 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -12,6 +12,9 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { var observer: NSKeyValueObservation? public var templateModel: StackPageTemplateModel? + public override func parsePageJSON() { + parseTemplateJSON() + } open override var loadObject: MVMCoreLoadObject? { didSet { diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index c6ceb97c..67326d09 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -11,7 +11,10 @@ import UIKit @objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { public var templateModel: ThreeLayerPageTemplateModel? - + public override func parsePageJSON() { + parseTemplateJSON() + } + override open func viewDidLoad() { super.viewDidLoad() bottomViewOutsideOfScroll = true From 30d864749aa42e4b251ac2f33dbf77d495a5db7d Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Sat, 11 Jan 2020 10:30:40 +0530 Subject: [PATCH 095/272] unordered list added numbered list added --- MVMCoreUI.xcodeproj/project.pbxproj | 36 +++- .../Models/Molecules/NumberedListModel.swift | 33 +++ .../Models/Molecules/UnOrderedListModel.swift | 34 +++ .../Molecules/LabelRightMoleculesStack.swift | 199 ++++++++++++++++++ MVMCoreUI/Molecules/NumberedList.swift | 18 ++ MVMCoreUI/Molecules/UnOrderedList.swift | 18 ++ .../MVMCoreUIMoleculeMappingObject.m | 4 +- .../OtherHandlers/MoleculeObjectMapping.swift | 2 + 8 files changed, 335 insertions(+), 9 deletions(-) create mode 100644 MVMCoreUI/Models/Molecules/NumberedListModel.swift create mode 100644 MVMCoreUI/Models/Molecules/UnOrderedListModel.swift create mode 100644 MVMCoreUI/Molecules/LabelRightMoleculesStack.swift create mode 100644 MVMCoreUI/Molecules/NumberedList.swift create mode 100644 MVMCoreUI/Molecules/UnOrderedList.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index dbee02e2..bb8d8b16 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -67,6 +67,11 @@ 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */; }; 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */; }; 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; }; + C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; + C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; }; + C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */; }; + C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */; }; + C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5123C77A4900A3614A /* NumberedList.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; @@ -307,6 +312,11 @@ 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = ""; }; 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; + C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; + C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = ""; }; + C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedList.swift; sourceTree = ""; }; + C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelRightMoleculesStack.swift; sourceTree = ""; }; + C6FA7D5123C77A4900A3614A /* NumberedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedList.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; @@ -538,10 +548,20 @@ 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */, + C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */, + C695A68023C9830D00BFB94E /* NumberedListModel.swift */, ); path = Molecules; sourceTree = ""; }; + 0A5D59C323AD488600EFD9E9 /* Protocols */ = { + isa = PBXGroup; + children = ( + 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, + ); + path = Protocols; + sourceTree = ""; + }; 0AA33B322398134B0067DD0F /* Primitive Models */ = { isa = PBXGroup; children = ( @@ -580,14 +600,6 @@ name = "Recovered References"; sourceTree = ""; }; - 0A5D59C323AD488600EFD9E9 /* Protocols */ = { - isa = PBXGroup; - children = ( - 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, - ); - path = Protocols; - sourceTree = ""; - }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -785,6 +797,9 @@ D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, + C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */, + C6FA7D5123C77A4900A3614A /* NumberedList.swift */, + C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */, ); path = Molecules; sourceTree = ""; @@ -1318,6 +1333,7 @@ 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */, D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, D2B18B812360945C00A9AEDC /* View.swift in Sources */, + C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, @@ -1343,6 +1359,7 @@ D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, + C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, @@ -1358,10 +1375,12 @@ DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, + C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, + C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, @@ -1400,6 +1419,7 @@ D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */, + C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */, 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, diff --git a/MVMCoreUI/Models/Molecules/NumberedListModel.swift b/MVMCoreUI/Models/Molecules/NumberedListModel.swift new file mode 100644 index 00000000..7686ade0 --- /dev/null +++ b/MVMCoreUI/Models/Molecules/NumberedListModel.swift @@ -0,0 +1,33 @@ +// +// NumberedListModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 10/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class NumberedListModel: OrderListProtocol { + public var backgroundColor: String? + public static var identifier: String = "numberedList" + public var list: [LabelModel] + + enum CodingKeys: String, CodingKey { + case list + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.list = try typeContainer.decodeMolecules(codingKey: .list) as! [LabelModel] + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeModels(list, forKey: .list) + } +} + +public protocol OrderListProtocol: MoleculeProtocol { + var list: [LabelModel] {get} +} diff --git a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift new file mode 100644 index 00000000..104119c3 --- /dev/null +++ b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift @@ -0,0 +1,34 @@ +// +// UnOrderedListModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 10/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class UnOrderedListModel: OrderListProtocol { + + public var backgroundColor: String? + public static var identifier: String = "unOrderedList" + public var bulletChar: String? + public var list: [LabelModel] + + enum CodingKeys: String, CodingKey { + case list + case bulletChar + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) + self.list = try typeContainer.decodeMolecules(codingKey: .list) as! [LabelModel] + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(bulletChar, forKey: .bulletChar) + try container.encodeModels(list, forKey: .list) + } +} diff --git a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift new file mode 100644 index 00000000..4cb5a89b --- /dev/null +++ b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift @@ -0,0 +1,199 @@ +// +// ListMoleculeContainer.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 03/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class LabelRightMoleculesStack: MoleculeStackView { + + var orderedListModel: OrderListProtocol? + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + let previousModel = self.orderedListModel + //Remove previously drawn views + removeAllItemViews() + guard let orderedListModel = model as? OrderListProtocol else { + return + } + + var items: [StackItem]? + if previousModel?.list.count == orderedListModel.list.count { + items = stackItems + } + stackItems = [] + self.model = MoleculeStackModel(molecules: []) + for (index, labelModel) in orderedListModel.list.enumerated() { + let labelContainer = items?[index].view as? LeftLabelRightMoleculeContainer ?? LeftLabelRightMoleculeContainer() + labelContainer.leftText = leftTextForIndex(index) + labelContainer.setWithModel(labelModel, delegateObject, additionalData) + addView(labelContainer, lastItem: index == orderedListModel.list.count - 1) + } + self.orderedListModel = orderedListModel + restack() + } + + //MARK: - Subclass should overirde this + func leftTextForIndex(_ index: Int) -> String { + return "" + } +} + +class LeftLabelRightMoleculeContainer: View { + + var label = Label.commonLabelB2(true) + var rightContainer = MVMCoreUICommonViewsUtility.commonView() + var leftContainer = MVMCoreUICommonViewsUtility.commonView() + var rightMoleculeName: String? + var rightMolecule: View? + var leftText: String? + var leftWidthConstraint: NSLayoutConstraint? + var percentage: CGFloat = 5 + + var constraintBtwViews: NSLayoutConstraint? + var spaceBtwViews: CGFloat = 0 { + didSet { + if spaceBtwViews != oldValue { + constraintBtwViews?.constant = spaceBtwViews + setNeedsDisplay() + } + } + } + + // MARK: - Inits + public override init() { + super.init() + } + + public override init(frame: CGRect) { + super.init(frame: frame) + } + + public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + super.init(frame: CGRect.zero) + setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func setupView() { + super.setupView() + + guard rightContainer.superview == nil else { + return + } + + translatesAutoresizingMaskIntoConstraints = false + addSubview(rightContainer) + addSubview(leftContainer) + leftContainer.addSubview(label) + + NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false) + leftContainer.rightAnchor.constraint(greaterThanOrEqualTo: label.rightAnchor).isActive = true + leftContainer.bottomAnchor.constraint(greaterThanOrEqualTo: label.bottomAnchor).isActive = true + + let lowRightConstraint = leftContainer.rightAnchor.constraint(equalTo: label.rightAnchor) + lowRightConstraint.priority = UILayoutPriority(rawValue: 200) + lowRightConstraint.isActive = true + + let lowBottomConstraint = leftContainer.bottomAnchor.constraint(equalTo: label.bottomAnchor) + lowBottomConstraint.priority = UILayoutPriority(rawValue: 200) + lowBottomConstraint.isActive = true + + NSLayoutConstraint.constraintPinSubview(leftContainer, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false) + bottomAnchor.constraint(greaterThanOrEqualTo: leftContainer.bottomAnchor).isActive = true + + NSLayoutConstraint.constraintPinSubview(rightContainer, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true) + constraintBtwViews = rightContainer.leftAnchor.constraint(equalTo: leftContainer.rightAnchor, constant: spaceBtwViews) + constraintBtwViews?.priority = .required + constraintBtwViews?.isActive = true + + setContentHuggingPriority(.defaultHigh, for: .vertical) + setContentHuggingPriority(.defaultHigh, for: .horizontal) + rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .vertical) + rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) + leftContainer.setContentHuggingPriority(.required, for: .horizontal) + leftContainer.setContentHuggingPriority(.required, for: .vertical) + updateLeftViewWidthConstraint(percentage) + + } + + override func updateView(_ size: CGFloat) { + super.updateView(size) + rightMolecule?.updateView(size) + label.updateView(size) + updateLeftViewWidthConstraint(percentage) + setNeedsDisplay() + } + + override func reset() { + super.reset() + rightMolecule?.reset() + } + + override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + let previousMoleculeName = model?.moleculeName + super.setWithModel(model, delegateObject, additionalData) + removeSubviewsInRightContainer() + guard let labelModel = model as? LabelModel else { + return + } + + label.text = leftText + rightMoleculeName = labelModel.moleculeName + //For reuse purpose check that allready added molecule is same + if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName { + rightMolecule.setWithModel(labelModel, delegateObject, additionalData) + addView(rightMolecule) + } else { + if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(labelModel, delegateObject, false) { + addView(molecule) + } + } + } + + override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + let previousMoleculeName = rightMoleculeName + removeSubviewsInRightContainer() + guard let moleculeJSON = json, let _ = moleculeJSON.optionalStringForKey(KeyMoleculeName) else { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + return + } + + label.text = leftText + rightMoleculeName = moleculeJSON.optionalStringForKey(KeyMoleculeName) + //For reuse purpose check that allready added molecule is same + if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName { + rightMolecule.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) + addView(rightMolecule) + } else { + if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: false) { + addView(molecule) + } + } + } + + func updateLeftViewWidthConstraint(_ percent: CGFloat) { + percentage = percent + leftWidthConstraint?.isActive = false + leftWidthConstraint = leftContainer.widthAnchor.constraint(equalTo: widthAnchor, multiplier: CGFloat(percent/100), constant: 0) + leftWidthConstraint?.isActive = true + } + + func removeSubviewsInRightContainer() { + rightContainer.subviews.forEach({ $0.removeFromSuperview() }) + } + + func addView(_ view: UIView) { + view.translatesAutoresizingMaskIntoConstraints = false + rightContainer.addSubview(view) + NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true) + rightMolecule = view as? View + } +} diff --git a/MVMCoreUI/Molecules/NumberedList.swift b/MVMCoreUI/Molecules/NumberedList.swift new file mode 100644 index 00000000..376dffc0 --- /dev/null +++ b/MVMCoreUI/Molecules/NumberedList.swift @@ -0,0 +1,18 @@ +// +// NumberedList.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 03/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class NumberedList: LabelRightMoleculesStack { + + //MARK:- Super class override methods + override func leftTextForIndex(_ index: Int) -> String { + return String(index+1) + "." + } + +} diff --git a/MVMCoreUI/Molecules/UnOrderedList.swift b/MVMCoreUI/Molecules/UnOrderedList.swift new file mode 100644 index 00000000..4f85a483 --- /dev/null +++ b/MVMCoreUI/Molecules/UnOrderedList.swift @@ -0,0 +1,18 @@ +// +// UnOrderedList.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 03/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class UnOrderedList: LabelRightMoleculesStack { + + //MARK:- Super class override methods + override func leftTextForIndex(_ index: Int) -> String { + return (orderedListModel as? UnOrderedListModel)?.bulletChar ?? "•" + } + +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index c656ab2f..acbf75b3 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -68,7 +68,9 @@ @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, - @"stackItem": StackItem.class + @"stackItem": StackItem.class, + @"unOrderedList": UnOrderedList.class, + @"numberedList": NumberedList.class } mutableCopy]; }); return mapping; diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index ac96c44f..31e645ce 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -29,5 +29,7 @@ import Foundation ModelRegistry.register(LabelAttributeUnderlineModel.self) ModelRegistry.register(LabelAttributeStrikeThroughModel.self) ModelRegistry.register(LabelAttributeActionModel.self) + ModelRegistry.register(NumberedListModel.self) + ModelRegistry.register(UnOrderedListModel.self) } } From 396c22f2434b0c5eb94c42add833adf30b978f2c Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Sat, 11 Jan 2020 16:06:25 +0530 Subject: [PATCH 096/272] doughnut chart model added doughnut chart view added doughnut chart added --- MVMCoreUI.xcodeproj/project.pbxproj | 28 ++- .../Models/Molecules/DoughnutChartModel.swift | 85 +++++++++ MVMCoreUI/Molecules/DoughnutChart.swift | 179 ++++++++++++++++++ MVMCoreUI/Molecules/DoughnutChartView.swift | 179 ++++++++++++++++++ .../MVMCoreUIMoleculeMappingObject.m | 3 +- .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 6 files changed, 466 insertions(+), 9 deletions(-) create mode 100644 MVMCoreUI/Models/Molecules/DoughnutChartModel.swift create mode 100644 MVMCoreUI/Molecules/DoughnutChart.swift create mode 100644 MVMCoreUI/Molecules/DoughnutChartView.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index dbee02e2..8efde844 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -67,6 +67,9 @@ 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */; }; 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */; }; 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; }; + C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; }; + C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; }; + C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; @@ -307,6 +310,9 @@ 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = ""; }; 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; + C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = ""; }; + C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = ""; }; + C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; @@ -530,6 +536,7 @@ 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( + C695A69323C9909000BFB94E /* DoughnutChartModel.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, @@ -542,6 +549,14 @@ path = Molecules; sourceTree = ""; }; + 0A5D59C323AD488600EFD9E9 /* Protocols */ = { + isa = PBXGroup; + children = ( + 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, + ); + path = Protocols; + sourceTree = ""; + }; 0AA33B322398134B0067DD0F /* Primitive Models */ = { isa = PBXGroup; children = ( @@ -580,14 +595,6 @@ name = "Recovered References"; sourceTree = ""; }; - 0A5D59C323AD488600EFD9E9 /* Protocols */ = { - isa = PBXGroup; - children = ( - 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, - ); - path = Protocols; - sourceTree = ""; - }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -785,6 +792,8 @@ D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, + C695A69523C990BC00BFB94E /* DoughnutChart.swift */, + C695A69723C990C200BFB94E /* DoughnutChartView.swift */, ); path = Molecules; sourceTree = ""; @@ -1296,6 +1305,7 @@ D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, + C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, @@ -1396,6 +1406,7 @@ D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, + C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, @@ -1404,6 +1415,7 @@ 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, + C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, diff --git a/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift b/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift new file mode 100644 index 00000000..f6a1efb8 --- /dev/null +++ b/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift @@ -0,0 +1,85 @@ +// +// DoughnutChartModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 10/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class DoughnutChartModel: MoleculeProtocol { + + public var backgroundColor: String? + public static var identifier: String = "doughnutChart" + public var title: LabelModel? + public var subtitle: LabelModel? + public var sections: [ChartItemModel] + public var lineWidth: CGFloat = 30.0 + public var lineGap: CGFloat = 0.05 //For 3px gap + public var spaceRequired = true + + enum CodingKeys: String, CodingKey { + case list + case title + case subtitle + case sections + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.title = try typeContainer.decodeMoleculeIfPresent(codingKey: .title) as? LabelModel + self.subtitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subtitle) as? LabelModel + //self.sections = try typeContainer.decodeMolecules(codingKey: .sections) as! [ChartItemModel] + + //TODO: Hasve to check with scott + self.sections = [] + guard var container = try? typeContainer.nestedUnkeyedContainer(forKey: .sections) else { + return + } + var sections = [ChartItemModel]() + while !container.isAtEnd { + if let element = try container + .decodeIfPresent(ChartItemModel.self) { + sections.append(element) + } + } + self.sections = sections + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeModelIfPresent(title, forKey: .title) + try container.encodeModelIfPresent(subtitle, forKey: .subtitle) + try container.encodeModels(sections as [Model], forKey: .sections) + } +} + + +@objcMembers public class ChartItemModel: MoleculeProtocol { + public var backgroundColor: String? + public var label: LabelModel + public var percent: CGFloat + public var color: String + public static var identifier: String = "chartItem" + + enum CodingKeys: String, CodingKey { + case label + case percent + case color + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.label = try typeContainer.decodeMolecule(codingKey: .label) as! LabelModel + self.percent = try typeContainer.decode(CGFloat.self, forKey: .percent) + self.color = try typeContainer.decode(String.self, forKey: .color) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeModel(label, forKey: .label) + try container.encode(percent, forKey: .percent) + try container.encode(color, forKey: .color) + } +} diff --git a/MVMCoreUI/Molecules/DoughnutChart.swift b/MVMCoreUI/Molecules/DoughnutChart.swift new file mode 100644 index 00000000..08bdefb1 --- /dev/null +++ b/MVMCoreUI/Molecules/DoughnutChart.swift @@ -0,0 +1,179 @@ +// +// DoughnutChart.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 07/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { + + var containerView = MVMCoreUICommonViewsUtility.commonView() + var containerLayer = CALayer() + var titleLabel = Label.commonLabelH3(true) + var subTitleLabel = Label.commonLabelB2(true) + var doughnutChartModel: DoughnutChartModel? { + get { return model as? DoughnutChartModel } + } + var labelContainer = ViewConstrainingView.empty() + var heightConstraint: NSLayoutConstraint? + + private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 150)! + //private var lineSizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 30)! + + var height: CGFloat = 150 { + didSet { + if height != oldValue { + sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)! + updateContainer() + drawGraph() + } + } + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + titleLabel.updateView(size) + subTitleLabel.updateView(size) + updateContainer() + drawGraph() + } + + open override func reset() { + super.reset() + titleLabel.reset() + subTitleLabel.reset() + clearLayers() + } + + public func setAsMolecule() { + titleLabel.setAsMolecule() + subTitleLabel.setAsMolecule() + } + + open override func setupView() { + super.setupView() + guard containerView.superview == nil else { + return + } + addSubview(containerView) + addSubview(labelContainer) + + labelContainer.addSubview(titleLabel) + labelContainer.addSubview(subTitleLabel) + titleLabel.textAlignment = .center + subTitleLabel.textAlignment = .center + + //Make label font size to adjust width if label content is high + titleLabel.numberOfLines = 1 + titleLabel.adjustsFontSizeToFitWidth = true + + containerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true + containerView.topAnchor.constraint(equalTo: topAnchor).isActive = true + bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true + trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true + containerView.layer.addSublayer(containerLayer) + heightConstraint = containerView.heightAnchor.constraint(equalToConstant: + sizeObject.getValueBasedOnApplicationWidth()) + heightConstraint?.isActive = true + containerView.widthAnchor.constraint(equalTo: containerView.heightAnchor).isActive = true + + labelContainer.leftPin = labelContainer.leftAnchor.constraint(greaterThanOrEqualTo: containerView.leftAnchor, constant: lineWidth()) + labelContainer.leftPin?.isActive = true + labelContainer.topPin = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: containerView.topAnchor, constant: lineWidth()) + labelContainer.topPin?.isActive = true + labelContainer.centerYAnchor.constraint(equalTo: containerView.centerYAnchor).isActive = true + labelContainer.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true + + NSLayoutConstraint.constraintPinSubview(titleLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true) + NSLayoutConstraint.constraintPinSubview(subTitleLabel, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) + _ = NSLayoutConstraint(pinFirstView: titleLabel, toSecondView: subTitleLabel, withConstant: 0, directionVertical: true) + //Rotate view for initial draw + containerLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0) + + } + + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) + clearLayers() + guard let doughnutChartModel = model as? DoughnutChartModel else { + return + } + titleLabel.setWithModel(doughnutChartModel.title, delegateObject, additionalData) + subTitleLabel.setWithModel(doughnutChartModel.subtitle, delegateObject, additionalData) + titleLabel.textAlignment = .center + subTitleLabel.textAlignment = .center + //lineSizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: doughnutChartModel.lineWidth)! + updateLabelContainer() + drawGraph() + } + + func drawGraph() { + clearLayers() + let widthHeight = sizeObject.getValueBasedOnApplicationWidth() + containerLayer.frame = CGRect(x: 0, y: 0, + width: widthHeight, + height: widthHeight) + if let doughnutChart = doughnutChartModel { + var prevPercent: CGFloat = 0.0 + //If Single item in array. We don't need gap + doughnutChartModel?.lineGap = (doughnutChart.sections.count == 1) ? 0.0 : doughnutChart.lineGap + for model in doughnutChart.sections { + prevPercent += drawBar(model, prevPercent, doughnutChart.spaceRequired, doughnutChart.lineGap) + } + } + } + + func drawBar(_ chartModel: ChartItemModel, _ prevPercent: CGFloat, _ spaceRequired: Bool, _ lineGap: CGFloat) -> CGFloat { + + let shapeLayer = CAShapeLayer() + shapeLayer.frame = containerLayer.frame + shapeLayer.lineWidth = lineWidth() + //lineSizeObject.getValueBasedOnApplicationWidth() + shapeLayer.fillColor = nil + shapeLayer.strokeColor = UIColor.mfGet(forHex: chartModel.color).cgColor + + let arcCenter = shapeLayer.position + let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0 + //lineSizeObject.getValueBasedOnApplicationWidth() / 2.0 + let clockwise = true + + let value: CGFloat = chartModel.percent + let gap: CGFloat = spaceRequired ? lineGap : 0.0 + let startAngle = ((prevPercent / 100.0) * 2 * .pi) - (0.5 * .pi) + let endAngle = ((value / 100.0) * 2 * .pi) + startAngle - gap + let circlePath = UIBezierPath(arcCenter: arcCenter, + radius: radius, + startAngle: startAngle, + endAngle: endAngle, + clockwise: clockwise) + + shapeLayer.path = circlePath.cgPath + containerLayer.addSublayer(shapeLayer) + return value + } + + func clearLayers() { + containerLayer.sublayers?.forEach({ $0.removeFromSuperlayer() }) + } + + func updateContainer() { + heightConstraint?.constant = sizeObject.getValueBasedOnApplicationWidth() + updateLabelContainer() + setNeedsDisplay() + } + + func lineWidth() -> CGFloat { + return doughnutChartModel?.lineWidth ?? 30 + //lineSizeObject.getValueBasedOnApplicationWidth() + 5 + } + + func updateLabelContainer() { + labelContainer.leftPin?.constant = lineWidth() + labelContainer.topPin?.constant = lineWidth() + labelContainer.setNeedsDisplay() + } + +} diff --git a/MVMCoreUI/Molecules/DoughnutChartView.swift b/MVMCoreUI/Molecules/DoughnutChartView.swift new file mode 100644 index 00000000..ebe77200 --- /dev/null +++ b/MVMCoreUI/Molecules/DoughnutChartView.swift @@ -0,0 +1,179 @@ +// +// DoughnutChartView.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 26/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class DoughnutChartView: View { + + var doughnutChart = DoughnutChart(frame: CGRect.zero) + var colorLablesStack = ColorViewLabelsStack() + var container = MVMCoreUICommonViewsUtility.commonView() + var doughnutChartModel: DoughnutChartModel? { + get { return model as? DoughnutChartModel } + } + + open override func setupView() { + super.setupView() + guard container.superview == nil else { + return + } + + addSubview(container) + doughnutChart.translatesAutoresizingMaskIntoConstraints = false + container.addSubview(doughnutChart) + colorLablesStack.translatesAutoresizingMaskIntoConstraints = false + container.addSubview(colorLablesStack) + + NSLayoutConstraint.constraintPinSubview(container, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true) + doughnutChart.leadingAnchor.constraint(equalTo: container.leadingAnchor).isActive = true + doughnutChart.topAnchor.constraint(equalTo: container.topAnchor, constant: PaddingFour).isActive = true + container.bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true + + let containerBottomAnchor = container.bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor) + containerBottomAnchor.priority = UILayoutPriority(rawValue: 200) + containerBottomAnchor.isActive = true + + let colorLablesBottomAnchor = container.bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor) + colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204) + colorLablesBottomAnchor.isActive = true + + let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor) + colorLablesTopAnchor.priority = UILayoutPriority(rawValue: 204) + colorLablesTopAnchor.isActive = true + + colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).isActive = true + container.bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true + container.trailingAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.trailingAnchor).isActive = true + + let centerY = colorLablesStack.centerYAnchor.constraint(equalTo: doughnutChart.centerYAnchor) + centerY.priority = .defaultLow + centerY.isActive = true + + colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true + colorLablesStack.backgroundColor = UIColor.clear + + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + doughnutChart.updateView(size) + colorLablesStack.updateView(size) + } + + open override func reset() { + super.reset() + colorLablesStack.reset() + } + + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) + doughnutChart.clearLayers() + colorLablesStack.removeAllItemViews() + doughnutChart.setWithModel(model, delegateObject, additionalData) + colorLablesStack.setWithModel(model, delegateObject, additionalData) + } + + open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + if model == nil { + let data = try! JSONSerialization.data(withJSONObject: json!) + let decoder = JSONDecoder() + let model = try! decoder.decode(DoughnutChartModel.self, from: data) + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + } else { + setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + } + } + +} + +class ColorViewLabelsStack: MoleculeStackView { + + var dougnutChartModel: DoughnutChartModel? + + override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + let previousModel = self.dougnutChartModel + removeAllItemViews() + guard let dougnutChartModel = model as? DoughnutChartModel else { + return + } + var items: [StackItem]? + if previousModel?.sections.count == dougnutChartModel.sections.count { + items = stackItems + } + stackItems = [] + self.model = MoleculeStackModel(molecules: []) + for (index, chartItemModel) in dougnutChartModel.sections.enumerated() { + let colorViewWithLabel = items?[index].view as? ColorViewWithLabel ?? ColorViewWithLabel() + colorViewWithLabel.setWithModel(chartItemModel, delegateObject, additionalData) + addView(colorViewWithLabel, lastItem: index == dougnutChartModel.sections.count - 1) + } + self.dougnutChartModel = dougnutChartModel + restack() + } +} + +class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol { + + var label = Label.commonLabelB2(true) + var colorView = MVMCoreUICommonViewsUtility.commonView() + private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 8)! + var heightConstraint: NSLayoutConstraint? + + override func setupView() { + super.setupView() + guard colorView.superview == nil else { + return + } + translatesAutoresizingMaskIntoConstraints = false + addSubview(colorView) + addSubview(label) + + heightConstraint = colorView.heightAnchor.constraint(equalToConstant: sizeObject.getValueBasedOnApplicationWidth()) + heightConstraint?.isActive = true + colorView.widthAnchor.constraint(equalTo: colorView.heightAnchor).isActive = true + colorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true + colorView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true + + label.leadingAnchor.constraint(equalTo: colorView.trailingAnchor, constant: PaddingOne).isActive = true + label.topAnchor.constraint(equalTo: topAnchor).isActive = true + trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true + bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true + + } + + override func updateView(_ size: CGFloat) { + super.updateView(size) + label.updateView(size) + heightConstraint?.constant = sizeObject.getValueBased(onSize: size) + setNeedsDisplay() + } + + override func reset() { + super.reset() + label.reset() + } + + func setAsMolecule() { + label.setAsMolecule() + } + + override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let chartItemModel = model as? ChartItemModel else { + return + } + label.setWithModel(chartItemModel.label, delegateObject, additionalData) + colorView.backgroundColor = UIColor.mfGet(forHex: chartItemModel.color) + } + + override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + Label.setUILabel(label, withJSON: json?.optionalDictionaryForKey("label"), delegate: delegateObject, additionalData: additionalData) + colorView.backgroundColor = UIColor.mfGet(forHex: json?.optionalStringForKey("color") ?? "#000000") + } + +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index c656ab2f..4b597288 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -68,7 +68,8 @@ @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, - @"stackItem": StackItem.class + @"stackItem": StackItem.class, + @"doughnutChart": DoughnutChartView.class } mutableCopy]; }); return mapping; diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index ac96c44f..651d18a7 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -29,5 +29,6 @@ import Foundation ModelRegistry.register(LabelAttributeUnderlineModel.self) ModelRegistry.register(LabelAttributeStrikeThroughModel.self) ModelRegistry.register(LabelAttributeActionModel.self) + ModelRegistry.register(DoughnutChartModel.self) } } From b4859988c20a42df28de56757cc508c0063993c9 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Mon, 13 Jan 2020 19:52:04 +0530 Subject: [PATCH 097/272] set with json removed --- .../Molecules/LabelRightMoleculesStack.swift | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift index 4cb5a89b..58a5ba7b 100644 --- a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift +++ b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift @@ -72,11 +72,6 @@ class LeftLabelRightMoleculeContainer: View { super.init(frame: frame) } - public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.init(frame: CGRect.zero) - setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - public required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -157,28 +152,6 @@ class LeftLabelRightMoleculeContainer: View { } } - override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - let previousMoleculeName = rightMoleculeName - removeSubviewsInRightContainer() - guard let moleculeJSON = json, let _ = moleculeJSON.optionalStringForKey(KeyMoleculeName) else { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - return - } - - label.text = leftText - rightMoleculeName = moleculeJSON.optionalStringForKey(KeyMoleculeName) - //For reuse purpose check that allready added molecule is same - if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName { - rightMolecule.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) - addView(rightMolecule) - } else { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: false) { - addView(molecule) - } - } - } - func updateLeftViewWidthConstraint(_ percent: CGFloat) { percentage = percent leftWidthConstraint?.isActive = false From 5bb6b9bc7591ce8263e317f7ae6b811150688592 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 09:38:39 -0500 Subject: [PATCH 098/272] Line items update --- MVMCoreUI.xcodeproj/project.pbxproj | 34 ++++++--- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 2 +- .../MFTextField+ModelExtension.swift | 2 +- MVMCoreUI/Atoms/Views/CaretView.swift | 6 +- MVMCoreUI/Atoms/Views/DashLine.swift | 4 +- MVMCoreUI/Atoms/Views/GraphView.swift | 4 +- MVMCoreUI/Atoms/Views/Label.swift | 2 +- .../Atoms/Views/LeftRightLabelView.swift | 2 +- MVMCoreUI/Atoms/Views/Line.swift | 2 +- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 2 +- .../Atoms/Views/MFView+ModelExtension.swift | 4 +- MVMCoreUI/Atoms/Views/MultiProgress.swift | 4 +- MVMCoreUI/Atoms/Views/ProgressBar.swift | 6 +- MVMCoreUI/BaseClasses/Control.swift | 2 +- MVMCoreUI/BaseClasses/View.swift | 2 +- .../MFViewController+Model.swift | 4 +- MVMCoreUI/Containers/Container.swift | 10 +-- MVMCoreUI/MVMCoreUI.h | 1 - MVMCoreUI/Models/Extensions/ModelHelper.swift | 13 ++++ .../ListItemModelProtocol.swift | 23 +++++- .../ModelProtocols/TemplateProtocol.swift | 2 +- .../Template/ListPageTemplateModel.swift | 67 ++++++++--------- .../TabsModel.swift | 50 +++++++++++++ .../Items/AccordionListItemModel.swift | 46 ++++++++++++ .../AccordionMoleculeTableViewCell.swift | 7 +- .../Items/DropDownFilterTableViewCell.swift | 17 ++--- .../Items}/DropDownListItemModel.swift | 26 ++++--- .../Items/MoleculeCollectionViewCell.swift | 4 +- .../Items/MoleculeTableViewCell.swift | 6 +- MVMCoreUI/Molecules/Items/StackItem.swift | 4 +- .../Items/StackItemModel.swift} | 2 +- MVMCoreUI/Molecules/Items/TableViewCell.swift | 71 ++++++------------- .../Molecules/Items/TabsListItemModel.swift | 54 ++++++++++++++ .../Molecules/Items/TabsTableViewCell.swift | 20 ++---- .../SwitchMolecules/HeadlineBodySwitch.swift | 2 +- .../Molecules/ModelMoleculeViewProtocol.swift | 2 +- MVMCoreUI/Molecules/ModuleMolecule.swift | 2 +- MVMCoreUI/Molecules/MoleculeContainer.swift | 2 +- MVMCoreUI/Molecules/Scroller.swift | 2 +- MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- .../EyebrowHeadlineBodyLink.swift | 8 +-- .../HeadlineBody.swift | 2 +- MVMCoreUI/Organisms/Carousel.swift | 2 +- .../MoleculeStackModel.swift | 6 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 8 +-- .../ModelMoleculeDelegateProtocol.swift | 2 +- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- .../Templates/MoleculeListCellProtocol.h | 22 ------ .../Templates/MoleculeListCellProtocol.swift | 32 +++++++++ .../Templates/MoleculeListTemplate.swift | 8 +-- 50 files changed, 393 insertions(+), 216 deletions(-) create mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift create mode 100644 MVMCoreUI/Molecules/Items/AccordionListItemModel.swift rename MVMCoreUI/{Models/Molecules => Molecules/Items}/DropDownListItemModel.swift (62%) rename MVMCoreUI/{Models/Molecules/MoleculeStackItemModel.swift => Molecules/Items/StackItemModel.swift} (94%) create mode 100644 MVMCoreUI/Molecules/Items/TabsListItemModel.swift rename MVMCoreUI/{Models/Molecules => Organisms}/MoleculeStackModel.swift (91%) delete mode 100644 MVMCoreUI/Templates/MoleculeListCellProtocol.h create mode 100644 MVMCoreUI/Templates/MoleculeListCellProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 7769203b..b34f888b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -108,7 +108,7 @@ D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; + D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* StackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; @@ -120,7 +120,10 @@ D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; }; D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */; }; D28A837923C7D5BC00DFE4FC /* PageModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */; }; - D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837A23C928DA00DFE4FC /* MoleculeListCellProtocol.swift */; }; + 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 */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -314,7 +317,7 @@ 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; - 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackItemModel.swift; sourceTree = ""; }; + 01EB368A23609801006832FA /* StackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StackItemModel.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 = ""; }; @@ -376,7 +379,10 @@ D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = ""; }; D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFCustomButton+ActionModel.swift"; sourceTree = ""; }; D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModelProtocol.swift; sourceTree = ""; }; - D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; + D28A837A23C928DA00DFE4FC /* MoleculeListCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListCellProtocol.swift; sourceTree = ""; }; + 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 = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -613,9 +619,6 @@ isa = PBXGroup; children = ( 011B58F323A2CCC80085F53C /* DropDownModel.swift */, - 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */, - 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, - 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, @@ -723,6 +726,7 @@ children = ( D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */, D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */, + D28A837E23CCA96400DFE4FC /* TabsModel.swift */, ); path = HorizontalCombinationViews; sourceTree = ""; @@ -739,6 +743,7 @@ D22479902316A9CB003FCCF9 /* Organisms */ = { isa = PBXGroup; children = ( + 01EB368B23609801006832FA /* MoleculeStackModel.swift */, D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, D2A6390022CBB1820052ED1F /* Carousel.swift */, ); @@ -752,9 +757,13 @@ 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, + D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */, D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, + D28A837C23CCA86A00DFE4FC /* TabsListItemModel.swift */, D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */, + 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */, D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */, + 01EB368A23609801006832FA /* StackItemModel.swift */, D2FB151C23A40F1500C20E10 /* StackItem.swift */, ); path = Items; @@ -790,7 +799,6 @@ D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */ = { isa = PBXGroup; children = ( - D29DF10D21E67A70003B2FB9 /* Atoms */, 01509D96232803B200EF99AA /* Models */, D2B18B7D236090D500A9AEDC /* BaseClasses */, 01C74D87224298E2009C25A3 /* FormUIHelpers */, @@ -803,6 +811,7 @@ D22D1F582204D2590077CEC0 /* Legacy */, D29DF10F21E67A7D003B2FB9 /* BaseControllers */, D29DF11E21E6851E003B2FB9 /* TopAlert */, + D29DF10D21E67A70003B2FB9 /* Atoms */, D29DF10E21E67A77003B2FB9 /* Molecules */, D22479902316A9CB003FCCF9 /* Organisms */, D29DF0DF21E418B2003B2FB9 /* Templates */, @@ -817,7 +826,7 @@ children = ( D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */, - D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */, + D28A837A23C928DA00DFE4FC /* MoleculeListCellProtocol.swift */, D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */, D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */, ); @@ -1231,7 +1240,6 @@ D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */, D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */, D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */, - D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */, D29DF32021ED0CBA003B2FB9 /* LabelView.h in Headers */, D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */, D29DF2E121E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h in Headers */, @@ -1325,6 +1333,7 @@ 012CA9E423888B1B003F810F /* (null) in Sources */, 9402C35023A2CEA3004B974C /* LeftRightLabelModel.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, + D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, @@ -1363,6 +1372,7 @@ D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, + D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */, 014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, @@ -1385,10 +1395,11 @@ 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, D213347723843825008E41B3 /* Line.swift in Sources */, D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */, + D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */, 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, - D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, + D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, @@ -1459,6 +1470,7 @@ D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, + D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */, 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */, 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index b3ff5409..16b571d1 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -132,7 +132,7 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let caretLinkModel = model as? CaretLinkModel else { return } if let color = caretLinkModel.backgroundColor { backgroundColor = color.uiColor diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift index 9944e22d..e0c5ce0f 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift +++ b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift @@ -16,7 +16,7 @@ enum TextType: String { } extension MFTextField: ModelMoleculeViewProtocol { // - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { //TODO: Need to create setWithModel in ViewConstraining View #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index 4a0b9c36..653bfef0 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -103,13 +103,13 @@ open class CaretView: View { defaultState() } - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: CaretViewModel.self) else { return } - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + setWithModel(model, delegateObject, additionalData) } //MARK: - MVMCoreMoleculeViewProtocol - override public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + override public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let caretModel = model as? CaretViewModel else { return diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 89541b0c..94bd987c 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -74,11 +74,11 @@ open class DashLine: View { open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: DashLineModel.self) else { return } - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + setWithModel(model, delegateObject, additionalData) } //MARK: - MVMCoreMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let dashLineModel = dashModel else { return diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index ca63c67f..40c353b2 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -126,11 +126,11 @@ public struct GraphObject { widthAnchor.constraint(equalTo: heightAnchor).isActive = true } - override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) } - override open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + override open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) let object = GraphObject(json) graphObject = object diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index b4b4e36a..28f0078f 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -218,7 +218,7 @@ public typealias ActionBlock = () -> () case left } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { clauses = [] guard let labelModel = model as? LabelModel else { return } attributedText = nil diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift index 979d2abb..5e128e26 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift @@ -179,7 +179,7 @@ import Foundation //MARK: - MVMCoreMoleculeViewProtocol - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let leftRightLabelModel = model as? LeftRightLabelModel else { return diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atoms/Views/Line.swift index 7b80d59a..d7cbc5e8 100644 --- a/MVMCoreUI/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atoms/Views/Line.swift @@ -67,7 +67,7 @@ import UIKit super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let lineModel = model as? LineModel { setStyle(lineModel.type ?? .standard) } diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 17515e71..7be1187a 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -209,7 +209,7 @@ import UIKit } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let imageModel = model as? ImageViewModel else { return } diff --git a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift index df6b09a5..2ba216d7 100644 --- a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift @@ -9,7 +9,7 @@ import Foundation extension MFView { - public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor @@ -18,7 +18,7 @@ extension MFView { } extension ModelMoleculeViewProtocol where Self: MFView { - func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { setUpDefaultWithModel(model, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index 29fbf465..e5978c9c 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -64,7 +64,7 @@ import UIKit } //MARK: - MVMCoreMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let multiProgressModel = multiProgressModel else { return @@ -83,6 +83,6 @@ import UIKit public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: MultiProgressBarModel.self) else { return } - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + setWithModel(model, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index dff5bfc4..bbf5a5de 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -51,7 +51,7 @@ import Foundation } //MARK: - MVMCoreMoleculeViewProtocol - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let progressBarModel = model as? ProgressBarModel else { return } @@ -64,9 +64,9 @@ import Foundation } // MARK: - MVMCoreUIMoleculeViewProtocol - public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: ProgressBarModel.self) else { return } - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + setWithModel(model, delegateObject, additionalData) } public func reset() { diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 769e7acb..915e0891 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -49,7 +49,7 @@ import UIKit } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 0cb1088d..45631d93 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -40,7 +40,7 @@ import UIKit return model?.moleculeName } - open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index b3ff4ec6..88f05360 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -16,10 +16,10 @@ extension MFViewController: MoleculeDelegateProtocol { return loadObject?.modulesJSON?.optionalDictionaryForKey(name) } - public func getModuleWithName(_ moduleName: String) -> Model? { + public func getModuleWithName(_ moduleName: String) -> MoleculeProtocol? { guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moduleName), let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), - let modelType = ModelRegistry.getType(for: moleculeName) else { + let modelType = ModelRegistry.getType(for: moleculeName) as? MoleculeProtocol.Type else { return nil } do { diff --git a/MVMCoreUI/Containers/Container.swift b/MVMCoreUI/Containers/Container.swift index f1998aac..ab495b81 100644 --- a/MVMCoreUI/Containers/Container.swift +++ b/MVMCoreUI/Containers/Container.swift @@ -172,11 +172,11 @@ public class ContainerHelper: NSObject { MFStyler.setMarginsFor(view, size: size, defaultHorizontal: model?.useHorizontalMargins ?? false, top: (model?.useVerticalMargins ?? false) ? (model?.topMarginPadding ?? 0) : 0, bottom: (model?.useVerticalMargins ?? false) ? (model?.bottomMarginPadding ?? 0) : 0) } - func set(with model: ContainerModelProtocol) { - if let horizontalAlignment = model.horizontalAlignment { + func set(with model: ContainerModelProtocol, for contained: MVMCoreUIViewConstrainingProtocol?) { + if let horizontalAlignment = model.horizontalAlignment ?? contained?.horizontalAlignment?() { alignHorizontal(horizontalAlignment) } - if let verticalAlignment = model.verticalAlignment { + if let verticalAlignment = model.verticalAlignment ?? contained?.verticalAlignment?() { alignVertical(verticalAlignment) } } @@ -203,10 +203,10 @@ open class Container: View { get { return model as? ContainerModelProtocol } } - override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let containerModel = model as? ContainerModelProtocol else { return } - containerHelper.set(with: containerModel) + containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol) } } diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index ff9b4087..a71be907 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -20,7 +20,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import -#import #import #pragma mark - TopAlert diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index 7c73f264..72bb5f8f 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -35,4 +35,17 @@ extension KeyedDecodingContainer where Key : CodingKey { public func decodeMoleculesIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] } + + /// Decodes an array with arrays of molecules based on the identifiers, optional. + public func decodeMolecules2DIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeProtocol]]? { + return try decodeModels2DIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeProtocol]] + } + + /// Decodes an array with arrays of models based on the identifiers. + public func decodeMolecules2D(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeProtocol]] { + guard let models = try decodeModels2D(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeProtocol]] else { + throw ModelRegistry.Error.decoderError + } + return models + } } diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index a77f9374..7a990d61 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -9,6 +9,27 @@ import Foundation public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeProtocol { - var molecule: MoleculeProtocol { get } var line: LineModel? { get set } + var action: ActionProtocol? { get set } + var hideArrow: Bool? { get set } + var style: String? { get set } +} + +// Not a strict requirement. +extension ListItemModelProtocol { + public var action: ActionProtocol? { + get { + return nil + } + set { + } + } + + public var style: String? { + get { + return nil + } + set { + } + } } diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift index 8293f18b..eb4463d5 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift @@ -15,7 +15,7 @@ public protocol TemplateProtocol: class { public extension TemplateProtocol where Self: MFViewController { func parseTemplateJSON() { - guard let pageJSON = self.loadObject?.pageJSON as? [String: AnyHashable] else { return } + guard let pageJSON = self.loadObject?.pageJSON else { return } do { let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift index c457969a..dd8d3979 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -19,6 +19,7 @@ import Foundation public var header: HeaderModel? public var molecules: [ListItemModelProtocol] public var footer: MoleculeStackModel? + public var line: LineModel? public init(pageType: String, screenHeading: String, molecules: [ListItemModelProtocol]) { self.pageType = pageType @@ -26,39 +27,41 @@ import Foundation self.molecules = molecules } - enum CodingKeys: String, CodingKey { - case moleculeName - case pageType - case screenHeading - case molecules - case header - case footer - case isAtomicTabs - } + enum CodingKeys: String, CodingKey { + case moleculeName + case pageType + case screenHeading + case molecules + case header + case footer + case line + case isAtomicTabs + } - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.pageType = try typeContainer.decode(String.self, forKey: .pageType) - self.screenHeading = try typeContainer.decode(String.self, forKey: .screenHeading) + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decode(String.self, forKey: .pageType) + screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) + + guard let molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as? [ListItemModelProtocol] else { + throw JSONError.pathNotFound + } + self.molecules = molecules + isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) + header = try typeContainer.decodeIfPresent(HeaderModel.self, forKey: .header) + footer = try typeContainer.decodeIfPresent(MoleculeStackModel.self, forKey: .footer) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + } - guard let molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as? [ListItemModelProtocol] else { - throw JSONError.pathNotFound - } - self.molecules = molecules - self.isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) - self.header = try typeContainer.decodeIfPresent(HeaderModel.self, forKey: .header) - self.footer = try typeContainer.decodeIfPresent(MoleculeStackModel.self, forKey: .footer) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(pageType, forKey: .pageType) - try container.encode(screenHeading, forKey: .screenHeading) - - try container.encodeModels(molecules, forKey: .molecules) - try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) - try container.encodeIfPresent(header, forKey: .header) - try container.encodeIfPresent(footer, forKey: .footer) - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(pageType, forKey: .pageType) + try container.encodeIfPresent(screenHeading, forKey: .screenHeading) + try container.encodeModels(molecules, forKey: .molecules) + try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) + try container.encodeIfPresent(header, forKey: .header) + try container.encodeIfPresent(footer, forKey: .footer) + try container.encode(line, forKey: .line) + } } diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift new file mode 100644 index 00000000..0e358871 --- /dev/null +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -0,0 +1,50 @@ +// +// TabsModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class TabsModel: MoleculeProtocol { + public static var identifier: String = "tabs" + public var backgroundColor: Color? + public var tabs: [LabelModel] + public var selectedColor = Color(uiColor: .mfTomatoRed()) + + // Must be capped to 0...(tabs.count - 1) + public var selectedIndex: Int = 0 + + enum TabsCodingKeys: String, CodingKey { + case tabs + case backgroundColor + case selectedColor + case selectedIndex + } + + public init(with tabs: [LabelModel]) { + self.tabs = tabs + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: TabsCodingKeys.self) + tabs = try typeContainer.decode([LabelModel].self, forKey: .tabs) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor) { + selectedColor = color + } + if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) { + selectedIndex = index + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: TabsCodingKeys.self) + try container.encode(tabs, forKey: .tabs) + try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encode(selectedColor, forKey: .selectedColor) + try container.encode(selectedIndex, forKey: .selectedIndex) + } +} diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift new file mode 100644 index 00000000..d5519288 --- /dev/null +++ b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift @@ -0,0 +1,46 @@ +// +// AccordionListItemModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { + public static var identifier: String = "accordionListItem" + public var molecules: [ListItemModelProtocol] + public var backgroundColor: Color? + public var hideLineWhenExpanded: Bool = false + public var hideArrow: Bool? = true + public var line: LineModel? + + enum AccordionListItemCodingKeys: String, CodingKey { + case molecules + case backgroundColor + case hideLineWhenExpanded + case hideArrow + case line + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: AccordionListItemCodingKeys.self) + molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [ListItemModelProtocol] + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + if let hideLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideLineWhenExpanded) { + hideLineWhenExpanded = hideLine + } + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: AccordionListItemCodingKeys.self) + try container.encodeModels(molecules, forKey: .molecules) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(hideLineWhenExpanded, forKey: .hideLineWhenExpanded) + try container.encodeIfPresent(line, forKey: .line) + } +} diff --git a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift index d6a5e05d..db4e322e 100644 --- a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -9,6 +9,7 @@ import UIKit @objcMembers public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { + var accordionListItemModel: AccordionListItemModel? let accordionButton = createAccordionButton() static func createAccordionButton() -> MFCustomButton { @@ -26,10 +27,10 @@ import UIKit accessoryView = accordionButton } - public override func didSelectCell(atIndex indexPath: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + override public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { accordionButton.isSelected = !accordionButton.isSelected accordionButton.setTitle(accordionButton.isSelected ? "-" : "+", for: .normal) - guard let molecules = json?.optionalArrayForKey(KeyMolecules) as? [[AnyHashable: Any]] else { + guard let molecules = accordionListItemModel?.molecules else { return } @@ -39,7 +40,7 @@ import UIKit delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: .automatic) } - if (json?.boolForKey("hideSeparatorWhenExpanded") ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { + if (accordionListItemModel?.hideLineWhenExpanded ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { bottomSeparatorView?.isHidden = accordionButton.isSelected } } diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index a2ca4383..4df2e7e2 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -9,6 +9,7 @@ import UIKit @objcMembers public class DropDownFilterTableViewCell: TableViewCell { + var dropDownListItemModel: DropDownListItemModel? let dropDown = DropDown(forDropDownWithBothDelegates: nil) var delegateObject: MVMCoreUIDelegateObject? var previousIndex = NSNotFound @@ -20,7 +21,6 @@ import UIKit guard let dropDown = dropDown, dropDown.superview == nil else { return } - bottomMarginPadding = 0 dropDown.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(dropDown) @@ -35,14 +35,12 @@ import UIKit guard change.newValue != change.oldValue, let self = self, let options = self.dropDown?.json?.optionalArrayForKey("options") as? [NSString], let index = options.firstIndex(of: change.newValue!! as NSString), - let moleculesArrays = self.json?.arrayForKey(KeyMolecules) as? [[[AnyHashable: Any]]] else { return } + let molecules = self.dropDownListItemModel?.molecules else { return } if self.previousIndex != NSNotFound { - let previousMolecules = moleculesArrays[self.previousIndex] - self.delegateObject?.moleculeDelegate?.removeMolecules(previousMolecules, sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(molecules[self.previousIndex], sender: self, animation: .fade) } - let molecules = moleculesArrays[index] - self.delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.addMolecules(molecules[index], sender: self, animation: .fade) self.previousIndex = index } } @@ -52,19 +50,18 @@ import UIKit dropDown?.updateView(size) } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - bottomSeparatorView?.setStyle(.none) + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + dropDownListItemModel = model as? DropDownListItemModel self.delegateObject = delegateObject super.setWithModel(model, delegateObject, additionalData) dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate - dropDown?.setWithJSON(json?.optionalDictionaryForKey("dropDown"), delegateObject: delegateObject, additionalData: additionalData) + dropDown?.setWithModel(dropDownListItemModel, delegateObject, additionalData) } public override func reset() { super.reset() - bottomMarginPadding = 0 bottomSeparatorView?.setStyle(.none) } } diff --git a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift similarity index 62% rename from MVMCoreUI/Models/Molecules/DropDownListItemModel.swift rename to MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 1ef1ca1f..64e8c69b 100644 --- a/MVMCoreUI/Models/Molecules/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -10,12 +10,13 @@ import Foundation @objcMembers public class DropDownListItemModel: MoleculeContainerModel, ListItemModelProtocol { public static var identifier: String = "dropDownListItem" - public var molecules: [[ListItemModel]] - public var backgroundColor: Color? - public var line: LineModel? + public var molecules: [[ListItemModelProtocol]] public var dropDown: DropDownModel + public var backgroundColor: Color? + public var line: LineModel? = LineModel(type: .none) + public var hideArrow: Bool? = true - public init(molecule: MoleculeProtocol, molecules: [[ListItemModel]], dropDown: DropDownModel) { + public init(molecule: MoleculeProtocol, molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { self.molecules = molecules self.dropDown = dropDown super.init(with: molecule) @@ -23,25 +24,28 @@ import Foundation enum DropDownCodingKeys: String, CodingKey { case molecules + case dropDown case line case backgroundColor - case dropDown } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: DropDownCodingKeys.self) - self.molecules = try typeContainer.decode([[ListItemModel]].self, forKey: .molecules) - self.line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - self.dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) + molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] + dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) + if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { + line = lineModel + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: DropDownCodingKeys.self) - try container.encode(molecules, forKey: .molecules) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeModels2D(molecules, forKey: .molecules) try container.encode(dropDown, forKey: .dropDown) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(line, forKey: .line) } } diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index 1603c876..b396dde6 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -8,7 +8,7 @@ import UIKit -open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol, ModelMoleculeViewProtocol { +open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeViewProtocol, ModelMoleculeViewProtocol { open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? open var json: [AnyHashable: Any]? @@ -68,7 +68,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let collectionModel = model as? CarouselItemModel else { return } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 40222f03..1fee9e20 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -11,11 +11,11 @@ import UIKit @objcMembers open class MoleculeTableViewCell: TableViewCell { // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model, - let moleculeModel = (model as? ListItemModelProtocol)?.molecule, + let moleculeModel = (model as? ListItemModel)?.molecule, let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) else { return } @@ -23,7 +23,7 @@ import UIKit } public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let moleculeModel = (molecule as? ListItemModelProtocol)?.molecule else { + guard let moleculeModel = (molecule as? ListItemModel)?.molecule else { return "\(self)<>" } let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol diff --git a/MVMCoreUI/Molecules/Items/StackItem.swift b/MVMCoreUI/Molecules/Items/StackItem.swift index e121a1ee..59c30962 100644 --- a/MVMCoreUI/Molecules/Items/StackItem.swift +++ b/MVMCoreUI/Molecules/Items/StackItem.swift @@ -9,7 +9,7 @@ import UIKit open class StackItem: MoleculeContainer { - var stackItemModel: MoleculeStackItemModel? { - get { return model as? MoleculeStackItemModel } + var stackItemModel: StackItemModel? { + get { return model as? StackItemModel } } } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift similarity index 94% rename from MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift rename to MVMCoreUI/Molecules/Items/StackItemModel.swift index 106ea6e5..a5128f1b 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol { +@objcMembers public class StackItemModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "stackItem" public var backgroundColor: Color? public var spacing: CGFloat? diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index ee6e79dd..3cf51ab6 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -11,12 +11,8 @@ import UIKit @objcMembers open class TableViewCell: UITableViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol, ModelMoleculeViewProtocol { open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? - open var json: [AnyHashable: Any]? - open var listItemModel: ListItemModel? + open var listItemModel: ListItemModelProtocol? public let containerHelper = ContainerHelper() - - // In updateView, will set padding to default. - open var updateViewHorizontalDefaults = true // For the accessory view convenience. private var caretView: CaretView? @@ -26,19 +22,10 @@ import UIKit // For separation between cells. public var topSeparatorView: Line? public var bottomSeparatorView: Line? - public enum SeparatorFrequency: String { - case all - case allExceptTop - case allExceptBottom - case between - } /// For subclasses that want to use a custom accessory view. open var customAccessoryView = false - open var topMarginPadding: CGFloat = 24 - open var bottomMarginPadding: CGFloat = 24 - private var heroAccessoryCenter: CGPoint? // MARK: - Styling @@ -62,36 +49,36 @@ import UIKit } open func styleStandard() { - topMarginPadding = 24 - bottomMarginPadding = 24 + listItemModel?.topMarginPadding = 24 + listItemModel?.bottomMarginPadding = 24 topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.standard) } open func styleTallDivider() { - topMarginPadding = 48 - bottomMarginPadding = 16 + listItemModel?.topMarginPadding = 48 + listItemModel?.bottomMarginPadding = 16 topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.thin) } open func styleShortDivider() { - topMarginPadding = 32 - bottomMarginPadding = 16 + listItemModel?.topMarginPadding = 32 + listItemModel?.bottomMarginPadding = 16 topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.thin) } open func styleFooter() { - topMarginPadding = 24 - bottomMarginPadding = 0 + listItemModel?.topMarginPadding = 24 + listItemModel?.bottomMarginPadding = 0 topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.none) } open func styleNone() { - topMarginPadding = 0 - bottomMarginPadding = 0 + listItemModel?.topMarginPadding = 0 + listItemModel?.bottomMarginPadding = 0 topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.none) } @@ -125,7 +112,7 @@ import UIKit // MARK: - MFViewProtocol public func updateView(_ size: CGFloat) { - MFStyler.setMarginsFor(self, size: size, defaultHorizontal: updateViewHorizontalDefaults, top: topMarginPadding, bottom: bottomMarginPadding) + containerHelper.updateViewMargins(self, model: listItemModel, size: size) if accessoryView != nil { // Smaller left margin if accessory view. @@ -155,23 +142,14 @@ import UIKit } //TODO: Model, Change to model - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - guard let model = model as? ListItemModel else { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let model = model as? ListItemModelProtocol else { return } self.listItemModel = model style(with: model.style) - if let useHorizontalMargins = model.useHorizontalMargins { - updateViewHorizontalDefaults = useHorizontalMargins - } - - if (model.useVerticalMargins ?? true) == false { - topMarginPadding = 0 - bottomMarginPadding = 0 - } - if let backgroundColor = model.backgroundColor { self.backgroundColor = backgroundColor.uiColor } @@ -192,12 +170,11 @@ import UIKit } guard let molecule = molecule else { return } - containerHelper.set(with: json, for: molecule) + containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) } public func reset() { molecule?.reset?() - updateViewHorizontalDefaults = true styleStandard() backgroundColor = .white } @@ -254,23 +231,19 @@ import UIKit // MARK: - MoleculeListCellProtocol /// For when the separator between cells shows using json and frequency. Default is type: standard, frequency: allExceptTop. - //TODO: Change to model - public func setSeparatorWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) { + public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?, indexPath: IndexPath) { addSeparatorsIfNeeded() - if let json = json { - topSeparatorView?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - bottomSeparatorView?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - if let separatorFrequencyString = json.optionalStringForKey("frequency"), let separatorFrequency = SeparatorFrequency(rawValue: separatorFrequencyString) { - setSeparatorFrequency(separatorFrequency, indexPath: indexPath) - } + if let model = model { + topSeparatorView?.setWithModel(model, delegateObject, additionalData) + bottomSeparatorView?.setWithModel(model, delegateObject, additionalData) } else { topSeparatorView?.setStyle(.standard) bottomSeparatorView?.setStyle(.standard) - setSeparatorFrequency(TableViewCell.SeparatorFrequency.allExceptTop, indexPath: indexPath) } + setSeparatorFrequency(model?.frequency ?? .allExceptTop, indexPath: indexPath) } - public func didSelectCell(atIndex indexPath: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { //TODO: Use object when handleAction is rewrote to handle action model if let actionMap = self.listItemModel?.action?.toJSON() { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) @@ -304,7 +277,7 @@ import UIKit } /// For when the separator between cells shows. - public func setSeparatorFrequency(_ separatorFrequency: SeparatorFrequency, indexPath: IndexPath) { + public func setSeparatorFrequency(_ separatorFrequency: LineModel.Frequency, indexPath: IndexPath) { switch separatorFrequency { case .all: if indexPath.row == 0 { diff --git a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift new file mode 100644 index 00000000..d27b9097 --- /dev/null +++ b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift @@ -0,0 +1,54 @@ +// +// TabsListItemModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class TabsListItemModel: ContainerModel, ListItemModelProtocol { + public static var identifier: String = "tabsListItem" + var tabs: TabsModel + var molecules: [[ListItemModelProtocol]] + + public var backgroundColor: Color? + public var hideArrow: Bool? = true + public var line: LineModel? = LineModel(type: .standard) + + enum TabsListItemCodingKeys: String, CodingKey { + case tabs + case molecules + case backgroundColor + case line + } + + public init(with tabs: TabsModel, molecules: [[ListItemModelProtocol]]) { + self.tabs = tabs + self.molecules = molecules + super.init() + self.topMarginPadding = 8 + self.bottomMarginPadding = 0 + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: TabsListItemCodingKeys.self) + tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs) + molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { + line = lineModel + } + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: TabsListItemCodingKeys.self) + try container.encode(tabs, forKey: .tabs) + try container.encodeModels2D(molecules, forKey: .molecules) + try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(line, forKey: .line) + } +} diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift index d9626ae0..99d2d9ab 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift @@ -9,6 +9,7 @@ import UIKit @objcMembers public class TabsTableViewCell: TableViewCell { + var tabsListItemModel: TabsListItemModel? let tabs = TopTabbar(frame: .zero) var delegateObject: MVMCoreUIDelegateObject? var previousTabIndex = 0 @@ -20,8 +21,6 @@ import UIKit return } tabs.paddingBeforeFirstTab = false - topMarginPadding = 8 - bottomMarginPadding = 0 tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self @@ -39,7 +38,7 @@ import UIKit // MARK: - MoleculeDelegateProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) self.delegateObject = delegateObject tabs.reloadData() @@ -47,17 +46,13 @@ import UIKit public override func reset() { super.reset() - topMarginPadding = 8 - bottomMarginPadding = 0 + tabs.reset() } } -//TODO: Models changes - extension TabsTableViewCell: TopTabbarDelegate { public func shouldSelectItem(at index: Int, topTabbar: TopTabbar) -> Bool { - if let moleculesArrays = json?.arrayForKey(KeyMolecules), - let molecules = moleculesArrays[topTabbar.selectedIndex] as? [[AnyHashable: Any]] { + if let molecules = tabsListItemModel?.molecules[topTabbar.selectedIndex] { delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) } previousTabIndex = tabs.selectedIndex @@ -65,8 +60,7 @@ extension TabsTableViewCell: TopTabbarDelegate { } public func topTabbar(_ topTabbar: TopTabbar, didSelectItemAt index: Int) { - if let moleculesArrays = json?.arrayForKey(KeyMolecules), - let molecules = moleculesArrays[index] as? [[AnyHashable: Any]] { + if let molecules = tabsListItemModel?.molecules[index] { delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) } } @@ -74,11 +68,11 @@ extension TabsTableViewCell: TopTabbarDelegate { extension TabsTableViewCell: TopTabbarDataSource { public func number(ofTopTabbarItems topTabbar: TopTabbar) -> Int { - return json?.optionalDictionaryForKey("tabs")?.optionalArrayForKey("tabs")?.count ?? 0 + return tabsListItemModel?.tabs.tabs.count ?? 0 } public func topTabbar(_ topTabbar: TopTabbar, titleForItemAt index: Int) -> String? { - guard let tabs = json?.optionalDictionaryForKey("tabs")?.arrayForKey("tabs"), let label = tabs[index] as? [AnyHashable: Any], let title = label.optionalStringForKey(KeyText) else { + guard let title = tabsListItemModel?.tabs.tabs[index].text else { return "Select" } return title diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 7e5fcda8..eca878ab 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -37,7 +37,7 @@ import UIKit //MARK: - MVMCoreMoleculeViewProtocol - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) // guard let headlineModel = model as? headlinebodyswitch // headlineBody.setWithModel(mode, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##additionalData: [String : AnyHashable]?##[String : AnyHashable]?#>) diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index 8b06ab0e..de8e4d4f 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol ModelMoleculeViewProtocol { - func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) + func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index 863df271..3b49544c 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -19,7 +19,7 @@ open class ModuleMolecule: Container { super.setupView() } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let moduleMoleculeModel = model as? ModuleMoleculeModel, diff --git a/MVMCoreUI/Molecules/MoleculeContainer.swift b/MVMCoreUI/Molecules/MoleculeContainer.swift index ed8555fb..f45ca482 100644 --- a/MVMCoreUI/Molecules/MoleculeContainer.swift +++ b/MVMCoreUI/Molecules/MoleculeContainer.swift @@ -25,7 +25,7 @@ open class MoleculeContainer: Container { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let casteModel = model as? MoleculeContainerModel { if view != nil { (view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index 4be1025a..ee83077d 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -28,7 +28,7 @@ import UIKit constraint.isActive = true } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. setUpDefaultWithModel(model, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index eeb46a6a..c13638d8 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -42,7 +42,7 @@ public class StandardHeaderView: MoleculeContainer { } } - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let headerModel = model as? HeaderModel else { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 706e4712..419df541 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -34,10 +34,10 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { guard stack.superview == nil else { return } - let eyebrowStackItem = MoleculeStackItemModel(with: casteModel!.eyeBrow!) - let headlineStackItem = MoleculeStackItemModel(with: casteModel!.headline!) - let bodyStackItem = MoleculeStackItemModel(with: casteModel!.body!) - let linkStackItem = MoleculeStackItemModel(with: casteModel!.link!) + let eyebrowStackItem = StackItemModel(with: casteModel!.eyeBrow!) + let headlineStackItem = StackItemModel(with: casteModel!.headline!) + let bodyStackItem = StackItemModel(with: casteModel!.body!) + let linkStackItem = StackItemModel(with: casteModel!.link!) // To visually take into account the extra padding in the intrinsic content of a button. linkStackItem.spacing = -6 diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index a70b106d..1d1f154a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -119,7 +119,7 @@ open class HeadlineBody: View { } } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let headlineBodyModel = model as? HeadlineBodyModel else { diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index ef19f1a3..181ae372 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -81,7 +81,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol //TODO: Model, Change to model - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let caroselModel = model as? CarouselModel else { return } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift similarity index 91% rename from MVMCoreUI/Models/Molecules/MoleculeStackModel.swift rename to MVMCoreUI/Organisms/MoleculeStackModel.swift index f8012a30..73c7c0a5 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -11,11 +11,11 @@ import Foundation @objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol { public static var identifier: String = "moleculeStack" public var backgroundColor: Color? - public var molecules: [MoleculeStackItemModel] + public var molecules: [StackItemModel] public var axis: NSLayoutConstraint.Axis = .vertical public var spacing: CGFloat = 16.0 - public init(molecules: [MoleculeStackItemModel]) { + public init(molecules: [StackItemModel]) { self.molecules = molecules super.init() } @@ -29,7 +29,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self) - molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [MoleculeStackItemModel] + molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [StackItemModel] if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) { axis = optionalAxis } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 8dd43193..738333d9 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -95,7 +95,7 @@ open class MoleculeStackView: Container { } } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { let previousModel = stackModel super.setWithModel(model, delegateObject, additionalData) removeAllItemViews() @@ -139,9 +139,9 @@ open class MoleculeStackView: Container { let data = try! JSONSerialization.data(withJSONObject: json!) let decoder = JSONDecoder() let model = try! decoder.decode(MoleculeStackModel.self, from: data) - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + setWithModel(model, delegateObject, additionalData) } else { - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) + setWithModel(model, delegateObject, additionalData) } } @@ -210,7 +210,7 @@ open class MoleculeStackView: Container { func addView(_ view: View, lastItem: Bool) { guard let model = view.model else { return } let stackItem = StackItem(andContain: view) - stackItem.model = MoleculeStackItemModel(with: model) + stackItem.model = StackItemModel(with: model) addStackItem(stackItem, lastItem: lastItem) } diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index 1ea4df38..1611930a 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -12,7 +12,7 @@ public protocol MoleculeDelegateProtocol { /// returns a module for the corresponding module name. func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? - func getModuleWithName(_ moleculeName: String) -> Model? + func getModuleWithName(_ moleculeName: String) -> MoleculeProtocol? /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) //optional diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 4eb9e4a8..a8401d3f 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -14,7 +14,7 @@ import Foundation ModelRegistry.register(HeaderModel.self) ModelRegistry.register(HeadlineBodyModel.self) ModelRegistry.register(MoleculeStackModel.self) - ModelRegistry.register(MoleculeStackItemModel.self) + ModelRegistry.register(StackItemModel.self) ModelRegistry.register(ListItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(LineModel.self) diff --git a/MVMCoreUI/Templates/MoleculeListCellProtocol.h b/MVMCoreUI/Templates/MoleculeListCellProtocol.h deleted file mode 100644 index 3fa19a02..00000000 --- a/MVMCoreUI/Templates/MoleculeListCellProtocol.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// MoleculeListCellProtocol.h -// MVMCoreUI -// -// Created by Scott Pfeil on 5/22/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// -#import -@class MVMCoreUIDelegateObject; - -@protocol MoleculeListCellProtocol -@optional - -/// Can set the separator according to what the moleculeList commands. -- (void)setSeparatorWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData indexPath:(nonnull NSIndexPath *)indexPath; - -/// Handle action -- (void)didSelectCellAtIndex:(nonnull NSIndexPath *)indexPath delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; - -- (void)willDisplay; - -@end diff --git a/MVMCoreUI/Templates/MoleculeListCellProtocol.swift b/MVMCoreUI/Templates/MoleculeListCellProtocol.swift new file mode 100644 index 00000000..5d9b9525 --- /dev/null +++ b/MVMCoreUI/Templates/MoleculeListCellProtocol.swift @@ -0,0 +1,32 @@ +// +// MoleculeListCellProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol MoleculeListCellProtocol { + /// Can set the separator according to what the moleculeList commands. + func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) + + /// Handle action when cell is pressed + func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) + + /// Called by the list when the cell will display. + func willDisplay() +} + +// Default implementation does nothing +extension MoleculeListCellProtocol { + public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) { + } + + public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + } + + func willDisplay() { + } +} diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 7b572c44..13d814e9 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -85,7 +85,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol let moleculeCell = cell as? MVMCoreUIMoleculeViewProtocol moleculeCell?.reset?() if let protocolCell = cell as? MoleculeListCellProtocol { - protocolCell.setSeparatorWithJSON?(loadObject?.pageJSON?.optionalDictionaryForKey("separator"), delegateObject: delegate, additionalData: nil, indexPath: indexPath) + protocolCell.setLines(with: templateModel?.line, delegateObject: delegate, additionalData: nil, indexPath: indexPath) } (moleculeCell as? ModelMoleculeViewProtocol)?.setWithModel(moleculeInfo.molecule, delegate, nil) moleculeCell?.updateView(tableView.bounds.width) @@ -95,13 +95,13 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if let protocolCell = cell as? MoleculeListCellProtocol { - protocolCell.willDisplay?() + protocolCell.willDisplay() } } open override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol { - cell.didSelectCell?(atIndex: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil) + cell.didSelectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil) } } @@ -167,7 +167,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? { guard let listItem = listItem, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), - let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.molecule.moleculeName else { + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) else { return nil } return (moleculeName, moleculeClass, listItem) From 1b06d7007b4149600794f852a3577693babd7cef Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 10:20:11 -0500 Subject: [PATCH 099/272] circle progress --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + .../Atoms/Views/CircleProgressModel.swift | 128 +++++++++++++++++ MVMCoreUI/Atoms/Views/GraphView.swift | 132 +++--------------- 3 files changed, 149 insertions(+), 115 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/CircleProgressModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b34f888b..b7c3e2fc 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -124,6 +124,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 */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -383,6 +384,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 = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -1040,6 +1042,7 @@ 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, + D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, 943784F3236B77BB006A1E82 /* GraphView.swift */, 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */, ); @@ -1399,6 +1402,7 @@ 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, + D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift new file mode 100644 index 00000000..20f49dc0 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -0,0 +1,128 @@ +// +// CircleProgressModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public enum GraphSize: String, Codable { + case small, medium, large +} + +public enum GraphStyle: String, Codable { + case unlimited, safetyMode +} + +public class CircleProgressModel: MoleculeProtocol { + public static var identifier: String = "circleProgress" + public var style: GraphStyle = .unlimited { + didSet { + updateStyle() + } + } + + public var size: GraphSize = .small { + didSet { + updateSize() + } + } + public var diameter: CGFloat = 24 + public var lineWidth: CGFloat = 5 + public var clockwise: Bool = true + public var duration : Double = 1.0 + public var colors = [Color]() + public var backgroundColor: Color? + + public init() {} + + enum CircleProgressCodingKeys: String, CodingKey { + case style + case size + case diameter + case lineWidth + case clockwise + case duration + case colors + case backgroundColor + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CircleProgressCodingKeys.self) + if let style = try typeContainer.decodeIfPresent(GraphStyle.self, forKey: .style) { + self.style = style + } + if let size = try typeContainer.decodeIfPresent(GraphSize.self, forKey: .size) { + self.size = size + } + if let diameter = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .diameter) { + self.diameter = diameter + } + if let lineWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .lineWidth) { + self.lineWidth = lineWidth + } + if let clockwise = try typeContainer.decodeIfPresent(Bool.self, forKey: .clockwise) { + self.clockwise = clockwise + } + if let duration = try typeContainer.decodeIfPresent(Double.self, forKey: .duration) { + self.duration = duration + } + if let colors = try typeContainer.decodeIfPresent([Color].self, forKey: .colors) { + self.colors = colors + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CircleProgressCodingKeys.self) + try container.encode(style, forKey: .style) + try container.encode(size, forKey: .size) + try container.encode(diameter, forKey: .diameter) + try container.encode(lineWidth, forKey: .lineWidth) + try container.encode(clockwise, forKey: .clockwise) + try container.encode(duration, forKey: .duration) + try container.encode(colors, forKey: .colors) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + } + + func getCGColorsFromArray(_ colorArray: [String]) -> [Color] { + return colorArray.map { (colorString) -> Color in + return Color(uiColor: UIColor.mfGet(forHex: colorString)) + } + } + + func updateStyle() { + switch style { + case .unlimited: + duration = 1.0 + clockwise = true + //current style, only the end part shows darker look + colors = getCGColorsFromArray(["#007AB8","#007AB8","#033554"]) + break + case .safetyMode: + duration = 1.5 + clockwise = true + colors = getCGColorsFromArray(["#CC4D0F","#CC4D0F","AB0309"]) + break + } + } + + func updateSize() { + switch size { + case .small: + diameter = MFSizeObject(standardSize: 20)?.getValueBasedOnApplicationWidth() ?? 20 + lineWidth = MFSizeObject(standardSize: 4)?.getValueBasedOnApplicationWidth() ?? 4 + break + case .medium: + diameter = MFSizeObject(standardSize: 100)?.getValueBasedOnApplicationWidth() ?? 100 + lineWidth = MFSizeObject(standardSize: 8)?.getValueBasedOnApplicationWidth() ?? 8 + break + case .large: + diameter = MFSizeObject(standardSize: 180)?.getValueBasedOnApplicationWidth() ?? 180 + lineWidth = MFSizeObject(standardSize: 12)?.getValueBasedOnApplicationWidth() ?? 12 + break + } + } +} diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index 40c353b2..146daecf 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -8,113 +8,13 @@ import UIKit - -enum GraphSize: String { - case small, medium, large -} - -enum GraphStyle: String { - case unlimited, safetyMode -} - -///Graph Object contains properties -public struct GraphObject { - - var style: GraphStyle { - didSet { - updateStyle() - } - } - var size: GraphSize { - didSet { - updateSize() - } - } - var diameter: CGFloat = 24 - var lineWidth: CGFloat = 5 - var clockwise: Bool = true - var duration : Double = 1.0 - var colors = [CGColor]() - - public init(_ json: [AnyHashable : Any]?) { - style = .unlimited - size = .small - guard let json = json else { - return - } - if let styleString = json.optionalStringForKey("style") { - style = GraphStyle(rawValue: styleString) ?? .unlimited - } - if let sizeString = json.optionalStringForKey("size") { - size = GraphSize(rawValue: sizeString) ?? .small - } - updateStyle() - updateSize() - if let diameter = json.optionalCGFloatForKey("diameter") { - self.diameter = diameter - } - if let lineWidth = json.optionalCGFloatForKey("lineWidth") { - self.lineWidth = lineWidth - } - if let clockwise = json.optionalBoolForKey("clockwise") { - self.clockwise = clockwise - } - if let duration = json["duration"] as? Double { - self.duration = duration - } - if let colorArray = json.optionalArrayForKey("colors") as? [String] { - colors = getCGColorsFromArray(colorArray) - } - } - - func getCGColorsFromArray(_ colorArray: [String]) -> [CGColor] { - return colorArray.map { (colorString) -> CGColor in - return UIColor.mfGet(forHex: colorString).cgColor - } - } - - mutating func updateStyle() { - switch style { - case .unlimited: - duration = 1.0 - clockwise = true - //current style, only the end part shows darker look - colors = getCGColorsFromArray(["#007AB8","#007AB8","#033554"]) - break - case .safetyMode: - duration = 1.5 - clockwise = true - colors = getCGColorsFromArray(["#CC4D0F","#CC4D0F","AB0309"]) - break - } - } - - //those are - mutating func updateSize() { - switch size { - case .small: - diameter = MFSizeObject(standardSize: 20)?.getValueBasedOnApplicationWidth() ?? 20 - lineWidth = MFSizeObject(standardSize: 4)?.getValueBasedOnApplicationWidth() ?? 4 - break - case .medium: - diameter = MFSizeObject(standardSize: 100)?.getValueBasedOnApplicationWidth() ?? 100 - lineWidth = MFSizeObject(standardSize: 8)?.getValueBasedOnApplicationWidth() ?? 8 - break - case .large: - diameter = MFSizeObject(standardSize: 180)?.getValueBasedOnApplicationWidth() ?? 180 - lineWidth = MFSizeObject(standardSize: 12)?.getValueBasedOnApplicationWidth() ?? 12 - break - } - } -} - - @objcMembers open class GraphView: View, MVMCoreUIViewConstrainingProtocol { var heightConstraint: NSLayoutConstraint? var gradientLayer: CALayer? - var graphObject: GraphObject? - + var graphModel: CircleProgressModel? { + return model as? CircleProgressModel + } // MARK: setup open override func setupView() { @@ -128,14 +28,16 @@ public struct GraphObject { override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? CircleProgressModel else { return } + createGraphCircle(model) + rotationAnimation(model) } override open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - let object = GraphObject(json) - graphObject = object - createGraphCircle(object) - rotationAnimation(object) + guard let graphModel = graphModel else { return } + createGraphCircle(graphModel) + rotationAnimation(graphModel) } class func getAngle(_ piValue: Double) -> Double { @@ -147,7 +49,7 @@ public struct GraphObject { } // MARK: circle - open func createGraphCircle(_ graphObject: GraphObject) { + open func createGraphCircle(_ graphObject: CircleProgressModel) { if let sublayers = layer.sublayers { for sublayer in sublayers { sublayer.removeAllAnimations() @@ -188,14 +90,14 @@ public struct GraphObject { | | | ------------- */ - func createGradientLayer(_ graphObject: GraphObject) -> CALayer { + func createGradientLayer(_ graphObject: CircleProgressModel) -> CALayer { let containLayer = CALayer() containLayer.frame = CGRect(x: 0, y: 0, width: graphObject.diameter, height: graphObject.diameter) let radius = graphObject.diameter / 2.0 //create graident layers guard graphObject.colors.count > 1 else { - containLayer.backgroundColor = graphObject.colors.first + containLayer.backgroundColor = graphObject.colors.first?.uiColor.cgColor return containLayer } var topGradientHeight : CGFloat = 0.0 @@ -214,7 +116,7 @@ public struct GraphObject { leftColors.removeLast() topLayer.colors = [leftColors.last!, rightColors.first!] } else { - topLayer.backgroundColor = leftColors.last + topLayer.backgroundColor = leftColors.last?.uiColor.cgColor } containLayer.addSublayer(topLayer) @@ -227,7 +129,7 @@ public struct GraphObject { if leftColors.count > 1 { leftLayer.colors = Array(leftColors) } else { - leftLayer.backgroundColor = leftColors.first + leftLayer.backgroundColor = leftColors.first?.uiColor.cgColor } containLayer.addSublayer(leftLayer) @@ -238,7 +140,7 @@ public struct GraphObject { if rightColors.count > 1 { rightLayer.colors = Array(rightColors) } else { - rightLayer.backgroundColor = rightColors.first + rightLayer.backgroundColor = rightColors.first?.uiColor.cgColor } containLayer.addSublayer(rightLayer) @@ -250,7 +152,7 @@ public struct GraphObject { } //MARK: Animation - func rotationAnimation(_ object: GraphObject) { + func rotationAnimation(_ object: CircleProgressModel) { MVMCoreDispatchUtility.performBlock(onMainThread:{ let rotation = CABasicAnimation(keyPath: "transform.rotation") let animationHandler = GraphViewAnimationHandler.shared @@ -281,7 +183,7 @@ public struct GraphObject { extension GraphView: CAAnimationDelegate { public func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { - if let object = graphObject { + if let object = graphModel { rotationAnimation(object) } } From fe9131f3c67157d2c0de2b863903557dea835b21 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 10:22:04 -0500 Subject: [PATCH 100/272] update json func --- MVMCoreUI/Atoms/Views/GraphView.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index 146daecf..cda77660 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -34,10 +34,8 @@ import UIKit } override open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - guard let graphModel = graphModel else { return } - createGraphCircle(graphModel) - rotationAnimation(graphModel) + guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: CircleProgressModel.self) else { return } + setWithModel(model, delegateObject, additionalData) } class func getAngle(_ piValue: Double) -> Double { From f9620e4bc718ad4b8cc28ef4a7868a343c2dfcbb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 10:40:53 -0500 Subject: [PATCH 101/272] List template fix --- .../Models/Template/ListPageTemplateModel.swift | 14 +++++++------- MVMCoreUI/Templates/MoleculeListTemplate.swift | 12 ++---------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift index dd8d3979..61729c99 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -16,12 +16,12 @@ import Foundation public var screenHeading: String? public var isAtomicTabs: Bool? - public var header: HeaderModel? + public var header: MoleculeProtocol? public var molecules: [ListItemModelProtocol] - public var footer: MoleculeStackModel? + public var footer: MoleculeProtocol? public var line: LineModel? - public init(pageType: String, screenHeading: String, molecules: [ListItemModelProtocol]) { + public init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol]) { self.pageType = pageType self.screenHeading = screenHeading self.molecules = molecules @@ -48,8 +48,8 @@ import Foundation } self.molecules = molecules isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) - header = try typeContainer.decodeIfPresent(HeaderModel.self, forKey: .header) - footer = try typeContainer.decodeIfPresent(MoleculeStackModel.self, forKey: .footer) + header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header) + footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) } @@ -59,8 +59,8 @@ import Foundation try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeModels(molecules, forKey: .molecules) try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) - try container.encodeIfPresent(header, forKey: .header) - try container.encodeIfPresent(footer, forKey: .footer) + try container.encodeModelIfPresent(header, forKey: .header) + try container.encodeModelIfPresent(footer, forKey: .footer) try container.encode(line, forKey: .line) } } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 13d814e9..03f4e0fc 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -167,7 +167,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? { guard let listItem = listItem, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), - let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) else { + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else { return nil } return (moleculeName, moleculeClass, listItem) @@ -188,15 +188,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol /// Sets up the header, footer, molecule list and ensures no errors loading all content. func setup() { - var moleculeList: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)] = [] - if let molecules = templateModel?.molecules { - for molecule in molecules { - if let info = getMoleculeInfo(with: molecule) { - moleculeList.append(info) - } - } - } - moleculesInfo = moleculeList + moleculesInfo = getMoleculeInfoList() } /// Adds modules from requiredModules() to the MVMCoreViewControllerMapping.requiredModules map. From 824e077097ad5444bdee0843ce94eb244cce151a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 10:46:18 -0500 Subject: [PATCH 102/272] stack model fixes --- .../Template/StackPageTemplateModel.swift | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift index 0d8bef77..9cce36ab 100644 --- a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift @@ -18,7 +18,41 @@ import Foundation public var isAtomicTabs: Bool? - public var header: HeaderModel? - public var moleculeStack: MoleculeStackModel? - public var footer: FooterModel? + public var header: MoleculeProtocol? + public var moleculeStack: MoleculeStackModel + public var footer: MoleculeProtocol? + + public init(pageType: String, moleculeStack: MoleculeStackModel) { + self.pageType = pageType + self.moleculeStack = moleculeStack + } + + enum CodingKeys: String, CodingKey { + case pageType + case screenHeading + case header + case footer + case moleculeStack + case isAtomicTabs + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decode(String.self, forKey: .pageType) + moleculeStack = try typeContainer.decode(MoleculeStackModel.self, forKey: .moleculeStack) + screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) + isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) + header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header) + footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(pageType, forKey: .pageType) + try container.encode(moleculeStack, forKey: .moleculeStack) + try container.encodeIfPresent(screenHeading, forKey: .screenHeading) + try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) + try container.encodeModelIfPresent(header, forKey: .header) + try container.encodeModelIfPresent(footer, forKey: .footer) + } } From 1feee6aa9a6ef15875a3d32dfd9443123e627a61 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 10:48:35 -0500 Subject: [PATCH 103/272] three layer model fix --- .../ThreeLayerPageTemplateModel.swift | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift index b4604fbc..5d4d1b25 100644 --- a/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift @@ -17,7 +17,43 @@ import Foundation public var isAtomicTabs: Bool? - public var header: MoleculeStackModel? - public var middle: MoleculeStackModel? - public var footer: MoleculeStackModel? + public var header: MoleculeProtocol? + public var middle: MoleculeProtocol? + public var footer: MoleculeProtocol? + + public init(pageType: String, header: MoleculeProtocol?, middle: MoleculeProtocol?, footer: MoleculeProtocol?) { + self.pageType = pageType + self.header = header + self.middle = middle + self.footer = footer + } + + enum CodingKeys: String, CodingKey { + case pageType + case screenHeading + case header + case footer + case middle + case isAtomicTabs + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decode(String.self, forKey: .pageType) + screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) + isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) + header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header) + header = try typeContainer.decodeMoleculeIfPresent(codingKey: .middle) + footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(pageType, forKey: .pageType) + try container.encodeIfPresent(screenHeading, forKey: .screenHeading) + try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) + try container.encodeModelIfPresent(header, forKey: .header) + try container.encodeModelIfPresent(header, forKey: .middle) + try container.encodeModelIfPresent(footer, forKey: .footer) + } } From 3edb1a583fddcc5e9d63a5b0897ed1addd34dbc6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 10:53:52 -0500 Subject: [PATCH 104/272] module molecule update --- MVMCoreUI/Molecules/ModuleMolecule.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index 3b49544c..e2411ec0 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -23,7 +23,7 @@ open class ModuleMolecule: Container { super.setWithModel(model, delegateObject, additionalData) guard let moduleMoleculeModel = model as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else { + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMoleculeModel.moduleName) else { // Critical error return } @@ -49,7 +49,7 @@ open class ModuleMolecule: Container { public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let moduleMolecule = molecule as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, let height = classType.estimatedHeight(forRow: moduleModel, delegateObject: delegateObject)else { // Critical error @@ -60,7 +60,7 @@ open class ModuleMolecule: Container { public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moduleMolecule = model as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol, let name = classType.nameForReuse(moduleModel, delegateObject) else { // Critical error @@ -69,7 +69,6 @@ open class ModuleMolecule: Container { return name } - //TODO: Scottt please check this. public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName, From 73c19383b6dc73b4130918e42a210341a658d5b8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 11:08:58 -0500 Subject: [PATCH 105/272] Scroller update --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ MVMCoreUI/Molecules/Scroller.swift | 48 ++++++------------- MVMCoreUI/Molecules/ScrollerModel.swift | 14 ++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 9 +++- 4 files changed, 40 insertions(+), 35 deletions(-) create mode 100644 MVMCoreUI/Molecules/ScrollerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b7c3e2fc..eaed8902 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -125,6 +125,7 @@ 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 */; }; + D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -385,6 +386,7 @@ 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 = ""; }; + D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -869,6 +871,7 @@ D274CA322236A78900B01B62 /* StandardFooterView.swift */, 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */, D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, + D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */, D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */, 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */, @@ -1486,6 +1489,7 @@ D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */, + D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index ee83077d..451eba75 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class Scroller: ViewConstrainingView { +@objcMembers open class Scroller: Container { public let scrollView = UIScrollView(frame: .zero) public let contentView = MVMCoreUICommonViewsUtility.commonView() @@ -20,7 +20,8 @@ import UIKit translatesAutoresizingMaskIntoConstraints = false scrollView.translatesAutoresizingMaskIntoConstraints = false addSubview(scrollView) - pinView(toSuperView: scrollView) + NSLayoutConstraint.constraintPinSubview(toSuperview: scrollView) + contentView.translatesAutoresizingMaskIntoConstraints = false scrollView.addSubview(contentView) NSLayoutConstraint.constraintPinSubview(toSuperview: contentView) let constraint = contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor, multiplier: 1.0) @@ -28,39 +29,18 @@ import UIKit constraint.isActive = true } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") - //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. - setUpDefaultWithModel(model, delegateObject, additionalData) - - guard let model = model, - let moleculeModel = (model as? MoleculeContainerModel)?.molecule else { - return - } - - if molecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) { - contentView.addSubview(moleculeView) - pinView(toSuperView: moleculeView) - molecule = moleculeView + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + if let casteModel = model as? ScrollerModel { + if view != nil { + (view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData) + } else { + if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(casteModel.molecule, delegateObject) { + contentView.addSubview(molecule) + molecule.translatesAutoresizingMaskIntoConstraints = false + containerHelper.constrainView(molecule) + } } - } else { - (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) } + super.setWithModel(model, delegateObject, additionalData) } - -// open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { -// guard let json = json, let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule) else { -// return -// } -// if molecule == nil { -// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) { -// contentView.addSubview(moleculeView) -// pinView(toSuperView: moleculeView) -// molecule = moleculeView -// } -// } else { -// molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) -// } -// } } diff --git a/MVMCoreUI/Molecules/ScrollerModel.swift b/MVMCoreUI/Molecules/ScrollerModel.swift new file mode 100644 index 00000000..3fa225fb --- /dev/null +++ b/MVMCoreUI/Molecules/ScrollerModel.swift @@ -0,0 +1,14 @@ +// +// ScrollerModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class ScrollerModel: MoleculeContainerModel, MoleculeProtocol { + public static var identifier: String = "scroller" + public var backgroundColor: Color? +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index a8401d3f..01677585 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -15,7 +15,6 @@ import Foundation ModelRegistry.register(HeadlineBodyModel.self) ModelRegistry.register(MoleculeStackModel.self) ModelRegistry.register(StackItemModel.self) - ModelRegistry.register(ListItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(LineModel.self) ModelRegistry.register(ProgressBarModel.self) @@ -23,6 +22,14 @@ import Foundation ModelRegistry.register(CaretViewModel.self) ModelRegistry.register(DashLineModel.self) ModelRegistry.register(ImageViewModel.self) + ModelRegistry.register(TabsModel.self) + ModelRegistry.register(ScrollerModel.self) + // list items + ModelRegistry.register(ListItemModel.self) + ModelRegistry.register(DropDownListItemModel.self) + ModelRegistry.register(AccordionListItemModel.self) + ModelRegistry.register(TabsListItemModel.self) + //need to move labelattributemodel to different method ModelRegistry.register(LabelAttributeFontModel.self) ModelRegistry.register(LabelAttributeColorModel.self) From 13183f7b76ffcbbcee6f90a33248137abf3902da Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 13 Jan 2020 11:10:51 -0500 Subject: [PATCH 106/272] remove null in project file --- MVMCoreUI.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b34f888b..0c0ccde7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -22,15 +22,11 @@ 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */; }; 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */; }; 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */; }; - 012A88DA238ED42E00FE3DA1 /* (null) in Sources */ = {isa = PBXBuildFile; }; 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */; }; 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88EB238F084D00FE3DA1 /* FooterModel.swift */; }; 012A88F123985E0100FE3DA1 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88F023985E0100FE3DA1 /* Color.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; - 012CA9DE2388723E003F810F /* (null) in Sources */ = {isa = PBXBuildFile; }; - 012CA9E223888AED003F810F /* (null) in Sources */ = {isa = PBXBuildFile; }; - 012CA9E423888B1B003F810F /* (null) in Sources */ = {isa = PBXBuildFile; }; 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */; }; 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72223C501E2006F3E93 /* ContainerModel.swift */; }; 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */; }; @@ -1330,7 +1326,6 @@ files = ( 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */, 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, - 012CA9E423888B1B003F810F /* (null) in Sources */, 9402C35023A2CEA3004B974C /* LeftRightLabelModel.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, @@ -1416,8 +1411,6 @@ D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, - 012CA9E223888AED003F810F /* (null) in Sources */, - 012A88DA238ED42E00FE3DA1 /* (null) in Sources */, 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */, @@ -1449,7 +1442,6 @@ D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, - 012CA9DE2388723E003F810F /* (null) in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, From bb0be7251949c26256d92644c8712208a9e0352f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 11:33:44 -0500 Subject: [PATCH 107/272] Link update --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ MVMCoreUI/Atoms/Buttons/LinkModel.swift | 53 +++++++++++++++++++ .../Buttons/MFTextButton+ModelExtension.swift | 24 +++++++++ .../EyebrowHeadlineBodyLink.swift | 32 ++++++----- 4 files changed, 104 insertions(+), 13 deletions(-) create mode 100644 MVMCoreUI/Atoms/Buttons/LinkModel.swift create mode 100644 MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index eaed8902..3b55716b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -126,6 +126,8 @@ D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */; }; D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */; }; D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; }; + D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */; }; + D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -387,6 +389,8 @@ D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionListItemModel.swift; sourceTree = ""; }; D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleProgressModel.swift; sourceTree = ""; }; D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = ""; }; + D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextButton+ModelExtension.swift"; sourceTree = ""; }; + D28A838823CCCFCB00DFE4FC /* LinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkModel.swift; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -998,6 +1002,8 @@ D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, D282AACA2243C61700C46919 /* ButtonView.swift */, + D28A838823CCCFCB00DFE4FC /* LinkModel.swift */, + D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */, D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, ); @@ -1343,6 +1349,7 @@ DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, + D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */, 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */, @@ -1383,6 +1390,7 @@ D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, + D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift new file mode 100644 index 00000000..6b3ff39e --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -0,0 +1,53 @@ +// +// LinkModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class LinkModel: MoleculeProtocol { + public static var identifier: String = "link" + public var backgroundColor: Color? + public var title: String + public var action: ActionProtocol + public var enabled = true + public var textColor = Color(uiColor: .mfTextButton()) + + public init(title: String, action: ActionProtocol) { + self.title = title + self.action = action + } + + enum CodingKeys: String, CodingKey { + case backgroundColor + case title + case action + case enabled + case textColor + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + title = try typeContainer.decode(String.self, forKey: .title) + action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type) + 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 + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(title, forKey: .title) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeModel(action, forKey: .action) + try container.encode(enabled, forKey: .enabled) + try container.encode(textColor, forKey: .textColor) + } +} diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift b/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift new file mode 100644 index 00000000..a6df6745 --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift @@ -0,0 +1,24 @@ +// +// MFTextButton_ModelExtension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +// temporary until link is finished +extension MFTextButton: ModelMoleculeViewProtocol { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let model = model as? LinkModel else { return } + setTitle(model.title, for: .normal) + setTitleColor(model.textColor.uiColor, for: .normal) + isEnabled = model.enabled + backgroundColor = model.backgroundColor?.uiColor + //TODO: Use object when handleAction is rewrote to handle action model + if let actionMap = model.action.toJSON() { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 419df541..1262994f 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -18,7 +18,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { public var link: LineModel? } -@objcMembers open class EyebrowHeadlineBodyLink: ViewConstrainingView { +@objcMembers open class EyebrowHeadlineBodyLink: Container { let stack = MoleculeStackView(frame: .zero) let eyebrow = Label.commonLabelB3(true) let headline = Label.commonLabelB1(true) @@ -48,7 +48,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)] addSubview(stack) - pinView(toSuperView: stack) + NSLayoutConstraint.constraintPinSubview(toSuperview: stack) } open override func updateView(_ size: CGFloat) { @@ -57,17 +57,23 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { } // MARK: - MVMCoreUIMoleculeViewProtocol + + open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + eyebrow.setWithModel(casteModel?.eyeBrow, delegateObject, additionalData) + headline.setWithModel(casteModel?.headline, delegateObject, additionalData) + body.setWithModel(casteModel?.body, delegateObject, additionalData) + link.setWithModel(casteModel?.link, delegateObject, additionalData) + + (stack.stackItems[0].model as? StackItemModel)?.gone = !eyebrow.hasText + (stack.stackItems[1].model as? StackItemModel)?.gone = !headline.hasText + (stack.stackItems[2].model as? StackItemModel)?.gone = !body.hasText + (stack.stackItems[3].model as? StackItemModel)?.gone = ((link.titleLabel?.text?.count) ?? 0) == 0 + stack.restack() + } open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - /* eyebrow.setWithJSON(json?.optionalDictionaryForKey("eyebrow"), delegateObject: delegateObject, additionalData: additionalData) - stack.stackItems[0].gone = !eyebrow.hasText - headline.setWithJSON(json?.optionalDictionaryForKey("headline"), delegateObject: delegateObject, additionalData: additionalData) - stack.stackItems[1].gone = !headline.hasText - body.setWithJSON(json?.optionalDictionaryForKey("body"), delegateObject: delegateObject, additionalData: additionalData) - stack.stackItems[2].gone = !body.hasText - link.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData) - stack.stackItems[3].gone = link.titleLabel?.text?.count ?? 0 == 0 - stack.restack()*/ + guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: EyebrowHeadlineBodyLinkModel.self) else { return } + setWithModel(model, delegateObject, additionalData) } open override func reset() { @@ -79,7 +85,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { body.styleB2(true) } - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 65 } } From be094b3cf91879c7d654d3b25c97ce585e3cb2e0 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Mon, 13 Jan 2020 22:49:51 +0530 Subject: [PATCH 108/272] review comments updated --- .../Models/Molecules/DoughnutChartModel.swift | 61 +------------------ MVMCoreUI/Molecules/DoughnutChart.swift | 21 ++++--- MVMCoreUI/Molecules/DoughnutChartView.swift | 5 -- 3 files changed, 14 insertions(+), 73 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift b/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift index f6a1efb8..15ecab85 100644 --- a/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift +++ b/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift @@ -9,50 +9,13 @@ import Foundation @objcMembers public class DoughnutChartModel: MoleculeProtocol { - public var backgroundColor: String? public static var identifier: String = "doughnutChart" public var title: LabelModel? public var subtitle: LabelModel? public var sections: [ChartItemModel] - public var lineWidth: CGFloat = 30.0 - public var lineGap: CGFloat = 0.05 //For 3px gap - public var spaceRequired = true - - enum CodingKeys: String, CodingKey { - case list - case title - case subtitle - case sections - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.title = try typeContainer.decodeMoleculeIfPresent(codingKey: .title) as? LabelModel - self.subtitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subtitle) as? LabelModel - //self.sections = try typeContainer.decodeMolecules(codingKey: .sections) as! [ChartItemModel] - - //TODO: Hasve to check with scott - self.sections = [] - guard var container = try? typeContainer.nestedUnkeyedContainer(forKey: .sections) else { - return - } - var sections = [ChartItemModel]() - while !container.isAtEnd { - if let element = try container - .decodeIfPresent(ChartItemModel.self) { - sections.append(element) - } - } - self.sections = sections - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModelIfPresent(title, forKey: .title) - try container.encodeModelIfPresent(subtitle, forKey: .subtitle) - try container.encodeModels(sections as [Model], forKey: .sections) - } + public var lineWidth: CGFloat? + public var spaceRequired: Bool? } @@ -62,24 +25,4 @@ import Foundation public var percent: CGFloat public var color: String public static var identifier: String = "chartItem" - - enum CodingKeys: String, CodingKey { - case label - case percent - case color - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.label = try typeContainer.decodeMolecule(codingKey: .label) as! LabelModel - self.percent = try typeContainer.decode(CGFloat.self, forKey: .percent) - self.color = try typeContainer.decode(String.self, forKey: .color) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModel(label, forKey: .label) - try container.encode(percent, forKey: .percent) - try container.encode(color, forKey: .color) - } } diff --git a/MVMCoreUI/Molecules/DoughnutChart.swift b/MVMCoreUI/Molecules/DoughnutChart.swift index 08bdefb1..ac19af7d 100644 --- a/MVMCoreUI/Molecules/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/DoughnutChart.swift @@ -21,7 +21,6 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { var heightConstraint: NSLayoutConstraint? private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 150)! - //private var lineSizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 30)! var height: CGFloat = 150 { didSet { @@ -105,7 +104,6 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { subTitleLabel.setWithModel(doughnutChartModel.subtitle, delegateObject, additionalData) titleLabel.textAlignment = .center subTitleLabel.textAlignment = .center - //lineSizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: doughnutChartModel.lineWidth)! updateLabelContainer() drawGraph() } @@ -118,20 +116,17 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { height: widthHeight) if let doughnutChart = doughnutChartModel { var prevPercent: CGFloat = 0.0 - //If Single item in array. We don't need gap - doughnutChartModel?.lineGap = (doughnutChart.sections.count == 1) ? 0.0 : doughnutChart.lineGap for model in doughnutChart.sections { - prevPercent += drawBar(model, prevPercent, doughnutChart.spaceRequired, doughnutChart.lineGap) + prevPercent += drawBar(model, prevPercent) } } } - func drawBar(_ chartModel: ChartItemModel, _ prevPercent: CGFloat, _ spaceRequired: Bool, _ lineGap: CGFloat) -> CGFloat { + func drawBar(_ chartModel: ChartItemModel, _ prevPercent: CGFloat) -> CGFloat { let shapeLayer = CAShapeLayer() shapeLayer.frame = containerLayer.frame shapeLayer.lineWidth = lineWidth() - //lineSizeObject.getValueBasedOnApplicationWidth() shapeLayer.fillColor = nil shapeLayer.strokeColor = UIColor.mfGet(forHex: chartModel.color).cgColor @@ -141,7 +136,7 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { let clockwise = true let value: CGFloat = chartModel.percent - let gap: CGFloat = spaceRequired ? lineGap : 0.0 + let gap: CGFloat = spaceReuired() ? lineGap() : 0.0 let startAngle = ((prevPercent / 100.0) * 2 * .pi) - (0.5 * .pi) let endAngle = ((value / 100.0) * 2 * .pi) + startAngle - gap let circlePath = UIBezierPath(arcCenter: arcCenter, @@ -167,7 +162,15 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { func lineWidth() -> CGFloat { return doughnutChartModel?.lineWidth ?? 30 - //lineSizeObject.getValueBasedOnApplicationWidth() + 5 + } + + func lineGap() -> CGFloat { + //If array is having the single item then no space required + return doughnutChartModel?.sections.count == 1 ? 0.0 : 0.05 + } + + func spaceReuired() -> Bool { + return doughnutChartModel?.spaceRequired ?? true } func updateLabelContainer() { diff --git a/MVMCoreUI/Molecules/DoughnutChartView.swift b/MVMCoreUI/Molecules/DoughnutChartView.swift index ebe77200..95e23440 100644 --- a/MVMCoreUI/Molecules/DoughnutChartView.swift +++ b/MVMCoreUI/Molecules/DoughnutChartView.swift @@ -171,9 +171,4 @@ class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol { colorView.backgroundColor = UIColor.mfGet(forHex: chartItemModel.color) } - override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - Label.setUILabel(label, withJSON: json?.optionalDictionaryForKey("label"), delegate: delegateObject, additionalData: additionalData) - colorView.backgroundColor = UIColor.mfGet(forHex: json?.optionalStringForKey("color") ?? "#000000") - } - } From 788145332f579c9d44b6b1df3bc0b181049ad46e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 12:44:05 -0500 Subject: [PATCH 109/272] Two button view temporary model fix primary button model --- MVMCoreUI.xcodeproj/project.pbxproj | 12 +++++ MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 50 +++++++++++++++++++ ...maryButton+MoleculeProtocolExtension.swift | 30 +++++++++++ .../TwoButtonView.swift | 22 ++++++-- .../TwoButtonViewModel.swift | 16 ++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 5 +- 6 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 MVMCoreUI/Atoms/Buttons/ButtonModel.swift create mode 100644 MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift create mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index dedc9cf9..d9e31e36 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -124,6 +124,9 @@ D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; }; D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */; }; D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; }; + D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */; }; + D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */; }; + D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -387,6 +390,9 @@ D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = ""; }; D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextButton+ModelExtension.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 = ""; }; + D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimaryButton+MoleculeProtocolExtension.swift"; sourceTree = ""; }; + D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonViewModel.swift; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -729,6 +735,7 @@ isa = PBXGroup; children = ( D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */, + D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */, D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */, D28A837E23CCA96400DFE4FC /* TabsModel.swift */, ); @@ -995,6 +1002,8 @@ D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */, + D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */, + D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */, D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, D282AACA2243C61700C46919 /* ButtonView.swift */, @@ -1383,6 +1392,8 @@ D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */, 014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, + D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */, + D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */, @@ -1448,6 +1459,7 @@ 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, + D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift new file mode 100644 index 00000000..9d9ad9c3 --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -0,0 +1,50 @@ +// +// ButtonModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public enum ButtonStyle: String, Codable { + case primary + case secondary +} + +public class ButtonModel: MoleculeProtocol { + public static var identifier: String = "button" + public var backgroundColor: Color? + public var title: String + public var action: ActionProtocol + public var style: ButtonStyle? + + init(with title: String, action: ActionProtocol) { + self.title = title + self.action = action + } + + enum CodingKeys: String, CodingKey { + case backgroundColor + case title + case action + case style + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + title = try typeContainer.decode(String.self, forKey: .title) + action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type) + style = try typeContainer.decode(ButtonStyle.self, forKey: .style) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(title, forKey: .title) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeModel(action, forKey: .action) + try container.encodeIfPresent(style, forKey: .style) + } +} diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift new file mode 100644 index 00000000..f7192fc9 --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift @@ -0,0 +1,30 @@ +// +// PrimaryButton+MoleculeProtocolExtension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +// temporary until link is finished +extension PrimaryButton: ModelMoleculeViewProtocol { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let model = model as? ButtonModel else { return } + setTitle(model.title, for: .normal) + backgroundColor = model.backgroundColor?.uiColor + if let style = model.style { + switch style { + case .primary: + setAsStandardCustom() + case .secondary: + setAsSecondaryCustom() + } + } + //TODO: Use object when handleAction is rewrote to handle action model + if let actionMap = model.action.toJSON() { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + } +} diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 2c5f0fe5..b2f43529 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -137,20 +137,25 @@ import UIKit } } + /// Legacy func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?) { - if primaryButtonMap != nil, secondaryButtonMap != nil { + setupUI(primaryButtonShowing: primaryButtonMap != nil, secondaryButtonShowing: secondaryButtonMap != nil) + } + + func setupUI(primaryButtonShowing: Bool, secondaryButtonShowing: Bool) { + if primaryButtonShowing, secondaryButtonShowing { heightConstraint?.isActive = false if primaryButton == nil || secondaryButton == nil { removeButtons() setupWithTwoButtons() } - } else if primaryButtonMap != nil { + } else if primaryButtonShowing { heightConstraint?.isActive = false if primaryButton == nil || secondaryButton != nil { removeButtons() setupWithPrimaryButton() } - } else if secondaryButtonMap != nil { + } else if secondaryButtonShowing { heightConstraint?.isActive = false if secondaryButton == nil || primaryButton != nil { removeButtons() @@ -291,3 +296,14 @@ extension TwoButtonView { setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) } } + +extension TwoButtonView: MoleculeViewProtocol { + func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let model = model as? TwoButtonViewModel else { return } + setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil) + setDefaultCustom() + primaryButton?.setWithModel(model.primaryButton, delegateObject, additionalData) + secondaryButton?.setWithModel(model.secondaryButton, delegateObject, additionalData) + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + } +} diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift new file mode 100644 index 00000000..50643e1c --- /dev/null +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -0,0 +1,16 @@ +// +// TwoButtonViewModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class TwoButtonViewModel: MoleculeProtocol { + public static var identifier: String = "twoButtonView" + public var backgroundColor: Color? + public var primaryButton: ButtonModel? + public var secondaryButton: ButtonModel? +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 01677585..21895f3d 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -16,7 +16,6 @@ import Foundation ModelRegistry.register(MoleculeStackModel.self) ModelRegistry.register(StackItemModel.self) ModelRegistry.register(TextFieldModel.self) - ModelRegistry.register(LineModel.self) ModelRegistry.register(ProgressBarModel.self) ModelRegistry.register(MultiProgressBarModel.self) ModelRegistry.register(CaretViewModel.self) @@ -24,6 +23,10 @@ import Foundation ModelRegistry.register(ImageViewModel.self) ModelRegistry.register(TabsModel.self) ModelRegistry.register(ScrollerModel.self) + // buttons + ModelRegistry.register(LineModel.self) + ModelRegistry.register(ButtonModel.self) + ModelRegistry.register(TwoButtonViewModel.self) // list items ModelRegistry.register(ListItemModel.self) ModelRegistry.register(DropDownListItemModel.self) From 5ce8446be2edbf2857fc56b8cbc4fe06dc47ab26 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 13:31:25 -0500 Subject: [PATCH 110/272] Updating Link class. adding identifier to molecule mapping. --- MVMCoreUI/Atoms/Buttons/Link.swift | 65 ++++++++++++------- .../MVMCoreUIMoleculeMappingObject.m | 1 + 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 9008c398..394807b6 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -14,6 +14,11 @@ import UIKit //-------------------------------------------------- private var additionalData: [AnyHashable: Any]? + + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + private var delegateObject: MVMCoreUIDelegateObject? //-------------------------------------------------- @@ -25,6 +30,10 @@ import UIKit setupView() } + public convenience init() { + self.init(frame: .zero) + } + public required init?(coder: NSCoder) { super.init(coder: coder) setupView() @@ -35,69 +44,77 @@ import UIKit //-------------------------------------------------- open override func draw(_ rect: CGRect) { + guard let textRect = titleLabel?.frame else { return } - let contextRef = UIGraphicsGetCurrentContext() + let context = UIGraphicsGetCurrentContext() - //set to the same color as the text + // Set to the same color as the text if let color = titleLabel?.textColor?.cgColor { - contextRef?.setStrokeColor(color) + context?.setStrokeColor(color) } - //x should be according to the text, not the button + // x should be according to the text, not the button let x = textRect.origin.x - // line is 1 point below the text + + // Line is 1 point below the text let y = textRect.origin.y + textRect.size.height + 1 - contextRef?.move(to: CGPoint(x: x, y: y)) - contextRef?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) - contextRef?.closePath() - contextRef?.drawPath(using: .stroke) + context?.move(to: CGPoint(x: x, y: y)) + context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) + context?.closePath() + context?.drawPath(using: .stroke) } //-------------------------------------------------- // MARK: - UITouch //-------------------------------------------------- - override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { - - let faultTolerance: CGFloat = 20.0 - let area = bounds.insetBy(dx: -faultTolerance, dy: -faultTolerance) - return area.contains(point) - } - open override func touchesEnded(_ touches: Set, with event: UIEvent?) { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } +// MARK: - AppleGuidelinesProtocol +extension Link: AppleGuidelinesProtocol { + + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + + return Self.acceptablyOutsideBounds(point: point, bounds: bounds) + } +} + // MARK: - MVMCoreViewProtocol extension Link: MVMCoreViewProtocol { public func updateView(_ size: CGFloat) { - MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in + + DispatchQueue.main.async { [weak self] in guard let self = self else { return } var width = size if MVMCoreGetterUtility.fequal(a: Float(CGFloat.leastNormalMagnitude), b: Float(size)) { width = MVMCoreUIUtility.getWidth() } + self.titleLabel?.font = MFStyler.fontB2(forWidth: width) - }) + } } public func setupView() { + translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear contentMode = .redraw setTitleColor(.mfTextButton(), for: .normal) setTitleColor(.mfCharcoal(), for: .highlighted) - // left alignment by default titleLabel?.textAlignment = .left contentHorizontalAlignment = .left + titleLabel?.numberOfLines = 1 } } +// MARK: - MVMCoreUIMoleculeViewProtocol extension Link: MVMCoreUIMoleculeViewProtocol { public func reset() { @@ -105,17 +122,18 @@ extension Link: MVMCoreUIMoleculeViewProtocol { } public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - guard let unwrappedJson = json else { return } - actionMap = unwrappedJson self.additionalData = additionalData self.delegateObject = delegateObject + + guard let unwrappedJson = json else { return } + actionMap = unwrappedJson + buttonDelegate = delegateObject?.buttonDelegate let color = unwrappedJson.stringForkey(KeyTextColor) setTitleColor(.mfGet(forHex: color), for: .normal) - titleLabel?.numberOfLines = 0 - titleLabel?.lineBreakMode = .byWordWrapping; + if let title = unwrappedJson.optionalStringForKey(KeyTitle) { setTitle(title, for: .normal) } @@ -130,6 +148,7 @@ extension Link: MVMCoreUIMoleculeViewProtocol { } } +// MARK:- MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { public func needsToBeConstrained() -> Bool { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index ecad0fc7..b43852a0 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -27,6 +27,7 @@ mapping = [@{ @"label": Label.class, @"line": Line.class, + @"link": Link.class, @"button": PrimaryButton.class, @"textButton": MFTextButton.class, @"header": StandardHeaderView.class, From e6079eab55ae91f602d1c5c08acb8798c6a9b2e4 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 14 Jan 2020 00:11:41 +0530 Subject: [PATCH 111/272] updated model --- .../Models/Molecules/NumberedListModel.swift | 14 -------------- .../Models/Molecules/UnOrderedListModel.swift | 18 ------------------ 2 files changed, 32 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/NumberedListModel.swift b/MVMCoreUI/Models/Molecules/NumberedListModel.swift index 7686ade0..2a440b27 100644 --- a/MVMCoreUI/Models/Molecules/NumberedListModel.swift +++ b/MVMCoreUI/Models/Molecules/NumberedListModel.swift @@ -12,20 +12,6 @@ import Foundation public var backgroundColor: String? public static var identifier: String = "numberedList" public var list: [LabelModel] - - enum CodingKeys: String, CodingKey { - case list - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.list = try typeContainer.decodeMolecules(codingKey: .list) as! [LabelModel] - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModels(list, forKey: .list) - } } public protocol OrderListProtocol: MoleculeProtocol { diff --git a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift index 104119c3..a795e903 100644 --- a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift +++ b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift @@ -9,26 +9,8 @@ import Foundation @objcMembers public class UnOrderedListModel: OrderListProtocol { - public var backgroundColor: String? public static var identifier: String = "unOrderedList" public var bulletChar: String? public var list: [LabelModel] - - enum CodingKeys: String, CodingKey { - case list - case bulletChar - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) - self.list = try typeContainer.decodeMolecules(codingKey: .list) as! [LabelModel] - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(bulletChar, forKey: .bulletChar) - try container.encodeModels(list, forKey: .list) - } } From 8ff92b5cc0b44762e6c067fa0a917ef476f1c367 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 14:31:04 -0500 Subject: [PATCH 112/272] one line, truncation. --- MVMCoreUI/Atoms/Buttons/Link.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 394807b6..4a23281b 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -8,6 +8,7 @@ import UIKit + @objcMembers open class Link: MFCustomButton { //-------------------------------------------------- // MARK: - Properties @@ -62,8 +63,7 @@ import UIKit context?.move(to: CGPoint(x: x, y: y)) context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) - context?.closePath() - context?.drawPath(using: .stroke) + context?.strokePath() } //-------------------------------------------------- @@ -77,7 +77,7 @@ import UIKit // MARK: - AppleGuidelinesProtocol extension Link: AppleGuidelinesProtocol { - + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { return Self.acceptablyOutsideBounds(point: point, bounds: bounds) @@ -108,9 +108,10 @@ extension Link: MVMCoreViewProtocol { contentMode = .redraw setTitleColor(.mfTextButton(), for: .normal) setTitleColor(.mfCharcoal(), for: .highlighted) + titleLabel?.numberOfLines = 1 + titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left contentHorizontalAlignment = .left - titleLabel?.numberOfLines = 1 } } @@ -125,20 +126,19 @@ extension Link: MVMCoreUIMoleculeViewProtocol { self.additionalData = additionalData self.delegateObject = delegateObject - guard let unwrappedJson = json else { return } - actionMap = unwrappedJson + guard let dictionary = json else { return } + actionMap = dictionary buttonDelegate = delegateObject?.buttonDelegate - let color = unwrappedJson.stringForkey(KeyTextColor) + let color = dictionary.stringForkey(KeyTextColor) setTitleColor(.mfGet(forHex: color), for: .normal) - - if let title = unwrappedJson.optionalStringForKey(KeyTitle) { + if let title = dictionary.optionalStringForKey(KeyTitle) { setTitle(title, for: .normal) } - if let enabled = unwrappedJson[KeyEnabled] as? Bool { + if let enabled = dictionary[KeyEnabled] as? Bool { isEnabled = enabled } } From 57753f66978a0cbe4970feb20d3f7b49fd0da828 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 15:26:51 -0500 Subject: [PATCH 113/272] Change keys --- MVMCoreUI/Atoms/Views/Checkbox.swift | 2 +- MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m | 2 +- .../Models/Template/StackPageTemplateModel.swift | 2 +- .../SwitchMolecules/HeadlineBodySwitch.swift | 4 +--- .../HeadlineBodyTextButtonSwitch.swift | 4 ++-- .../SwitchMolecules/LabelSwitch.swift | 2 +- MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- .../HeadlineBodyTextButton.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackModel.swift | 2 +- .../MVMCoreUIMoleculeMappingObject.m | 16 ++++++++-------- .../MVMCoreUIViewControllerMappingObject.m | 4 ++-- 11 files changed, 20 insertions(+), 22 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index a206953a..50571e30 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -454,7 +454,7 @@ import MVMCore isEnabled(enabled) } - if let actionMap = dictionary.optionalDictionaryForKey("actionMap") { + if let actionMap = dictionary.optionalDictionaryForKey("action") { actionBlock = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } } diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m index 33874a8d..4b66d519 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m @@ -171,7 +171,7 @@ const CGFloat SwitchShakeIntensity = 2; [self setState:[json boolForKey:@"state"] animated:false]; - NSDictionary *actionMap = [json dict:@"actionMap"]; + NSDictionary *actionMap = [json dict:@"action"]; if (actionMap) { [self addTarget:self action:@selector(addCustomAction) forControlEvents:UIControlEventTouchUpInside]; } diff --git a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift index 9cce36ab..0e5e4488 100644 --- a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class StackPageTemplateModel: TemplateModelProtocol { - public static var identifier: String = "moleculeStack" + public static var identifier: String = "stack" public var pageType: String diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index eca878ab..fee32b2f 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -39,8 +39,6 @@ import UIKit open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) -// guard let headlineModel = model as? headlinebodyswitch -// headlineBody.setWithModel(mode, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##additionalData: [String : AnyHashable]?##[String : AnyHashable]?#>) } public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -52,7 +50,7 @@ import UIKit open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData) + mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } open class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift index b0cf6956..5ee9c41f 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift @@ -37,8 +37,8 @@ import UIKit // MARK: - MVMCoreUIMoleculeViewProtocol public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyTextButton"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData) + headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyLink"), delegateObject: delegateObject, additionalData: additionalData) + mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift index f60202b3..50c19c1d 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift @@ -38,7 +38,7 @@ import UIKit public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData) + mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index c13638d8..ad231597 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -37,7 +37,7 @@ public class StandardHeaderView: MoleculeContainer { // MARK: - MVMCoreUIMoleculeViewProtocol open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - if let separatorJSON = json?.optionalDictionaryForKey("separator") { + if let separatorJSON = json?.optionalDictionaryForKey("line") { line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift index 7c24cff4..ca696f1a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift @@ -66,7 +66,7 @@ import UIKit open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData) + textButton.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData) } open override func reset() { diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift index 73c7c0a5..e364ca07 100644 --- a/MVMCoreUI/Organisms/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol { - public static var identifier: String = "moleculeStack" + public static var identifier: String = "stack" public var backgroundColor: Color? public var molecules: [StackItemModel] public var axis: NSLayoutConstraint.Axis = .vertical diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index e32f8962..2b8aa2fa 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -29,9 +29,9 @@ @"label": Label.class, @"line": Line.class, @"button": PrimaryButton.class, - @"textButton": MFTextButton.class, + @"link": MFTextButton.class, @"header": StandardHeaderView.class, - @"moleculeStack": MoleculeStackView.class, + @"stack": MoleculeStackView.class, @"twoButtonView": TwoButtonView.class, @"footer": StandardFooterView.class, @"caretView": CaretView.class, @@ -40,7 +40,7 @@ @"dropDown": DropDown.class, @"digitTextField": MFDigitTextField.class, @"checkbox": Checkbox.class, - @"checkboxWithLabel": CheckboxWithLabelView.class, + @"checkboxLabel": CheckboxWithLabelView.class, @"cornerLabels" : CornerLabels.class, @"progressbar": ProgressBar.class, @"circleProgress": GraphView.class, @@ -49,7 +49,7 @@ @"radioButtonLabel": RadioButtonLabel.class, @"listItem": MoleculeTableViewCell.class, @"accordionListItem": AccordionMoleculeTableViewCell.class, - @"switch": MVMCoreUISwitch.class, + @"toggle": MVMCoreUISwitch.class, @"leftRightLabelView": LeftRightLabelView.class, @"actionDetailWithImage": ActionDetailWithImage.class, @"image": MFLoadImageView.class, @@ -60,10 +60,10 @@ @"barsPager": MVMCoreUIPageControl.class, @"scroller": Scroller.class, @"imageHeadlineBody": ImageHeadlineBody.class, - @"labelSwitch": LabelSwitch.class, - @"headlineBodySwitch": HeadlineBodySwitch.class, - @"headlineBodyTextButton": HeadlineBodyTextButton.class, - @"headlineBodyTextButtonSwitch": HeadlineBodyTextButtonSwitch.class, + @"labelToggle": LabelSwitch.class, + @"headlineBodyToggle": HeadlineBodySwitch.class, + @"headlineBodyLink": HeadlineBodyTextButton.class, + @"headlineBodyLinkToggle": HeadlineBodyTextButtonSwitch.class, @"tabsListItem": TabsTableViewCell.class, @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index 2bc1a0dd..7bdccc8e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -19,9 +19,9 @@ static NSMutableDictionary *viewControllerMapping; dispatch_once(&onceToken, ^{ viewControllerMapping = [@{ - @"moleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], + @"stack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]], - @"moleculeList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], + @"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], @"threeLayer" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]] } mutableCopy]; From 5c2f93e06f04b39a1dbaae6be874deb0ac227edb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 15:28:53 -0500 Subject: [PATCH 114/272] move register to init for now dash line update temporary for legacy --- MVMCoreUI/Atoms/Views/DashLine.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 94bd987c..9d438af5 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -19,6 +19,8 @@ open class DashLine: View { get { return model as? DashLineModel } } + // Legacy + @objc public var dashColor: UIColor? @objc private var dashLayer: CAShapeLayer? //------------------------------------------------------ @@ -56,7 +58,7 @@ open class DashLine: View { dashLayer.lineCap = .round dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)] dashLayer.path = path.cgPath - dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? UIColor.mfLighterGray().cgColor + dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor dashLayer.fillColor = UIColor.clear.cgColor dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor self.dashLayer = dashLayer From 8490ef3572191d28aaa92bd7c5042f7cb03a4f22 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 15:46:50 -0500 Subject: [PATCH 115/272] enabled/disabled colors. --- MVMCoreUI/Atoms/Buttons/Link.swift | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 4a23281b..04484307 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -16,6 +16,15 @@ import UIKit private var additionalData: [AnyHashable: Any]? + public var titleColor: (enabled: UIColor?, disabled: UIColor?) = (.mfTextButton(), .mfSilver()) + + public override var isEnabled: Bool { + didSet { + setTitleColor(isEnabled ? titleColor.enabled : titleColor.disabled, for: .normal) + setNeedsDisplay() + } + } + //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- @@ -50,7 +59,7 @@ import UIKit let context = UIGraphicsGetCurrentContext() - // Set to the same color as the text + // Set line to the same color as the text if let color = titleLabel?.textColor?.cgColor { context?.setStrokeColor(color) } @@ -108,6 +117,7 @@ extension Link: MVMCoreViewProtocol { contentMode = .redraw setTitleColor(.mfTextButton(), for: .normal) setTitleColor(.mfCharcoal(), for: .highlighted) + titleColor = (.mfTextButton(), .mfSilver()) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left @@ -125,14 +135,15 @@ extension Link: MVMCoreUIMoleculeViewProtocol { public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.additionalData = additionalData self.delegateObject = delegateObject + buttonDelegate = delegateObject?.buttonDelegate guard let dictionary = json else { return } actionMap = dictionary - buttonDelegate = delegateObject?.buttonDelegate - - let color = dictionary.stringForkey(KeyTextColor) - setTitleColor(.mfGet(forHex: color), for: .normal) + if let colorHex = dictionary[KeyTextColor] as? String { + titleColor.enabled = .mfGet(forHex: colorHex) + setTitleColor(titleColor.enabled, for: .normal) + } if let title = dictionary.optionalStringForKey(KeyTitle) { setTitle(title, for: .normal) From d7844d607eb038fbc34b2d177afdee1caec6a7dc Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 16:00:00 -0500 Subject: [PATCH 116/272] space. --- MVMCoreUI/Atoms/Buttons/Link.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 04484307..4c5e6f03 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -80,6 +80,7 @@ import UIKit //-------------------------------------------------- open override func touchesEnded(_ touches: Set, with event: UIEvent?) { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } From 3d2137fc11821ef262314f4f2dac3359498bb430 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 16:19:49 -0500 Subject: [PATCH 117/272] Now subclassing Button. --- MVMCoreUI/Atoms/Buttons/Link.swift | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 4c5e6f03..550870fc 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -9,7 +9,7 @@ import UIKit -@objcMembers open class Link: MFCustomButton { +@objcMembers open class Link: Button { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -85,19 +85,11 @@ import UIKit } } -// MARK: - AppleGuidelinesProtocol -extension Link: AppleGuidelinesProtocol { - - override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { - - return Self.acceptablyOutsideBounds(point: point, bounds: bounds) - } -} - // MARK: - MVMCoreViewProtocol -extension Link: MVMCoreViewProtocol { +extension Link { - public func updateView(_ size: CGFloat) { + public override func updateView(_ size: CGFloat) { + super.updateView(size) DispatchQueue.main.async { [weak self] in guard let self = self else { return } @@ -111,7 +103,7 @@ extension Link: MVMCoreViewProtocol { } } - public func setupView() { + public override func setupView() { translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear @@ -127,13 +119,15 @@ extension Link: MVMCoreViewProtocol { } // MARK: - MVMCoreUIMoleculeViewProtocol -extension Link: MVMCoreUIMoleculeViewProtocol { +extension Link { - public func reset() { + public override func reset() { + super.reset() setTitleColor(.mfTextButton(), for: .normal) } - public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) self.additionalData = additionalData self.delegateObject = delegateObject buttonDelegate = delegateObject?.buttonDelegate From 32f85dfbf1a4d37b3355647152e034d6a2352664 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 16:30:29 -0500 Subject: [PATCH 118/272] renamed func. changed location of action. --- MVMCoreUI/Atoms/Buttons/Link.swift | 3 +-- MVMCoreUI/BaseClasses/Button.swift | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 550870fc..1ec7e9a3 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -80,8 +80,7 @@ import UIKit //-------------------------------------------------- open override func touchesEnded(_ touches: Set, with event: UIEvent?) { - - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + callActionBlock(self) } } diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 1d5d743e..55ac0195 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -64,10 +64,10 @@ public typealias ButtonBlock = (Button) -> () public func addBlock( event: Event, _ buttonBlock: @escaping ButtonBlock) { self.buttonBlock = buttonBlock - addTarget(self, action: #selector(callBlock(_:)), for: event) + addTarget(self, action: #selector(callActionBlock(_:)), for: event) } - func callBlock(_ sender: Button) { + func callActionBlock(_ sender: Button) { buttonBlock?(self) } @@ -90,6 +90,7 @@ public typealias ButtonBlock = (Button) -> () extension Button: MVMCoreUIMoleculeViewProtocol { public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData) self.json = json guard let dictionary = json else { return } From a6dc16889c81c1f9b929a36be0ba50bc4d3c1fb2 Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 13 Jan 2020 17:07:16 -0500 Subject: [PATCH 119/272] fix error from merging --- MVMCoreUI/Models/Molecules/NumberedListModel.swift | 2 +- MVMCoreUI/Models/Molecules/UnOrderedListModel.swift | 2 +- MVMCoreUI/Molecules/LabelRightMoleculesStack.swift | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/NumberedListModel.swift b/MVMCoreUI/Models/Molecules/NumberedListModel.swift index 2a440b27..496db1b1 100644 --- a/MVMCoreUI/Models/Molecules/NumberedListModel.swift +++ b/MVMCoreUI/Models/Molecules/NumberedListModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class NumberedListModel: OrderListProtocol { - public var backgroundColor: String? + public var backgroundColor: Color? public static var identifier: String = "numberedList" public var list: [LabelModel] } diff --git a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift index a795e903..2c80dc6f 100644 --- a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift +++ b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class UnOrderedListModel: OrderListProtocol { - public var backgroundColor: String? + public var backgroundColor: Color? public static var identifier: String = "unOrderedList" public var bulletChar: String? public var list: [LabelModel] diff --git a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift index 58a5ba7b..312927fd 100644 --- a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift +++ b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift @@ -12,7 +12,7 @@ open class LabelRightMoleculesStack: MoleculeStackView { var orderedListModel: OrderListProtocol? - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { let previousModel = self.orderedListModel //Remove previously drawn views removeAllItemViews() @@ -64,8 +64,8 @@ class LeftLabelRightMoleculeContainer: View { } // MARK: - Inits - public override init() { - super.init() + public convenience init() { + self.init(frame:.zero) } public override init(frame: CGRect) { @@ -131,7 +131,7 @@ class LeftLabelRightMoleculeContainer: View { rightMolecule?.reset() } - override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { let previousMoleculeName = model?.moleculeName super.setWithModel(model, delegateObject, additionalData) removeSubviewsInRightContainer() From cd3555466f7b21d3b487429869e96e4a57726ed6 Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 13 Jan 2020 17:18:49 -0500 Subject: [PATCH 120/272] remove duplicate --- MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index ff0a6056..0aee8405 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -73,7 +73,6 @@ @"headlineBodyButton": HeadlineBodyButton.class, @"stackItem": StackItem.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, - @"stackItem": StackItem.class, @"unOrderedList": UnOrderedList.class, @"numberedList": NumberedList.class, @"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class From 6b7bb180fc408b7da8497c51f34311125f56354b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 21:15:21 -0500 Subject: [PATCH 121/272] corner labels temporary --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ MVMCoreUI/Atoms/Views/DashLine.swift | 1 - .../LeftRightViews/CornerLabels.swift | 18 +++++++ .../LeftRightViews/CornerLabelsModel.swift | 52 +++++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 017a5a78..8536e6be 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -148,6 +148,7 @@ D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */; }; D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */; }; D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */; }; + D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -414,6 +415,7 @@ D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonModel.swift; sourceTree = ""; }; D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimaryButton+MoleculeProtocolExtension.swift"; sourceTree = ""; }; D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonViewModel.swift; sourceTree = ""; }; + D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerLabelsModel.swift; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -775,6 +777,7 @@ D224798F2316A99F003FCCF9 /* LeftRightViews */ = { isa = PBXGroup; children = ( + D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, D224798823142BF2003FCCF9 /* SwitchMolecules */, ); @@ -1550,6 +1553,7 @@ 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */, D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, + D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index edd59574..de4d6d4a 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -37,7 +37,6 @@ open class DashLine: View { required public init?(coder: NSCoder) { super.init(coder: coder) - fatalError("DashLine xib not supported") } //------------------------------------------------------ diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift index 9b7dc062..bde3ab6f 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift @@ -178,3 +178,21 @@ import UIKit return 34 } } + +extension CornerLabels: MoleculeViewProtocol { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let model = model as? CornerLabelsModel, + let data = try? model.encode(using: JSONEncoder()), + let json = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] else { + return + } + self.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) +// topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData) +// topRightLabel.setWithModel(model.topRightLabel, delegateObject, additionalData) +// bottomLeftLabel.setWithModel(model.bottomLeftLabel, delegateObject, additionalData) +// bottomRightLabel.setWithModel(model.bottomRightLabel, delegateObject, additionalData) +// +// topLabelToMoleculeConstraint?.constant = (molecule != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0 +// bottomLabelToMoleculeConstraint?.constant = (molecule != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0 + } +} diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift new file mode 100644 index 00000000..c61bd408 --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -0,0 +1,52 @@ +// +// CornerLabelsModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class CornerLabelsModel: MoleculeProtocol { + public static var identifier: String = "cornerLabels" + public var backgroundColor: Color? + public var topLeftLabel: LabelModel? + public var topRightLabel: LabelModel? + public var bottomLeftLabel: LabelModel? + public var bottomRightLabel: LabelModel? + public var molecule: MoleculeProtocol + + init(with molecule: MoleculeProtocol) { + self.molecule = molecule + } + + enum CodingKeys: String, CodingKey { + case backgroundColor + case topLeftLabel + case topRightLabel + case bottomLeftLabel + case bottomRightLabel + case molecule + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + topLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topLeftLabel) + topRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topRightLabel) + bottomLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomLeftLabel) + bottomRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomRightLabel) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeModelIfPresent(molecule, forKey: .molecule) + try container.encodeIfPresent(topLeftLabel, forKey: .topLeftLabel) + try container.encodeIfPresent(topRightLabel, forKey: .topRightLabel) + try container.encodeIfPresent(bottomLeftLabel, forKey: .bottomLeftLabel) + try container.encodeIfPresent(bottomRightLabel, forKey: .bottomRightLabel) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 21895f3d..53d14e44 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -23,6 +23,7 @@ import Foundation ModelRegistry.register(ImageViewModel.self) ModelRegistry.register(TabsModel.self) ModelRegistry.register(ScrollerModel.self) + ModelRegistry.register(CornerLabelsModel.self) // buttons ModelRegistry.register(LineModel.self) ModelRegistry.register(ButtonModel.self) From 96d533780f1e43869a008e1567342c4f26dfe230 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 21:25:24 -0500 Subject: [PATCH 122/272] update multi progress to match color --- MVMCoreUI/Atoms/Views/MultiProgress.swift | 2 +- MVMCoreUI/Atoms/Views/MultiProgressModel.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index e5978c9c..38945134 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -30,7 +30,7 @@ import UIKit let view = UIView(frame: .zero) view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) - view.backgroundColor = progressObject.color.uiColor + view.backgroundColor = progressObject.progressColor.uiColor view.widthAnchor.constraint(equalTo: widthAnchor, multiplier: progressObject.progress).isActive = true view.leadingAnchor.constraint(equalTo: previous?.trailingAnchor ?? leadingAnchor).isActive = true previous = view diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index b0251ff6..497fc9d5 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -10,11 +10,11 @@ import Foundation @objcMembers public class SingleProgressBarModel: Codable { @Percent var progress: CGFloat - var color: Color + var progressColor: Color init(_ progress: CGFloat, color: Color) { self.progress = progress - self.color = color + self.progressColor = color } } From 461a51d8802d5ef4f1d5f60b0e6e72e2b67a78dd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 22:18:40 -0500 Subject: [PATCH 123/272] stack item change decoding --- MVMCoreUI/Organisms/MoleculeStackModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift index e364ca07..2a149e73 100644 --- a/MVMCoreUI/Organisms/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -29,7 +29,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self) - molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [StackItemModel] + molecules = try typeContainer.decode([StackItemModel].self, forKey: .molecules) if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) { axis = optionalAxis } From 198ebe722b186151134e56faa44b3726ced4b323 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 08:59:58 -0500 Subject: [PATCH 124/272] missed name change --- MVMCoreUI/Templates/MoleculeStackTemplate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 3dc9a58c..39c814fa 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -88,7 +88,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { let delegate = delegateObject() as? MVMCoreUIDelegateObject MVMCoreUIMoleculeMappingObject.addRequiredModules(forJSON: loadObject?.pageJSON?.optionalDictionaryForKey("header"), delegateObject: delegate, moduleList: modules, errorList: nil) MVMCoreUIMoleculeMappingObject.addRequiredModules(forJSON: loadObject?.pageJSON?.optionalDictionaryForKey("footer"), delegateObject: delegate, moduleList: modules, errorList: nil) - MVMCoreUIMoleculeMappingObject.addRequiredModules(forJSON: loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack"), delegateObject: delegate, moduleList: modules, errorList: nil) + MVMCoreUIMoleculeMappingObject.addRequiredModules(forJSON: loadObject?.pageJSON?.optionalDictionaryForKey("stack"), delegateObject: delegate, moduleList: modules, errorList: nil) return modules as? [Any] } } From 874addef638149acdd86d20be47a14a3380ee2e9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 14 Jan 2020 09:06:39 -0500 Subject: [PATCH 125/272] Changed name. New disabled KV. mild updates. --- MVMCoreUI/Atoms/Buttons/Link.swift | 14 +++++--------- MVMCoreUI/BaseClasses/Button.swift | 12 ++++++------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 1ec7e9a3..3b6cabb8 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -74,14 +74,6 @@ import UIKit context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) context?.strokePath() } - - //-------------------------------------------------- - // MARK: - UITouch - //-------------------------------------------------- - - open override func touchesEnded(_ touches: Set, with event: UIEvent?) { - callActionBlock(self) - } } // MARK: - MVMCoreViewProtocol @@ -134,6 +126,10 @@ extension Link { guard let dictionary = json else { return } actionMap = dictionary + if let disabledColorHex = dictionary["disabledColor"] as? String { + titleColor.disabled = .mfGet(forHex: disabledColorHex) + } + if let colorHex = dictionary[KeyTextColor] as? String { titleColor.enabled = .mfGet(forHex: colorHex) setTitleColor(titleColor.enabled, for: .normal) @@ -153,7 +149,7 @@ extension Link { } } -// MARK:- MVMCoreUIViewConstrainingProtocol +// MARK: - MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { public func needsToBeConstrained() -> Bool { diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 55ac0195..356ef59d 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -public typealias ButtonBlock = (Button) -> () +public typealias ButtonAction = (Button) -> () @objcMembers open class Button: UIButton, MFButtonProtocol { @@ -19,7 +19,7 @@ public typealias ButtonBlock = (Button) -> () private var initialSetupPerformed = false - private var buttonBlock: ButtonBlock? + private var buttonAction: ButtonAction? //-------------------------------------------------- // MARK: - Delegate @@ -62,13 +62,13 @@ public typealias ButtonBlock = (Button) -> () // MARK: - Methods //-------------------------------------------------- - public func addBlock( event: Event, _ buttonBlock: @escaping ButtonBlock) { - self.buttonBlock = buttonBlock + public func addActionBlock( event: Event, _ buttonBlock: @escaping ButtonAction) { + self.buttonAction = buttonBlock addTarget(self, action: #selector(callActionBlock(_:)), for: event) } func callActionBlock(_ sender: Button) { - buttonBlock?(self) + buttonAction?(self) } public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { @@ -76,7 +76,7 @@ public typealias ButtonBlock = (Button) -> () buttonDelegate = delegateObject?.buttonDelegate - addBlock(event: .touchUpInside) { [weak self] sender in + addActionBlock(event: .touchUpInside) { [weak self] sender in guard let self = self else { return } if self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { From 447df655df903ca3adbe393820c4cd23cbd0bf71 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 09:12:09 -0500 Subject: [PATCH 126/272] make the error throwable --- .../BaseControllers/MFViewController+Model.swift | 2 +- MVMCoreUI/BaseControllers/MFViewController.m | 13 +++++++++++-- .../Models/ModelProtocols/TemplateProtocol.swift | 14 +++++--------- MVMCoreUI/Templates/MoleculeListTemplate.swift | 4 ++-- MVMCoreUI/Templates/MoleculeStackTemplate.swift | 4 ++-- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 4 ++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 88f05360..3468748b 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -32,6 +32,6 @@ extension MFViewController: MoleculeDelegateProtocol { } public extension MFViewController { - @objc func parsePageJSON() { + @objc func parsePageJSON() throws { } } diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 1d97efd9..d2ff7cda 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -96,7 +96,15 @@ - (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error { self.pageType = loadObject.pageType; self.loadObject = loadObject; - [self parsePageJSON]; + + NSError *parseError = nil; + [self parsePageJSONAndReturnError:&parseError]; + if (parseError) { + if (error) { + *error = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; + } + return false; + } // Verifies all modules needed are loaded. return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error]; @@ -250,7 +258,8 @@ - (BOOL)newPageLoaded:(nonnull NSDictionary *)page { self.loadObject.pageJSON = page; - [self parsePageJSON]; + NSError *parseError = nil; + [self parsePageJSONAndReturnError:&parseError]; return YES; } diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift index eb4463d5..0498ec5d 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift @@ -14,15 +14,11 @@ public protocol TemplateProtocol: class { } public extension TemplateProtocol where Self: MFViewController { - func parseTemplateJSON() { + func parseTemplateJSON() throws { guard let pageJSON = self.loadObject?.pageJSON else { return } - do { - let data = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = JSONDecoder() - let templateModel = try decoder.decode(TemplateModel.self, from: data) - self.templateModel = templateModel - } catch { - MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - } + let data = try JSONSerialization.data(withJSONObject: pageJSON) + let decoder = JSONDecoder() + let templateModel = try decoder.decode(TemplateModel.self, from: data) + self.templateModel = templateModel } } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 03f4e0fc..3a551a79 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -14,8 +14,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol var observer: NSKeyValueObservation? public var templateModel: ListPageTemplateModel? - public override func parsePageJSON() { - parseTemplateJSON() + @objc public override func parsePageJSON() throws { + try parseTemplateJSON() } open override var loadObject: MVMCoreLoadObject? { diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 39c814fa..74eae770 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -12,8 +12,8 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { var observer: NSKeyValueObservation? public var templateModel: StackPageTemplateModel? - public override func parsePageJSON() { - parseTemplateJSON() + public override func parsePageJSON() throws { + try parseTemplateJSON() } open override var loadObject: MVMCoreLoadObject? { diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 67326d09..472985e3 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -11,8 +11,8 @@ import UIKit @objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { public var templateModel: ThreeLayerPageTemplateModel? - public override func parsePageJSON() { - parseTemplateJSON() + @objc public override func parsePageJSON() throws { + try parseTemplateJSON() } override open func viewDidLoad() { From 77af932f5d52b5928973c93dd3efa7eba3a4c351 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 09:26:04 -0500 Subject: [PATCH 127/272] update old key --- MVMCoreUI/Models/Template/ListPageTemplateModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift index 61729c99..c3b2a120 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/ListPageTemplateModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class ListPageTemplateModel: TemplateModelProtocol { - public static var identifier: String = "listTemplate" + public static var identifier: String = "list" public var pageType: String public var screenHeading: String? From 9c0bea033c955a9807a0a8f6e9dfbea1b4cdb3ba Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 10:13:19 -0500 Subject: [PATCH 128/272] actionType fix --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 2 +- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 +- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 9d9ad9c3..03eb7fc3 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -36,8 +36,8 @@ public class ButtonModel: MoleculeProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) - action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type) - style = try typeContainer.decode(ButtonStyle.self, forKey: .style) + action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 3cc77a54..db2de2b0 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -45,7 +45,7 @@ public class CaretLinkModel: MoleculeProtocol { if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled } - action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type) + action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index 6b3ff39e..e2fca66c 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -33,7 +33,7 @@ public class LinkModel: MoleculeProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) - action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type) + action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled } diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index bef2cb84..7208a2ce 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -28,7 +28,7 @@ import MVMCore required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.type) + action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) style = try typeContainer.decodeIfPresent(String.self, forKey: .style) diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 53d14e44..5bc59593 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -24,10 +24,11 @@ import Foundation ModelRegistry.register(TabsModel.self) ModelRegistry.register(ScrollerModel.self) ModelRegistry.register(CornerLabelsModel.self) - // buttons ModelRegistry.register(LineModel.self) + // buttons ModelRegistry.register(ButtonModel.self) ModelRegistry.register(TwoButtonViewModel.self) + ModelRegistry.register(LinkModel.self) // list items ModelRegistry.register(ListItemModel.self) ModelRegistry.register(DropDownListItemModel.self) From 7e38657b63aee00d4b326c0855b53d7e57796f9a Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 14 Jan 2020 20:48:15 +0530 Subject: [PATCH 129/272] review comments updated models updated --- .../Models/Molecules/NumberedListModel.swift | 18 ++++++++++++++++-- .../Models/Molecules/UnOrderedListModel.swift | 19 ++++++++++++++++++- .../Molecules/LabelRightMoleculesStack.swift | 17 ++++++----------- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/NumberedListModel.swift b/MVMCoreUI/Models/Molecules/NumberedListModel.swift index 496db1b1..380c193f 100644 --- a/MVMCoreUI/Models/Molecules/NumberedListModel.swift +++ b/MVMCoreUI/Models/Molecules/NumberedListModel.swift @@ -11,9 +11,23 @@ import Foundation @objcMembers public class NumberedListModel: OrderListProtocol { public var backgroundColor: Color? public static var identifier: String = "numberedList" - public var list: [LabelModel] + public var list: [MoleculeProtocol] + + enum CodingKeys: String, CodingKey { + case list + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + list = try typeContainer.decodeMolecules(codingKey: .list) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeModels(list, forKey: .list) + } } public protocol OrderListProtocol: MoleculeProtocol { - var list: [LabelModel] {get} + var list: [MoleculeProtocol] {get} } diff --git a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift index 2c80dc6f..8d3280d9 100644 --- a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift +++ b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift @@ -12,5 +12,22 @@ import Foundation public var backgroundColor: Color? public static var identifier: String = "unOrderedList" public var bulletChar: String? - public var list: [LabelModel] + public var list: [MoleculeProtocol] + + enum CodingKeys: String, CodingKey { + case bulletChar + case list + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) + list = try typeContainer.decodeMolecules(codingKey: .list) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(bulletChar, forKey: .bulletChar) + try container.encodeModels(list, forKey: .list) + } } diff --git a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift index 312927fd..693df09c 100644 --- a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift +++ b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift @@ -110,10 +110,6 @@ class LeftLabelRightMoleculeContainer: View { setContentHuggingPriority(.defaultHigh, for: .vertical) setContentHuggingPriority(.defaultHigh, for: .horizontal) - rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .vertical) - rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) - leftContainer.setContentHuggingPriority(.required, for: .horizontal) - leftContainer.setContentHuggingPriority(.required, for: .vertical) updateLeftViewWidthConstraint(percentage) } @@ -132,21 +128,20 @@ class LeftLabelRightMoleculeContainer: View { } public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - let previousMoleculeName = model?.moleculeName + let previousMoleculeName = self.rightMoleculeName super.setWithModel(model, delegateObject, additionalData) removeSubviewsInRightContainer() - guard let labelModel = model as? LabelModel else { + label.text = leftText + rightMoleculeName = model?.moleculeName + guard let validModel = model else { return } - - label.text = leftText - rightMoleculeName = labelModel.moleculeName //For reuse purpose check that allready added molecule is same if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName { - rightMolecule.setWithModel(labelModel, delegateObject, additionalData) + rightMolecule.setWithModel(validModel, delegateObject, additionalData) addView(rightMolecule) } else { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(labelModel, delegateObject, false) { + if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(validModel, delegateObject, false) { addView(molecule) } } From 0090b686a576a96ed3bff93a74b46eabf23b629a Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 14 Jan 2020 11:11:28 -0500 Subject: [PATCH 130/272] default stryle and spacing --- MVMCoreUI/Molecules/Items/ListItemModel.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 7208a2ce..24cb05e0 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -15,7 +15,7 @@ import MVMCore public var action: ActionProtocol? public var hideArrow: Bool? public var line: LineModel? - public var style: String? + public var style: String? = "standard" enum ListItemCodingKeys: String, CodingKey { case backgroundColor @@ -31,10 +31,20 @@ import MVMCore action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { + self.style = style + } + try super.init(from: decoder) + + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } } - + public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: ListItemCodingKeys.self) @@ -43,5 +53,6 @@ import MVMCore try container.encodeIfPresent(hideArrow, forKey: .hideArrow) try container.encodeIfPresent(line, forKey: .line) try container.encodeIfPresent(style, forKey: .style) - } + } } + From 2f6859f5435275d406389afa86df42ce9905c207 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 11:17:10 -0500 Subject: [PATCH 131/272] button model fix --- MVMCoreUI.xcodeproj/project.pbxproj | 9 ++++----- .../Atoms/Buttons/MFTextButton+ModelExtension.swift | 5 +---- .../PrimaryButton+MoleculeProtocolExtension.swift | 5 +---- .../{ModelHelper.swift => MoleculeModelHelper.swift} | 2 +- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 2 +- 5 files changed, 8 insertions(+), 15 deletions(-) rename MVMCoreUI/Models/Extensions/{ModelHelper.swift => MoleculeModelHelper.swift} (98%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 1497d632..6580f328 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; }; 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; - 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; + 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; }; 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */; }; @@ -364,7 +364,7 @@ 944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = ""; }; 944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; - 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; + 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = ""; }; 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = ""; }; @@ -684,7 +684,7 @@ 946EE1B5237B663A0036751F /* Extensions */ = { isa = PBXGroup; children = ( - 946EE1B9237B66D80036751F /* ModelHelper.swift */, + 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */, ); path = Extensions; sourceTree = ""; @@ -1561,7 +1561,6 @@ 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, C003506123AA94CD00B6AC29 /* Button.swift in Sources */, - D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */, @@ -1588,7 +1587,7 @@ 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, - 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */, + 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, ); diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift b/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift index a6df6745..a86c072e 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift @@ -16,9 +16,6 @@ extension MFTextButton: ModelMoleculeViewProtocol { setTitleColor(model.textColor.uiColor, for: .normal) isEnabled = model.enabled backgroundColor = model.backgroundColor?.uiColor - //TODO: Use object when handleAction is rewrote to handle action model - if let actionMap = model.action.toJSON() { - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) - } + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift index f7192fc9..6f285e19 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift @@ -22,9 +22,6 @@ extension PrimaryButton: ModelMoleculeViewProtocol { setAsSecondaryCustom() } } - //TODO: Use object when handleAction is rewrote to handle action model - if let actionMap = model.action.toJSON() { - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) - } + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift similarity index 98% rename from MVMCoreUI/Models/Extensions/ModelHelper.swift rename to MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift index 72bb5f8f..e10fcc38 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift @@ -1,5 +1,5 @@ // -// ModelHelper.swift +// MoleculeModelHelper.swift // MVMCoreUI // // Created by Ryan on 11/12/19. diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 5bc59593..6a958061 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -38,7 +38,7 @@ import Foundation //need to move labelattributemodel to different method ModelRegistry.register(LabelAttributeFontModel.self) ModelRegistry.register(LabelAttributeColorModel.self) - ModelRegistry.register(LabelAttributeImageModel.self) + //ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... ModelRegistry.register(LabelAttributeUnderlineModel.self) ModelRegistry.register(LabelAttributeStrikeThroughModel.self) ModelRegistry.register(LabelAttributeActionModel.self) From 979718d4b8836e69323dcf24146b75dcc5d6cd79 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 11:56:50 -0500 Subject: [PATCH 132/272] Defaults, percent fix --- MVMCoreUI/Models/Molecules/FooterModel.swift | 22 +++++++++++++ MVMCoreUI/Models/Molecules/HeaderModel.swift | 29 ++++++++++++----- MVMCoreUI/Molecules/Items/ListItemModel.swift | 31 ++++++++++++++----- .../Molecules/Items/StackItemModel.swift | 8 ++--- MVMCoreUI/Organisms/MoleculeStackView.swift | 8 ++--- 5 files changed, 75 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 757e2fd5..e31ec1fc 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -16,11 +16,33 @@ import Foundation enum FooterCodingKeys: String, CodingKey { case backgroundColor } + + /// Defaults to set + func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } + if topMarginPadding == nil { + topMarginPadding = PaddingDefaultVerticalSpacing + } + if bottomMarginPadding == nil { + bottomMarginPadding = PaddingDefaultVerticalSpacing + } + } + + public override init(with moleculeModel: MoleculeProtocol) { + super.init(with: moleculeModel) + setDefaults() + } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) + setDefaults() } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 1e4ab9f2..4499d313 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -18,19 +18,34 @@ import Foundation case line case backgroundColor } - - required public init(from decoder: Decoder) throws { - try super.init(from: decoder) - let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - - // Default Values + + /// Defaults to set + func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } if topMarginPadding == nil { topMarginPadding = PaddingDefaultVerticalSpacing } if bottomMarginPadding == nil { bottomMarginPadding = PaddingDefaultVerticalSpacing } + line?.type = .heavy + } + + public override init(with moleculeModel: MoleculeProtocol) { + super.init(with: moleculeModel) + setDefaults() + } + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + setDefaults() } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 24cb05e0..cd0b1dc3 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -24,6 +24,28 @@ import MVMCore case line case style } + + /// Defaults to set + func setDefaults() { + style = "standard" + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } + if topMarginPadding == nil { + topMarginPadding = 24 + } + if bottomMarginPadding == nil { + bottomMarginPadding = 24 + } + } + + public override init(with moleculeModel: MoleculeProtocol) { + super.init(with: moleculeModel) + setDefaults() + } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self) @@ -34,15 +56,8 @@ import MVMCore if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { self.style = style } - try super.init(from: decoder) - - if useHorizontalMargins == nil { - useHorizontalMargins = true - } - if useVerticalMargins == nil { - useVerticalMargins = true - } + setDefaults() } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index a5128f1b..d19f2401 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -12,12 +12,12 @@ import Foundation public static var identifier: String = "stackItem" public var backgroundColor: Color? public var spacing: CGFloat? - public var percentage: Int? = 0 + public var percent: Int? public var gone: Bool = false enum MoleculeStackItemCodingKeys: String, CodingKey { case spacing - case percentage + case percent case gone } @@ -28,7 +28,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self) spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) - percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage) + percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent) if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) { self.gone = gone } @@ -39,7 +39,7 @@ import Foundation try super.encode(to: encoder) var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self) try container.encodeIfPresent(spacing, forKey: .spacing) - try container.encodeIfPresent(percentage, forKey: .percentage) + try container.encodeIfPresent(percent, forKey: .percent) try container.encode(gone, forKey: .gone) } } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 5345549c..1783e19a 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -222,8 +222,8 @@ open class MoleculeStackView: Container { stackItem.translatesAutoresizingMaskIntoConstraints = false let spacing = model.spacing ?? stackModel.spacing - let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percentage == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center)) - let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percentage == nil ? .fill : .leading) + let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center)) + let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading) stackItem.containerHelper.alignHorizontal(horizontalAlignment) stackItem.containerHelper.alignVertical(verticalAlignment) @@ -238,7 +238,7 @@ open class MoleculeStackView: Container { } pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: stackItem, attribute: .trailing, relation: .equal, priority: .required, constant: 0) - if let percent = model.percentage { + if let percent = model.percent { stackItem.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true } if lastItem { @@ -255,7 +255,7 @@ open class MoleculeStackView: Container { } pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0) - if let percent = model.percentage { + if let percent = model.percent { stackItem.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true } if lastItem { From a2046036164c05d895b1a127bbe59858aae7a580 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 12:19:26 -0500 Subject: [PATCH 133/272] temp corner labels fix --- MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift index bde3ab6f..5c0dbfcf 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers public class CornerLabels: ViewConstrainingView { +@objcMembers public class CornerLabels: ViewConstrainingView, ModelMoleculeViewProtocol { let topLeftLabel = Label.commonLabelB1(true) let topRightLabel = Label.commonLabelB1(true) @@ -177,9 +177,7 @@ import UIKit public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 34 } -} -extension CornerLabels: MoleculeViewProtocol { public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? CornerLabelsModel, let data = try? model.encode(using: JSONEncoder()), From 3d2fd02ac54a4d3011c4298735da6b7f78742d08 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 13:58:18 -0500 Subject: [PATCH 134/272] undo view constraining removal code fix molecule table cell fix corner labels --- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 39 +++++++++++ MVMCoreUI/BaseClasses/View.swift | 1 + .../Items/MoleculeTableViewCell.swift | 11 ++-- .../LeftRightViews/CornerLabels.swift | 66 ++++++++----------- MVMCoreUI/Molecules/MoleculeContainer.swift | 7 +- 5 files changed, 80 insertions(+), 44 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 54a12612..b98e72a5 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -352,6 +352,45 @@ } - (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + // Only treated as a container if we are constraining a molecule. + if (!self.constrainedView) { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; + } + if (self.shouldSetupMoleculeFromJSON) { + NSDictionary *moleculeJSON = [json dict:KeyMolecule]; + if (self.molecule) { + [self.molecule setWithJSON:moleculeJSON delegateObject:delegateObject additionalData:additionalData]; + } else if (moleculeJSON) { + UIView *molecule = [[MVMCoreUIMoleculeMappingObject sharedMappingObject] createMoleculeForJSON:moleculeJSON delegateObject:delegateObject constrainIfNeeded:true]; + if (molecule) { + [self addMolecule:molecule]; + } + self.molecule = molecule; + [self setMoleculeAccessibility]; + } + } else { + [self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; + } + + NSNumber *useHorizontalMargins = [json optionalNumberForKey:@"useHorizontalMargins"]; + if (useHorizontalMargins) { + self.updateViewHorizontalDefaults = [useHorizontalMargins boolValue]; + } + NSNumber *useVerticalMargins = [json optionalNumberForKey:@"useVerticalMargins"]; + if (useVerticalMargins) { + self.updateViewVerticalDefaults = [useVerticalMargins boolValue]; + } + + // Set the alignment for the stack in the containing view. The json driven value is for the axis direction alignment. + NSString *alignment = [json string:@"horizontalAlignment"]; + if (alignment) { + [self alignHorizontal:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; + } + alignment = [json string:@"verticalAlignment"]; + if (alignment) { + [self alignVertical:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]]; + } + if ([self.molecule respondsToSelector:@selector(copyBackgroundColor)] && [self.molecule performSelector:@selector(copyBackgroundColor)]) { self.backgroundColor = self.molecule.backgroundColor; } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 4691f8e7..d3843f43 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -61,6 +61,7 @@ extension View: MVMCoreViewProtocol { open func setupView() { translatesAutoresizingMaskIntoConstraints = false insetsLayoutMarginsFromSafeArea = false + MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0) } } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 1fee9e20..2b4fa0a8 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -13,13 +13,12 @@ import UIKit // MARK: - MVMCoreUIMoleculeViewProtocol public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) - - guard let model = model, - let moleculeModel = (model as? ListItemModel)?.molecule, - let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) else { - return + guard let moleculeModel = (model as? ListItemModel)?.molecule else { return } + if molecule != nil { + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) + } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) { + addMolecule(moleculeView) } - addMolecule(moleculeView) } public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift index 5c0dbfcf..ac9fe240 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift @@ -8,8 +8,8 @@ import UIKit -@objcMembers public class CornerLabels: ViewConstrainingView, ModelMoleculeViewProtocol { - +@objcMembers public class CornerLabels: View { + var middleView: UIView? let topLeftLabel = Label.commonLabelB1(true) let topRightLabel = Label.commonLabelB1(true) let bottomLeftLabel = Label.commonLabelB3(true) @@ -38,18 +38,19 @@ import UIKit var topLabelToMoleculeConstraint: NSLayoutConstraint? var bottomLabelToMoleculeConstraint: NSLayoutConstraint? - public override func addMolecule(_ molecule: UIView) { - insertSubview(molecule, at: 0) + public func addMiddleView(_ view: UIView) { + insertSubview(view, at: 0) topLabelToMoleculeConstraint?.isActive = false bottomLabelToMoleculeConstraint?.isActive = false - molecule.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true - layoutMarginsGuide.rightAnchor.constraint(equalTo: molecule.rightAnchor).isActive = true + view.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true + layoutMarginsGuide.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - topLabelToMoleculeConstraint = molecule.topAnchor.constraint(equalTo: topLabelsView.bottomAnchor, constant: spaceAboveMolecule) + topLabelToMoleculeConstraint = view.topAnchor.constraint(equalTo: topLabelsView.bottomAnchor, constant: spaceAboveMolecule) topLabelToMoleculeConstraint?.isActive = true - bottomLabelToMoleculeConstraint = bottomLabelsView.topAnchor.constraint(equalTo: molecule.bottomAnchor, constant: spaceBelowMolecule) + bottomLabelToMoleculeConstraint = bottomLabelsView.topAnchor.constraint(equalTo: view.bottomAnchor, constant: spaceBelowMolecule) bottomLabelToMoleculeConstraint?.isActive = true + self.middleView = view } // MARK: - MVMCoreViewProtocol @@ -59,12 +60,11 @@ import UIKit topRightLabel.updateView(size) bottomLeftLabel.updateView(size) bottomRightLabel.updateView(size) + (middleView as? MVMCoreViewProtocol)?.updateView(size) } public override func setupView() { super.setupView() - shouldSetupMoleculeFromJSON = true - guard topLeftLabel.superview == nil else { return } @@ -141,17 +141,6 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - topLeftLabel.setWithJSON(json?.optionalDictionaryForKey("topLeftLabel"), delegateObject: delegateObject, additionalData: additionalData) - topRightLabel.setWithJSON(json?.optionalDictionaryForKey("topRightLabel"), delegateObject: delegateObject, additionalData: additionalData) - bottomLeftLabel.setWithJSON(json?.optionalDictionaryForKey("bottomLeftLabel"), delegateObject: delegateObject, additionalData: additionalData) - bottomRightLabel.setWithJSON(json?.optionalDictionaryForKey("bottomRightLabel"), delegateObject: delegateObject, additionalData: additionalData) - - topLabelToMoleculeConstraint?.constant = (molecule != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0 - bottomLabelToMoleculeConstraint?.constant = (molecule != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0 - } - public override func setAsMolecule() { super.setAsMolecule() styleDefault() @@ -163,8 +152,7 @@ import UIKit styleDefault() spaceAboveMolecule = 6.0 spaceBelowMolecule = 6.0 - - molecule?.reset?() + (middleView as? MoleculeViewProtocol)?.reset?() } func styleDefault() { @@ -174,23 +162,27 @@ import UIKit bottomRightLabel.styleB3(true) } - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 34 } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let model = model as? CornerLabelsModel, - let data = try? model.encode(using: JSONEncoder()), - let json = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] else { - return + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? CornerLabelsModel else { return } + if middleView != nil { + (middleView as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) + } else { + if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model.molecule, delegateObject) { + addMiddleView(molecule) + } } - self.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) -// topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData) -// topRightLabel.setWithModel(model.topRightLabel, delegateObject, additionalData) -// bottomLeftLabel.setWithModel(model.bottomLeftLabel, delegateObject, additionalData) -// bottomRightLabel.setWithModel(model.bottomRightLabel, delegateObject, additionalData) -// -// topLabelToMoleculeConstraint?.constant = (molecule != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0 -// bottomLabelToMoleculeConstraint?.constant = (molecule != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0 + + topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData) + topRightLabel.setWithModel(model.topRightLabel, delegateObject, additionalData) + bottomLeftLabel.setWithModel(model.bottomLeftLabel, delegateObject, additionalData) + bottomRightLabel.setWithModel(model.bottomRightLabel, delegateObject, additionalData) + + topLabelToMoleculeConstraint?.constant = (middleView != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0 + bottomLabelToMoleculeConstraint?.constant = (middleView != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0 } } diff --git a/MVMCoreUI/Molecules/MoleculeContainer.swift b/MVMCoreUI/Molecules/MoleculeContainer.swift index f45ca482..e3646bcf 100644 --- a/MVMCoreUI/Molecules/MoleculeContainer.swift +++ b/MVMCoreUI/Molecules/MoleculeContainer.swift @@ -9,6 +9,11 @@ import UIKit open class MoleculeContainer: Container { + + /// Can be overriden to change how the molecule is added to the hierarchy. + public func addMolecule(_ molecule: UIView) { + addAndContain(molecule) + } override public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule) else { @@ -31,7 +36,7 @@ open class MoleculeContainer: Container { (view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData) } else { if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(casteModel.molecule, delegateObject) { - addAndContain(molecule) + addMolecule(molecule) } } } From 147ce53c90f6a0dd771cb1ddebbb25996f4d1d60 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 14 Jan 2020 15:50:46 -0500 Subject: [PATCH 135/272] name for class --- MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift | 10 +++++----- MVMCoreUI/Molecules/Items/TableViewCell.swift | 9 ++++++--- MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift | 5 ++--- MVMCoreUI/Molecules/ModuleMolecule.swift | 2 +- MVMCoreUI/Organisms/Carousel.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 3 ++- MVMCoreUI/Templates/MoleculeListTemplate.swift | 2 +- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 1fee9e20..3733ea6e 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -22,12 +22,12 @@ import UIKit addMolecule(moleculeView) } - public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let moleculeModel = (molecule as? ListItemModel)?.molecule else { + public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let moleculeModel = (model as? ListItemModel)?.molecule else { return "\(self)<>" } - let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol - let moleculeName = className?.nameForReuse(molecule, delegateObject) ?? moleculeModel.moleculeName ?? "" + let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type + let moleculeName = className?.nameForReuse(model, delegateObject) ?? moleculeModel.moleculeName ?? "" return "\(self)<\(moleculeName)>" } @@ -39,7 +39,7 @@ import UIKit return theClass.requiredModules?(moleculeJSON, delegateObject: delegateObject, error: error) } - public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { guard let moleculeModel = (molecule as? MoleculeContainerModel)?.molecule, let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type, let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else { diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 774f50d1..ffdcd85b 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -179,10 +179,13 @@ import UIKit backgroundColor = .white } - public class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - return molecule?.moleculeName ?? "" + public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + return model?.moleculeName } - + + public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return nil + } // MARK: - Arrow /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index de8e4d4f..34f2c67b 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -10,13 +10,13 @@ import Foundation public protocol ModelMoleculeViewProtocol { func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) - func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? + static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? } extension ModelMoleculeViewProtocol { - public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return nil } public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -25,7 +25,6 @@ extension ModelMoleculeViewProtocol { public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } - // Temporary public static func decodeJSONToModel(json: [AnyHashable: Any], type: T.Type) throws -> T where T : Decodable { let data = try JSONSerialization.data(withJSONObject: json) diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index e2411ec0..0cb0e541 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -61,7 +61,7 @@ open class ModuleMolecule: Container { public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moduleMolecule = model as? ModuleMoleculeModel, let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), - let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol, + let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, let name = classType.nameForReuse(moduleModel, delegateObject) else { // Critical error return "moduleMolecule<>" diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 181ae372..98f1e6a2 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -169,7 +169,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { /// Returns the (identifier, class) of the molecule for the given map. func getMoleculeInfo(with molecule: MoleculeProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? { guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) , - let moleculeName = (className as? ModelMoleculeViewProtocol)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else { + let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else { return nil } return (moleculeName, className, molecule) diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 5345549c..a09ec83d 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -119,7 +119,8 @@ open class MoleculeStackView: Container { var name = "stack<" for case let item in model.molecules { if let moleculeName = item.molecule.moleculeName { - if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol, let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { + if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type, + let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { name.append(nameForReuse + ",") } else { name.append(moleculeName + ",") diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 3a551a79..5570bb1a 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -167,7 +167,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? { guard let listItem = listItem, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), - let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else { + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else { return nil } return (moleculeName, moleculeClass, listItem) From 27793931f5c1f56bccfb09ed832de3a2e10736cf Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 15:55:18 -0500 Subject: [PATCH 136/272] fix for static functions --- MVMCoreUI/BaseClasses/View.swift | 4 ---- .../Molecules/Items/MoleculeCollectionViewCell.swift | 8 +++++--- .../Molecules/Items/MoleculeTableViewCell.swift | 12 ++++++------ MVMCoreUI/Molecules/Items/TableViewCell.swift | 4 ---- MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift | 6 +++--- MVMCoreUI/Molecules/ModuleMolecule.swift | 4 ++-- MVMCoreUI/Organisms/Carousel.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 6 +++--- MVMCoreUI/Templates/MoleculeListTemplate.swift | 2 +- 9 files changed, 21 insertions(+), 27 deletions(-) diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index d3843f43..4d6e247d 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -40,10 +40,6 @@ import UIKit } } - public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - return model?.moleculeName - } - open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index b396dde6..93f5e039 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -114,11 +114,13 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi backgroundColor = .white } - public class func name(forReuse molecule: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let molecule = molecule?.optionalDictionaryForKey(KeyMolecule) else { + public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let molecule = (model as? CarouselItemModel)?.molecule, + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type, + let name = moleculeClass.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else { return nil } - return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) + return name } public func updateView(_ size: CGFloat) { diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 2b4fa0a8..6b57c0f5 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -20,16 +20,16 @@ import UIKit addMolecule(moleculeView) } } - - public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let moleculeModel = (molecule as? ListItemModel)?.molecule else { + + public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let moleculeModel = (model as? ListItemModel)?.molecule else { return "\(self)<>" } - let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol - let moleculeName = className?.nameForReuse(molecule, delegateObject) ?? moleculeModel.moleculeName ?? "" + let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type + let moleculeName = className?.nameForReuse(moleculeModel, delegateObject) ?? moleculeModel.moleculeName ?? "" return "\(self)<\(moleculeName)>" } - + public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON) else { diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 774f50d1..dfcf7252 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -178,10 +178,6 @@ import UIKit styleStandard() backgroundColor = .white } - - public class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - return molecule?.moleculeName ?? "" - } // MARK: - Arrow /// Adds the standard mvm style caret to the accessory view diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index de8e4d4f..fcf03ccd 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -10,14 +10,14 @@ import Foundation public protocol ModelMoleculeViewProtocol { func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) - func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? + static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? } extension ModelMoleculeViewProtocol { - public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - return nil + public static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + return model?.moleculeName } public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index e2411ec0..be13fc79 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -58,10 +58,10 @@ open class ModuleMolecule: Container { return height } - public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moduleMolecule = model as? ModuleMoleculeModel, let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), - let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol, + let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, let name = classType.nameForReuse(moduleModel, delegateObject) else { // Critical error return "moduleMolecule<>" diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 181ae372..98f1e6a2 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -169,7 +169,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { /// Returns the (identifier, class) of the molecule for the given map. func getMoleculeInfo(with molecule: MoleculeProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? { guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) , - let moleculeName = (className as? ModelMoleculeViewProtocol)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else { + let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else { return nil } return (moleculeName, className, molecule) diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 1783e19a..60c6515f 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -97,7 +97,7 @@ open class MoleculeStackView: Container { removeAllItemViews() // If the items in the stack are different, clear them, create new ones. - if (previousModel == nil) || nameForReuse(previousModel, delegateObject) != nameForReuse(model, delegateObject) { + if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) { stackItems = [] createStackItemsFromModel(with: delegateObject) } else if let models = stackModel?.molecules { @@ -111,7 +111,7 @@ open class MoleculeStackView: Container { stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins } - public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { // This will aggregate names of molecules to make an id. guard let model = model as? MoleculeStackModel else { return "stack<>" @@ -119,7 +119,7 @@ open class MoleculeStackView: Container { var name = "stack<" for case let item in model.molecules { if let moleculeName = item.molecule.moleculeName { - if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol, let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { + if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type, let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { name.append(nameForReuse + ",") } else { name.append(moleculeName + ",") diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 3a551a79..5570bb1a 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -167,7 +167,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? { guard let listItem = listItem, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), - let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else { + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else { return nil } return (moleculeName, moleculeClass, listItem) From fc2326e9a8706b81bf2c2c597ba9e138e56977dc Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 16:32:42 -0500 Subject: [PATCH 137/272] button size --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 17 +++++++++++-- ...maryButton+MoleculeProtocolExtension.swift | 8 +++++++ MVMCoreUI/BaseClasses/View.swift | 12 ++++++++++ MVMCoreUI/Molecules/Items/ListItemModel.swift | 1 - .../SwitchMolecules/HeadlineBodySwitch.swift | 2 +- MVMCoreUI/Molecules/ModuleMolecule.swift | 6 ++--- .../EyebrowHeadlineBodyLink.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 24 +++++++++---------- 8 files changed, 52 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 03eb7fc3..4329ccff 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -13,12 +13,18 @@ public enum ButtonStyle: String, Codable { case secondary } +public enum ButtonSize: String, Codable { + case standard + case tiny +} + public class ButtonModel: MoleculeProtocol { public static var identifier: String = "button" public var backgroundColor: Color? public var title: String public var action: ActionProtocol - public var style: ButtonStyle? + public var style: ButtonStyle? = .primary + public var size: ButtonSize? = .standard init(with title: String, action: ActionProtocol) { self.title = title @@ -30,6 +36,7 @@ public class ButtonModel: MoleculeProtocol { case title case action case style + case size } required public init(from decoder: Decoder) throws { @@ -37,7 +44,12 @@ public class ButtonModel: MoleculeProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) - style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) + if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) { + self.style = style + } + if let size = try typeContainer.decodeIfPresent(ButtonSize.self, forKey: .size) { + self.size = size + } } public func encode(to encoder: Encoder) throws { @@ -46,5 +58,6 @@ public class ButtonModel: MoleculeProtocol { try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) try container.encodeIfPresent(style, forKey: .style) + try container.encodeIfPresent(size, forKey: .size) } } diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift index 6f285e19..2d7ecf40 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift @@ -22,6 +22,14 @@ extension PrimaryButton: ModelMoleculeViewProtocol { setAsSecondaryCustom() } } + if let size = model.size { + switch size { + case .standard: + setAsTiny(false) + case .tiny: + setAsTiny(true) + } + } set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 4d6e247d..05cbef15 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -46,6 +46,18 @@ import UIKit self.backgroundColor = backgroundColor.uiColor } } + + public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + return model?.moleculeName + } + + public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return nil + } + + public class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + return nil + } } // MARK:- MVMCoreViewProtocol diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index cd0b1dc3..5e54a2e9 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -27,7 +27,6 @@ import MVMCore /// Defaults to set func setDefaults() { - style = "standard" if useHorizontalMargins == nil { useHorizontalMargins = true } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index fee32b2f..1c937df1 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -41,7 +41,7 @@ import UIKit super.setWithModel(model, delegateObject, additionalData) } - public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public class override func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 30 } diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index be13fc79..04caa9da 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -46,7 +46,7 @@ open class ModuleMolecule: Container { } } - public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let moduleMolecule = molecule as? ModuleMoleculeModel, let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), @@ -58,7 +58,7 @@ open class ModuleMolecule: Container { return height } - public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moduleMolecule = model as? ModuleMoleculeModel, let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, @@ -69,7 +69,7 @@ open class ModuleMolecule: Container { return name } - public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName, let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 1262994f..d5557eca 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -85,7 +85,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { body.styleB2(true) } - public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 65 } } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index c3da98ef..9f2f526f 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -111,7 +111,18 @@ open class MoleculeStackView: Container { stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins } - public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + if model == nil { + let data = try! JSONSerialization.data(withJSONObject: json!) + let decoder = JSONDecoder() + let model = try! decoder.decode(MoleculeStackModel.self, from: data) + setWithModel(model, delegateObject, additionalData) + } else { + setWithModel(model, delegateObject, additionalData) + } + } + + public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { // This will aggregate names of molecules to make an id. guard let model = model as? MoleculeStackModel else { return "stack<>" @@ -131,17 +142,6 @@ open class MoleculeStackView: Container { return name } - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - if model == nil { - let data = try! JSONSerialization.data(withJSONObject: json!) - let decoder = JSONDecoder() - let model = try! decoder.decode(MoleculeStackModel.self, from: data) - setWithModel(model, delegateObject, additionalData) - } else { - setWithModel(model, delegateObject, additionalData) - } - } - public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { // This will aggregate names of molecules to make an id. guard let molecules = molecule?.optionalArrayForKey(KeyMolecules) else { From 7723ffb260bb1755d48879f8c41478e4687a232d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 17:40:51 -0500 Subject: [PATCH 138/272] verbose errors --- MVMCoreUI/BaseControllers/MFViewController.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index d2ff7cda..09700268 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -101,7 +101,9 @@ [self parsePageJSONAndReturnError:&parseError]; if (parseError) { if (error) { - *error = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; + MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; + errorObject.messageToDisplay = [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess]; + *error = errorObject; } return false; } From e85270d0389857eaae0f67fe941bb731e0796fea Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 18:33:34 -0500 Subject: [PATCH 139/272] new molecules to model --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ .../HeadLineBodyCaretLinkImage.swift | 15 ++++++++++++--- .../HeadlineBodyCaretLinkImageModel.swift | 17 +++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 3 +++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6580f328..9c93c8dc 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -150,6 +150,7 @@ D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */; }; D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */; }; D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */; }; + D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -418,6 +419,7 @@ D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimaryButton+MoleculeProtocolExtension.swift"; sourceTree = ""; }; D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonViewModel.swift; sourceTree = ""; }; D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerLabelsModel.swift; sourceTree = ""; }; + D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyCaretLinkImageModel.swift; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -760,6 +762,7 @@ 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */, + D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */, C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, ); path = VerticalCombinationViews; @@ -1536,6 +1539,7 @@ 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, D243859923A16B1800332775 /* Container.swift in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, + D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index 9c3dba8a..3b52e6bf 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -7,7 +7,7 @@ // import Foundation -@objcMembers public class HeadLineBodyCaretLinkImage: ViewConstrainingView { +@objcMembers public class HeadLineBodyCaretLinkImage: View { let headlineBody = HeadlineBody(frame: .zero) let caretButton = CaretButton(frame: .zero) @@ -34,7 +34,7 @@ import Foundation } let view = MVMCoreUICommonViewsUtility.commonView() addSubview(view) - pinView(toSuperView: view) + NSLayoutConstraint.constraintPinSubview(toSuperview: view) view.addSubview(headlineBody) view.addSubview(caretButton) @@ -78,7 +78,16 @@ import Foundation backgroundImageView.reset() } - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 320 } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? HeadlineBodyCaretLinkImageModel else { return } + headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData) + caretButton.setWithModel(model.caretLink, delegateObject, additionalData) + backgroundImageView.setWithModel(model.image, delegateObject, additionalData) + } } + diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift new file mode 100644 index 00000000..4bfa2740 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift @@ -0,0 +1,17 @@ +// +// headlineBodyCaretLinkImageModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/14/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class HeadlineBodyCaretLinkImageModel: MoleculeProtocol { + public static var identifier: String = "headlineBodyCaretLinkImageMolecule" + public var backgroundColor: Color? + public var caretLink: LinkModel? + public var headlineBody: HeadlineBodyModel + public var image: ImageViewModel +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 6a958061..e4c35777 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -25,10 +25,13 @@ import Foundation ModelRegistry.register(ScrollerModel.self) ModelRegistry.register(CornerLabelsModel.self) ModelRegistry.register(LineModel.self) + ModelRegistry.register(CircleProgressModel.self) + ModelRegistry.register(HeadlineBodyCaretLinkImageModel.self) // buttons ModelRegistry.register(ButtonModel.self) ModelRegistry.register(TwoButtonViewModel.self) ModelRegistry.register(LinkModel.self) + ModelRegistry.register(CaretLinkModel.self) // list items ModelRegistry.register(ListItemModel.self) ModelRegistry.register(DropDownListItemModel.self) From f87ddf34480333952e3847b1dd2b706cc405ba27 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 18:41:54 -0500 Subject: [PATCH 140/272] name update --- .../HeadlineBodyCaretLinkImageModel.swift | 2 +- MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift index 4bfa2740..8052a7db 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift @@ -9,7 +9,7 @@ import UIKit public class HeadlineBodyCaretLinkImageModel: MoleculeProtocol { - public static var identifier: String = "headlineBodyCaretLinkImageMolecule" + public static var identifier: String = "headlineBodyCaretLinkImage" public var backgroundColor: Color? public var caretLink: LinkModel? public var headlineBody: HeadlineBodyModel diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index b2590566..ad987229 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -73,7 +73,7 @@ @"headlineBodyButton": HeadlineBodyButton.class, @"stackItem": StackItem.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, - @"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class + @"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class } mutableCopy]; }); return mapping; From 76b14f6e8ed8b5d2b8612c2a83ac1270f19723ce Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 20:20:02 -0500 Subject: [PATCH 141/272] fix typo --- MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 4172e4dc..88531ceb 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -16,7 +16,7 @@ import UIKit guard let moleculeModel = (model as? ListItemModel)?.molecule else { return } if molecule != nil { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) - } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) { + } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, false) { addMolecule(moleculeView) } } From a737b3b94c0e2dc4f20adcb419cf9645e9788e9a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 20:23:14 -0500 Subject: [PATCH 142/272] Remove adding view constraining view --- MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift | 2 +- MVMCoreUI/Molecules/ModuleMolecule.swift | 2 +- MVMCoreUI/Organisms/Carousel.swift | 2 +- MVMCoreUI/Templates/MoleculeListTemplate.swift | 4 ++-- MVMCoreUI/Templates/MoleculeStackTemplate.swift | 4 ++-- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index 93f5e039..976b6e60 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -92,7 +92,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi } if molecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(collectionModel.molecule, delegateObject, true) { + if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(collectionModel.molecule, delegateObject, false) { contentView.insertSubview(moleculeView, at: 0) containerHelper.constrainView(moleculeView) molecule = moleculeView diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index 04caa9da..ba0801f3 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -29,7 +29,7 @@ open class ModuleMolecule: Container { } if moduleMolecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moduleModel, delegateObject, true) { + if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moduleModel, delegateObject, false) { addSubview(moleculeView) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) moduleMolecule = moleculeView as? (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 98f1e6a2..50d55c16 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -151,7 +151,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { open func setupPagingMolecule(_ molecule: PagingMoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) { var pagingView: (UIView & MVMCoreUIPagingProtocol)? = nil if let molecule = molecule { - pagingView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(molecule, delegateObject, true) as? (UIView & MVMCoreUIPagingProtocol) + pagingView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(molecule, delegateObject, false) as? (UIView & MVMCoreUIPagingProtocol) } addPaging(view: pagingView, position: (CGFloat(molecule?.position ?? 20))) } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 5570bb1a..092c8648 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -34,7 +34,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func viewForTop() -> UIView { guard let headerModel = templateModel?.header, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return super.viewForTop() } return molecule @@ -42,7 +42,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol override open func viewForBottom() -> UIView { guard let footerModel = templateModel?.footer, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return super.viewForBottom() } return molecule diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 74eae770..a4f69518 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -36,7 +36,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { open override func viewForTop() -> UIView? { guard let headerModel = templateModel?.header, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return nil } return molecule @@ -57,7 +57,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { override open func viewForBottom() -> UIView? { guard let footerModel = templateModel?.footer, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return nil } return molecule diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 472985e3..9c963693 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -29,7 +29,7 @@ import UIKit open override func viewForTop() -> UIView? { guard let headerModel = templateModel?.header, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return nil } return molecule @@ -37,7 +37,7 @@ import UIKit open override func viewForMiddle() -> UIView? { guard let middleModel = templateModel?.middle, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(middleModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(middleModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return nil } return molecule @@ -45,7 +45,7 @@ import UIKit override open func viewForBottom() -> UIView? { guard let footerModel = templateModel?.footer, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return nil } return molecule From 8936f510b2b48571b8830011e075b6258efb2fb3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 20:35:53 -0500 Subject: [PATCH 143/272] temporary change to match --- MVMCoreUI/Templates/MoleculeListTemplate.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 092c8648..61e1121c 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -37,6 +37,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { return super.viewForTop() } + + // Temporary, Default the horizontal padding + if var container = templateModel?.header as? ContainerModelProtocol, container.useHorizontalMargins == nil { + container.useHorizontalMargins = true + } return molecule } From 952c3bdb53ee6c6571d723ce88d5faa0fe001dbd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 14 Jan 2020 21:08:48 -0500 Subject: [PATCH 144/272] Toggle model temporary --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++ .../Atoms/Views/MVMCoreUISwitch+Model.swift | 31 ++++++++++++++ MVMCoreUI/Atoms/Views/ToggleModel.swift | 41 +++++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 81 insertions(+) create mode 100644 MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift create mode 100644 MVMCoreUI/Atoms/Views/ToggleModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9c93c8dc..c5ac1374 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -123,6 +123,8 @@ D22D1F562204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; + D260105323CEA61600764D80 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105223CEA61600764D80 /* ToggleModel.swift */; }; + D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */; }; D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -393,6 +395,8 @@ D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIStackableViewController.h; sourceTree = ""; }; D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIStackableViewController.m; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; + D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = ""; }; + D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUISwitch+Model.swift"; sourceTree = ""; }; D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = ""; }; D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = ""; }; D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; @@ -1087,6 +1091,8 @@ D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */, D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */, D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */, + D260105223CEA61600764D80 /* ToggleModel.swift */, + D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */, D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, @@ -1471,6 +1477,7 @@ DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, + D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */, @@ -1478,6 +1485,7 @@ D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, D2B18B812360945C00A9AEDC /* View.swift in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, + D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift new file mode 100644 index 00000000..68482f09 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift @@ -0,0 +1,31 @@ +// +// MVMCoreUISwitch+Model.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/14/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +// temporary until link is finished +extension MVMCoreUISwitch: ModelMoleculeViewProtocol { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let model = model as? ToggleModel else { return } + + if let castSelf = self as? FormValidationProtocol { + FormValidator.setupValidation(molecule: castSelf, delegate: delegateObject?.formValidationProtocol) + } + + setState(model.on, animated: false) + + guard let action = model.action else { return } + actionBlock = { + if let data = try? action.encode(using: JSONEncoder()), + let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + + } + } + } +} diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift new file mode 100644 index 00000000..df7d2ba8 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -0,0 +1,41 @@ +// +// ToggleModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/14/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class ToggleModel: MoleculeProtocol { + public static var identifier: String = "toggle" + public var backgroundColor: Color? + public var on: Bool = true + public var action: ActionProtocol? + + enum CodingKeys: String, CodingKey { + case on + case action + case backgroundColor + } + + public init(_ on: Bool) { + self.on = on + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let on = try typeContainer.decodeIfPresent(Bool.self, forKey: .on) { + self.on = on + } + action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeModelIfPresent(action, forKey: .action) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index e4c35777..1a041e2c 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -27,6 +27,7 @@ import Foundation ModelRegistry.register(LineModel.self) ModelRegistry.register(CircleProgressModel.self) ModelRegistry.register(HeadlineBodyCaretLinkImageModel.self) + ModelRegistry.register(ToggleModel.self) // buttons ModelRegistry.register(ButtonModel.self) ModelRegistry.register(TwoButtonViewModel.self) From 703e0cd32bc06b1866fee7a95c5dbb411b3a699c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 15 Jan 2020 12:38:31 -0500 Subject: [PATCH 145/272] Convenience to access cgColor. --- MVMCoreUI/Models/Primitive Models/Color.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift index e4c0e4fa..d72e1af9 100644 --- a/MVMCoreUI/Models/Primitive Models/Color.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -19,6 +19,11 @@ public final class Color: Codable { //-------------------------------------------------- public let uiColor: UIColor + + public var cgColor: CGColor { + return uiColor.cgColor + } + public private(set) var hex: String = "" public private(set) var name: String = "" From 388d88b47c4049cd78f2c532891e6b5ec028deeb Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 15 Jan 2020 13:13:15 -0500 Subject: [PATCH 146/272] autorResiszing exception. --- MVMCoreUI/Molecules/Items/TableViewCell.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 537af049..dc62ae65 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -192,6 +192,7 @@ import UIKit @objc public func addCaretViewAccessory() { guard accessoryView == nil else { return } caretView = CaretView(lineWidth: 1) + caretView?.translatesAutoresizingMaskIntoConstraints = true caretView?.size = .small(.vertical) caretView?.setConstraints() From 9329f0ca15cfd8dac6a1c5979f7b8e36fbf348b2 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 15 Jan 2020 13:28:40 -0500 Subject: [PATCH 147/272] update left and right padding --- MVMCoreUI/Molecules/DoughnutChart.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Molecules/DoughnutChart.swift b/MVMCoreUI/Molecules/DoughnutChart.swift index d7f25ac6..d58dc7c4 100644 --- a/MVMCoreUI/Molecules/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/DoughnutChart.swift @@ -173,10 +173,15 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { return doughnutChartModel?.spaceRequired ?? true } - func updateLabelContainer() { - labelContainer.leftPin?.constant = lineWidth() - labelContainer.topPin?.constant = lineWidth() - labelContainer.setNeedsDisplay() - } + func updateLabelContainer() { + labelContainer.layoutIfNeeded() + let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth() + let labelheight = labelContainer.frame.height/2 + let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2)) + + labelContainer.leftPin?.constant = padding + labelContainer.topPin?.constant = padding + labelContainer.setNeedsDisplay() + } } From 00d78cfdedcdf238466c35c6fea4852cac6da925 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 15 Jan 2020 13:53:54 -0500 Subject: [PATCH 148/272] update label frame --- MVMCoreUI/Molecules/DoughnutChart.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/DoughnutChart.swift b/MVMCoreUI/Molecules/DoughnutChart.swift index d58dc7c4..e6a169f1 100644 --- a/MVMCoreUI/Molecules/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/DoughnutChart.swift @@ -20,9 +20,9 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { var labelContainer = ViewConstrainingView.empty() var heightConstraint: NSLayoutConstraint? - private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 150)! + private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 100)! - var height: CGFloat = 150 { + var height: CGFloat = 100 { didSet { if height != oldValue { sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)! @@ -174,14 +174,14 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { } func updateLabelContainer() { + labelContainer.setNeedsDisplay() labelContainer.layoutIfNeeded() let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth() let labelheight = labelContainer.frame.height/2 let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2)) labelContainer.leftPin?.constant = padding - labelContainer.topPin?.constant = padding - labelContainer.setNeedsDisplay() + labelContainer.topPin?.constant = max(radius - labelheight, labelheight) } } From e5accc7611d5f836e2793c9e3205ca536822b574 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 15 Jan 2020 13:54:31 -0500 Subject: [PATCH 149/272] update height --- MVMCoreUI/Molecules/DoughnutChart.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/DoughnutChart.swift b/MVMCoreUI/Molecules/DoughnutChart.swift index e6a169f1..1175a563 100644 --- a/MVMCoreUI/Molecules/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/DoughnutChart.swift @@ -20,9 +20,9 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { var labelContainer = ViewConstrainingView.empty() var heightConstraint: NSLayoutConstraint? - private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 100)! + private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 150)! - var height: CGFloat = 100 { + var height: CGFloat = 150 { didSet { if height != oldValue { sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)! From e95afdc2491ba00193122adc00ed02172f4e9d74 Mon Sep 17 00:00:00 2001 From: "Pan, Xinlei (Ryan)" Date: Wed, 15 Jan 2020 16:36:13 -0500 Subject: [PATCH 150/272] update color --- MVMCoreUI/Atoms/Views/GraphView.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index cda77660..1f6ea45b 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -112,7 +112,9 @@ import UIKit //if number of colors is even, need to display gradient layer, otherwise make top layer as solid color layer if graphObject.colors.count % 2 == 0 { leftColors.removeLast() - topLayer.colors = [leftColors.last!, rightColors.first!] + let firstColor = leftColors.last!.uiColor.cgColor + let secondColor = rightColors.first!.uiColor.cgColor + topLayer.colors = [firstColor, secondColor] } else { topLayer.backgroundColor = leftColors.last?.uiColor.cgColor } @@ -125,7 +127,9 @@ import UIKit //count of graidentLayer.colors must be bigger than 1, otherwise set backgroundColor if leftColors.count > 1 { - leftLayer.colors = Array(leftColors) + leftLayer.colors = leftColors.map({ (color) -> CGColor in + return color.uiColor.cgColor + }) } else { leftLayer.backgroundColor = leftColors.first?.uiColor.cgColor } @@ -136,7 +140,9 @@ import UIKit rightLayer.startPoint = CGPoint(x: 0, y: 0) rightLayer.endPoint = CGPoint(x: 0, y: 1) if rightColors.count > 1 { - rightLayer.colors = Array(rightColors) + rightLayer.colors = rightColors.map({ (color) -> CGColor in + return color.uiColor.cgColor + }) } else { rightLayer.backgroundColor = rightColors.first?.uiColor.cgColor } From d69dbc41d00229c4c7d57a29ac9682a047ae5511 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 15 Jan 2020 18:27:56 -0500 Subject: [PATCH 151/272] fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ .../Atoms/Views/MVMCoreUISwitch+Model.swift | 2 +- MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m | 8 +++---- MVMCoreUI/Atoms/Views/Toggle.swift | 9 +++++++ MVMCoreUI/Atoms/Views/ToggleModel.swift | 24 ++++++++++++++----- .../TwoButtonView.swift | 4 ++-- .../SwitchMolecules/LabelSwitch.swift | 12 ++++++++-- .../SwitchMolecules/LabelToggleModel.swift | 16 +++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 2 ++ 9 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 022ed193..5d855ab3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -50,6 +50,7 @@ 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; + 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D223CF9E740021F976 /* LabelToggleModel.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; @@ -333,6 +334,7 @@ 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; + 01C851D223CF9E740021F976 /* LabelToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggleModel.swift; sourceTree = ""; }; 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; @@ -756,6 +758,7 @@ children = ( 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */, D22479892314445E003FCCF9 /* LabelSwitch.swift */, + 01C851D223CF9E740021F976 /* LabelToggleModel.swift */, D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */, ); path = SwitchMolecules; @@ -1438,6 +1441,7 @@ 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, + 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift index 68482f09..e62a8b94 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift +++ b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift @@ -17,7 +17,7 @@ extension MVMCoreUISwitch: ModelMoleculeViewProtocol { FormValidator.setupValidation(molecule: castSelf, delegate: delegateObject?.formValidationProtocol) } - setState(model.on, animated: false) + setState(model.state, animated: false) guard let action = model.action else { return } actionBlock = { diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m index 4b66d519..1c40bc5a 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m @@ -423,16 +423,16 @@ const CGFloat SwitchShakeIntensity = 2; return UIAccessibilityTraitButton; } -- (NSString * _Nullable)formFieldGroupName { - return [self.json string:@"groupName"]; -} - - (NSString *)accessibilityHint { return [MVMCoreUIUtility hardcodedStringWithKey:@"AccToggleHint"]; } #pragma mark FormValidationProtocol +- (NSString * _Nullable)formFieldGroupName { + return [self.json string:@"groupName"]; +} + - (BOOL)isValidField { return self.isOn && [self.json boolForKey:@"required"]; } diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 17d286ac..4e855532 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -332,6 +332,15 @@ public typealias ActionBlockConfirmation = () -> (Bool) layoutIfNeeded() } } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let toggleModel = model as? ToggleModel else { + return + } + + let toggleModelJSON = toggleModel.toJSON() + setWithJSON(toggleModelJSON, delegateObject: delegateObject, additionalData: additionalData) + } } // MARK: - Accessibility diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index df7d2ba8..81602c2a 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -10,32 +10,44 @@ import UIKit public class ToggleModel: MoleculeProtocol { public static var identifier: String = "toggle" + public var moleculeName: String? public var backgroundColor: Color? - public var on: Bool = true + public var state: Bool = true public var action: ActionProtocol? + public var required: Bool? + public var fieldKey: String? enum CodingKeys: String, CodingKey { - case on + case moleculeName + case state case action case backgroundColor + case required + case fieldKey } - public init(_ on: Bool) { - self.on = on + public init(_ state: Bool) { + self.state = state } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - if let on = try typeContainer.decodeIfPresent(Bool.self, forKey: .on) { - self.on = on + if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { + self.state = state } action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(state, forKey: .state) + try container.encodeIfPresent(required, forKey: .required) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) } } diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index b2f43529..9a7bd952 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -297,8 +297,8 @@ extension TwoButtonView { } } -extension TwoButtonView: MoleculeViewProtocol { - func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { +extension TwoButtonView: ModelMoleculeViewProtocol { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? TwoButtonViewModel else { return } setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil) setDefaultCustom() diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift index 50c19c1d..0713d40f 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift @@ -8,9 +8,9 @@ import UIKit -@objcMembers public class LabelSwitch: ViewConstrainingView { +@objcMembers public class LabelSwitch: ViewConstrainingView, ModelMoleculeViewProtocol { let label = Label.commonLabelB1(true) - let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault() + let mvmSwitch = Toggle() // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { @@ -40,6 +40,14 @@ import UIKit label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData) mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } + + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let labelToggleModel = model as? LabelToggleModel else { + return + } + label.setWithModel(labelToggleModel.label, delegateObject, additionalData) + mvmSwitch.setWithModel(labelToggleModel.toggle, delegateObject, additionalData) + } public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return MVMCoreUISwitch.estimatedHeight(forRow: json, delegateObject: delegateObject) diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift new file mode 100644 index 00000000..6ac592d6 --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift @@ -0,0 +1,16 @@ +// +// LabelToggle.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 1/15/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class LabelToggleModel: MoleculeProtocol { + public static var identifier: String = "labelToggle" + public var backgroundColor: Color? + public var label: LabelModel + public var toggle: ToggleModel +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 1a041e2c..d84f48b7 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -12,6 +12,7 @@ import Foundation public static func registerObjects() { ModelRegistry.register(LabelModel.self) ModelRegistry.register(HeaderModel.self) + ModelRegistry.register(FooterModel.self) ModelRegistry.register(HeadlineBodyModel.self) ModelRegistry.register(MoleculeStackModel.self) ModelRegistry.register(StackItemModel.self) @@ -51,5 +52,6 @@ import Foundation ModelRegistry.register(LeftRightLabelModel.self) ModelRegistry.register(CaretViewModel.self) ModelRegistry.register(CaretLinkModel.self) + ModelRegistry.register(LabelToggleModel.self) } } From de27398c49de13fac16143703c90698db43fb865 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 15 Jan 2020 18:59:48 -0500 Subject: [PATCH 152/272] leftRightLabelView --- MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index 5e091446..be703bef 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -9,7 +9,7 @@ import UIKit @objcMembers public class LeftRightLabelModel: MoleculeProtocol { - public static var identifier: String = "leftRightLabel" + public static var identifier: String = "leftRightLabelView" public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel From e3b0b43272c38917d2abc15f68d74e872c5bb211 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Thu, 16 Jan 2020 10:30:20 -0500 Subject: [PATCH 153/272] update link method --- MVMCoreUI/Atoms/Buttons/Link.swift | 12 ++++++++++++ MVMCoreUI/BaseClasses/Button.swift | 12 ++++++++++++ .../OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 1 - 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 3b6cabb8..39187ac8 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -109,6 +109,18 @@ extension Link { } } +extension Link: ModelMoleculeViewProtocol { + public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let model = model as? LinkModel else { return } + setTitle(model.title, for: .normal) + setTitleColor(model.textColor.uiColor, for: .normal) + isEnabled = model.enabled + backgroundColor = model.backgroundColor?.uiColor + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) + } +} + + // MARK: - MVMCoreUIMoleculeViewProtocol extension Link { diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 356ef59d..816063f4 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -84,6 +84,18 @@ public typealias ButtonAction = (Button) -> () } } } + + public func set(with action: ActionProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + buttonDelegate = delegateObject?.buttonDelegate + addActionBlock(event: .touchUpInside) { [weak self] (sender) in + guard let self = self else { return } + if let data = try? action.encode(using: JSONEncoder()), + let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any], + delegateObject?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + } + } } // MARK: - MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 19c4d9ef..5a4bfd5b 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -30,7 +30,6 @@ @"line": Line.class, @"link": Link.class, @"button": PrimaryButton.class, - @"link": MFTextButton.class, @"header": StandardHeaderView.class, @"stack": MoleculeStackView.class, @"twoButtonView": TwoButtonView.class, From 9bf9d711951dc078eab2b1268f2ae28e2f5fe2b1 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 16 Jan 2020 13:30:30 -0500 Subject: [PATCH 154/272] optional --- MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift | 2 +- .../VerticalCombinationViews/HeadlineBodyModel.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index be703bef..73abb4d6 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -12,5 +12,5 @@ import UIKit public static var identifier: String = "leftRightLabelView" public var backgroundColor: Color? public var leftText: LabelModel - public var rightText: LabelModel + public var rightText: LabelModel? } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 6ce51d3e..bc63c12c 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -10,8 +10,8 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeProtocol { public static var identifier: String = "headlineBody" - public var headline: LabelModel - public var body: LabelModel + public var headline: LabelModel? + public var body: LabelModel? public var style: String? public var backgroundColor: Color? From 71efaa9026dd839c0af64a1c3e8220e4c4907354 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 16 Jan 2020 13:51:55 -0500 Subject: [PATCH 155/272] alignment --- MVMCoreUI/Organisms/MoleculeStackView.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 9f2f526f..aad48bd0 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -107,8 +107,6 @@ open class MoleculeStackView: Container { } restack() - stackModel?.useHorizontalMargins = moleculesShouldSetHorizontalMargins - stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins } open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { From b876d81922373bda1a1ecabe0ca8fea1aa3aa6bf Mon Sep 17 00:00:00 2001 From: "Pan, Xinlei (Ryan)" Date: Thu, 16 Jan 2020 14:29:30 -0500 Subject: [PATCH 156/272] two button view's internal spacing constraint change for a huge height bug --- .../TwoButtonView.swift | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 9a7bd952..10a41daa 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -84,17 +84,19 @@ import UIKit } open func setupConstraintsForViewWithButtons() { - guard let viewForButtons = viewForButtons, let primaryButton = primaryButton, let secondaryButton = secondaryButton else { - return - } + guard let viewForButtons = viewForButtons, + let primaryButton = primaryButton, + let secondaryButton = secondaryButton + else { return } + viewForButtons.addSubview(primaryButton) viewForButtons.addSubview(secondaryButton) secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1).isActive = true - secondaryButton.topAnchor.constraint(equalTo: viewForButtons.topAnchor).isActive = true - primaryButton.topAnchor.constraint(equalTo: viewForButtons.topAnchor).isActive = true - viewForButtons.bottomAnchor.constraint(equalTo: secondaryButton.bottomAnchor).isActive = true - viewForButtons.bottomAnchor.constraint(equalTo: primaryButton.bottomAnchor).isActive = true - NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[leftButton]-10-[rightButton]-0-|", options: NSLayoutConstraint.FormatOptions.alignAllCenterY, metrics: nil, views: ["leftButton": secondaryButton, "rightButton": primaryButton])) + NSLayoutConstraint.constraintPinSubview(primaryButton, pinTop: true, pinBottom: true, pinLeft: true, pinRight: false) + NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true) + let constraint = secondaryButton.leadingAnchor.constraint(equalTo: primaryButton.trailingAnchor, constant: 10) + constraint.priority = UILayoutPriority(900) + constraint.isActive = true } func setupWithTwoButtons() { @@ -107,7 +109,6 @@ import UIKit pinView(toSuperView: viewForButtons) alignCenterHorizontal() - createPrimaryButton() createSecondaryButton() setupConstraintsForViewWithButtons() From db0d9f43531d19da30b7991a081e738133735d51 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 16 Jan 2020 14:59:24 -0500 Subject: [PATCH 157/272] Container protocol Doughnut chart model Break stack into regular and dynamic components --- MVMCoreUI.xcodeproj/project.pbxproj | 65 +++-- MVMCoreUI/Containers/Container.swift | 15 +- MVMCoreUI/Containers/ContainerProtocol.swift | 15 ++ .../{ => Doughnut}/DoughnutChart.swift | 80 +++--- .../Doughnut}/DoughnutChartModel.swift | 22 +- .../{ => Doughnut}/DoughnutChartView.swift | 103 ++++--- .../Molecules/Items/MoleculeStackItem.swift | 16 ++ .../Items/MoleculeStackItemModel.swift | 45 ++++ MVMCoreUI/Molecules/Items/StackItem.swift | 8 +- .../Molecules/Items/StackItemModel.swift | 39 +-- .../Items/StackItemModelProtocol.swift | 15 ++ .../EyebrowHeadlineBodyLink.swift | 25 +- MVMCoreUI/Organisms/MoleculeStackModel.swift | 10 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 252 +----------------- MVMCoreUI/Organisms/Stack.swift | 239 +++++++++++++++++ MVMCoreUI/Organisms/StackModel.swift | 22 ++ MVMCoreUI/Organisms/StackModelProtocol.swift | 18 ++ .../MVMCoreUIMoleculeMappingObject.m | 1 - .../OtherHandlers/MoleculeObjectMapping.swift | 4 +- .../Templates/MoleculeStackTemplate.swift | 4 +- .../NSLayoutConstraintAxis+Extension.swift | 31 +++ 21 files changed, 602 insertions(+), 427 deletions(-) create mode 100644 MVMCoreUI/Containers/ContainerProtocol.swift rename MVMCoreUI/Molecules/{ => Doughnut}/DoughnutChart.swift (65%) rename MVMCoreUI/{Models/Molecules => Molecules/Doughnut}/DoughnutChartModel.swift (50%) rename MVMCoreUI/Molecules/{ => Doughnut}/DoughnutChartView.swift (55%) create mode 100644 MVMCoreUI/Molecules/Items/MoleculeStackItem.swift create mode 100644 MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift create mode 100644 MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift create mode 100644 MVMCoreUI/Organisms/Stack.swift create mode 100644 MVMCoreUI/Organisms/StackModel.swift create mode 100644 MVMCoreUI/Organisms/StackModelProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 32d9b7ba..e2e09a72 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -105,10 +105,10 @@ 94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; }; 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; - C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; }; C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; }; C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; }; + C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; @@ -128,10 +128,17 @@ D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; D260105323CEA61600764D80 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105223CEA61600764D80 /* ToggleModel.swift */; }; D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */; }; + D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105823D0A92900764D80 /* ContainerProtocol.swift */; }; + D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105A23D0BB7100764D80 /* StackModelProtocol.swift */; }; + D260105D23D0BCD400764D80 /* Stack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105C23D0BCD400764D80 /* Stack.swift */; }; + D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105E23D0BFFC00764D80 /* StackItem.swift */; }; + D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */; }; + D260106323D0C05000764D80 /* StackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106223D0C05000764D80 /* StackItemModel.swift */; }; + D260106523D0CEA700764D80 /* StackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106423D0CEA700764D80 /* StackModel.swift */; }; D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* StackItemModel.swift */; }; + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; @@ -282,7 +289,7 @@ D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; }; - D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* StackItem.swift */; }; + D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */; }; DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; }; DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; }; DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; @@ -338,7 +345,7 @@ 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; - 01EB368A23609801006832FA /* StackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StackItemModel.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 = ""; }; @@ -380,10 +387,10 @@ 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; - C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = ""; }; C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = ""; }; C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = ""; }; C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = ""; }; + C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; @@ -403,6 +410,13 @@ D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = ""; }; D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUISwitch+Model.swift"; sourceTree = ""; }; + D260105823D0A92900764D80 /* ContainerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerProtocol.swift; sourceTree = ""; }; + D260105A23D0BB7100764D80 /* StackModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackModelProtocol.swift; sourceTree = ""; }; + D260105C23D0BCD400764D80 /* Stack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stack.swift; sourceTree = ""; }; + D260105E23D0BFFC00764D80 /* StackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItem.swift; sourceTree = ""; }; + D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItemModelProtocol.swift; sourceTree = ""; }; + D260106223D0C05000764D80 /* StackItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItemModel.swift; sourceTree = ""; }; + D260106423D0CEA700764D80 /* StackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackModel.swift; sourceTree = ""; }; D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = ""; }; D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = ""; }; D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; @@ -572,7 +586,7 @@ D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainer.swift; sourceTree = ""; }; - D2FB151C23A40F1500C20E10 /* StackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItem.swift; sourceTree = ""; }; + D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackItem.swift; sourceTree = ""; }; DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftRightLabelView.swift; sourceTree = ""; }; DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = ""; }; @@ -665,10 +679,6 @@ 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( - C695A69323C9909000BFB94E /* DoughnutChartModel.swift */, - 01EB368923609801006832FA /* ListItemModel.swift */, - 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, - 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 011B58F323A2CCC80085F53C /* DropDownModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, @@ -806,6 +816,9 @@ D22479902316A9CB003FCCF9 /* Organisms */ = { isa = PBXGroup; children = ( + D260105A23D0BB7100764D80 /* StackModelProtocol.swift */, + D260106423D0CEA700764D80 /* StackModel.swift */, + D260105C23D0BCD400764D80 /* Stack.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, D2A6390022CBB1820052ED1F /* Carousel.swift */, @@ -826,8 +839,11 @@ D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */, 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */, D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */, - 01EB368A23609801006832FA /* StackItemModel.swift */, - D2FB151C23A40F1500C20E10 /* StackItem.swift */, + D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */, + D260106223D0C05000764D80 /* StackItemModel.swift */, + D260105E23D0BFFC00764D80 /* StackItem.swift */, + 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, + D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */, ); path = Items; sourceTree = ""; @@ -841,6 +857,16 @@ path = Legacy; sourceTree = ""; }; + D260105723CF9CC500764D80 /* Doughnut */ = { + isa = PBXGroup; + children = ( + C695A69323C9909000BFB94E /* DoughnutChartModel.swift */, + C695A69523C990BC00BFB94E /* DoughnutChart.swift */, + C695A69723C990C200BFB94E /* DoughnutChartView.swift */, + ); + path = Doughnut; + sourceTree = ""; + }; D29DF0C221E404D4003B2FB9 = { isa = PBXGroup; children = ( @@ -937,8 +963,7 @@ D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, - C695A69523C990BC00BFB94E /* DoughnutChart.swift */, - C695A69723C990C200BFB94E /* DoughnutChartView.swift */, + D260105723CF9CC500764D80 /* Doughnut */, ); path = Molecules; sourceTree = ""; @@ -986,6 +1011,7 @@ D29DF2B721E7BE79003B2FB9 /* TabBarController */, D29DF2B621E7BE66003B2FB9 /* SplitViewController */, D2B18B93236214AD00A9AEDC /* NavigationController.swift */, + D260105823D0A92900764D80 /* ContainerProtocol.swift */, D243859823A16B1800332775 /* Container.swift */, ); path = Containers; @@ -1424,7 +1450,7 @@ 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, - D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */, + D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, @@ -1449,6 +1475,7 @@ D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, + D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, @@ -1465,6 +1492,7 @@ D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */, C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, + D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, @@ -1486,7 +1514,7 @@ D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, - D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */, + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, @@ -1504,6 +1532,7 @@ D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, + D260105D23D0BCD400764D80 /* Stack.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, @@ -1559,9 +1588,11 @@ D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, D243859923A16B1800332775 /* Container.swift in Sources */, + D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, + D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, 0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */, @@ -1601,6 +1632,7 @@ 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, 0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, + D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */, @@ -1616,6 +1648,7 @@ D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, + D260106523D0CEA700764D80 /* StackModel.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/MVMCoreUI/Containers/Container.swift b/MVMCoreUI/Containers/Container.swift index ab495b81..43fd62c8 100644 --- a/MVMCoreUI/Containers/Container.swift +++ b/MVMCoreUI/Containers/Container.swift @@ -196,7 +196,7 @@ public class ContainerHelper: NSObject { } } -open class Container: View { +open class Container: View, ContainerProtocol { var view: UIView? let containerHelper = ContainerHelper() var containerModel: ContainerModelProtocol? { @@ -208,6 +208,19 @@ open class Container: View { guard let containerModel = model as? ContainerModelProtocol else { return } containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol) } + + // MARK:- ContainerProtocol + public func alignHorizontal(_ alignment: UIStackView.Alignment) { + containerHelper.alignHorizontal(alignment) + } + + public func alignVertical(_ alignment: UIStackView.Alignment) { + containerHelper.alignVertical(alignment) + } + + public func constrainView(_ view: UIView) { + containerHelper.constrainView(view) + } } // MARK: - MVMCoreViewProtocol diff --git a/MVMCoreUI/Containers/ContainerProtocol.swift b/MVMCoreUI/Containers/ContainerProtocol.swift new file mode 100644 index 00000000..8079ca24 --- /dev/null +++ b/MVMCoreUI/Containers/ContainerProtocol.swift @@ -0,0 +1,15 @@ +// +// ContainerProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ContainerProtocol { + func alignHorizontal(_ alignment: UIStackView.Alignment) + func alignVertical(_ alignment: UIStackView.Alignment) + func constrainView(_ view: UIView) +} diff --git a/MVMCoreUI/Molecules/DoughnutChart.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift similarity index 65% rename from MVMCoreUI/Molecules/DoughnutChart.swift rename to MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift index d7f25ac6..5b0763e6 100644 --- a/MVMCoreUI/Molecules/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift @@ -8,21 +8,23 @@ import UIKit -open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { - - var containerView = MVMCoreUICommonViewsUtility.commonView() - var containerLayer = CALayer() +open class DoughnutChart: View { + var doughnutLayer = CALayer() var titleLabel = Label.commonLabelH3(true) var subTitleLabel = Label.commonLabelB2(true) var doughnutChartModel: DoughnutChartModel? { get { return model as? DoughnutChartModel } } - var labelContainer = ViewConstrainingView.empty() + var labelContainer = MVMCoreUICommonViewsUtility.commonView() + var labelContainerLeftConstraint: NSLayoutConstraint? + var labelContainerTopConstraint: NSLayoutConstraint? + var labelContainerBottomConstraint: NSLayoutConstraint? + var labelContainerRightConstraint: NSLayoutConstraint? var heightConstraint: NSLayoutConstraint? - private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 150)! - - var height: CGFloat = 150 { + static let heightConstant: CGFloat = 150 + private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)! + var height: CGFloat = heightConstant { didSet { if height != oldValue { sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)! @@ -47,17 +49,16 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { clearLayers() } - public override func setAsMolecule() { + public override func setAsMolecule() { titleLabel.setAsMolecule() subTitleLabel.setAsMolecule() } open override func setupView() { super.setupView() - guard containerView.superview == nil else { + guard labelContainer.superview == nil else { return } - addSubview(containerView) addSubview(labelContainer) labelContainer.addSubview(titleLabel) @@ -68,36 +69,35 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { //Make label font size to adjust width if label content is high titleLabel.numberOfLines = 1 titleLabel.adjustsFontSizeToFitWidth = true - - containerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true - containerView.topAnchor.constraint(equalTo: topAnchor).isActive = true - bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true - trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true - containerView.layer.addSublayer(containerLayer) - heightConstraint = containerView.heightAnchor.constraint(equalToConstant: + + layer.addSublayer(doughnutLayer) + heightConstraint = heightAnchor.constraint(equalToConstant: sizeObject.getValueBasedOnApplicationWidth()) heightConstraint?.isActive = true - containerView.widthAnchor.constraint(equalTo: containerView.heightAnchor).isActive = true + widthAnchor.constraint(equalTo: heightAnchor).isActive = true - labelContainer.leftPin = labelContainer.leftAnchor.constraint(greaterThanOrEqualTo: containerView.leftAnchor, constant: lineWidth()) - labelContainer.leftPin?.isActive = true - labelContainer.topPin = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: containerView.topAnchor, constant: lineWidth()) - labelContainer.topPin?.isActive = true - labelContainer.centerYAnchor.constraint(equalTo: containerView.centerYAnchor).isActive = true - labelContainer.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true + labelContainerLeftConstraint = labelContainer.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor, constant: lineWidth()) + labelContainerLeftConstraint?.isActive = true + labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: lineWidth()) + labelContainerTopConstraint?.isActive = true + labelContainerRightConstraint = rightAnchor.constraint(greaterThanOrEqualTo: labelContainer.rightAnchor, constant: lineWidth()) + labelContainerRightConstraint?.isActive = true + labelContainerBottomConstraint = bottomAnchor.constraint(greaterThanOrEqualTo: labelContainer.bottomAnchor, constant: lineWidth()) + labelContainerBottomConstraint?.isActive = true + labelContainer.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true + labelContainer.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true NSLayoutConstraint.constraintPinSubview(titleLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true) NSLayoutConstraint.constraintPinSubview(subTitleLabel, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) _ = NSLayoutConstraint(pinFirstView: titleLabel, toSecondView: subTitleLabel, withConstant: 0, directionVertical: true) //Rotate view for initial draw - containerLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0) - + doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0) } open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) clearLayers() - guard let doughnutChartModel = model as? DoughnutChartModel else { + guard let doughnutChartModel = doughnutChartModel else { return } titleLabel.setWithModel(doughnutChartModel.title, delegateObject, additionalData) @@ -111,7 +111,7 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { func drawGraph() { clearLayers() let widthHeight = sizeObject.getValueBasedOnApplicationWidth() - containerLayer.frame = CGRect(x: 0, y: 0, + doughnutLayer.frame = CGRect(x: 0, y: 0, width: widthHeight, height: widthHeight) if let doughnutChart = doughnutChartModel { @@ -122,17 +122,16 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { } } - func drawBar(_ chartModel: ChartItemModel, _ prevPercent: CGFloat) -> CGFloat { + func drawBar(_ chartModel: DoughnutChartItemModel, _ prevPercent: CGFloat) -> CGFloat { let shapeLayer = CAShapeLayer() - shapeLayer.frame = containerLayer.frame + shapeLayer.frame = doughnutLayer.frame shapeLayer.lineWidth = lineWidth() shapeLayer.fillColor = nil - shapeLayer.strokeColor = UIColor.mfGet(forHex: chartModel.color).cgColor + shapeLayer.strokeColor = chartModel.color.uiColor.cgColor let arcCenter = shapeLayer.position - let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0 - //lineSizeObject.getValueBasedOnApplicationWidth() / 2.0 + let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0 let clockwise = true let value: CGFloat = chartModel.percent @@ -146,12 +145,12 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { clockwise: clockwise) shapeLayer.path = circlePath.cgPath - containerLayer.addSublayer(shapeLayer) + doughnutLayer.addSublayer(shapeLayer) return value } func clearLayers() { - containerLayer.sublayers?.forEach({ $0.removeFromSuperlayer() }) + doughnutLayer.sublayers?.forEach({ $0.removeFromSuperlayer() }) } func updateContainer() { @@ -161,7 +160,7 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { } func lineWidth() -> CGFloat { - return doughnutChartModel?.lineWidth ?? 30 + return 30 } func lineGap() -> CGFloat { @@ -174,9 +173,10 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol { } func updateLabelContainer() { - labelContainer.leftPin?.constant = lineWidth() - labelContainer.topPin?.constant = lineWidth() + labelContainerLeftConstraint?.constant = lineWidth() + labelContainerTopConstraint?.constant = lineWidth() + labelContainerRightConstraint?.constant = lineWidth() + labelContainerBottomConstraint?.constant = lineWidth() labelContainer.setNeedsDisplay() } - } diff --git a/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift similarity index 50% rename from MVMCoreUI/Models/Molecules/DoughnutChartModel.swift rename to MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift index 7aab35fd..1f4098e2 100644 --- a/MVMCoreUI/Models/Molecules/DoughnutChartModel.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift @@ -13,16 +13,24 @@ import Foundation public static var identifier: String = "doughnutChart" public var title: LabelModel? public var subtitle: LabelModel? - public var sections: [ChartItemModel] - public var lineWidth: CGFloat? + public var sections: [DoughnutChartItemModel] public var spaceRequired: Bool? + + public init(sections: [DoughnutChartItemModel]) { + self.sections = sections + } } - -@objcMembers public class ChartItemModel: MoleculeProtocol { +@objcMembers public class DoughnutChartItemModel: MoleculeProtocol { public var backgroundColor: Color? + public static var identifier: String = "doughnutChartItem" public var label: LabelModel - public var percent: CGFloat - public var color: String - public static var identifier: String = "chartItem" + @Percent public var percent: CGFloat + public var color: Color + + public init(percent: CGFloat, color: Color, label: LabelModel) { + self.percent = percent + self.color = color + self.label = label + } } diff --git a/MVMCoreUI/Molecules/DoughnutChartView.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift similarity index 55% rename from MVMCoreUI/Molecules/DoughnutChartView.swift rename to MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift index a54c04d4..4893edbc 100644 --- a/MVMCoreUI/Molecules/DoughnutChartView.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift @@ -9,54 +9,48 @@ import Foundation @objcMembers open class DoughnutChartView: View { - var doughnutChart = DoughnutChart(frame: CGRect.zero) var colorLablesStack = ColorViewLabelsStack() - var container = MVMCoreUICommonViewsUtility.commonView() var doughnutChartModel: DoughnutChartModel? { get { return model as? DoughnutChartModel } } open override func setupView() { super.setupView() - guard container.superview == nil else { + guard doughnutChart.superview == nil else { return } - - addSubview(container) doughnutChart.translatesAutoresizingMaskIntoConstraints = false - container.addSubview(doughnutChart) + addSubview(doughnutChart) colorLablesStack.translatesAutoresizingMaskIntoConstraints = false - container.addSubview(colorLablesStack) + addSubview(colorLablesStack) - NSLayoutConstraint.constraintPinSubview(container, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true) - doughnutChart.leadingAnchor.constraint(equalTo: container.leadingAnchor).isActive = true - doughnutChart.topAnchor.constraint(equalTo: container.topAnchor, constant: PaddingFour).isActive = true - container.bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true + doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true + doughnutChart.topAnchor.constraint(equalTo: topAnchor, constant: PaddingFour).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true - let containerBottomAnchor = container.bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor) - containerBottomAnchor.priority = UILayoutPriority(rawValue: 200) - containerBottomAnchor.isActive = true + let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor) + doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200) + doughnutBottomAnchor.isActive = true - let colorLablesBottomAnchor = container.bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor) + let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor) colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204) colorLablesBottomAnchor.isActive = true let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor) - colorLablesTopAnchor.priority = UILayoutPriority(rawValue: 204) + colorLablesTopAnchor.priority = .defaultLow colorLablesTopAnchor.isActive = true colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).isActive = true - container.bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true - container.trailingAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.trailingAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true + trailingAnchor.constraint(equalTo: colorLablesStack.trailingAnchor).isActive = true let centerY = colorLablesStack.centerYAnchor.constraint(equalTo: doughnutChart.centerYAnchor) - centerY.priority = .defaultLow + centerY.priority = UILayoutPriority(rawValue: 500) centerY.isActive = true colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true colorLablesStack.backgroundColor = UIColor.clear - } open override func updateView(_ size: CGFloat) { @@ -67,56 +61,51 @@ import Foundation open override func reset() { super.reset() + doughnutChart.reset() colorLablesStack.reset() } open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) - doughnutChart.clearLayers() - colorLablesStack.removeAllItemViews() + + guard let model = doughnutChartModel else { return } doughnutChart.setWithModel(model, delegateObject, additionalData) - colorLablesStack.setWithModel(model, delegateObject, additionalData) + + // Create the stack model + var stackItems: [MoleculeStackItemModel] = [] + for item in model.sections { + stackItems.append(MoleculeStackItemModel(with: item)) + } + let stack = MoleculeStackModel(molecules: stackItems) + stack.verticalAlignment = .fill + colorLablesStack.setWithModel(stack, delegateObject, additionalData) } open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - if model == nil { - let data = try! JSONSerialization.data(withJSONObject: json!) - let decoder = JSONDecoder() - let model = try! decoder.decode(DoughnutChartModel.self, from: data) - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) - } else { - setWithModel(model, delegateObject, additionalData as? [String : AnyHashable]) - } + guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: DoughnutChartModel.self) else { return } + setWithModel(model, delegateObject, additionalData) + } +} + +extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { + open func horizontalAlignment() -> UIStackView.Alignment { + return .leading } - } class ColorViewLabelsStack: MoleculeStackView { - - var dougnutChartModel: DoughnutChartModel? - override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - let previousModel = self.dougnutChartModel - removeAllItemViews() - guard let dougnutChartModel = model as? DoughnutChartModel else { - return + override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { + guard let stackItemModels = stackModel?.molecules else { return } + for model in stackItemModels { + let view = ColorViewWithLabel() + let stackItem = MoleculeStackItem(andContain: view) + stackItem.setWithModel(model, delegate, nil) + stackItems.append(stackItem) } - var items: [StackItem]? - if previousModel?.sections.count == dougnutChartModel.sections.count { - items = stackItems - } - stackItems = [] - self.model = MoleculeStackModel(molecules: []) - for (index, chartItemModel) in dougnutChartModel.sections.enumerated() { - let colorViewWithLabel = items?[index].view as? ColorViewWithLabel ?? ColorViewWithLabel() - colorViewWithLabel.setWithModel(chartItemModel, delegateObject, additionalData) - addView(colorViewWithLabel, lastItem: index == dougnutChartModel.sections.count - 1) - } - self.dougnutChartModel = dougnutChartModel - restack() } } -class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol { +class ColorViewWithLabel: View { var label = Label.commonLabelB2(true) var colorView = MVMCoreUICommonViewsUtility.commonView() @@ -140,9 +129,8 @@ class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol { label.leadingAnchor.constraint(equalTo: colorView.trailingAnchor, constant: PaddingOne).isActive = true label.topAnchor.constraint(equalTo: topAnchor).isActive = true - trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true + trailingAnchor.constraint(equalTo: label.trailingAnchor).isActive = true bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true - } override func updateView(_ size: CGFloat) { @@ -163,11 +151,10 @@ class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol { override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let chartItemModel = model as? ChartItemModel else { + guard let chartItemModel = model as? DoughnutChartItemModel else { return } label.setWithModel(chartItemModel.label, delegateObject, additionalData) - colorView.backgroundColor = UIColor.mfGet(forHex: chartItemModel.color) + colorView.backgroundColor = chartItemModel.color.uiColor } - } diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift new file mode 100644 index 00000000..d883f93e --- /dev/null +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift @@ -0,0 +1,16 @@ +// +// StackItem.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 12/13/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// +// A list item that contains a molecule + +import UIKit + +open class MoleculeStackItem: MoleculeContainer { + var stackItemModel: StackItemModel? { + get { return model as? StackItemModel } + } +} diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift new file mode 100644 index 00000000..e2ee337d --- /dev/null +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift @@ -0,0 +1,45 @@ +// +// MoleculeStackItem.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/4/19. +// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// + +import Foundation + +@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol, StackItemModelProtocol { + public static var identifier: String = "stackItem" + public var backgroundColor: Color? + public var spacing: CGFloat? + public var percent: Int? + public var gone: Bool = false + + enum MoleculeStackItemCodingKeys: String, CodingKey { + case spacing + case percent + case gone + } + + public override init(with moleculeModel: MoleculeProtocol) { + super.init(with: moleculeModel) + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self) + spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) + percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent) + if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) { + self.gone = gone + } + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self) + try container.encodeIfPresent(spacing, forKey: .spacing) + try container.encodeIfPresent(percent, forKey: .percent) + try container.encode(gone, forKey: .gone) + } +} diff --git a/MVMCoreUI/Molecules/Items/StackItem.swift b/MVMCoreUI/Molecules/Items/StackItem.swift index 59c30962..07cae3d0 100644 --- a/MVMCoreUI/Molecules/Items/StackItem.swift +++ b/MVMCoreUI/Molecules/Items/StackItem.swift @@ -2,13 +2,13 @@ // StackItem.swift // MVMCoreUI // -// Created by Scott Pfeil on 12/13/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. +// Created by Scott Pfeil on 1/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. // -import UIKit +import Foundation -open class StackItem: MoleculeContainer { +open class StackItem: Container { var stackItemModel: StackItemModel? { get { return model as? StackItemModel } } diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index d19f2401..9ab86687 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -1,45 +1,20 @@ // -// MoleculeStackItem.swift +// StackItemModel.swift // MVMCoreUI // -// Created by Suresh, Kamlesh on 10/4/19. -// Copyright © 2019 Suresh, Kamlesh. All rights reserved. +// Created by Scott Pfeil on 1/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. // import Foundation -@objcMembers public class StackItemModel: MoleculeContainerModel, MoleculeProtocol { - public static var identifier: String = "stackItem" - public var backgroundColor: Color? +@objcMembers public class StackItemModel: StackItemModelProtocol, Codable { public var spacing: CGFloat? public var percent: Int? public var gone: Bool = false - enum MoleculeStackItemCodingKeys: String, CodingKey { - case spacing - case percent - case gone - } - - public override init(with moleculeModel: MoleculeProtocol) { - super.init(with: moleculeModel) - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self) - spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) - percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent) - if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) { - self.gone = gone - } - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self) - try container.encodeIfPresent(spacing, forKey: .spacing) - try container.encodeIfPresent(percent, forKey: .percent) - try container.encode(gone, forKey: .gone) + public convenience init(gone: Bool) { + self.init() + self.gone = gone } } diff --git a/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift b/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift new file mode 100644 index 00000000..2223ed39 --- /dev/null +++ b/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift @@ -0,0 +1,15 @@ +// +// StackItemModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol StackItemModelProtocol { + var spacing: CGFloat? { get set } + var percent: Int? { get set } + var gone: Bool { get set } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index d5557eca..01844e07 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -19,7 +19,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { } @objcMembers open class EyebrowHeadlineBodyLink: Container { - let stack = MoleculeStackView(frame: .zero) + let stack = Stack(frame: .zero) let eyebrow = Label.commonLabelB3(true) let headline = Label.commonLabelB1(true) let body = Label.commonLabelB2(true) @@ -34,19 +34,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { guard stack.superview == nil else { return } - let eyebrowStackItem = StackItemModel(with: casteModel!.eyeBrow!) - let headlineStackItem = StackItemModel(with: casteModel!.headline!) - let bodyStackItem = StackItemModel(with: casteModel!.body!) - let linkStackItem = StackItemModel(with: casteModel!.link!) - - // To visually take into account the extra padding in the intrinsic content of a button. - linkStackItem.spacing = -6 - - let stackModel = MoleculeStackModel(molecules: [eyebrowStackItem,headlineStackItem,bodyStackItem,linkStackItem]) - stackModel.spacing = 0 - stack.model = stackModel stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)] - addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) } @@ -64,13 +52,14 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { headline.setWithModel(casteModel?.headline, delegateObject, additionalData) body.setWithModel(casteModel?.body, delegateObject, additionalData) link.setWithModel(casteModel?.link, delegateObject, additionalData) - - (stack.stackItems[0].model as? StackItemModel)?.gone = !eyebrow.hasText - (stack.stackItems[1].model as? StackItemModel)?.gone = !headline.hasText - (stack.stackItems[2].model as? StackItemModel)?.gone = !body.hasText - (stack.stackItems[3].model as? StackItemModel)?.gone = ((link.titleLabel?.text?.count) ?? 0) == 0 + + // Create a stack model to use for the internal stack. + let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText),StackItemModel(gone: !headline.hasText),StackItemModel(gone: !body.hasText),StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)]) + stackModel.spacing = 0 + stack.model = stackModel stack.restack() } + open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: EyebrowHeadlineBodyLinkModel.self) else { return } setWithModel(model, delegateObject, additionalData) diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift index 2a149e73..7136718c 100644 --- a/MVMCoreUI/Organisms/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -5,17 +5,19 @@ // 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, MoleculeProtocol { +@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol, StackModelProtocol { public static var identifier: String = "stack" public var backgroundColor: Color? - public var molecules: [StackItemModel] + public var molecules: [MoleculeStackItemModel] public var axis: NSLayoutConstraint.Axis = .vertical public var spacing: CGFloat = 16.0 + public var useStackSpacingBeforeFirstItem = false - public init(molecules: [StackItemModel]) { + public init(molecules: [MoleculeStackItemModel]) { self.molecules = molecules super.init() } @@ -29,7 +31,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self) - molecules = try typeContainer.decode([StackItemModel].self, forKey: .molecules) + 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 } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 9f2f526f..2674de0a 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -8,193 +8,22 @@ import UIKit -open class MoleculeStackView: Container { - var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() - var useStackSpacingBeforeFirstItem = false - var stackModel: MoleculeStackModel? { +open class MoleculeStackView: Stack { + override var stackModel: MoleculeStackModel? { get { return model as? MoleculeStackModel } } - var stackItems: [StackItem] = [] - var moleculesShouldSetHorizontalMargins = false - var moleculesShouldSetVerticalMargins = false - - // MARK: - Helpers - public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) { - let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant) - constraint.priority = priority - constraint.isActive = true - } - - /// Restacks the existing items. - func restack() { - removeAllItemViews() - let stackItems = self.stackItems - self.stackItems = [] - let lastItem = stackItems.last(where: { (item) -> Bool in - return !item.stackItemModel!.gone - }) - for item in stackItems { - addStackItem(item, lastItem: item === lastItem) - } - } - - /// Removes all stack items views from the view. - func removeAllItemViews() { - for item in stackItems { - item.removeFromSuperview() - } + /// Convenience function, adds a molecule to a MoleculeStackItem to the MoleculeStack + func addMolecule(_ view: View, lastItem: Bool) { + guard let model = view.model else { return } + let stackItemModel = MoleculeStackItemModel(with: model) + let stackItem = MoleculeStackItem(andContain: view) + addView(stackItem, stackItemModel, lastItem: lastItem) } - // MARK: - Inits - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.init(frame: CGRect.zero) - setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - // MARK: - MFViewProtocol - public override func setupView() { - super.setupView() - guard contentView.superview == nil else { - return - } - MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0) - translatesAutoresizingMaskIntoConstraints = false - backgroundColor = .clear - addSubview(contentView) - containerHelper.constrainView(contentView) - contentView.setContentHuggingPriority(.defaultHigh, for: .vertical) - contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal) - } - - public override func updateView(_ size: CGFloat) { - super.updateView(size) - for item in stackItems { - item.updateView(size) - } - } - - // MARK: - MVMCoreUIMoleculeViewProtocol - public override func reset() { - super.reset() - backgroundColor = .clear - for item in stackItems { - item.reset() - } - } - - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - let previousModel = stackModel - super.setWithModel(model, delegateObject, additionalData) - removeAllItemViews() - - // If the items in the stack are different, clear them, create new ones. - if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) { - stackItems = [] - createStackItemsFromModel(with: delegateObject) - } else if let models = stackModel?.molecules { - for (index, element) in models.enumerated() { - stackItems[index].setWithModel(element, delegateObject, additionalData) - } - } - - restack() - stackModel?.useHorizontalMargins = moleculesShouldSetHorizontalMargins - stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins - } - - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - if model == nil { - let data = try! JSONSerialization.data(withJSONObject: json!) - let decoder = JSONDecoder() - let model = try! decoder.decode(MoleculeStackModel.self, from: data) - setWithModel(model, delegateObject, additionalData) - } else { - setWithModel(model, delegateObject, additionalData) - } - } - - public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - // This will aggregate names of molecules to make an id. - guard let model = model as? MoleculeStackModel else { - return "stack<>" - } - var name = "stack<" - for case let item in model.molecules { - if let moleculeName = item.molecule.moleculeName { - if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type, - let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { - name.append(nameForReuse + ",") - } else { - name.append(moleculeName + ",") - } - } - } - name.append(">") - return name - } - - public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - // This will aggregate names of molecules to make an id. - guard let molecules = molecule?.optionalArrayForKey(KeyMolecules) else { - return "stack<>" - } - var name = "stack<" - for case let item as [AnyHashable: Any] in molecules { - if let molecule = item.optionalDictionaryForKey(KeyMolecule), let moleculeName = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) { - name.append(moleculeName + ",") - } - } - name.append(">") - return name - } - - public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let items = json?.optionalArrayForKey(KeyMolecules) else { - return 0 - } - let horizontal = json?.optionalStringForKey("axis") == "horizontal" - var estimatedHeight: CGFloat = 0 - for case let item as [AnyHashable: AnyHashable] in items { - if let molecule = item.optionalDictionaryForKey(KeyMolecule) { - let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.estimatedHeight?(forRow: molecule, delegateObject: delegateObject) - if !horizontal { - // Vertical stack aggregates the items - let spacing = item.optionalCGFloatForKey("spacing") ?? (estimatedHeight != 0 ? (json?.optionalCGFloatForKey("spacing") ?? 16) : 0) - estimatedHeight += ((height ?? 0) + spacing) - } else if let height = height { - // Horizontal stack takes the tallest item. - estimatedHeight = max(estimatedHeight, height) - } - } - } - return estimatedHeight - } - - public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { - guard let items = json?.optionalArrayForKey(KeyMolecules) else { - return nil - } - var modules: [String] = [] - for case let item as [AnyHashable: AnyHashable] in items { - if let molecule = item.optionalDictionaryForKey(KeyMolecule), let modulesForMolecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.requiredModules?(molecule, delegateObject: delegateObject, error: error) { - modules += modulesForMolecule - } - } - return modules.count > 0 ? modules : nil - } - // MARK: - Adding to stack /// Creates all of the stackItems for the stackItemModels - func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { + override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? StackItem { @@ -202,67 +31,4 @@ open class MoleculeStackView: Container { } } } - - /// Adds the view to the stack. - func addView(_ view: View, lastItem: Bool) { - guard let model = view.model else { return } - let stackItem = StackItem(andContain: view) - stackItem.model = StackItemModel(with: model) - addStackItem(stackItem, lastItem: lastItem) - } - - /// Adds the stack item view - private func addStackItem(_ stackItem: StackItem, lastItem: Bool) { - let stackModel = self.stackModel! - let model = stackItem.stackItemModel! - guard !model.gone else { - // Gone views do not show - return - } - contentView.addSubview(stackItem) - stackItem.translatesAutoresizingMaskIntoConstraints = false - - let spacing = model.spacing ?? stackModel.spacing - let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center)) - let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading) - stackItem.containerHelper.alignHorizontal(horizontalAlignment) - stackItem.containerHelper.alignVertical(verticalAlignment) - - let first = stackItems.first { !($0.stackItemModel?.gone ?? false) } == nil - if stackModel.axis == .vertical { - if first { - pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) - } else if let previousView = stackItems.last(where: { item in - return !item.stackItemModel!.gone - }) { - stackItem.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true - } - pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) - pinView(contentView, toView: stackItem, attribute: .trailing, relation: .equal, priority: .required, constant: 0) - if let percent = model.percent { - stackItem.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true - } - if lastItem { - pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0) - } - } else { - if first { - // First horizontal item has no spacing by default unless told otherwise. - pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) - } else if let previousView = stackItems.last(where: { item in - return !item.stackItemModel!.gone - }) { - stackItem.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true - } - pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) - pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0) - if let percent = model.percent { - stackItem.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true - } - if lastItem { - pinView(contentView, toView: stackItem, attribute: .right, relation: .equal, priority: .required, constant: 0) - } - } - stackItems.append(stackItem) - } } diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift new file mode 100644 index 00000000..29f9cd9f --- /dev/null +++ b/MVMCoreUI/Organisms/Stack.swift @@ -0,0 +1,239 @@ +// +// Stack.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class Stack: Container where T: StackModelProtocol { + var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() + var stackModel: T? { + get { return model as? T } + } + var stackItems: [UIView] = [] + + // MARK: - Helpers + public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) { + let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant) + constraint.priority = priority + constraint.isActive = true + } + + /// Restacks the existing items. + func restack() { + removeAllItemViews() + guard let stackModel = stackModel else { return } + let stackItems = self.stackItems + self.stackItems = [] + let lastItemIndex = stackModel.molecules.lastIndex(where: { (item) -> Bool in + return !item.gone + }) + for (index, view) in stackItems.enumerated() { + addView(view, stackModel.molecules[index], lastItem: lastItemIndex == index) + } + } + + /// Removes all stack items views from the view. + func removeAllItemViews() { + for item in stackItems { + item.removeFromSuperview() + } + } + + // MARK: - Inits + public override init(frame: CGRect) { + super.init(frame: frame) + } + + public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + super.init(frame: CGRect.zero) + setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - MFViewProtocol + public override func setupView() { + super.setupView() + guard contentView.superview == nil else { + return + } + MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0) + translatesAutoresizingMaskIntoConstraints = false + backgroundColor = .clear + addSubview(contentView) + containerHelper.constrainView(contentView) + contentView.setContentHuggingPriority(.defaultHigh, for: .vertical) + contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal) + } + + public override func updateView(_ size: CGFloat) { + super.updateView(size) + for item in stackItems { + (item as? MVMCoreViewProtocol)?.updateView(size) + } + } + + // MARK: - MVMCoreUIMoleculeViewProtocol + public override func reset() { + super.reset() + backgroundColor = .clear + for item in stackItems { + (item as? MoleculeViewProtocol)?.reset?() + } + } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + let previousModel = self.model + super.setWithModel(model, delegateObject, additionalData) + removeAllItemViews() + + // If the items in the stack are different, clear them, create new ones. + if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) { + stackItems = [] + createStackItemsFromModel(with: delegateObject) + } else if let models = stackModel?.molecules { + for (index, element) in models.enumerated() { + (stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element as? MoleculeProtocol, delegateObject, additionalData) + } + } + + restack() + } + + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + if model == nil { + let data = try! JSONSerialization.data(withJSONObject: json!) + let decoder = JSONDecoder() + let model = try! decoder.decode(MoleculeStackModel.self, from: data) + setWithModel(model, delegateObject, additionalData) + } else { + setWithModel(model, delegateObject, additionalData) + } + } + + public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + // This will aggregate names of molecules to make an id. + guard let model = model as? MoleculeStackModel else { + return "stack<>" + } + var name = "stack<" + for case let item in model.molecules { + if let moleculeName = item.molecule.moleculeName { + if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type, + let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { + name.append(nameForReuse + ",") + } else { + name.append(moleculeName + ",") + } + } + } + name.append(">") + return name + } + + // Need to update to take into account first spacing flag + public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + guard let model = molecule as? MoleculeStackModel else { return 0 } + let horizontal = model.axis == .horizontal + var estimatedHeight: CGFloat = 0 + for case let item in model.molecules { + if item.gone { continue } + let height = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(forRow: item, delegateObject: delegateObject) ?? 0 + if !horizontal { + // Vertical stack aggregates the items + let spacing = item.spacing ?? model.spacing + estimatedHeight += (height + spacing) + } else { + // Horizontal stack takes the tallest item. + estimatedHeight = max(estimatedHeight, height) + } + } + return estimatedHeight + } + + public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + guard let model = molecule as? MoleculeStackModel else { return nil } + var modules: [String] = [] + for case let item in model.molecules { + if let modulesForMolecule = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.requiredModules(item, delegateObject: delegateObject, error: error) { + modules += modulesForMolecule + } + } + return modules.count > 0 ? modules : nil + } + + // MARK: - Adding to stack + /// Can be subclassed to create views when we get stack item models and have no views yet + func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { + } + + /// Convenience function, adds a view to a StackItem to the Stack + func addViewToItemToStack(_ view: UIView, lastItem: Bool) { + let stackItemModel = StackItemModel() + let stackItem = StackItem(andContain: view) + addView(stackItem, stackItemModel, lastItem: lastItem) + } + + /// Adds the stack item view + func addView(_ view: UIView,_ model: StackItemModelProtocol, lastItem: Bool) { + let stackModel = self.stackModel! + guard !model.gone else { + // Gone views do not show + stackItems.append(view) + return + } + contentView.addSubview(view) + view.translatesAutoresizingMaskIntoConstraints = false + + let spacing = model.spacing ?? stackModel.spacing + if let container = view as? ContainerProtocol { + let verticalAlignment = (model as? ContainerModelProtocol)?.verticalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center)) + let horizontalAlignment = (model as? ContainerModelProtocol)?.horizontalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading) + container.alignHorizontal(horizontalAlignment) + container.alignVertical(verticalAlignment) + } + + let first = contentView.subviews.count == 1 + if stackModel.axis == .vertical { + if first { + pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) + } else if let previousView = stackItems.last(where: { item in + return !model.gone + }) { + view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true + } + pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) + pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0) + if let percent = model.percent { + view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true + } + if lastItem { + pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) + } + } else { + if first { + // First horizontal item has no spacing by default unless told otherwise. + pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0) + } else if let previousView = stackItems.last(where: { item in + return !model.gone + }) { + view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true + } + pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) + pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) + if let percent = model.percent { + view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true + } + if lastItem { + pinView(contentView, toView: view, attribute: .right, relation: .equal, priority: .required, constant: 0) + } + } + stackItems.append(view) + } +} diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Organisms/StackModel.swift new file mode 100644 index 00000000..b647b791 --- /dev/null +++ b/MVMCoreUI/Organisms/StackModel.swift @@ -0,0 +1,22 @@ +// +// StackModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class StackModel: StackModelProtocol, MoleculeProtocol { + public static var identifier: String = "simpleStack" + public var backgroundColor: Color? + public var molecules: [StackItemModel] + @Axis public var axis: NSLayoutConstraint.Axis = .vertical + public var spacing: CGFloat = 16.0 + public var useStackSpacingBeforeFirstItem = false + + public init(molecules: [StackItemModel]) { + self.molecules = molecules + } +} diff --git a/MVMCoreUI/Organisms/StackModelProtocol.swift b/MVMCoreUI/Organisms/StackModelProtocol.swift new file mode 100644 index 00000000..b7385466 --- /dev/null +++ b/MVMCoreUI/Organisms/StackModelProtocol.swift @@ -0,0 +1,18 @@ +// +// StackModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol StackModelProtocol { + associatedtype AnyStackItemModel: StackItemModelProtocol + + var molecules: [AnyStackItemModel] { get set } + var axis: NSLayoutConstraint.Axis { get set } + var spacing: CGFloat { get set } + var useStackSpacingBeforeFirstItem: Bool { get set } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 6c3e139e..ab054232 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -31,7 +31,6 @@ @"button": PrimaryButton.class, @"link": MFTextButton.class, @"header": StandardHeaderView.class, - @"stack": MoleculeStackView.class, @"twoButtonView": TwoButtonView.class, @"footer": StandardFooterView.class, @"caretView": CaretView.class, diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 86e7ee7e..ddc2d13f 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -10,11 +10,13 @@ import Foundation @objcMembers public class MoleculeObjectMapping: NSObject { public static func registerObjects() { + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MoleculeStackView.self, forKey: "stack" as NSString) + ModelRegistry.register(LabelModel.self) ModelRegistry.register(HeaderModel.self) ModelRegistry.register(HeadlineBodyModel.self) ModelRegistry.register(MoleculeStackModel.self) - ModelRegistry.register(StackItemModel.self) + ModelRegistry.register(MoleculeStackItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(ProgressBarModel.self) ModelRegistry.register(MultiProgressBarModel.self) diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index a4f69518..03d21c6b 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -49,8 +49,8 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { } let stack = MoleculeStackView(frame: .zero) - stack.useStackSpacingBeforeFirstItem = true - stack.moleculesShouldSetHorizontalMargins = true + moleculeStackModel.useStackSpacingBeforeFirstItem = true + moleculeStackModel.useHorizontalMargins = true stack.setWithModel(moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil) return stack } diff --git a/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift b/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift index 05d13bcd..f989e17b 100644 --- a/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift +++ b/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift @@ -30,6 +30,11 @@ import Foundation try container.encode(axis.rawValueString, forKey: .axis) } */ + +enum AxisError: Error { + case notAnAxis +} + extension NSLayoutConstraint.Axis: RawRepresentable { init?(rawValue: String) { @@ -54,3 +59,29 @@ extension NSLayoutConstraint.Axis: RawRepresentable { } } } + +@propertyWrapper +public struct Axis { + public var wrappedValue: NSLayoutConstraint.Axis + + public init(wrappedValue value: NSLayoutConstraint.Axis) { + self.wrappedValue = value + } +} + +extension Axis: Codable { + public init(from decoder: Decoder) throws { + let typeContainer = try decoder.singleValueContainer() + let string = try typeContainer.decode(String.self) + guard let axis = NSLayoutConstraint.Axis(rawValue: string) else { + throw AxisError.notAnAxis + } + wrappedValue = axis + } + + public func encode(to encoder: Encoder) throws { + let string = wrappedValue.rawValueString + var container = encoder.singleValueContainer() + try container.encode(string) + } +} From 7d5bee5654525ed5dc7af19c73c66e65078abf5b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 16 Jan 2020 15:51:15 -0500 Subject: [PATCH 158/272] Label fix --- MVMCoreUI/Atoms/Views/Label.swift | 17 ++++++++++++++--- .../LabelModel/LabelAttributeActionModel.swift | 11 ++++++++++- .../Molecules/Doughnut/DoughnutChart.swift | 9 ++++----- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index e5491baf..b4173add 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -244,10 +244,15 @@ public typealias ActionBlock = () -> () } if let fontStyle = labelModel.fontStyle { MFStyler.styleLabel(self, withStyle: fontStyle) + MFStyler.styleLabel(self, withStyle: fontStyle, genericScaling: false) + standardFontSize = font.pointSize } else { let fontSize = labelModel.fontSize + if let fontSize = fontSize { + standardFontSize = fontSize + } if let fontName = labelModel.fontName { - font = MFFonts.mfFont(withName: fontName, size: fontSize ?? font.pointSize) + font = MFFonts.mfFont(withName: fontName, size: fontSize ?? standardFontSize) } else if let fontSize = fontSize { font = font.withSize(fontSize) } @@ -262,9 +267,9 @@ public typealias ActionBlock = () -> () for attribute in attributes { let range = NSRange(location: attribute.location, length: attribute.length) switch attribute { - case let underLineAtt as LabelAttributeUnderlineModel: + case let _ as LabelAttributeUnderlineModel: attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range) - case let strikeAtt as LabelAttributeStrikeThroughModel: + case let _ as LabelAttributeStrikeThroughModel: attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range) attributedString.addAttribute(.baselineOffset, value: 0, range: range) case let colorAtt as LabelAttributeColorModel: @@ -309,11 +314,17 @@ public typealias ActionBlock = () -> () } } case let actionAtt as LabelAttributeActionModel: + addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) { + if let data = try? actionAtt.encode(using: JSONEncoder()), let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + } addActionAttributes(range: range, string: attributedString) default: continue } } + attributedText = attributedString originalAttributedString = attributedText hero = labelModel.hero } diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift index eb5a3cd7..8dd5c562 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift @@ -12,12 +12,21 @@ class LabelAttributeActionModel: LabelAttributeModel { override public class var identifier: String { return "action" } - + var action: ActionProtocol + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) 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.encodeModel(action, forKey: .action) + } + + private enum CodingKeys: String, CodingKey { + case action } } diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift index a3961833..acb2e9ea 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift @@ -179,10 +179,9 @@ open class DoughnutChart: View { let labelheight = labelContainer.frame.height/2 let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2)) - labelContainer.leftPin?.constant = padding - labelContainer.rightPin?.constant = padding - labelContainer.topPin?.constant = max(radius - labelheight, labelheight) - labelContainer.bottomPin?.constant = max(radius - labelheight, labelheight) + labelContainerLeftConstraint?.constant = padding + labelContainerRightConstraint?.constant = padding + labelContainerTopConstraint?.constant = max(radius - labelheight, labelheight) + labelContainerBottomConstraint?.constant = max(radius - labelheight, labelheight) } - } From cb89795b4cb78ba86fa43b40333557cebeb27413 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 16 Jan 2020 16:17:36 -0500 Subject: [PATCH 159/272] remove ! --- MVMCoreUI/Organisms/Stack.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 29f9cd9f..0fc1ca8f 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -107,12 +107,11 @@ open class Stack: Container where T: StackModelProtocol { } open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - if model == nil { - let data = try! JSONSerialization.data(withJSONObject: json!) - let decoder = JSONDecoder() - let model = try! decoder.decode(MoleculeStackModel.self, from: data) + if let model = model { setWithModel(model, delegateObject, additionalData) - } else { + } else if let json = json, + let data = try? JSONSerialization.data(withJSONObject: json), + let model = try? JSONDecoder().decode(MoleculeStackModel.self, from: data) { setWithModel(model, delegateObject, additionalData) } } @@ -182,7 +181,7 @@ open class Stack: Container where T: StackModelProtocol { /// Adds the stack item view func addView(_ view: UIView,_ model: StackItemModelProtocol, lastItem: Bool) { - let stackModel = self.stackModel! + guard let stackModel = self.stackModel else { return } guard !model.gone else { // Gone views do not show stackItems.append(view) From 36cbccd39c0e5efb0f11dcaea6d609408d9c964c Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Thu, 16 Jan 2020 16:30:05 -0500 Subject: [PATCH 160/272] update name --- MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift | 4 ++-- MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift index acb2e9ea..233ca7d7 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift @@ -135,7 +135,7 @@ open class DoughnutChart: View { let clockwise = true let value: CGFloat = chartModel.percent - let gap: CGFloat = spaceReuired() ? lineGap() : 0.0 + let gap: CGFloat = spaceRequired() ? lineGap() : 0.0 let startAngle = ((prevPercent / 100.0) * 2 * .pi) - (0.5 * .pi) let endAngle = ((value / 100.0) * 2 * .pi) + startAngle - gap let circlePath = UIBezierPath(arcCenter: arcCenter, @@ -168,7 +168,7 @@ open class DoughnutChart: View { return doughnutChartModel?.sections.count == 1 ? 0.0 : 0.05 } - func spaceReuired() -> Bool { + func spaceRequired() -> Bool { return doughnutChartModel?.spaceRequired ?? true } diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift index 4893edbc..31091796 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift @@ -50,7 +50,7 @@ import Foundation centerY.isActive = true colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true - colorLablesStack.backgroundColor = UIColor.clear + colorLablesStack.backgroundColor = .clear } open override func updateView(_ size: CGFloat) { From b1abe0810cf78c9db39df2868d5bad64483152eb Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Thu, 16 Jan 2020 16:43:16 -0500 Subject: [PATCH 161/272] put clockwise into method --- MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift index 233ca7d7..130536e4 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift @@ -132,8 +132,7 @@ open class DoughnutChart: View { let arcCenter = shapeLayer.position let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0 - let clockwise = true - + let value: CGFloat = chartModel.percent let gap: CGFloat = spaceRequired() ? lineGap() : 0.0 let startAngle = ((prevPercent / 100.0) * 2 * .pi) - (0.5 * .pi) @@ -142,7 +141,7 @@ open class DoughnutChart: View { radius: radius, startAngle: startAngle, endAngle: endAngle, - clockwise: clockwise) + clockwise: true) shapeLayer.path = circlePath.cgPath doughnutLayer.addSublayer(shapeLayer) From 3cfe5aa4237a1f6ce6bb0d05aa9c53f49a21f0da Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 16 Jan 2020 16:47:53 -0500 Subject: [PATCH 162/272] StackModel --- MVMCoreUI/Organisms/StackModel.swift | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Organisms/StackModel.swift index b647b791..deea2457 100644 --- a/MVMCoreUI/Organisms/StackModel.swift +++ b/MVMCoreUI/Organisms/StackModel.swift @@ -12,11 +12,38 @@ import Foundation public static var identifier: String = "simpleStack" public var backgroundColor: Color? public var molecules: [StackItemModel] - @Axis public var axis: NSLayoutConstraint.Axis = .vertical + public var axis: NSLayoutConstraint.Axis = .vertical public var spacing: CGFloat = 16.0 public var useStackSpacingBeforeFirstItem = false public init(molecules: [StackItemModel]) { self.molecules = molecules } + + enum StackCodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case molecules + case axis + case spacing + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self) + + molecules = try typeContainer.decode([StackItemModel].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 + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StackCodingKeys.self) + try container.encodeIfPresent(molecules, forKey: .molecules) + try container.encodeIfPresent(axis.rawValueString, forKey: .axis) + try container.encodeIfPresent(spacing, forKey: .spacing) + } } From 4dde423d2f8668e47a806eff6ed06bc9dd53f4c7 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 16 Jan 2020 17:32:00 -0500 Subject: [PATCH 163/272] button fixes --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 7 +++++++ .../PrimaryButton+MoleculeProtocolExtension.swift | 10 ++++++++++ MVMCoreUI/Atoms/Buttons/PrimaryButton.h | 3 +++ MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 2 -- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 4329ccff..64d9a3c3 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -25,6 +25,8 @@ public class ButtonModel: MoleculeProtocol { public var action: ActionProtocol public var style: ButtonStyle? = .primary public var size: ButtonSize? = .standard + public var required: Bool? + public var requiredGroups: [String]? init(with title: String, action: ActionProtocol) { self.title = title @@ -37,6 +39,8 @@ public class ButtonModel: MoleculeProtocol { case action case style case size + case required + case requiredGroups } required public init(from decoder: Decoder) throws { @@ -44,6 +48,8 @@ public class ButtonModel: MoleculeProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) + requiredGroups = try typeContainer.decodeIfPresent([String].self, forKey: .requiredGroups) if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) { self.style = style } @@ -59,5 +65,6 @@ public class ButtonModel: MoleculeProtocol { try container.encodeModel(action, forKey: .action) try container.encodeIfPresent(style, forKey: .style) try container.encodeIfPresent(size, forKey: .size) + try container.encodeIfPresent(required, forKey: .required) } } diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift index 2d7ecf40..09c94bdf 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift @@ -14,6 +14,16 @@ extension PrimaryButton: ModelMoleculeViewProtocol { guard let model = model as? ButtonModel else { return } setTitle(model.title, for: .normal) backgroundColor = model.backgroundColor?.uiColor + + self.validationRequired = model.required ?? false + self.requiredGroupsList = model.requiredGroups + + if self.validationRequired, + let selfForm = self as? FormValidationEnableDisableProtocol { + FormValidator.setupValidation(molecule: selfForm, delegate: delegateObject?.formValidationProtocol) + } + + if let style = model.style { switch style { case .primary: diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h index 99929430..e83484a0 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h @@ -46,6 +46,9 @@ static CGFloat const PrimaryButtonSmallHeight = 30.0; // set YES to skip highlight method, for customer color button @property (nonatomic) BOOL skipHighlighted; +@property (nonatomic) BOOL validationRequired; +@property (nullable, nonatomic, strong) NSArray *requiredGroupsList; + // The main creation functions, changed to black button for 2.0 for default + (nullable instancetype)primaryButton:(BOOL)enabled; + (nullable instancetype)primarySmallButton:(BOOL)enabled; diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 2bc9e026..439d5479 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -20,8 +20,6 @@ @interface PrimaryButton() -@property (nonatomic) BOOL validationRequired; -@property (nonatomic, strong) NSArray *requiredGroupsList; @property (nonatomic) BOOL smallButton; @property (assign, nonatomic) BOOL tinyButton; @property (nonatomic) CGFloat sizeForSizing; From 8209101b73683a59ab27cde568fee99fe0f5d230 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 16 Jan 2020 18:54:01 -0500 Subject: [PATCH 164/272] hot fix --- MVMCoreUI/Molecules/Items/MoleculeStackItem.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 2 +- MVMCoreUI/OtherHandlers/CoreUIObject.swift | 1 + .../OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 10 +--------- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 3 ++- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift index d883f93e..279e7948 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift @@ -1,5 +1,5 @@ // -// StackItem.swift +// MoleculeStackItem.swift // MVMCoreUI // // Created by Scott Pfeil on 12/13/19. diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index 2674de0a..a7dd1640 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -26,7 +26,7 @@ open class MoleculeStackView: Stack { override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { - if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? StackItem { + if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? MoleculeStackItem { stackItems.append(stackItem) } } diff --git a/MVMCoreUI/OtherHandlers/CoreUIObject.swift b/MVMCoreUI/OtherHandlers/CoreUIObject.swift index af0f5023..427fcfba 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIObject.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIObject.swift @@ -19,5 +19,6 @@ import UIKit viewControllerMapping = MVMCoreUIViewControllerMappingObject() loggingDelegate = MVMCoreUILoggingHandler() moleculeMap = MVMCoreUIMoleculeMappingObject() + MoleculeObjectMapping.registerObjects() } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 09c98c1a..1eda2454 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -70,10 +70,9 @@ @"tabsListItem": TabsTableViewCell.class, @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, - @"stackItem": StackItem.class, + @"stackItem": MoleculeStackItem.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, @"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class, - @"stackItem": StackItem.class, @"doughnutChart": DoughnutChartView.class, @"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class } mutableCopy]; @@ -85,13 +84,6 @@ return [MVMCoreActionUtility initializerClassCheck:[CoreUIObject sharedInstance].moleculeMap classToVerify:self]; } -- (instancetype)init { - if (self = [super init]) { - [MoleculeObjectMapping registerObjects]; - } - return self; -} - - (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json { NSString *moleculeName = [json string:KeyMoleculeName]; if (moleculeName) { diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index fe4c7e11..6bcdd4cd 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -10,7 +10,8 @@ import Foundation @objcMembers public class MoleculeObjectMapping: NSObject { public static func registerObjects() { - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MoleculeStackView.self, forKey: "stack" as NSString) + let mapping = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping + mapping?.setObject(MoleculeStackView.self, forKey: "stack" as NSString) ModelRegistry.register(LabelModel.self) ModelRegistry.register(HeaderModel.self) From 54cc1f54261e76fb2d126bb8fb4a3f4b86815129 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 16 Jan 2020 19:48:14 -0500 Subject: [PATCH 165/272] registerModels() --- MVMCoreUI/OtherHandlers/CoreUIObject.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/CoreUIObject.swift b/MVMCoreUI/OtherHandlers/CoreUIObject.swift index 427fcfba..9d2957c2 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIObject.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIObject.swift @@ -10,7 +10,11 @@ import UIKit @objcMembers open class CoreUIObject: MVMCoreObject { public var moleculeMap: MVMCoreUIMoleculeMappingObject? - + + open func registerModels() { + MoleculeObjectMapping.registerObjects() + } + open override func defaultInitialSetup() { cache = MVMCoreCache() sessionHandler = MVMCoreSessionTimeHandler() @@ -19,6 +23,6 @@ import UIKit viewControllerMapping = MVMCoreUIViewControllerMappingObject() loggingDelegate = MVMCoreUILoggingHandler() moleculeMap = MVMCoreUIMoleculeMappingObject() - MoleculeObjectMapping.registerObjects() + registerModels() } } From d8a7efde8a727fb0f6f9849041ebacfdfd69c669 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 16 Jan 2020 20:57:17 -0500 Subject: [PATCH 166/272] undo register change --- MVMCoreUI/OtherHandlers/CoreUIObject.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/CoreUIObject.swift b/MVMCoreUI/OtherHandlers/CoreUIObject.swift index 9d2957c2..d60cdd6a 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIObject.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIObject.swift @@ -11,10 +11,6 @@ import UIKit @objcMembers open class CoreUIObject: MVMCoreObject { public var moleculeMap: MVMCoreUIMoleculeMappingObject? - open func registerModels() { - MoleculeObjectMapping.registerObjects() - } - open override func defaultInitialSetup() { cache = MVMCoreCache() sessionHandler = MVMCoreSessionTimeHandler() @@ -23,6 +19,6 @@ import UIKit viewControllerMapping = MVMCoreUIViewControllerMappingObject() loggingDelegate = MVMCoreUILoggingHandler() moleculeMap = MVMCoreUIMoleculeMappingObject() - registerModels() + MoleculeObjectMapping.registerObjects() } } From 017dc1d0020520a01d75bf887eaea9b8bbb3350d Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 17 Jan 2020 21:32:49 +0530 Subject: [PATCH 167/272] secondary button top alignment fix, which was breaking all BAU secondary buttons. --- .../Molecules/HorizontalCombinationViews/TwoButtonView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 10a41daa..47e67724 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -93,7 +93,7 @@ import UIKit viewForButtons.addSubview(secondaryButton) secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1).isActive = true NSLayoutConstraint.constraintPinSubview(primaryButton, pinTop: true, pinBottom: true, pinLeft: true, pinRight: false) - NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true) + NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: true, pinBottom: false, pinLeft: false, pinRight: true) let constraint = secondaryButton.leadingAnchor.constraint(equalTo: primaryButton.trailingAnchor, constant: 10) constraint.priority = UILayoutPriority(900) constraint.isActive = true From 13dbb283571e42bf931a51130ff02e9b63c7a016 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 11:04:35 -0500 Subject: [PATCH 168/272] caret title --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 2 +- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 6c8e4d31..64120043 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -149,7 +149,7 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI } isEnabled = caretLinkModel.enabled set(with: caretLinkModel.action, delegateObject: delegateObject, additionalData: additionalData) - setTitle(caretLinkModel.label.text, for: .normal) + setTitle(caretLinkModel.title, for: .normal) } public func needsToBeConstrained() -> Bool { diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index db2de2b0..b2fc5841 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -12,20 +12,20 @@ import MVMCore public class CaretLinkModel: MoleculeProtocol { public static var identifier: String = "caretLink" public var backgroundColor: Color? - public var label: LabelModel + public var title: String public var action: ActionProtocol public var enabledColor: Color = Color(uiColor: .black) public var disabledColor: Color? = Color(uiColor: .mfSilver()) public var enabled: Bool = true - public init(label: LabelModel, action: ActionProtocol) { - self.label = label + public init(title: String, action: ActionProtocol) { + self.title = title self.action = action } enum CodingKeys: String, CodingKey { case backgroundColor - case label + case title case action case enabledColor case disabledColor @@ -35,7 +35,7 @@ public class CaretLinkModel: MoleculeProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - label = try typeContainer.decode(LabelModel.self, forKey: .label) + title = try typeContainer.decode(String.self, forKey: .title) if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor) { enabledColor = color } @@ -50,7 +50,7 @@ public class CaretLinkModel: MoleculeProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(label, forKey: .label) + try container.encode(title, forKey: .title) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) try container.encode(enabled, forKey: .enabledColor) From 401370f97610d022221b350cb7df8c7c3ae2fb56 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 12:03:31 -0500 Subject: [PATCH 169/272] toggle action --- MVMCoreUI/Atoms/Views/Toggle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 4e855532..366b6b89 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -398,7 +398,7 @@ extension Toggle { changeStateNoAnimation(state) } - if let actionMap = dictionary.optionalDictionaryForKey("actionMap") { + if let actionMap = dictionary.optionalDictionaryForKey("action") { didToggleAction = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } From 9847ef5302218e82df157a83659edcd989427832 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 17 Jan 2020 13:51:46 -0500 Subject: [PATCH 170/272] stack flexibility update molecule container protocol fix missing functions update numbered and unordered list to more model approach --- MVMCoreUI.xcodeproj/project.pbxproj | 64 +- MVMCoreUI.xcodeproj/project.pbxproj.orig | 1622 ----------------- MVMCoreUI/Containers/Container.swift | 1 + .../Models/Molecules/NumberedListModel.swift | 33 - .../Models/Molecules/UnOrderedListModel.swift | 33 - .../Doughnut/DoughnutChartView.swift | 4 +- .../Molecules/Items/StackItemModel.swift | 4 +- .../Items/StackItemModelProtocol.swift | 2 +- .../Molecules/LabelRightMoleculesStack.swift | 167 -- MVMCoreUI/Molecules/MoleculeContainer.swift | 24 + MVMCoreUI/Molecules/NumberedList.swift | 18 - MVMCoreUI/Molecules/UnOrderedList.swift | 18 - .../Lists/NumberedList.swift | 14 + .../Lists/NumberedListModel.swift | 47 + .../StringAndMoleculeModel.swift | 42 + .../StringAndMoleculeStack.swift | 28 + .../StringAndMoleculeView.swift | 92 + .../Lists/UnOrderedList.swift | 12 + .../Lists/UnOrderedListModel.swift | 51 + MVMCoreUI/Organisms/MoleculeStackModel.swift | 4 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 4 +- MVMCoreUI/Organisms/Stack.swift | 44 +- .../MVMCoreUIMoleculeMappingObject.m | 2 - .../OtherHandlers/MoleculeObjectMapping.swift | 16 +- 24 files changed, 396 insertions(+), 1950 deletions(-) delete mode 100644 MVMCoreUI.xcodeproj/project.pbxproj.orig delete mode 100644 MVMCoreUI/Models/Molecules/NumberedListModel.swift delete mode 100644 MVMCoreUI/Models/Molecules/UnOrderedListModel.swift delete mode 100644 MVMCoreUI/Molecules/LabelRightMoleculesStack.swift delete mode 100644 MVMCoreUI/Molecules/NumberedList.swift delete mode 100644 MVMCoreUI/Molecules/UnOrderedList.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedList.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0ab12529..11ba168e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -107,15 +107,15 @@ 94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; }; 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; + C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; + C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; }; C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; }; C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; }; C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; }; - C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; - C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; - C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; }; C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */; }; - C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */; }; + C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */; }; C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5123C77A4900A3614A /* NumberedList.swift */; }; + C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; @@ -272,6 +272,8 @@ D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32821EE8736003B2FB9 /* Localizable.strings */; }; D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */; }; + D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */; }; + D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */; }; D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */; }; D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -370,9 +372,9 @@ 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; - 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = ""; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; + 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = ""; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = ""; }; @@ -396,15 +398,15 @@ 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; + C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; + C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = ""; }; C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = ""; }; C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = ""; }; C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = ""; }; - C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = ""; }; - C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; - C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = ""; }; C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedList.swift; sourceTree = ""; }; - C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelRightMoleculesStack.swift; sourceTree = ""; }; + C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeStack.swift; sourceTree = ""; }; C6FA7D5123C77A4900A3614A /* NumberedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedList.swift; sourceTree = ""; }; + C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; @@ -575,6 +577,8 @@ D29DF32A21EE8736003B2FB9 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; D29DF32B21EE8736003B2FB9 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; + D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeView.swift; sourceTree = ""; }; + D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeModel.swift; sourceTree = ""; }; D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeMappingObject.h; sourceTree = ""; }; D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIMoleculeMappingObject.m; sourceTree = ""; }; D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeViewProtocol.h; sourceTree = ""; }; @@ -701,8 +705,6 @@ 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */, - C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */, - C695A68023C9830D00BFB94E /* NumberedListModel.swift */, ); path = Molecules; sourceTree = ""; @@ -715,7 +717,7 @@ path = Protocols; sourceTree = ""; }; - 0ABD1369237B18EE0081388D /* views */ = { + 0ABD1369237B18EE0081388D /* views */ = { isa = PBXGroup; children = ( 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */, @@ -723,14 +725,6 @@ path = views; sourceTree = ""; }; - 0AA33B322398134B0067DD0F /* Primitive Models */ = { - isa = PBXGroup; - children = ( - 0AA33B35239813EE0067DD0F /* Color.swift */, - ); - path = "Primitive Models"; - sourceTree = ""; - }; 946EE1B5237B663A0036751F /* Extensions */ = { isa = PBXGroup; children = ( @@ -807,6 +801,7 @@ D224798D2316A988003FCCF9 /* VerticalCombinationViews */ = { isa = PBXGroup; children = ( + D29E28D423D1FFFA00ACEA85 /* Lists */, D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, @@ -988,9 +983,6 @@ D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, - C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */, - C6FA7D5123C77A4900A3614A /* NumberedList.swift */, - C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */, D260105723CF9CC500764D80 /* Doughnut */, ); path = Molecules; @@ -1299,6 +1291,28 @@ path = Strings; sourceTree = ""; }; + D29E28D423D1FFFA00ACEA85 /* Lists */ = { + isa = PBXGroup; + children = ( + D29E28DB23D21B0A00ACEA85 /* StringAndMoleculeStack */, + C695A68023C9830D00BFB94E /* NumberedListModel.swift */, + C6FA7D5123C77A4900A3614A /* NumberedList.swift */, + C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */, + C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */, + ); + path = Lists; + sourceTree = ""; + }; + D29E28DB23D21B0A00ACEA85 /* StringAndMoleculeStack */ = { + isa = PBXGroup; + children = ( + D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */, + D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */, + C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */, + ); + path = StringAndMoleculeStack; + sourceTree = ""; + }; D2B18B7D236090D500A9AEDC /* BaseClasses */ = { isa = PBXGroup; children = ( @@ -1543,6 +1557,7 @@ D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */, 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, + D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, @@ -1563,6 +1578,7 @@ D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, + D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D260105D23D0BCD400764D80 /* Stack.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, @@ -1589,7 +1605,7 @@ 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, - C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */, + C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, diff --git a/MVMCoreUI.xcodeproj/project.pbxproj.orig b/MVMCoreUI.xcodeproj/project.pbxproj.orig deleted file mode 100644 index 2036d4b5..00000000 --- a/MVMCoreUI.xcodeproj/project.pbxproj.orig +++ /dev/null @@ -1,1622 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 48; - objects = { - -/* Begin PBXBuildFile section */ - 01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; }; - 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; }; - 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; - 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; - 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; - 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; - 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; - 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; - 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; - 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; - 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */; }; - 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */; }; - 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D902327ECE600EF99AA /* CornerLabels.swift */; }; - 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; }; - 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */; }; - 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */; }; - 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB392360EEB40024EF95 /* PageModel.swift */; }; - 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */; }; - 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3F23620A230024EF95 /* TextFieldModel.swift */; }; - 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */; }; - 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */; }; - 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */; }; - 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; - 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; - 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; }; - 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; - 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; - 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; - 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; - 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; - 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; - 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; - 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.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 */; }; - 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; - 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; - 0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; }; - 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; - 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; - 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; - 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; - 0AA33B36239813EE0067DD0F /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B35239813EE0067DD0F /* Color.swift */; }; - 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; - 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.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 */; }; - 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; }; - 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; }; - 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; - 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; - 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; - 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; }; - 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */; }; - 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */; }; - 94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */; }; - 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */; }; - 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */; }; - 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; }; - D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; - D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; - D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; - D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; }; - D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */; }; - D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */; }; - D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */; }; - D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */; }; - D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */; }; - D22D1F1E220343560077CEC0 /* MVMCoreUICheckMarkView.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */; }; - D22D1F46220496A30077CEC0 /* MVMCoreUISwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */; }; - D22D1F562204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */; }; - D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; - D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; - D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; - D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; - D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; - D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; - D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; - D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; - D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */; }; - D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */; }; - D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; }; - D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; }; - D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; - D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */; }; - D29770F321F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */; }; - D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */; }; - D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */; }; - D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */; }; - D29DF11521E6805F003B2FB9 /* UIColor+MFConvenience.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF11621E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */; }; - D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */; }; - D29DF11C21E684A9003B2FB9 /* MVMCoreUISplitViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF11A21E684A9003B2FB9 /* MVMCoreUISplitViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF11B21E684A9003B2FB9 /* MVMCoreUISplitViewController.m */; }; - D29DF12921E6851E003B2FB9 /* MVMCoreUITopAlertMainView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF11F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF12A21E6851E003B2FB9 /* MVMCoreUITopAlertView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF12021E6851E003B2FB9 /* MVMCoreUITopAlertView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF12121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m */; }; - D29DF12C21E6851E003B2FB9 /* MVMCoreUITopAlertShortView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF12221E6851E003B2FB9 /* MVMCoreUITopAlertShortView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF12D21E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF12321E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF12421E6851E003B2FB9 /* MVMCoreUITopAlertView.m */; }; - D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF12521E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m */; }; - D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF12621E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m */; }; - D29DF13121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF12721E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF12821E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m */; }; - D29DF15421E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF15321E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF15F21E69996003B2FB9 /* MFViewController.m */; }; - D29DF16221E69996003B2FB9 /* MFViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16021E69996003B2FB9 /* MFViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */; }; - D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */; }; - D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17221E69E1F003B2FB9 /* MFTextButton.m */; }; - D29DF18021E69E49003B2FB9 /* MFView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF17E21E69E2E003B2FB9 /* MFView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF18121E69E50003B2FB9 /* MFView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17F21E69E2E003B2FB9 /* MFView.m */; }; - D29DF18221E69E54003B2FB9 /* SeparatorView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF15921E697DA003B2FB9 /* SeparatorView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF15A21E697DA003B2FB9 /* SeparatorView.m */; }; - D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24221E6A176003B2FB9 /* MFTextField.m */; }; - D29DF24E21E6A177003B2FB9 /* MFDigitTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24321E6A176003B2FB9 /* MFDigitTextField.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF24F21E6A177003B2FB9 /* MFTextField.xib in Resources */ = {isa = PBXBuildFile; fileRef = D29DF24421E6A176003B2FB9 /* MFTextField.xib */; }; - D29DF25021E6A177003B2FB9 /* MFDigitTextBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24521E6A176003B2FB9 /* MFDigitTextBox.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24621E6A176003B2FB9 /* MFDigitTextBox.m */; }; - D29DF25221E6A177003B2FB9 /* MFMdnTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24821E6A177003B2FB9 /* MFDigitTextField.m */; }; - D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24921E6A177003B2FB9 /* MFMdnTextField.m */; }; - D29DF25521E6A177003B2FB9 /* MFDigitTextField.xib in Resources */ = {isa = PBXBuildFile; fileRef = D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */; }; - D29DF25621E6A177003B2FB9 /* MFTextFieldSubclassExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF25721E6A177003B2FB9 /* MFTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24C21E6A177003B2FB9 /* MFTextField.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF25921E6A22D003B2FB9 /* MFButtonProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF26821E6AA0B003B2FB9 /* FLAnimatedImage.m */; }; - D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF26921E6AA0B003B2FB9 /* FLAnimatedImageView.m */; }; - D29DF26E21E6AA0B003B2FB9 /* FLAnimatedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF26A21E6AA0B003B2FB9 /* FLAnimatedImage.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF26F21E6AA0B003B2FB9 /* FLAnimatedImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF26B21E6AA0B003B2FB9 /* FLAnimatedImageView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27321E79E81003B2FB9 /* MVMCoreUILoggingHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */; }; - D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF27821E7A533003B2FB9 /* MVMCoreUISession.m */; }; - D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */; }; - D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */; }; - D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */; }; - D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */; }; - D29DF29721E7ADB8003B2FB9 /* MFScrollingViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */; }; - D29DF29921E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF29A21E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF29B21E7ADB9003B2FB9 /* StackableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */; }; - D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF13821E68636003B2FB9 /* MFStyler.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF13921E68637003B2FB9 /* MFStyler.m */; }; - D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29F21E7AF4E003B2FB9 /* MVMCoreUIUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2A021E7AF4E003B2FB9 /* MVMCoreUIUtility.m */; }; - D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */; }; - D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */; }; - D29DF2AF21E7B3A4003B2FB9 /* MFTextView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */; }; - D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */; }; - D29DF2BC21E7BEA4003B2FB9 /* TopTabbar.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2B821E7BEA4003B2FB9 /* TopTabbar.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2BD21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2B921E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2BA21E7BEA4003B2FB9 /* TopTabbar.m */; }; - D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2BB21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m */; }; - D29DF2C421E7BF57003B2FB9 /* MFTabBarSwipeAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2C021E7BF56003B2FB9 /* MFTabBarSwipeAnimator.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2C121E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m */; }; - D29DF2C621E7BF57003B2FB9 /* MFTabBarInteractor.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2C221E7BF57003B2FB9 /* MFTabBarInteractor.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2C321E7BF57003B2FB9 /* MFTabBarInteractor.m */; }; - D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF14521E68728003B2FB9 /* MFSizeObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF14421E68728003B2FB9 /* MFSizeObject.m */; }; - D29DF2CA21E7BFC8003B2FB9 /* MFSizeThreshold.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF14621E68728003B2FB9 /* MFSizeThreshold.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF14721E68728003B2FB9 /* MFSizeThreshold.m */; }; - D29DF2CE21E7C104003B2FB9 /* MFLoadingViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */; }; - D29DF2E121E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2EE21ECEADF003B2FB9 /* MFFonts.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF14D21E693AD003B2FB9 /* MFFonts.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF14C21E693AD003B2FB9 /* MFFonts.m */; }; - D29DF31A21ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31621ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf */; }; - D29DF31B21ECECC0003B2FB9 /* OCRAExtended.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31721ECECC0003B2FB9 /* OCRAExtended.ttf */; }; - D29DF31C21ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31821ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf */; }; - D29DF31D21ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31921ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf */; }; - D29DF32021ED0CBA003B2FB9 /* LabelView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF31E21ED0CBA003B2FB9 /* LabelView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF31F21ED0CBA003B2FB9 /* LabelView.m */; }; - D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */; }; - D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32821EE8736003B2FB9 /* Localizable.strings */; }; - D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */; }; - D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */; }; - D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 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 /* StandardHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* StandardHeaderView.swift */; }; - D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; - D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A638FC22CA98280052ED1F /* HeadlineBody.swift */; }; - D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390022CBB1820052ED1F /* Carousel.swift */; }; - D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */; }; - D2B18B7F2360913400A9AEDC /* Control.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B7E2360913400A9AEDC /* Control.swift */; }; - D2B18B812360945C00A9AEDC /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B802360945C00A9AEDC /* View.swift */; }; - D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */; }; - D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B93236214AD00A9AEDC /* NavigationController.swift */; }; - D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */; }; - D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; - D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */; }; - D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */; }; - D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; - D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; - D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; - D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; }; - D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* StackItem.swift */; }; - DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; }; - DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; }; - DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; - DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; }; - DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */; }; - DBEFFA04225A829700230692 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 01004F2F22721C3800991ECC /* RadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = ""; }; - 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; - 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; - 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; - 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; - 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; - 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; - 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; - 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; - 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstrainingMoleculeProtocol.swift; sourceTree = ""; }; - 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = ""; }; - 01509D902327ECE600EF99AA /* CornerLabels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerLabels.swift; sourceTree = ""; }; - 01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; - 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButtonSwitch.swift; sourceTree = ""; }; - 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonLabel.swift; sourceTree = ""; }; - 017BEB392360EEB40024EF95 /* PageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModel.swift; sourceTree = ""; }; - 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFViewController+Model.swift"; sourceTree = ""; }; - 017BEB3F23620A230024EF95 /* TextFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldModel.swift; sourceTree = ""; }; - 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormModelProtocol.swift; sourceTree = ""; }; - 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelExtension.swift"; sourceTree = ""; }; - 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeViewProtocol.swift; sourceTree = ""; }; - 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; - 017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = ""; }; - 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.swift; sourceTree = ""; }; - 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; - 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; - 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; - 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; - 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; - 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; - 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; - 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.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 = ""; }; - 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; - 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackViewAlignment+Extension.swift"; sourceTree = ""; }; - 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; - 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; - 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; - 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; - 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; - 0AA33B35239813EE0067DD0F /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.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 = ""; }; - 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 = ""; }; - 944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = ""; }; - 944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = ""; }; - 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; - 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; - 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; - 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = ""; }; - 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = ""; }; - 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeStrikeThroughModel.swift; sourceTree = ""; }; - 94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeFontModel.swift; sourceTree = ""; }; - 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = ""; }; - 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; - 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; - D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; - D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; - D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; - D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = ""; }; - D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodySwitch.swift; sourceTree = ""; }; - D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutConstraintExtension.swift; sourceTree = ""; }; - D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButton.swift; sourceTree = ""; }; - D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionMoleculeTableViewCell.swift; sourceTree = ""; }; - D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckBox.h; sourceTree = ""; }; - D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICheckBox.m; sourceTree = ""; }; - D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckMarkView.h; sourceTree = ""; }; - D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICheckMarkView.m; sourceTree = ""; }; - D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUISwitch.h; sourceTree = ""; }; - D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUISwitch.m; sourceTree = ""; }; - D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIStackableViewController.h; sourceTree = ""; }; - D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIStackableViewController.m; sourceTree = ""; }; - D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; - D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = ""; }; - D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = ""; }; - D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; - D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; - D268C711238D6699007F2C1C /* DropDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDown.swift; sourceTree = ""; }; - D274CA322236A78900B01B62 /* StandardFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardFooterView.swift; sourceTree = ""; }; - D2755D7A23689C7500485468 /* TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; }; - D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = ""; }; - D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyLink.swift; sourceTree = ""; }; - D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFLoadImageView.swift; sourceTree = ""; }; - D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = ""; }; - D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = ""; }; - D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; - D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = ""; }; - D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; - D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; - D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; - D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsAndBottomButtonsTableViewController.m; sourceTree = ""; }; - D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsAndBottomButtonsTableViewController.h; sourceTree = ""; }; - D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsAndBottomButtonsViewController.h; sourceTree = ""; }; - D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsAndBottomButtonsViewController.m; sourceTree = ""; }; - D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITextFieldView.m; sourceTree = ""; }; - D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITextFieldView.h; sourceTree = ""; }; - D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMolecule.swift; sourceTree = ""; }; - D29DF0CC21E404D4003B2FB9 /* MVMCoreUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MVMCoreUI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUI.h; sourceTree = ""; }; - D29DF0D021E404D4003B2FB9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MVMCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+MFConvenience.h"; sourceTree = ""; }; - D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+MFConvenience.h"; sourceTree = ""; }; - D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+MFConvenience.m"; sourceTree = ""; }; - D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+MFConvenience.m"; sourceTree = ""; }; - D29DF11A21E684A9003B2FB9 /* MVMCoreUISplitViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUISplitViewController.h; sourceTree = ""; }; - D29DF11B21E684A9003B2FB9 /* MVMCoreUISplitViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUISplitViewController.m; sourceTree = ""; }; - D29DF11F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITopAlertMainView.h; sourceTree = ""; }; - D29DF12021E6851E003B2FB9 /* MVMCoreUITopAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITopAlertView.h; sourceTree = ""; }; - D29DF12121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITopAlertExpandableView.m; sourceTree = ""; }; - D29DF12221E6851E003B2FB9 /* MVMCoreUITopAlertShortView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITopAlertShortView.h; sourceTree = ""; }; - D29DF12321E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITopAlertBaseView.h; sourceTree = ""; }; - D29DF12421E6851E003B2FB9 /* MVMCoreUITopAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITopAlertView.m; sourceTree = ""; }; - D29DF12521E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITopAlertMainView.m; sourceTree = ""; }; - D29DF12621E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITopAlertShortView.m; sourceTree = ""; }; - D29DF12721E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITopAlertExpandableView.h; sourceTree = ""; }; - D29DF12821E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITopAlertBaseView.m; sourceTree = ""; }; - D29DF13821E68636003B2FB9 /* MFStyler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFStyler.h; sourceTree = ""; }; - D29DF13921E68637003B2FB9 /* MFStyler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFStyler.m; sourceTree = ""; }; - D29DF14421E68728003B2FB9 /* MFSizeObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFSizeObject.m; sourceTree = ""; }; - D29DF14521E68728003B2FB9 /* MFSizeObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFSizeObject.h; sourceTree = ""; }; - D29DF14621E68728003B2FB9 /* MFSizeThreshold.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFSizeThreshold.h; sourceTree = ""; }; - D29DF14721E68728003B2FB9 /* MFSizeThreshold.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFSizeThreshold.m; sourceTree = ""; }; - D29DF14C21E693AD003B2FB9 /* MFFonts.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFFonts.m; sourceTree = ""; }; - D29DF14D21E693AD003B2FB9 /* MFFonts.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFFonts.h; sourceTree = ""; }; - D29DF15321E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPanelButtonProtocol.h; sourceTree = ""; }; - D29DF15921E697DA003B2FB9 /* SeparatorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SeparatorView.h; sourceTree = ""; }; - D29DF15A21E697DA003B2FB9 /* SeparatorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SeparatorView.m; sourceTree = ""; }; - D29DF15F21E69996003B2FB9 /* MFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFViewController.m; sourceTree = ""; }; - D29DF16021E69996003B2FB9 /* MFViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFViewController.h; sourceTree = ""; }; - D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFCustomButton.h; sourceTree = ""; }; - D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonDelegateProtocol.h; sourceTree = ""; }; - D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimaryButton.h; sourceTree = ""; }; - D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; - D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFCustomButton.m; sourceTree = ""; }; - D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrimaryButton.m; sourceTree = ""; }; - D29DF17221E69E1F003B2FB9 /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; - D29DF17E21E69E2E003B2FB9 /* MFView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFView.h; sourceTree = ""; }; - D29DF17F21E69E2E003B2FB9 /* MFView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFView.m; sourceTree = ""; }; - D29DF24221E6A176003B2FB9 /* MFTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextField.m; sourceTree = ""; }; - D29DF24321E6A176003B2FB9 /* MFDigitTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFDigitTextField.h; sourceTree = ""; }; - D29DF24421E6A176003B2FB9 /* MFTextField.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MFTextField.xib; sourceTree = ""; }; - D29DF24521E6A176003B2FB9 /* MFDigitTextBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFDigitTextBox.h; sourceTree = ""; }; - D29DF24621E6A176003B2FB9 /* MFDigitTextBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFDigitTextBox.m; sourceTree = ""; }; - D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFMdnTextField.h; sourceTree = ""; }; - D29DF24821E6A177003B2FB9 /* MFDigitTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFDigitTextField.m; sourceTree = ""; }; - D29DF24921E6A177003B2FB9 /* MFMdnTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFMdnTextField.m; sourceTree = ""; }; - D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MFDigitTextField.xib; sourceTree = ""; }; - D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextFieldSubclassExtension.h; sourceTree = ""; }; - D29DF24C21E6A177003B2FB9 /* MFTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextField.h; sourceTree = ""; }; - D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFButtonProtocol.h; sourceTree = ""; }; - D29DF26821E6AA0B003B2FB9 /* FLAnimatedImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImage.m; sourceTree = ""; }; - D29DF26921E6AA0B003B2FB9 /* FLAnimatedImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImageView.m; sourceTree = ""; }; - D29DF26A21E6AA0B003B2FB9 /* FLAnimatedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLAnimatedImage.h; sourceTree = ""; }; - D29DF26B21E6AA0B003B2FB9 /* FLAnimatedImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLAnimatedImageView.h; sourceTree = ""; }; - D29DF27321E79E81003B2FB9 /* MVMCoreUILoggingHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUILoggingHandler.h; sourceTree = ""; }; - D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUILoggingHandler.m; sourceTree = ""; }; - D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUISession.h; sourceTree = ""; }; - D29DF27821E7A533003B2FB9 /* MVMCoreUISession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUISession.m; sourceTree = ""; }; - D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIDetailViewProtocol.h; sourceTree = ""; }; - D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICommonViewsUtility.m; sourceTree = ""; }; - D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICommonViewsUtility.h; sourceTree = ""; }; - D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewConstrainingView.h; sourceTree = ""; }; - D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewConstrainingView.m; sourceTree = ""; }; - D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProgrammaticScrollViewController.m; sourceTree = ""; }; - D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StackableViewController.m; sourceTree = ""; }; - D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFScrollingViewController.h; sourceTree = ""; }; - D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFScrollingViewController.m; sourceTree = ""; }; - D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgrammaticScrollViewController.h; sourceTree = ""; }; - D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFProgrammaticTableViewController.h; sourceTree = ""; }; - D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackableViewController.h; sourceTree = ""; }; - D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFProgrammaticTableViewController.m; sourceTree = ""; }; - D29DF29F21E7AF4E003B2FB9 /* MVMCoreUIUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIUtility.h; sourceTree = ""; }; - D29DF2A021E7AF4E003B2FB9 /* MVMCoreUIUtility.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIUtility.m; sourceTree = ""; }; - D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIConstants.h; sourceTree = ""; }; - D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIConstants.m; sourceTree = ""; }; - D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextView.m; sourceTree = ""; }; - D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MFTextView.xib; sourceTree = ""; }; - D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextView.h; sourceTree = ""; }; - D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLoadingSpinner.h; sourceTree = ""; }; - D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLoadingSpinner.m; sourceTree = ""; }; - D29DF2B821E7BEA4003B2FB9 /* TopTabbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopTabbar.h; sourceTree = ""; }; - D29DF2B921E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITabBarPageControlViewController.h; sourceTree = ""; }; - D29DF2BA21E7BEA4003B2FB9 /* TopTabbar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopTabbar.m; sourceTree = ""; }; - D29DF2BB21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITabBarPageControlViewController.m; sourceTree = ""; }; - D29DF2C021E7BF56003B2FB9 /* MFTabBarSwipeAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTabBarSwipeAnimator.h; sourceTree = ""; }; - D29DF2C121E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTabBarSwipeAnimator.m; sourceTree = ""; }; - D29DF2C221E7BF57003B2FB9 /* MFTabBarInteractor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTabBarInteractor.h; sourceTree = ""; }; - D29DF2C321E7BF57003B2FB9 /* MFTabBarInteractor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTabBarInteractor.m; sourceTree = ""; }; - D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLoadingViewController.h; sourceTree = ""; }; - D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLoadingViewController.m; sourceTree = ""; }; - D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPanelProtocol.h; sourceTree = ""; }; - D29DF31621ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-45Lt.otf"; sourceTree = ""; }; - D29DF31721ECECC0003B2FB9 /* OCRAExtended.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = OCRAExtended.ttf; sourceTree = ""; }; - D29DF31821ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; - D29DF31921ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-55Rg.otf"; sourceTree = ""; }; - D29DF31E21ED0CBA003B2FB9 /* LabelView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelView.h; sourceTree = ""; }; - D29DF31F21ED0CBA003B2FB9 /* LabelView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LabelView.m; sourceTree = ""; }; - D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextButtonView.m; sourceTree = ""; }; - D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextButtonView.h; sourceTree = ""; }; - D29DF32921EE8736003B2FB9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; - D29DF32A21EE8736003B2FB9 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; - D29DF32B21EE8736003B2FB9 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; - D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; - D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeMappingObject.h; sourceTree = ""; }; - D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIMoleculeMappingObject.m; sourceTree = ""; }; - D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeViewProtocol.h; 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 /* StandardHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardHeaderView.swift; sourceTree = ""; }; - D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; - D2A638FC22CA98280052ED1F /* HeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBody.swift; sourceTree = ""; }; - D2A6390022CBB1820052ED1F /* Carousel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Carousel.swift; sourceTree = ""; }; - D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeCollectionViewCell.swift; sourceTree = ""; }; - D2B18B7E2360913400A9AEDC /* Control.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Control.swift; sourceTree = ""; }; - D2B18B802360945C00A9AEDC /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = ""; }; - D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreUIObject.swift; sourceTree = ""; }; - D2B18B93236214AD00A9AEDC /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = ""; }; - D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageHeadlineBody.swift; sourceTree = ""; }; - D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; - D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; - D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scroller.swift; sourceTree = ""; }; - D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTemplate.swift; sourceTree = ""; }; - D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; - D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; - D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; - D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainer.swift; sourceTree = ""; }; - D2FB151C23A40F1500C20E10 /* StackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItem.swift; sourceTree = ""; }; - DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftRightLabelView.swift; sourceTree = ""; }; - DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; - DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = ""; }; - DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = ""; }; - DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = ""; }; - DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelWithInternalButton.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - D29DF0C921E404D4003B2FB9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */, - 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 01509D96232803B200EF99AA /* Models */ = { - isa = PBXGroup; - children = ( - 0AA33B322398134B0067DD0F /* Primitive Models */, - 017BEB392360EEB40024EF95 /* PageModel.swift */, - 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, - 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, - 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, - 946EE1B5237B663A0036751F /* Extensions */, - 01EB368723609801006832FA /* Molecules */, - ); - path = Models; - sourceTree = ""; - }; - 01C74D87224298E2009C25A3 /* FormUIHelpers */ = { - isa = PBXGroup; - children = ( - 0198F79E225679870066C936 /* FormValidationProtocol.swift */, - 0105618A224BBE7700E1557D /* FormValidator.swift */, - 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */, - 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */, - ); - path = FormUIHelpers; - sourceTree = ""; - }; - 01EB368723609801006832FA /* Molecules */ = { - isa = PBXGroup; - children = ( - 012CA98823849699003F810F /* SeperatorModel.swift */, - 01EB368923609801006832FA /* ListItemModel.swift */, - 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, - 01EB368B23609801006832FA /* MoleculeStackModel.swift */, - 01EB368C23609801006832FA /* HeaderModel.swift */, - 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, - 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, - 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, - 017BEB7A236763000024EF95 /* LineModel.swift */, - ); - path = Molecules; - sourceTree = ""; - }; - 0AA33B322398134B0067DD0F /* Primitive Models */ = { - isa = PBXGroup; - children = ( - 0AA33B35239813EE0067DD0F /* Color.swift */, - ); - path = "Primitive Models"; - sourceTree = ""; - }; - 946EE1B5237B663A0036751F /* Extensions */ = { - isa = PBXGroup; - children = ( - 946EE1B9237B66D80036751F /* ModelHelper.swift */, - ); - path = Extensions; - sourceTree = ""; - }; - 94C2D9822386F3E30006CF46 /* LabelModel */ = { - isa = PBXGroup; - children = ( - 01EB368823609801006832FA /* LabelModel.swift */, - 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */, - 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */, - 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */, - 94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */, - 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */, - 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */, - 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */, - ); - path = LabelModel; - sourceTree = ""; - }; - 94FB5B83238D892800EB2193 /* Recovered References */ = { - isa = PBXGroup; - children = ( - ); - name = "Recovered References"; - sourceTree = ""; - }; - D213347423842FE3008E41B3 /* Controllers */ = { - isa = PBXGroup; - children = ( - D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */, - D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */, - D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */, - D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */, - D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */, - D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */, - ); - path = Controllers; - sourceTree = ""; - }; - D213347523842FF5008E41B3 /* Views */ = { - isa = PBXGroup; - children = ( - D29DF17E21E69E2E003B2FB9 /* MFView.h */, - D29DF17F21E69E2E003B2FB9 /* MFView.m */, - D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, - D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, - D29DF15921E697DA003B2FB9 /* SeparatorView.h */, - D29DF15A21E697DA003B2FB9 /* SeparatorView.m */, - D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */, - D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */, - D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */, - D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, - 0198F7A02256A80A0066C936 /* MFRadioButton.h */, - 0198F7A22256A80A0066C936 /* MFRadioButton.m */, - ); - path = Views; - sourceTree = ""; - }; - D224798823142BF2003FCCF9 /* SwitchMolecules */ = { - isa = PBXGroup; - children = ( - 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */, - D22479892314445E003FCCF9 /* LabelSwitch.swift */, - D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */, - ); - path = SwitchMolecules; - sourceTree = ""; - }; - D224798D2316A988003FCCF9 /* VerticalCombinationViews */ = { - isa = PBXGroup; - children = ( - D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, - D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, - D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */, - ); - path = VerticalCombinationViews; - sourceTree = ""; - }; - D224798E2316A995003FCCF9 /* HorizontalCombinationViews */ = { - isa = PBXGroup; - children = ( - D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */, - D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */, - ); - path = HorizontalCombinationViews; - sourceTree = ""; - }; - D224798F2316A99F003FCCF9 /* LeftRightViews */ = { - isa = PBXGroup; - children = ( - 01509D902327ECE600EF99AA /* CornerLabels.swift */, - D224798823142BF2003FCCF9 /* SwitchMolecules */, - ); - path = LeftRightViews; - sourceTree = ""; - }; - D22479902316A9CB003FCCF9 /* Organisms */ = { - isa = PBXGroup; - children = ( - D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, - D2A6390022CBB1820052ED1F /* Carousel.swift */, - ); - path = Organisms; - sourceTree = ""; - }; - D22479912316A9EF003FCCF9 /* Items */ = { - isa = PBXGroup; - children = ( - D2755D7A23689C7500485468 /* TableViewCell.swift */, - 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, - D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, - D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, - D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */, - D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */, - D2FB151C23A40F1500C20E10 /* StackItem.swift */, - ); - path = Items; - sourceTree = ""; - }; - D22D1F582204D2590077CEC0 /* Legacy */ = { - isa = PBXGroup; - children = ( - D213347523842FF5008E41B3 /* Views */, - D213347423842FE3008E41B3 /* Controllers */, - ); - path = Legacy; - sourceTree = ""; - }; - D29DF0C221E404D4003B2FB9 = { - isa = PBXGroup; - children = ( - D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */, - D29DF0CD21E404D4003B2FB9 /* Products */, - D29DF0E421E4F3C7003B2FB9 /* Frameworks */, - 94FB5B83238D892800EB2193 /* Recovered References */, - ); - sourceTree = ""; - }; - D29DF0CD21E404D4003B2FB9 /* Products */ = { - isa = PBXGroup; - children = ( - D29DF0CC21E404D4003B2FB9 /* MVMCoreUI.framework */, - ); - name = Products; - sourceTree = ""; - }; - D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */ = { - isa = PBXGroup; - children = ( - D29DF10D21E67A70003B2FB9 /* Atoms */, - 01509D96232803B200EF99AA /* Models */, - D2B18B7D236090D500A9AEDC /* BaseClasses */, - 01C74D87224298E2009C25A3 /* FormUIHelpers */, - D29DF31421ECECA7003B2FB9 /* SupportingFiles */, - D29DF27021E79B2C003B2FB9 /* OtherHandlers */, - D29DF13A21E68682003B2FB9 /* Utility */, - D29DF13321E68604003B2FB9 /* Styles */, - D29DF11021E6805F003B2FB9 /* Categories */, - D29DF11921E68467003B2FB9 /* Containers */, - D22D1F582204D2590077CEC0 /* Legacy */, - D29DF10F21E67A7D003B2FB9 /* BaseControllers */, - D29DF11E21E6851E003B2FB9 /* TopAlert */, - D29DF10E21E67A77003B2FB9 /* Molecules */, - D22479902316A9CB003FCCF9 /* Organisms */, - D29DF0DF21E418B2003B2FB9 /* Templates */, - D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */, - D29DF0D021E404D4003B2FB9 /* Info.plist */, - ); - path = MVMCoreUI; - sourceTree = ""; - }; - D29DF0DF21E418B2003B2FB9 /* Templates */ = { - isa = PBXGroup; - children = ( - 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */, - D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, - D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */, - D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */, - D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */, - D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */, - ); - path = Templates; - sourceTree = ""; - }; - D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { - isa = PBXGroup; - children = ( - D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */, - 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - D29DF10D21E67A70003B2FB9 /* Atoms */ = { - isa = PBXGroup; - children = ( - D29DF22B21E6A0FA003B2FB9 /* TextFields */, - D29DF17D21E69E26003B2FB9 /* Views */, - D29DF16821E69E1F003B2FB9 /* Buttons */, - ); - path = Atoms; - sourceTree = ""; - }; - D29DF10E21E67A77003B2FB9 /* Molecules */ = { - isa = PBXGroup; - children = ( - D22479912316A9EF003FCCF9 /* Items */, - D224798F2316A99F003FCCF9 /* LeftRightViews */, - D224798E2316A995003FCCF9 /* HorizontalCombinationViews */, - D224798D2316A988003FCCF9 /* VerticalCombinationViews */, - D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, - 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, - 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */, - D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */, - D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */, - D2A514662213885800345BFB /* StandardHeaderView.swift */, - D274CA322236A78900B01B62 /* StandardFooterView.swift */, - 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */, - D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, - D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */, - 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, - 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */, -<<<<<<< HEAD - 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, - 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, - D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, -======= - D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, - 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, - 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, ->>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c - ); - path = Molecules; - sourceTree = ""; - }; - D29DF10F21E67A7D003B2FB9 /* BaseControllers */ = { - isa = PBXGroup; - children = ( - D29DF16021E69996003B2FB9 /* MFViewController.h */, - D29DF15F21E69996003B2FB9 /* MFViewController.m */, - 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */, - D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */, - D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */, - D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */, - D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */, - D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */, - D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */, - D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */, - D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */, - D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */, - D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, - D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */, - D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */, - D2F4DDE52371A4CB00CD28BB /* ViewController.swift */, - ); - path = BaseControllers; - sourceTree = ""; - }; - D29DF11021E6805F003B2FB9 /* Categories */ = { - isa = PBXGroup; - children = ( - D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */, - D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */, - D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */, - D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */, - D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */, - 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */, - ); - path = Categories; - sourceTree = ""; - }; - D29DF11921E68467003B2FB9 /* Containers */ = { - isa = PBXGroup; - children = ( - D29DF2B721E7BE79003B2FB9 /* TabBarController */, - D29DF2B621E7BE66003B2FB9 /* SplitViewController */, - D2B18B93236214AD00A9AEDC /* NavigationController.swift */, - D243859823A16B1800332775 /* Container.swift */, - ); - path = Containers; - sourceTree = ""; - }; - D29DF11E21E6851E003B2FB9 /* TopAlert */ = { - isa = PBXGroup; - children = ( - D29DF12021E6851E003B2FB9 /* MVMCoreUITopAlertView.h */, - D29DF12421E6851E003B2FB9 /* MVMCoreUITopAlertView.m */, - D29DF12321E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h */, - D29DF12821E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m */, - D29DF11F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.h */, - D29DF12521E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m */, - D29DF12221E6851E003B2FB9 /* MVMCoreUITopAlertShortView.h */, - D29DF12621E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m */, - D29DF12721E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h */, - D29DF12121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m */, - ); - path = TopAlert; - sourceTree = ""; - }; - D29DF13321E68604003B2FB9 /* Styles */ = { - isa = PBXGroup; - children = ( - D29DF13821E68636003B2FB9 /* MFStyler.h */, - D29DF13921E68637003B2FB9 /* MFStyler.m */, - ); - path = Styles; - sourceTree = ""; - }; - D29DF13A21E68682003B2FB9 /* Utility */ = { - isa = PBXGroup; - children = ( - D29DF13B21E6870B003B2FB9 /* Sizing */, - D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */, - D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */, - D29DF14D21E693AD003B2FB9 /* MFFonts.h */, - D29DF14C21E693AD003B2FB9 /* MFFonts.m */, - D29DF29F21E7AF4E003B2FB9 /* MVMCoreUIUtility.h */, - D29DF2A021E7AF4E003B2FB9 /* MVMCoreUIUtility.m */, - D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */, - D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */, - 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */, - 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */, - D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */, - ); - path = Utility; - sourceTree = ""; - }; - D29DF13B21E6870B003B2FB9 /* Sizing */ = { - isa = PBXGroup; - children = ( - D29DF14521E68728003B2FB9 /* MFSizeObject.h */, - D29DF14421E68728003B2FB9 /* MFSizeObject.m */, - D29DF14621E68728003B2FB9 /* MFSizeThreshold.h */, - D29DF14721E68728003B2FB9 /* MFSizeThreshold.m */, - ); - path = Sizing; - sourceTree = ""; - }; - D29DF16821E69E1F003B2FB9 /* Buttons */ = { - isa = PBXGroup; - children = ( - DBC4391A224421A0001AB423 /* CaretButton.swift */, - D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, - D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, - D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, - D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, - D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, - D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, - D282AACA2243C61700C46919 /* ButtonView.swift */, - D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, - D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, - ); - path = Buttons; - sourceTree = ""; - }; - D29DF17D21E69E26003B2FB9 /* Views */ = { - isa = PBXGroup; - children = ( - 01509D922327ECFB00EF99AA /* ProgressBar.swift */, - 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, - D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */, - D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */, - D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */, - 948DB67D2326DCD90011F916 /* MultiProgress.swift */, - 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, - DBC4391622442196001AB423 /* CaretView.swift */, - 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */, - DBC4391722442197001AB423 /* DashLine.swift */, - 944589202385D6E900DE9FD4 /* DashLineModel.swift */, - DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, - 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, - D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, - D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, - 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */, - D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */, - D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, - 944589222385DA9500DE9FD4 /* ImageViewModel.swift */, - D213347623843825008E41B3 /* Line.swift */, - D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, - D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */, - D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, - D268C711238D6699007F2C1C /* DropDown.swift */, - D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */, - D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */, - D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */, - D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */, - D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */, - D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */, - D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, - D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, - DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, - DB891E822253FA8500022516 /* Label.swift */, - 94C2D9822386F3E30006CF46 /* LabelModel */, - 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, - 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, - 01004F2F22721C3800991ECC /* RadioButton.swift */, - 943784F3236B77BB006A1E82 /* GraphView.swift */, - 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */, - ); - path = Views; - sourceTree = ""; - }; - D29DF22B21E6A0FA003B2FB9 /* TextFields */ = { - isa = PBXGroup; - children = ( - D29DF24C21E6A177003B2FB9 /* MFTextField.h */, - D29DF24221E6A176003B2FB9 /* MFTextField.m */, - 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */, - D29DF24421E6A176003B2FB9 /* MFTextField.xib */, - D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */, - D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */, - D29DF24921E6A177003B2FB9 /* MFMdnTextField.m */, - D29DF24521E6A176003B2FB9 /* MFDigitTextBox.h */, - D29DF24621E6A176003B2FB9 /* MFDigitTextBox.m */, - D29DF24321E6A176003B2FB9 /* MFDigitTextField.h */, - D29DF24821E6A177003B2FB9 /* MFDigitTextField.m */, - D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */, - ); - path = TextFields; - sourceTree = ""; - }; - D29DF26621E6A9E4003B2FB9 /* ThirdParty */ = { - isa = PBXGroup; - children = ( - D29DF26721E6AA0B003B2FB9 /* FLAnimatedImage */, - ); - path = ThirdParty; - sourceTree = ""; - }; - D29DF26721E6AA0B003B2FB9 /* FLAnimatedImage */ = { - isa = PBXGroup; - children = ( - D29DF26A21E6AA0B003B2FB9 /* FLAnimatedImage.h */, - D29DF26821E6AA0B003B2FB9 /* FLAnimatedImage.m */, - D29DF26B21E6AA0B003B2FB9 /* FLAnimatedImageView.h */, - D29DF26921E6AA0B003B2FB9 /* FLAnimatedImageView.m */, - ); - path = FLAnimatedImage; - sourceTree = ""; - }; - D29DF27021E79B2C003B2FB9 /* OtherHandlers */ = { - isa = PBXGroup; - children = ( - D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */, - D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */, - D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */, - D29DF27821E7A533003B2FB9 /* MVMCoreUISession.m */, - D29DF27321E79E81003B2FB9 /* MVMCoreUILoggingHandler.h */, - D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */, - D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */, - D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */, - D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, - D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */, - D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, - D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, - 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, - 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, - ); - path = OtherHandlers; - sourceTree = ""; - }; - D29DF2B621E7BE66003B2FB9 /* SplitViewController */ = { - isa = PBXGroup; - children = ( - D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */, - D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */, - D29DF15321E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h */, - D29DF11A21E684A9003B2FB9 /* MVMCoreUISplitViewController.h */, - D29DF11B21E684A9003B2FB9 /* MVMCoreUISplitViewController.m */, - ); - path = SplitViewController; - sourceTree = ""; - }; - D29DF2B721E7BE79003B2FB9 /* TabBarController */ = { - isa = PBXGroup; - children = ( - D29DF2C021E7BF56003B2FB9 /* MFTabBarSwipeAnimator.h */, - D29DF2C121E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m */, - D29DF2C221E7BF57003B2FB9 /* MFTabBarInteractor.h */, - D29DF2C321E7BF57003B2FB9 /* MFTabBarInteractor.m */, - D29DF2B821E7BEA4003B2FB9 /* TopTabbar.h */, - D29DF2BA21E7BEA4003B2FB9 /* TopTabbar.m */, - D29DF2B921E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h */, - D29DF2BB21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m */, - ); - path = TabBarController; - sourceTree = ""; - }; - D29DF31421ECECA7003B2FB9 /* SupportingFiles */ = { - isa = PBXGroup; - children = ( - D29DF32721EE8736003B2FB9 /* Strings */, - D29DF26621E6A9E4003B2FB9 /* ThirdParty */, - D29DF31521ECECC0003B2FB9 /* Fonts */, - D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */, - ); - path = SupportingFiles; - sourceTree = ""; - }; - D29DF31521ECECC0003B2FB9 /* Fonts */ = { - isa = PBXGroup; - children = ( - D29DF31621ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf */, - D29DF31721ECECC0003B2FB9 /* OCRAExtended.ttf */, - D29DF31821ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf */, - D29DF31921ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf */, - ); - path = Fonts; - sourceTree = ""; - }; - D29DF32721EE8736003B2FB9 /* Strings */ = { - isa = PBXGroup; - children = ( - D29DF32821EE8736003B2FB9 /* Localizable.strings */, - ); - path = Strings; - sourceTree = ""; - }; - D2B18B7D236090D500A9AEDC /* BaseClasses */ = { - isa = PBXGroup; - children = ( - D2B18B7E2360913400A9AEDC /* Control.swift */, - D2B18B802360945C00A9AEDC /* View.swift */, - ); - path = BaseClasses; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - D29DF0C721E404D4003B2FB9 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */, - D29DF18021E69E49003B2FB9 /* MFView.h in Headers */, - D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */, - D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */, - D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */, - D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */, - 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */, - D29DF25221E6A177003B2FB9 /* MFMdnTextField.h in Headers */, - D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */, - D29DF29921E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h in Headers */, - D29DF11C21E684A9003B2FB9 /* MVMCoreUISplitViewController.h in Headers */, - D29DF29B21E7ADB9003B2FB9 /* StackableViewController.h in Headers */, - D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */, - D29DF15421E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h in Headers */, - D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */, - D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */, - D29DF29A21E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h in Headers */, - D29DF25621E6A177003B2FB9 /* MFTextFieldSubclassExtension.h in Headers */, - D29DF11521E6805F003B2FB9 /* UIColor+MFConvenience.h in Headers */, - D29DF2BC21E7BEA4003B2FB9 /* TopTabbar.h in Headers */, - D29DF25921E6A22D003B2FB9 /* MFButtonProtocol.h in Headers */, - D22D1F46220496A30077CEC0 /* MVMCoreUISwitch.h in Headers */, - D22D1F1E220343560077CEC0 /* MVMCoreUICheckMarkView.h in Headers */, - D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */, - D22D1F562204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h in Headers */, - D29DF2CE21E7C104003B2FB9 /* MFLoadingViewController.h in Headers */, - D29DF12A21E6851E003B2FB9 /* MVMCoreUITopAlertView.h in Headers */, - D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */, - D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */, - D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */, - D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */, - D29DF25021E6A177003B2FB9 /* MFDigitTextBox.h in Headers */, - D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */, - D29DF2C621E7BF57003B2FB9 /* MFTabBarInteractor.h in Headers */, - D29DF25721E6A177003B2FB9 /* MFTextField.h in Headers */, - D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */, - D29DF18221E69E54003B2FB9 /* SeparatorView.h in Headers */, - D29DF26E21E6AA0B003B2FB9 /* FLAnimatedImage.h in Headers */, - D29DF11621E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h in Headers */, - D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */, - 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */, - D29DF16221E69996003B2FB9 /* MFViewController.h in Headers */, - D29DF13121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h in Headers */, - D29DF2C421E7BF57003B2FB9 /* MFTabBarSwipeAnimator.h in Headers */, - D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */, - D29DF2CA21E7BFC8003B2FB9 /* MFSizeThreshold.h in Headers */, - D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */, - D29DF2BD21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h in Headers */, - D29DF2EE21ECEADF003B2FB9 /* MFFonts.h in Headers */, - D29DF12D21E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h in Headers */, - D29DF24E21E6A177003B2FB9 /* MFDigitTextField.h in Headers */, - D29770F321F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h in Headers */, - D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */, - D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */, - D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */, - D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */, - D29DF29721E7ADB8003B2FB9 /* MFScrollingViewController.h in Headers */, - D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */, - D29DF26F21E6AA0B003B2FB9 /* FLAnimatedImageView.h in Headers */, - D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */, - D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */, - D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */, - D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */, - D29DF32021ED0CBA003B2FB9 /* LabelView.h in Headers */, - D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */, - D29DF2E121E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h in Headers */, - D29DF12921E6851E003B2FB9 /* MVMCoreUITopAlertMainView.h in Headers */, - D29DF12C21E6851E003B2FB9 /* MVMCoreUITopAlertShortView.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - D29DF0CB21E404D4003B2FB9 /* MVMCoreUI */ = { - isa = PBXNativeTarget; - buildConfigurationList = D29DF0D421E404D4003B2FB9 /* Build configuration list for PBXNativeTarget "MVMCoreUI" */; - buildPhases = ( - D29DF0C721E404D4003B2FB9 /* Headers */, - D29DF0C821E404D4003B2FB9 /* Sources */, - D29DF0C921E404D4003B2FB9 /* Frameworks */, - D29DF0CA21E404D4003B2FB9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = MVMCoreUI; - productName = MVMCoreUI; - productReference = D29DF0CC21E404D4003B2FB9 /* MVMCoreUI.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - D29DF0C321E404D4003B2FB9 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1010; - ORGANIZATIONNAME = "Verizon Wireless"; - TargetAttributes = { - D29DF0CB21E404D4003B2FB9 = { - CreatedOnToolsVersion = 10.1; - LastSwiftMigration = 1010; - ProvisioningStyle = Automatic; - }; - }; - }; - buildConfigurationList = D29DF0C621E404D4003B2FB9 /* Build configuration list for PBXProject "MVMCoreUI" */; - compatibilityVersion = "Xcode 8.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - es, - "es-MX", - ); - mainGroup = D29DF0C221E404D4003B2FB9; - productRefGroup = D29DF0CD21E404D4003B2FB9 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - D29DF0CB21E404D4003B2FB9 /* MVMCoreUI */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - D29DF0CA21E404D4003B2FB9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D29DF25521E6A177003B2FB9 /* MFDigitTextField.xib in Resources */, - D29DF2AF21E7B3A4003B2FB9 /* MFTextView.xib in Resources */, - D29DF31C21ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf in Resources */, - D29DF24F21E6A177003B2FB9 /* MFTextField.xib in Resources */, - D29DF31D21ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf in Resources */, - D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */, - D29DF31A21ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf in Resources */, - D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */, - D29DF31B21ECECC0003B2FB9 /* OCRAExtended.ttf in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - D29DF0C821E404D4003B2FB9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, - D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, - DBC4391822442197001AB423 /* CaretView.swift in Sources */, - D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, - 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */, - D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, - 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, - 012CA98923849699003F810F /* SeperatorModel.swift in Sources */, - DBC4391922442197001AB423 /* DashLine.swift in Sources */, - 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */, - 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, - D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */, - D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, - 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, - 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, - D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, - D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, - D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, - D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, - 0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */, - 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, - D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */, - 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, - D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, - D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, - D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */, - D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, - D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, - DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, - D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, - 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, - 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, - D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */, - 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, - D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, - D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, - 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, - D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, - D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, - 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */, - D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, - D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, - 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, - D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, - D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, - D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, - 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, - 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, - D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, - D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, - 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, - D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, - 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, - 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */, - D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, - D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, - 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, - D213347723843825008E41B3 /* Line.swift in Sources */, - D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, - 01EB369023609801006832FA /* ListItemModel.swift in Sources */, - D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, - DBEFFA04225A829700230692 /* Label.swift in Sources */, - D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, - 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, - D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, - 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */, - D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, - D2B18B812360945C00A9AEDC /* View.swift in Sources */, - D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, - D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, - D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, - 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */, - D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, - D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, - D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, - 01EB368F23609801006832FA /* LabelModel.swift in Sources */, - 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, - 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, - D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, - 0AA33B36239813EE0067DD0F /* Color.swift in Sources */, - D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, - 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, - D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, - D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, - D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, - 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, - 94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */, - 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */, - D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, - D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, - D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, - 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, - 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, - D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, - 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, - D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, - D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, - 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */, - D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, - D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, - D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, - D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, - D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, - D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, - D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, - D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, - DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, - D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */, - D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, - 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */, - D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, - D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, - 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, - 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */, - 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */, - D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, - D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, - 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, - D243859923A16B1800332775 /* Container.swift in Sources */, - D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, - D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, - 01EB369323609801006832FA /* HeaderModel.swift in Sources */, - D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, - 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, - D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, - D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, - 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, - D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, - 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, - D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, - D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, - 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, - D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, - D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, - D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, - DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, - 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, - D268C712238D6699007F2C1C /* DropDown.swift in Sources */, - 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */, - D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, - D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, - 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */, - 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */, - 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, - D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, - D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, - D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, - D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, - D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, - D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, - D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */, - 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */, - 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, - 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, - D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, - D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, - 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */, - 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, - D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - D29DF32821EE8736003B2FB9 /* Localizable.strings */ = { - isa = PBXVariantGroup; - children = ( - D29DF32921EE8736003B2FB9 /* en */, - D29DF32A21EE8736003B2FB9 /* es */, - D29DF32B21EE8736003B2FB9 /* es-MX */, - ); - name = Localizable.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - D29DF0D221E404D4003B2FB9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - D29DF0D321E404D4003B2FB9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - D29DF0D521E404D4003B2FB9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BITCODE_GENERATION_MODE = bitcode; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = FCMA4QKS77; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../SharedFrameworks"; - INFOPLIST_FILE = MVMCoreUI/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - D29DF0D621E404D4003B2FB9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BITCODE_GENERATION_MODE = bitcode; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = FCMA4QKS77; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../SharedFrameworks"; - INFOPLIST_FILE = MVMCoreUI/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - D29DF0C621E404D4003B2FB9 /* Build configuration list for PBXProject "MVMCoreUI" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D29DF0D221E404D4003B2FB9 /* Debug */, - D29DF0D321E404D4003B2FB9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - D29DF0D421E404D4003B2FB9 /* Build configuration list for PBXNativeTarget "MVMCoreUI" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D29DF0D521E404D4003B2FB9 /* Debug */, - D29DF0D621E404D4003B2FB9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = D29DF0C321E404D4003B2FB9 /* Project object */; -} diff --git a/MVMCoreUI/Containers/Container.swift b/MVMCoreUI/Containers/Container.swift index 43fd62c8..a2e34a49 100644 --- a/MVMCoreUI/Containers/Container.swift +++ b/MVMCoreUI/Containers/Container.swift @@ -203,6 +203,7 @@ open class Container: View, ContainerProtocol { get { return model as? ContainerModelProtocol } } + // MARK:- ModelMoleculeViewProtocol override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let containerModel = model as? ContainerModelProtocol else { return } diff --git a/MVMCoreUI/Models/Molecules/NumberedListModel.swift b/MVMCoreUI/Models/Molecules/NumberedListModel.swift deleted file mode 100644 index 380c193f..00000000 --- a/MVMCoreUI/Models/Molecules/NumberedListModel.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// NumberedListModel.swift -// MVMCoreUI -// -// Created by Murugan, Vimal on 10/01/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers public class NumberedListModel: OrderListProtocol { - public var backgroundColor: Color? - public static var identifier: String = "numberedList" - public var list: [MoleculeProtocol] - - enum CodingKeys: String, CodingKey { - case list - } - - public required init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - list = try typeContainer.decodeMolecules(codingKey: .list) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModels(list, forKey: .list) - } -} - -public protocol OrderListProtocol: MoleculeProtocol { - var list: [MoleculeProtocol] {get} -} diff --git a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift b/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift deleted file mode 100644 index 8d3280d9..00000000 --- a/MVMCoreUI/Models/Molecules/UnOrderedListModel.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// UnOrderedListModel.swift -// MVMCoreUI -// -// Created by Murugan, Vimal on 10/01/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers public class UnOrderedListModel: OrderListProtocol { - public var backgroundColor: Color? - public static var identifier: String = "unOrderedList" - public var bulletChar: String? - public var list: [MoleculeProtocol] - - enum CodingKeys: String, CodingKey { - case bulletChar - case list - } - - public required init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) - list = try typeContainer.decodeMolecules(codingKey: .list) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(bulletChar, forKey: .bulletChar) - try container.encodeModels(list, forKey: .list) - } -} diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift index 31091796..72aceab7 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift @@ -94,12 +94,12 @@ extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { } class ColorViewLabelsStack: MoleculeStackView { - override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { + override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { let view = ColorViewWithLabel() let stackItem = MoleculeStackItem(andContain: view) - stackItem.setWithModel(model, delegate, nil) + stackItem.setWithModel(model, delegateObject, additionalData) stackItems.append(stackItem) } } diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index 9ab86687..9484cd8d 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -8,7 +8,9 @@ import Foundation -@objcMembers public class StackItemModel: StackItemModelProtocol, Codable { +@objcMembers public class StackItemModel: StackItemModelProtocol, MoleculeProtocol { + public static var identifier: String = "simpleStackItem" + public var backgroundColor: Color? public var spacing: CGFloat? public var percent: Int? public var gone: Bool = false diff --git a/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift b/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift index 2223ed39..165cb1ac 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol StackItemModelProtocol { +public protocol StackItemModelProtocol: MoleculeProtocol { var spacing: CGFloat? { get set } var percent: Int? { get set } var gone: Bool { get set } diff --git a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift b/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift deleted file mode 100644 index 693df09c..00000000 --- a/MVMCoreUI/Molecules/LabelRightMoleculesStack.swift +++ /dev/null @@ -1,167 +0,0 @@ -// -// ListMoleculeContainer.swift -// MVMCoreUI -// -// Created by Murugan, Vimal on 03/01/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class LabelRightMoleculesStack: MoleculeStackView { - - var orderedListModel: OrderListProtocol? - - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - let previousModel = self.orderedListModel - //Remove previously drawn views - removeAllItemViews() - guard let orderedListModel = model as? OrderListProtocol else { - return - } - - var items: [StackItem]? - if previousModel?.list.count == orderedListModel.list.count { - items = stackItems - } - stackItems = [] - self.model = MoleculeStackModel(molecules: []) - for (index, labelModel) in orderedListModel.list.enumerated() { - let labelContainer = items?[index].view as? LeftLabelRightMoleculeContainer ?? LeftLabelRightMoleculeContainer() - labelContainer.leftText = leftTextForIndex(index) - labelContainer.setWithModel(labelModel, delegateObject, additionalData) - addView(labelContainer, lastItem: index == orderedListModel.list.count - 1) - } - self.orderedListModel = orderedListModel - restack() - } - - //MARK: - Subclass should overirde this - func leftTextForIndex(_ index: Int) -> String { - return "" - } -} - -class LeftLabelRightMoleculeContainer: View { - - var label = Label.commonLabelB2(true) - var rightContainer = MVMCoreUICommonViewsUtility.commonView() - var leftContainer = MVMCoreUICommonViewsUtility.commonView() - var rightMoleculeName: String? - var rightMolecule: View? - var leftText: String? - var leftWidthConstraint: NSLayoutConstraint? - var percentage: CGFloat = 5 - - var constraintBtwViews: NSLayoutConstraint? - var spaceBtwViews: CGFloat = 0 { - didSet { - if spaceBtwViews != oldValue { - constraintBtwViews?.constant = spaceBtwViews - setNeedsDisplay() - } - } - } - - // MARK: - Inits - public convenience init() { - self.init(frame:.zero) - } - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func setupView() { - super.setupView() - - guard rightContainer.superview == nil else { - return - } - - translatesAutoresizingMaskIntoConstraints = false - addSubview(rightContainer) - addSubview(leftContainer) - leftContainer.addSubview(label) - - NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false) - leftContainer.rightAnchor.constraint(greaterThanOrEqualTo: label.rightAnchor).isActive = true - leftContainer.bottomAnchor.constraint(greaterThanOrEqualTo: label.bottomAnchor).isActive = true - - let lowRightConstraint = leftContainer.rightAnchor.constraint(equalTo: label.rightAnchor) - lowRightConstraint.priority = UILayoutPriority(rawValue: 200) - lowRightConstraint.isActive = true - - let lowBottomConstraint = leftContainer.bottomAnchor.constraint(equalTo: label.bottomAnchor) - lowBottomConstraint.priority = UILayoutPriority(rawValue: 200) - lowBottomConstraint.isActive = true - - NSLayoutConstraint.constraintPinSubview(leftContainer, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false) - bottomAnchor.constraint(greaterThanOrEqualTo: leftContainer.bottomAnchor).isActive = true - - NSLayoutConstraint.constraintPinSubview(rightContainer, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true) - constraintBtwViews = rightContainer.leftAnchor.constraint(equalTo: leftContainer.rightAnchor, constant: spaceBtwViews) - constraintBtwViews?.priority = .required - constraintBtwViews?.isActive = true - - setContentHuggingPriority(.defaultHigh, for: .vertical) - setContentHuggingPriority(.defaultHigh, for: .horizontal) - updateLeftViewWidthConstraint(percentage) - - } - - override func updateView(_ size: CGFloat) { - super.updateView(size) - rightMolecule?.updateView(size) - label.updateView(size) - updateLeftViewWidthConstraint(percentage) - setNeedsDisplay() - } - - override func reset() { - super.reset() - rightMolecule?.reset() - } - - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - let previousMoleculeName = self.rightMoleculeName - super.setWithModel(model, delegateObject, additionalData) - removeSubviewsInRightContainer() - label.text = leftText - rightMoleculeName = model?.moleculeName - guard let validModel = model else { - return - } - //For reuse purpose check that allready added molecule is same - if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName { - rightMolecule.setWithModel(validModel, delegateObject, additionalData) - addView(rightMolecule) - } else { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(validModel, delegateObject, false) { - addView(molecule) - } - } - } - - func updateLeftViewWidthConstraint(_ percent: CGFloat) { - percentage = percent - leftWidthConstraint?.isActive = false - leftWidthConstraint = leftContainer.widthAnchor.constraint(equalTo: widthAnchor, multiplier: CGFloat(percent/100), constant: 0) - leftWidthConstraint?.isActive = true - } - - func removeSubviewsInRightContainer() { - rightContainer.subviews.forEach({ $0.removeFromSuperview() }) - } - - func addView(_ view: UIView) { - view.translatesAutoresizingMaskIntoConstraints = false - rightContainer.addSubview(view) - NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true) - rightMolecule = view as? View - } -} diff --git a/MVMCoreUI/Molecules/MoleculeContainer.swift b/MVMCoreUI/Molecules/MoleculeContainer.swift index e3646bcf..dc70e38d 100644 --- a/MVMCoreUI/Molecules/MoleculeContainer.swift +++ b/MVMCoreUI/Molecules/MoleculeContainer.swift @@ -42,4 +42,28 @@ open class MoleculeContainer: Container { } super.setWithModel(model, delegateObject, additionalData) } + + public override static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let containerModel = model as? MoleculeContainerModel, + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, + let moleculeName = moleculeClass.nameForReuse(containerModel.molecule, delegateObject) else { + return "\(model?.moleculeName ?? "moleculeContainer")<>" + } + return "\(model?.moleculeName ?? "moleculeContainer")<\(moleculeName)>" + } + + public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + guard let containerModel = molecule as? MoleculeContainerModel else { return 0 } + guard let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, + let moleculeHeight = moleculeClass.estimatedHeight(forRow: containerModel.molecule, delegateObject: delegateObject) else { + return (containerModel.topMarginPadding ?? 0) + (containerModel.bottomMarginPadding ?? 0) + } + return moleculeHeight + (containerModel.topMarginPadding ?? 0) + (containerModel.bottomMarginPadding ?? 0) + } + + public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + guard let containerModel = molecule as? MoleculeContainerModel, + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type else { return nil } + return moleculeClass.requiredModules(containerModel.molecule, delegateObject: delegateObject, error: error) + } } diff --git a/MVMCoreUI/Molecules/NumberedList.swift b/MVMCoreUI/Molecules/NumberedList.swift deleted file mode 100644 index 376dffc0..00000000 --- a/MVMCoreUI/Molecules/NumberedList.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// NumberedList.swift -// MVMCoreUI -// -// Created by Murugan, Vimal on 03/01/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class NumberedList: LabelRightMoleculesStack { - - //MARK:- Super class override methods - override func leftTextForIndex(_ index: Int) -> String { - return String(index+1) + "." - } - -} diff --git a/MVMCoreUI/Molecules/UnOrderedList.swift b/MVMCoreUI/Molecules/UnOrderedList.swift deleted file mode 100644 index 4f85a483..00000000 --- a/MVMCoreUI/Molecules/UnOrderedList.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// UnOrderedList.swift -// MVMCoreUI -// -// Created by Murugan, Vimal on 03/01/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class UnOrderedList: LabelRightMoleculesStack { - - //MARK:- Super class override methods - override func leftTextForIndex(_ index: Int) -> String { - return (orderedListModel as? UnOrderedListModel)?.bulletChar ?? "•" - } - -} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedList.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedList.swift new file mode 100644 index 00000000..8f977ed7 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedList.swift @@ -0,0 +1,14 @@ +// +// NumberedList.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 03/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class NumberedList: StringAndMoleculeStack { +} + + diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift new file mode 100644 index 00000000..728ae3a8 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -0,0 +1,47 @@ +// +// NumberedListModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 10/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class NumberedListModel: MoleculeStackModel { + public override class var identifier: String { + return "numberedList" + } + + private enum NumberedListCodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case list + } + + // Numbered list model comes in the from of list = [MoleculeProtocol] + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: NumberedListCodingKeys.self) + + let list = try typeContainer.decodeMolecules(codingKey: .list) + var models: [MoleculeStackItemModel] = [] + for (index, molecule) in list.enumerated() { + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index).", molecule: molecule))) + } + super.init(molecules: models) + spacing = 0 + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: NumberedListCodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + + var models: [MoleculeProtocol] = [] + for molecule in molecules { + models.append(molecule.molecule) + } + try container.encodeModels(models, forKey: .list) + } +} + + diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift new file mode 100644 index 00000000..f2c73cab --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -0,0 +1,42 @@ +// +// StringAndMoleculeModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/17/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class StringAndMoleculeModel: MoleculeProtocol { + public static var identifier: String = "stringAndMoleculeModel" + public var backgroundColor: Color? + public var string: String + public var molecule: MoleculeProtocol + + public init(string: String, molecule: MoleculeProtocol) { + self.string = string + self.molecule = molecule + } + + enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case string + case molecule + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + string = try typeContainer.decode(String.self, forKey: .string) + molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(string, forKey: .string) + try container.encodeModel(molecule, forKey: .molecule) + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift new file mode 100644 index 00000000..2606ecf4 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift @@ -0,0 +1,28 @@ +// +// ListMoleculeContainer.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 03/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +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 { + override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let model = stackModel else { return } + for stackItemModel in model.molecules { + guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel, + let moleculeName = stringAndMoleculeModel.molecule.moleculeName, + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: moleculeName) as? (UIView & ModelMoleculeViewProtocol) else { + // Throw error + return + } + let view = StringAndMoleculeView(string: stringAndMoleculeModel.string, molecule: molecule) + let stackItem = MoleculeStackItem(andContain: view) + stackItem.setWithModel(stackItemModel, delegateObject, nil) + stackItems.append(stackItem) + } + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift new file mode 100644 index 00000000..1874c163 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -0,0 +1,92 @@ +// +// StringAndMoleculeView.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/17/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class StringAndMoleculeView: View { + var label = Label.commonLabelB2(true) + var string: String + var molecule: UIView & ModelMoleculeViewProtocol + + var leftWidthConstraint: NSLayoutConstraint? + @Percent var percentage: CGFloat = 5 + + var constraintBetweenViews: NSLayoutConstraint? + var spaceBetweenViews: CGFloat = 0 { + didSet { + if spaceBetweenViews != oldValue { + constraintBetweenViews?.constant = spaceBetweenViews + setNeedsDisplay() + } + } + } + + // MARK: - Inits + public init(string: String, molecule: UIView & ModelMoleculeViewProtocol) { + self.string = string + self.molecule = molecule + super.init(frame: .zero) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override public func setupView() { + super.setupView() + guard subviews.count == 0 else { + return + } + + translatesAutoresizingMaskIntoConstraints = false + addSubview(label) + addSubview(molecule) + + NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false) + bottomAnchor.constraint(greaterThanOrEqualTo: label.bottomAnchor).isActive = true + + let lowBottomConstraint = bottomAnchor.constraint(equalTo: label.bottomAnchor) + lowBottomConstraint.priority = UILayoutPriority(rawValue: 200) + lowBottomConstraint.isActive = true + + NSLayoutConstraint.constraintPinSubview(molecule, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true) + constraintBetweenViews = molecule.leftAnchor.constraint(equalTo: label.rightAnchor, constant: spaceBetweenViews) + constraintBetweenViews?.priority = .required + constraintBetweenViews?.isActive = true + + setContentHuggingPriority(.defaultHigh, for: .vertical) + setContentHuggingPriority(.defaultHigh, for: .horizontal) + updateLeftViewWidthConstraint(percentage) + } + + override open func updateView(_ size: CGFloat) { + super.updateView(size) + (molecule as? MVMCoreViewProtocol)?.updateView(size) + label.updateView(size) + } + + override open func reset() { + super.reset() + label.reset() + (molecule as? MoleculeViewProtocol)?.reset?() + } + + public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? StringAndMoleculeModel else { return } + label.text = model.string + molecule.setWithModel(model.molecule, delegateObject, additionalData) + } + + func updateLeftViewWidthConstraint(_ percent: CGFloat) { + percentage = percent + leftWidthConstraint?.isActive = false + leftWidthConstraint = label.widthAnchor.constraint(equalTo: widthAnchor, multiplier: CGFloat(percent/100), constant: 0) + leftWidthConstraint?.isActive = true + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift new file mode 100644 index 00000000..b393866c --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift @@ -0,0 +1,12 @@ +// +// UnOrderedList.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 03/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class UnOrderedList: StringAndMoleculeStack { +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift new file mode 100644 index 00000000..a905401c --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -0,0 +1,51 @@ +// +// UnOrderedListModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 10/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class UnOrderedListModel: MoleculeStackModel { + public override class var identifier: String { + return "unOrderedList" + } + public var bulletChar = "•" + + private enum NumberedListCodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case list + case bulletChar + } + + // Numbered list model comes in the from of list = [MoleculeProtocol] + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: NumberedListCodingKeys.self) + if let bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) { + self.bulletChar = bulletChar + } + + let list = try typeContainer.decodeMolecules(codingKey: .list) + var models: [MoleculeStackItemModel] = [] + for molecule in list { + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule))) + } + super.init(molecules: models) + spacing = 0 + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: NumberedListCodingKeys.self) + try container.encode(bulletChar, forKey: .bulletChar) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + + var models: [MoleculeProtocol] = [] + for molecule in molecules { + models.append(molecule.molecule) + } + try container.encodeModels(models, forKey: .list) + } +} diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift index 7136718c..5f33725e 100644 --- a/MVMCoreUI/Organisms/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -10,7 +10,9 @@ import Foundation @objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol, StackModelProtocol { - public static var identifier: String = "stack" + public class var identifier: String { + return "stack" + } public var backgroundColor: Color? public var molecules: [MoleculeStackItemModel] public var axis: NSLayoutConstraint.Axis = .vertical diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index a7dd1640..aa81ff80 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -23,10 +23,10 @@ open class MoleculeStackView: Stack { // MARK: - Adding to stack /// Creates all of the stackItems for the stackItemModels - override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { + override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { - if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? MoleculeStackItem { + if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegateObject) as? MoleculeStackItem { stackItems.append(stackItem) } } diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 0fc1ca8f..572c772f 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -94,38 +94,26 @@ open class Stack: Container where T: StackModelProtocol { removeAllItemViews() // If the items in the stack are different, clear them, create new ones. - if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) { + if (previousModel == nil) || Self.nameForReuse(previousModel, delegateObject) != Self.nameForReuse(model, delegateObject) { stackItems = [] - createStackItemsFromModel(with: delegateObject) - } else if let models = stackModel?.molecules { - for (index, element) in models.enumerated() { - (stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element as? MoleculeProtocol, delegateObject, additionalData) - } + createStackItemsFromModel(model, delegateObject, additionalData) + } else { + setStackItemsFromModel(model, delegateObject, additionalData) } restack() } - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - if let model = model { - setWithModel(model, delegateObject, additionalData) - } else if let json = json, - let data = try? JSONSerialization.data(withJSONObject: json), - let model = try? JSONDecoder().decode(MoleculeStackModel.self, from: data) { - setWithModel(model, delegateObject, additionalData) - } - } - public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { // This will aggregate names of molecules to make an id. - guard let model = model as? MoleculeStackModel else { + guard let model = model as? T else { return "stack<>" } var name = "stack<" for case let item in model.molecules { - if let moleculeName = item.molecule.moleculeName { + if let moleculeName = item.moleculeName { if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type, - let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) { + let nameForReuse = moleculeClass.nameForReuse(item, delegateObject) { name.append(nameForReuse + ",") } else { name.append(moleculeName + ",") @@ -138,7 +126,7 @@ open class Stack: Container where T: StackModelProtocol { // Need to update to take into account first spacing flag public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - guard let model = molecule as? MoleculeStackModel else { return 0 } + guard let model = molecule as? T else { return 0 } let horizontal = model.axis == .horizontal var estimatedHeight: CGFloat = 0 for case let item in model.molecules { @@ -157,7 +145,7 @@ open class Stack: Container where T: StackModelProtocol { } public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { - guard let model = molecule as? MoleculeStackModel else { return nil } + guard let model = molecule as? T else { return nil } var modules: [String] = [] for case let item in model.molecules { if let modulesForMolecule = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.requiredModules(item, delegateObject: delegateObject, error: error) { @@ -167,11 +155,21 @@ open class Stack: Container where T: StackModelProtocol { return modules.count > 0 ? modules : nil } - // MARK: - Adding to stack + // MARK: - Subclassables + /// Can be subclassed to create views when we get stack item models and have no views yet - func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) { + func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { } + /// Can be subclassed to set stack items with model when we already have views + func setStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let models = stackModel?.molecules else { return } + for (index, element) in models.enumerated() { + (stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element, delegateObject, additionalData) + } + } + + // MARK: - Adding to stack /// Convenience function, adds a view to a StackItem to the Stack func addViewToItemToStack(_ view: UIView, lastItem: Bool) { let stackItemModel = StackItemModel() diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 5199cf96..1eda2454 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -72,8 +72,6 @@ @"headlineBodyButton": HeadlineBodyButton.class, @"stackItem": MoleculeStackItem.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, - @"unOrderedList": UnOrderedList.class, - @"numberedList": NumberedList.class, @"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class, @"doughnutChart": DoughnutChartView.class, @"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index b81c6e08..b12145f2 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -11,13 +11,23 @@ import Foundation @objcMembers public class MoleculeObjectMapping: NSObject { public static func registerObjects() { let mapping = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping - mapping?.setObject(MoleculeStackView.self, forKey: "stack" as NSString) - + ModelRegistry.register(MoleculeStackModel.self) + mapping?.setObject(MoleculeStackView.self, forKey: MoleculeStackModel.identifier as NSString) + ModelRegistry.register(StackModel.self) + mapping?.setObject(Stack.self, forKey: StackModel.identifier as NSString) + ModelRegistry.register(StackItemModel.self) + mapping?.setObject(StackItem.self, forKey: StackItemModel.identifier as NSString) + ModelRegistry.register(StringAndMoleculeModel.self) + mapping?.setObject(StringAndMoleculeView.self, forKey: StringAndMoleculeModel.identifier as NSString) + ModelRegistry.register(UnOrderedListModel.self) + mapping?.setObject(UnOrderedList.self, forKey: UnOrderedListModel.identifier as NSString) + ModelRegistry.register(NumberedListModel.self) + mapping?.setObject(NumberedList.self, forKey: NumberedListModel.identifier as NSString) + ModelRegistry.register(LabelModel.self) ModelRegistry.register(HeaderModel.self) ModelRegistry.register(FooterModel.self) ModelRegistry.register(HeadlineBodyModel.self) - ModelRegistry.register(MoleculeStackModel.self) ModelRegistry.register(MoleculeStackItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(ProgressBarModel.self) From d80ae0bd04989a851c8e425fd442b4e903c4c7f2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 17 Jan 2020 14:07:31 -0500 Subject: [PATCH 171/272] more label fix --- MVMCoreUI/Atoms/Views/Label.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index b4173add..2188b2a2 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -263,13 +263,13 @@ public typealias ActionBlock = () -> () } if let attributes = labelModel.attributes, let labelText = text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor]) + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.withSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) for attribute in attributes { let range = NSRange(location: attribute.location, length: attribute.length) switch attribute { - case let _ as LabelAttributeUnderlineModel: + case _ as LabelAttributeUnderlineModel: attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range) - case let _ as LabelAttributeStrikeThroughModel: + case _ as LabelAttributeStrikeThroughModel: attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range) attributedString.addAttribute(.baselineOffset, value: 0, range: range) case let colorAtt as LabelAttributeColorModel: From 19d3b960ae2c47f8e5cb168f552b53fe72cf0785 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 14:10:26 -0500 Subject: [PATCH 172/272] button alignment --- .../HorizontalCombinationViews/TwoButtonView.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 47e67724..a50e9488 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -93,7 +93,7 @@ import UIKit viewForButtons.addSubview(secondaryButton) secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1).isActive = true NSLayoutConstraint.constraintPinSubview(primaryButton, pinTop: true, pinBottom: true, pinLeft: true, pinRight: false) - NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: true, pinBottom: false, pinLeft: false, pinRight: true) + NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true) let constraint = secondaryButton.leadingAnchor.constraint(equalTo: primaryButton.trailingAnchor, constant: 10) constraint.priority = UILayoutPriority(900) constraint.isActive = true @@ -257,6 +257,10 @@ import UIKit primaryButton?.isHidden = true secondaryButton?.isHidden = true } + + override open func horizontalAlignment() -> UIStackView.Alignment { + return .center + } } // MARK: - Deprecate From 9e789e23122128e7fbccbbbcfe04165f7c627f35 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 14:11:37 -0500 Subject: [PATCH 173/272] secondary --- .../Molecules/HorizontalCombinationViews/TwoButtonView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index a50e9488..ddfd89de 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -309,6 +309,7 @@ extension TwoButtonView: ModelMoleculeViewProtocol { setDefaultCustom() primaryButton?.setWithModel(model.primaryButton, delegateObject, additionalData) secondaryButton?.setWithModel(model.secondaryButton, delegateObject, additionalData) + secondaryButton?.setAsSecondaryCustom() super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } } From dc19d850c1275e83f2d89b6792c5c1b587852846 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 14:12:51 -0500 Subject: [PATCH 174/272] setDefaultCustom --- .../Molecules/HorizontalCombinationViews/TwoButtonView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index ddfd89de..c6111c74 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -306,10 +306,9 @@ extension TwoButtonView: ModelMoleculeViewProtocol { public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? TwoButtonViewModel else { return } setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil) - setDefaultCustom() primaryButton?.setWithModel(model.primaryButton, delegateObject, additionalData) secondaryButton?.setWithModel(model.secondaryButton, delegateObject, additionalData) - secondaryButton?.setAsSecondaryCustom() + setDefaultCustom() super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } } From 69c86c4479572639c5b29bd60ed0585a1b6afc47 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 14:15:37 -0500 Subject: [PATCH 175/272] flip button position --- .../HorizontalCombinationViews/TwoButtonView.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index c6111c74..eae223d2 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -92,9 +92,9 @@ import UIKit viewForButtons.addSubview(primaryButton) viewForButtons.addSubview(secondaryButton) secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1).isActive = true - NSLayoutConstraint.constraintPinSubview(primaryButton, pinTop: true, pinBottom: true, pinLeft: true, pinRight: false) - NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true) - let constraint = secondaryButton.leadingAnchor.constraint(equalTo: primaryButton.trailingAnchor, constant: 10) + NSLayoutConstraint.constraintPinSubview(primaryButton, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true) + NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: false, pinBottom: false, pinLeft: true, pinRight: false) + let constraint = primaryButton.leadingAnchor.constraint(equalTo: secondaryButton.trailingAnchor, constant: 10) constraint.priority = UILayoutPriority(900) constraint.isActive = true } From c2f3a7a2db4b31fac31b031afa94b8ccf79d0eef Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 14:31:32 -0500 Subject: [PATCH 176/272] primary button and top bottom pin --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 2 +- .../Molecules/HorizontalCombinationViews/TwoButtonView.swift | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 64d9a3c3..b480aa2c 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -23,7 +23,7 @@ public class ButtonModel: MoleculeProtocol { public var backgroundColor: Color? public var title: String public var action: ActionProtocol - public var style: ButtonStyle? = .primary + public var style: ButtonStyle? public var size: ButtonSize? = .standard public var required: Bool? public var requiredGroups: [String]? diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index eae223d2..f1c5c6a8 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -92,8 +92,8 @@ import UIKit viewForButtons.addSubview(primaryButton) viewForButtons.addSubview(secondaryButton) secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1).isActive = true + NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: true, pinBottom: true, pinLeft: true, pinRight: false) NSLayoutConstraint.constraintPinSubview(primaryButton, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true) - NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: false, pinBottom: false, pinLeft: true, pinRight: false) let constraint = primaryButton.leadingAnchor.constraint(equalTo: secondaryButton.trailingAnchor, constant: 10) constraint.priority = UILayoutPriority(900) constraint.isActive = true @@ -308,7 +308,6 @@ extension TwoButtonView: ModelMoleculeViewProtocol { setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil) primaryButton?.setWithModel(model.primaryButton, delegateObject, additionalData) secondaryButton?.setWithModel(model.secondaryButton, delegateObject, additionalData) - setDefaultCustom() super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } } From 9e066be3fa90fa3265d193c676fa01102ce88c50 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 17 Jan 2020 14:53:23 -0500 Subject: [PATCH 177/272] setDefaultCustom --- .../Molecules/HorizontalCombinationViews/TwoButtonView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index f1c5c6a8..1559e1a5 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -306,6 +306,7 @@ extension TwoButtonView: ModelMoleculeViewProtocol { public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? TwoButtonViewModel else { return } setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil) + setDefaultCustom() primaryButton?.setWithModel(model.primaryButton, delegateObject, additionalData) secondaryButton?.setWithModel(model.secondaryButton, delegateObject, additionalData) super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) From 299a519e20009a22e18d70fad5a7db125c99ea79 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 17 Jan 2020 15:56:48 -0500 Subject: [PATCH 178/272] Default alignment fix --- MVMCoreUI/Containers/Container.swift | 2 +- MVMCoreUI/Containers/ContainerProtocol.swift | 1 + MVMCoreUI/Organisms/Stack.swift | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Containers/Container.swift b/MVMCoreUI/Containers/Container.swift index a2e34a49..42a53848 100644 --- a/MVMCoreUI/Containers/Container.swift +++ b/MVMCoreUI/Containers/Container.swift @@ -197,7 +197,7 @@ public class ContainerHelper: NSObject { } open class Container: View, ContainerProtocol { - var view: UIView? + public var view: UIView? let containerHelper = ContainerHelper() var containerModel: ContainerModelProtocol? { get { return model as? ContainerModelProtocol } diff --git a/MVMCoreUI/Containers/ContainerProtocol.swift b/MVMCoreUI/Containers/ContainerProtocol.swift index 8079ca24..10bac27c 100644 --- a/MVMCoreUI/Containers/ContainerProtocol.swift +++ b/MVMCoreUI/Containers/ContainerProtocol.swift @@ -9,6 +9,7 @@ import Foundation public protocol ContainerProtocol { + var view: UIView? { get set } func alignHorizontal(_ alignment: UIStackView.Alignment) func alignVertical(_ alignment: UIStackView.Alignment) func constrainView(_ view: UIView) diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 572c772f..f67f7a0e 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -190,8 +190,8 @@ open class Stack: Container where T: StackModelProtocol { let spacing = model.spacing ?? stackModel.spacing if let container = view as? ContainerProtocol { - let verticalAlignment = (model as? ContainerModelProtocol)?.verticalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center)) - let horizontalAlignment = (model as? ContainerModelProtocol)?.horizontalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading) + let verticalAlignment = (model as? ContainerModelProtocol)?.verticalAlignment ?? (container.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center)) + let horizontalAlignment = (model as? ContainerModelProtocol)?.horizontalAlignment ?? (container.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading) container.alignHorizontal(horizontalAlignment) container.alignVertical(verticalAlignment) } From 332e05f8a5f6e8bfc6ee7747c3d82950123ca95e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 17 Jan 2020 16:32:00 -0500 Subject: [PATCH 179/272] fix to wrong model --- .../HeadlineBodyCaretLinkImageModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift index 8052a7db..76333d08 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift @@ -11,7 +11,7 @@ import UIKit public class HeadlineBodyCaretLinkImageModel: MoleculeProtocol { public static var identifier: String = "headlineBodyCaretLinkImage" public var backgroundColor: Color? - public var caretLink: LinkModel? + public var caretLink: CaretLinkModel? public var headlineBody: HeadlineBodyModel public var image: ImageViewModel } From 0c7726bcc3b5b99cd3fe9c3240a86d32932e01f1 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Fri, 17 Jan 2020 17:32:32 -0500 Subject: [PATCH 180/272] fix caretbutton --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 64120043..1574a9e8 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -89,6 +89,8 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI NSLayoutConstraint(item: caretView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0).isActive = true NSLayoutConstraint(item: self, attribute: .right, relatedBy: .greaterThanOrEqual, toItem: caretView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true + caretView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: caretView.bottomAnchor).isActive = true contentHorizontalAlignment = .left //set correct color after layout @@ -108,6 +110,7 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI @objc open func setAsMolecule() { backgroundColor = .clear + translatesAutoresizingMaskIntoConstraints = false setTitleColor(enabledColor, for: .normal) setTitleColor(disabledColor, for: .disabled) } From a76fb75200040168c29226cd0c6346913f8a319a Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Mon, 20 Jan 2020 11:53:22 +0530 Subject: [PATCH 181/272] crash fix --- MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift index 130536e4..51532228 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift @@ -176,7 +176,7 @@ open class DoughnutChart: View { labelContainer.layoutIfNeeded() let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth() let labelheight = labelContainer.frame.height/2 - let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2)) + let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(abs(pow(radius, 2) - pow(labelheight, 2))) labelContainerLeftConstraint?.constant = padding labelContainerRightConstraint?.constant = padding From d3c644805352a92933719b41ddd20bc1b1fcc681 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Mon, 20 Jan 2020 14:50:53 +0530 Subject: [PATCH 182/272] fix for separator --- MVMCoreUI/Models/Molecules/HeaderModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 4499d313..0277e9fe 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -44,8 +44,8 @@ import Foundation required public init(from decoder: Decoder) throws { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) setDefaults() + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) } public override func encode(to encoder: Encoder) throws { From 8c373ebfa41ec923fd341a8b9f4712b85ea8132f Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 21 Jan 2020 16:56:30 +0530 Subject: [PATCH 183/272] index update --- .../VerticalCombinationViews/Lists/NumberedListModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 728ae3a8..943dfd11 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -26,7 +26,7 @@ import Foundation let list = try typeContainer.decodeMolecules(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index).", molecule: molecule))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule))) } super.init(molecules: models) spacing = 0 From 13cc6bf2090e05b45213421376c4431758e26d19 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 21 Jan 2020 17:11:00 +0530 Subject: [PATCH 184/272] removed padding --- MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift index 72aceab7..e33601ad 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift @@ -26,7 +26,7 @@ import Foundation addSubview(colorLablesStack) doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true - doughnutChart.topAnchor.constraint(equalTo: topAnchor, constant: PaddingFour).isActive = true + doughnutChart.topAnchor.constraint(equalTo: topAnchor).isActive = true bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor) From fffb04e5e15380bbd4dc2ac01610dc64034f4260 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 21 Jan 2020 20:31:02 +0530 Subject: [PATCH 185/272] avoid negative value --- MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift index 51532228..03d87ec9 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift @@ -176,7 +176,7 @@ open class DoughnutChart: View { labelContainer.layoutIfNeeded() let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth() let labelheight = labelContainer.frame.height/2 - let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(abs(pow(radius, 2) - pow(labelheight, 2))) + let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(max(0, pow(radius, 2) - pow(labelheight, 2))) labelContainerLeftConstraint?.constant = padding labelContainerRightConstraint?.constant = padding From 4760c10c8db7d58ea05aadcb645e9080f65b1241 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 21 Jan 2020 21:51:22 +0530 Subject: [PATCH 186/272] removed comment --- MVMCoreUI/Models/Molecules/HeaderModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 0277e9fe..4499d313 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -44,8 +44,8 @@ import Foundation required public init(from decoder: Decoder) throws { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) - setDefaults() line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + setDefaults() } public override func encode(to encoder: Encoder) throws { From 42b57dcd5dd4e5e117cdb9fc6bdf90724e994f0d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 21 Jan 2020 12:10:48 -0500 Subject: [PATCH 187/272] Cleaning --- MVMCoreUI.xcodeproj/project.pbxproj | 202 ++++++------- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 2 +- .../TextFields}/TextFieldModel.swift | 0 MVMCoreUI/Atoms/Views/CaretViewModel.swift | 2 +- .../Atoms/Views/CircleProgressModel.swift | 6 +- MVMCoreUI/Atoms/Views/DashLineModel.swift | 2 +- .../Views}/DropDownModel.swift | 0 MVMCoreUI/Atoms/Views/{ => Label}/Label.swift | 0 .../LabelAttributeActionModel.swift | 0 .../LabelAttributeColorModel.swift | 0 .../LabelAttributeFontModel.swift | 0 .../LabelAttributeImageModel.swift | 0 .../LabelAttributeModel.swift | 0 .../LabelAttributeStrikeThroughModel.swift | 0 .../LabelAttributeUnderlineModel.swift | 0 .../{LabelModel => Label}/LabelModel.swift | 2 +- .../Molecules => Atoms/Views}/LineModel.swift | 28 +- .../Atoms/Views/MultiProgressModel.swift | 2 +- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 2 +- MVMCoreUI/Atoms/Views/ToggleModel.swift | 2 +- .../Views/Container/Container.swift | 82 +++++ .../Container/ContainerHelper.swift} | 82 +---- .../Views}/Container/ContainerModel.swift | 2 +- .../Container}/ContainerProtocol.swift | 0 .../Views/EntryFieldContainer.swift | 285 ++++++++++++++++++ .../Views}/MoleculeContainer.swift | 0 .../Views}/MoleculeContainerModel.swift | 6 +- .../Color.swift | 0 .../Views}/ButtonDelegateProtocol.h | 0 .../Views}/MFButtonProtocol.h | 0 .../Buttons => Legacy/Views}/MFCustomButton.h | 0 .../Buttons => Legacy/Views}/MFCustomButton.m | 0 .../Views}/MFDigitTextBox.h | 0 .../Views}/MFDigitTextBox.m | 0 .../Views}/MFDigitTextField.h | 0 .../Views}/MFDigitTextField.m | 0 .../Views}/MFDigitTextField.xib | 0 .../Views/MFLoadingSpinner.h | 0 .../Views/MFLoadingSpinner.m | 0 .../Views}/MFMdnTextField.h | 0 .../Views}/MFMdnTextField.m | 0 .../Buttons => Legacy/Views}/MFTextButton.h | 0 .../Buttons => Legacy/Views}/MFTextButton.m | 0 .../TextFields => Legacy/Views}/MFTextField.h | 0 .../TextFields => Legacy/Views}/MFTextField.m | 0 .../Views}/MFTextField.xib | 0 .../Views}/MFTextFieldSubclassExtension.h | 0 .../{Atoms => Legacy}/Views/MFTextView.h | 0 .../{Atoms => Legacy}/Views/MFTextView.m | 0 .../{Atoms => Legacy}/Views/MFTextView.xib | 0 .../Views}/MVMCoreUIMoleculeViewProtocol.h | 0 .../Views/MVMCoreUIPageControl.h | 0 .../Views/MVMCoreUIPageControl.m | 0 .../Views/MVMCoreUIPagingProtocol.h | 0 .../{Atoms => Legacy}/Views/MVMCoreUISwitch.h | 0 .../{Atoms => Legacy}/Views/MVMCoreUISwitch.m | 0 .../Views/MVMCoreUITextFieldView.h | 0 .../Views/MVMCoreUITextFieldView.m | 0 .../Buttons => Legacy/Views}/PrimaryButton.h | 0 .../Buttons => Legacy/Views}/PrimaryButton.m | 0 .../{Atoms => Legacy}/Views/TextButtonView.h | 0 .../{Atoms => Legacy}/Views/TextButtonView.m | 0 .../Views}/TopLabelsView.h | 0 .../Views}/TopLabelsView.m | 0 .../Views/ViewConstrainingView.h | 0 .../Views/ViewConstrainingView.m | 0 .../ContainerModelProtocol.swift | 0 .../{Models => }/Molecules/FooterModel.swift | 6 +- ...ndardFooterView.swift => FooterView.swift} | 4 +- .../{Models => }/Molecules/HeaderModel.swift | 8 +- ...ndardHeaderView.swift => HeaderView.swift} | 4 +- .../TabsModel.swift | 6 +- .../Items/AccordionListItemModel.swift | 6 +- .../Items/DropDownListItemModel.swift | 6 +- MVMCoreUI/Molecules/Items/ListItemModel.swift | 6 +- .../Items/MoleculeStackItemModel.swift | 6 +- .../Molecules/Items/TabsListItemModel.swift | 6 +- .../LeftRightViews/CornerLabelsModel.swift | 2 +- .../Lists/NumberedListModel.swift | 6 +- .../StringAndMoleculeModel.swift | 2 +- .../Lists/UnOrderedListModel.swift | 6 +- MVMCoreUI/Organisms/MoleculeStackModel.swift | 6 +- MVMCoreUI/Organisms/StackModel.swift | 6 +- .../MVMCoreUIMoleculeMappingObject.m | 4 +- .../ListPageTemplateModel.swift | 2 +- .../StackCenteredPageTemplateModel.swift | 4 - .../StackPageTemplateModel.swift | 4 +- .../ThreeLayerPageTemplateModel.swift | 4 +- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 1 - 91 files changed, 562 insertions(+), 254 deletions(-) rename MVMCoreUI/{Models/Molecules => Atoms/TextFields}/TextFieldModel.swift (100%) rename MVMCoreUI/{Models/Molecules => Atoms/Views}/DropDownModel.swift (100%) rename MVMCoreUI/Atoms/Views/{ => Label}/Label.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelAttributeActionModel.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelAttributeColorModel.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelAttributeFontModel.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelAttributeImageModel.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelAttributeModel.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelAttributeStrikeThroughModel.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelAttributeUnderlineModel.swift (100%) rename MVMCoreUI/Atoms/Views/{LabelModel => Label}/LabelModel.swift (98%) rename MVMCoreUI/{Models/Molecules => Atoms/Views}/LineModel.swift (51%) create mode 100644 MVMCoreUI/Containers/Views/Container/Container.swift rename MVMCoreUI/Containers/{Container.swift => Views/Container/ContainerHelper.swift} (76%) rename MVMCoreUI/{Models => Containers/Views}/Container/ContainerModel.swift (98%) rename MVMCoreUI/Containers/{ => Views/Container}/ContainerProtocol.swift (100%) create mode 100644 MVMCoreUI/Containers/Views/EntryFieldContainer.swift rename MVMCoreUI/{Molecules => Containers/Views}/MoleculeContainer.swift (100%) rename MVMCoreUI/{Models/Container => Containers/Views}/MoleculeContainerModel.swift (77%) rename MVMCoreUI/{Models/Primitive Models => CustomPrimitives}/Color.swift (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/ButtonDelegateProtocol.h (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/MFButtonProtocol.h (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/MFCustomButton.h (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/MFCustomButton.m (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFDigitTextBox.h (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFDigitTextBox.m (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFDigitTextField.h (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFDigitTextField.m (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFDigitTextField.xib (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFLoadingSpinner.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFLoadingSpinner.m (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFMdnTextField.h (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFMdnTextField.m (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/MFTextButton.h (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/MFTextButton.m (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFTextField.h (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFTextField.m (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFTextField.xib (100%) rename MVMCoreUI/{Atoms/TextFields => Legacy/Views}/MFTextFieldSubclassExtension.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFTextView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFTextView.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFTextView.xib (100%) rename MVMCoreUI/{Molecules => Legacy/Views}/MVMCoreUIMoleculeViewProtocol.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUIPageControl.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUIPageControl.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUIPagingProtocol.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUISwitch.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUISwitch.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUITextFieldView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUITextFieldView.m (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/PrimaryButton.h (100%) rename MVMCoreUI/{Atoms/Buttons => Legacy/Views}/PrimaryButton.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/TextButtonView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/TextButtonView.m (100%) rename MVMCoreUI/{Molecules => Legacy/Views}/TopLabelsView.h (100%) rename MVMCoreUI/{Molecules => Legacy/Views}/TopLabelsView.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/ViewConstrainingView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/ViewConstrainingView.m (100%) rename MVMCoreUI/Models/{Container => ModelProtocols}/ContainerModelProtocol.swift (100%) rename MVMCoreUI/{Models => }/Molecules/FooterModel.swift (87%) rename MVMCoreUI/Molecules/{StandardFooterView.swift => FooterView.swift} (88%) rename MVMCoreUI/{Models => }/Molecules/HeaderModel.swift (86%) rename MVMCoreUI/Molecules/{StandardHeaderView.swift => HeaderView.swift} (96%) rename MVMCoreUI/{Models/Template => Templates}/ListPageTemplateModel.swift (98%) rename MVMCoreUI/{Models/Template => Templates}/StackCenteredPageTemplateModel.swift (99%) rename MVMCoreUI/{Models/Template => Templates}/StackPageTemplateModel.swift (97%) rename MVMCoreUI/{Models/Template => Templates}/ThreeLayerPageTemplateModel.swift (97%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 11ba168e..2ae882f5 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -148,7 +148,7 @@ D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; - D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; + D274CA332236A78900B01B62 /* FooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* FooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */; }; @@ -274,13 +274,14 @@ D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */; }; 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 */; }; D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */; }; D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 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 /* StandardHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* StandardHeaderView.swift */; }; + D2A514672213885800345BFB /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* HeaderView.swift */; }; D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A638FC22CA98280052ED1F /* HeadlineBody.swift */; }; D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390022CBB1820052ED1F /* Carousel.swift */; }; @@ -438,7 +439,7 @@ D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; D268C711238D6699007F2C1C /* DropDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDown.swift; sourceTree = ""; }; - D274CA322236A78900B01B62 /* StandardFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardFooterView.swift; sourceTree = ""; }; + D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; D2755D7A23689C7500485468 /* TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; }; D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = ""; }; D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyLink.swift; sourceTree = ""; }; @@ -579,13 +580,14 @@ D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; 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 = ""; }; D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeMappingObject.h; sourceTree = ""; }; D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIMoleculeMappingObject.m; sourceTree = ""; }; D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeViewProtocol.h; 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 /* StandardHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardHeaderView.swift; sourceTree = ""; }; + D2A514662213885800345BFB /* HeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = ""; }; D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2A638FC22CA98280052ED1F /* HeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBody.swift; sourceTree = ""; }; D2A6390022CBB1820052ED1F /* Carousel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Carousel.swift; sourceTree = ""; }; @@ -629,6 +631,7 @@ 011B58EE23A2AA850085F53C /* ModelProtocols */ = { isa = PBXGroup; children = ( + 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, @@ -641,42 +644,18 @@ path = ModelProtocols; sourceTree = ""; }; - 012A88EF23985E0100FE3DA1 /* Primitive Models */ = { + 012A88EF23985E0100FE3DA1 /* CustomPrimitives */ = { isa = PBXGroup; children = ( 012A88F023985E0100FE3DA1 /* Color.swift */, ); - path = "Primitive Models"; - sourceTree = ""; - }; - 014AA72023C501E2006F3E93 /* Container */ = { - isa = PBXGroup; - children = ( - 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */, - 014AA72223C501E2006F3E93 /* ContainerModel.swift */, - 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */, - ); - path = Container; - sourceTree = ""; - }; - 014AA72723C5059B006F3E93 /* Template */ = { - isa = PBXGroup; - children = ( - 014AA72823C5059B006F3E93 /* StackPageTemplateModel.swift */, - 014AA72923C5059B006F3E93 /* StackCenteredPageTemplateModel.swift */, - 014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */, - 014AA72C23C5059B006F3E93 /* ListPageTemplateModel.swift */, - ); - path = Template; + path = CustomPrimitives; sourceTree = ""; }; 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( - 014AA72723C5059B006F3E93 /* Template */, - 014AA72023C501E2006F3E93 /* Container */, 011B58EE23A2AA850085F53C /* ModelProtocols */, - 012A88EF23985E0100FE3DA1 /* Primitive Models */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, ); @@ -697,11 +676,6 @@ 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( - 011B58F323A2CCC80085F53C /* DropDownModel.swift */, - 01EB368C23609801006832FA /* HeaderModel.swift */, - 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, - 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, - 017BEB7A236763000024EF95 /* LineModel.swift */, 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */, @@ -717,12 +691,15 @@ path = Protocols; sourceTree = ""; }; - 0ABD1369237B18EE0081388D /* views */ = { + 0ABD1369237B18EE0081388D /* Views */ = { isa = PBXGroup; children = ( + D29E28DE23D740FC00ACEA85 /* Container */, 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */, + 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */, + D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, ); - path = views; + path = Views; sourceTree = ""; }; 946EE1B5237B663A0036751F /* Extensions */ = { @@ -733,7 +710,7 @@ path = Extensions; sourceTree = ""; }; - 94C2D9822386F3E30006CF46 /* LabelModel */ = { + 94C2D9822386F3E30006CF46 /* Label */ = { isa = PBXGroup; children = ( 01EB368823609801006832FA /* LabelModel.swift */, @@ -744,8 +721,9 @@ 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */, 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */, 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */, + DB891E822253FA8500022516 /* Label.swift */, ); - path = LabelModel; + path = Label; sourceTree = ""; }; 94FB5B83238D892800EB2193 /* Recovered References */ = { @@ -783,6 +761,44 @@ D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, 0198F7A02256A80A0066C936 /* MFRadioButton.h */, 0198F7A22256A80A0066C936 /* MFRadioButton.m */, + D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, + D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, + D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, + D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */, + D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, + D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */, + D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */, + D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */, + D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */, + D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */, + D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */, + D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, + D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, + D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, + D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, + D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, + D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, + D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, + D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, + D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, + D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, + D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */, + D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */, + D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */, + D29DF24C21E6A177003B2FB9 /* MFTextField.h */, + D29DF24221E6A176003B2FB9 /* MFTextField.m */, + D29DF24421E6A176003B2FB9 /* MFTextField.xib */, + D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */, + D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */, + D29DF24921E6A177003B2FB9 /* MFMdnTextField.m */, + D29DF24521E6A176003B2FB9 /* MFDigitTextBox.h */, + D29DF24621E6A176003B2FB9 /* MFDigitTextBox.m */, + D29DF24321E6A176003B2FB9 /* MFDigitTextField.h */, + D29DF24821E6A177003B2FB9 /* MFDigitTextField.m */, + D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */, + D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, + D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */, + D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */, ); path = Views; sourceTree = ""; @@ -791,8 +807,8 @@ isa = PBXGroup; children = ( 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */, - D22479892314445E003FCCF9 /* LabelSwitch.swift */, 01C851D223CF9E740021F976 /* LabelToggleModel.swift */, + D22479892314445E003FCCF9 /* LabelSwitch.swift */, D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */, ); path = SwitchMolecules; @@ -802,8 +818,8 @@ isa = PBXGroup; children = ( D29E28D423D1FFFA00ACEA85 /* Lists */, - D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, + D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */, D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */, @@ -850,8 +866,8 @@ isa = PBXGroup; children = ( D2755D7A23689C7500485468 /* TableViewCell.swift */, - 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, + 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */, D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, @@ -909,6 +925,7 @@ isa = PBXGroup; children = ( 01509D96232803B200EF99AA /* Models */, + 012A88EF23985E0100FE3DA1 /* CustomPrimitives */, D2B18B7D236090D500A9AEDC /* BaseClasses */, 01C74D87224298E2009C25A3 /* FormUIHelpers */, D29DF31421ECECA7003B2FB9 /* SupportingFiles */, @@ -933,10 +950,14 @@ D29DF0DF21E418B2003B2FB9 /* Templates */ = { isa = PBXGroup; children = ( + 014AA72823C5059B006F3E93 /* StackPageTemplateModel.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, + 014AA72923C5059B006F3E93 /* StackCenteredPageTemplateModel.swift */, D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */, D28A837A23C928DA00DFE4FC /* MoleculeListCellProtocol.swift */, + 014AA72C23C5059B006F3E93 /* ListPageTemplateModel.swift */, D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */, + 014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */, D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */, ); path = Templates; @@ -968,19 +989,17 @@ D224798F2316A99F003FCCF9 /* LeftRightViews */, D224798E2316A995003FCCF9 /* HorizontalCombinationViews */, D224798D2316A988003FCCF9 /* VerticalCombinationViews */, - D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, - D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */, - D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */, - D2A514662213885800345BFB /* StandardHeaderView.swift */, - D274CA322236A78900B01B62 /* StandardFooterView.swift */, + 01EB368C23609801006832FA /* HeaderModel.swift */, + D2A514662213885800345BFB /* HeaderView.swift */, + 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, + D274CA322236A78900B01B62 /* FooterView.swift */, 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */, D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */, D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */, 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */, - D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, D260105723CF9CC500764D80 /* Doughnut */, @@ -1027,12 +1046,10 @@ D29DF11921E68467003B2FB9 /* Containers */ = { isa = PBXGroup; children = ( - 0ABD1369237B18EE0081388D /* views */, + 0ABD1369237B18EE0081388D /* Views */, D29DF2B721E7BE79003B2FB9 /* TabBarController */, D29DF2B621E7BE66003B2FB9 /* SplitViewController */, D2B18B93236214AD00A9AEDC /* NavigationController.swift */, - D260105823D0A92900764D80 /* ContainerProtocol.swift */, - D243859823A16B1800332775 /* Container.swift */, ); path = Containers; sourceTree = ""; @@ -1096,22 +1113,14 @@ D29DF16821E69E1F003B2FB9 /* Buttons */ = { isa = PBXGroup; children = ( - DBC4391A224421A0001AB423 /* CaretButton.swift */, 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */, - D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, - D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, - D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, - D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, - D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */, + DBC4391A224421A0001AB423 /* CaretButton.swift */, D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */, - D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */, - D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, - D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, D282AACA2243C61700C46919 /* ButtonView.swift */, D28A838823CCCFCB00DFE4FC /* LinkModel.swift */, + D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */, D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */, - D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, - D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, + D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */, ); path = Buttons; sourceTree = ""; @@ -1119,50 +1128,35 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( - 01509D922327ECFB00EF99AA /* ProgressBar.swift */, 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, - D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */, - D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */, - D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */, - 948DB67D2326DCD90011F916 /* MultiProgress.swift */, + 01509D922327ECFB00EF99AA /* ProgressBar.swift */, 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, - DBC4391622442196001AB423 /* CaretView.swift */, + 948DB67D2326DCD90011F916 /* MultiProgress.swift */, 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */, - DBC4391722442197001AB423 /* DashLine.swift */, + DBC4391622442196001AB423 /* CaretView.swift */, 944589202385D6E900DE9FD4 /* DashLineModel.swift */, - DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, + DBC4391722442197001AB423 /* DashLine.swift */, 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */, - 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, - D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, - D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, + DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */, - D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, 944589222385DA9500DE9FD4 /* ImageViewModel.swift */, + D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, + 017BEB7A236763000024EF95 /* LineModel.swift */, D213347623843825008E41B3 /* Line.swift */, - D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, - D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */, - D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, + 011B58F323A2CCC80085F53C /* DropDownModel.swift */, D268C711238D6699007F2C1C /* DropDown.swift */, - D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */, - D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */, - D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */, - D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */, - D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */, - D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */, - D260105223CEA61600764D80 /* ToggleModel.swift */, - D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */, - D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, - D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, - DB891E822253FA8500022516 /* Label.swift */, - 94C2D9822386F3E30006CF46 /* LabelModel */, + 94C2D9822386F3E30006CF46 /* Label */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, 943784F3236B77BB006A1E82 /* GraphView.swift */, 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */, + D260105223CEA61600764D80 /* ToggleModel.swift */, 0AA33B392398524F0067DD0F /* Toggle.swift */, + D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */, + 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, ); path = Views; sourceTree = ""; @@ -1170,18 +1164,7 @@ D29DF22B21E6A0FA003B2FB9 /* TextFields */ = { isa = PBXGroup; children = ( - D29DF24C21E6A177003B2FB9 /* MFTextField.h */, - D29DF24221E6A176003B2FB9 /* MFTextField.m */, - 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */, - D29DF24421E6A176003B2FB9 /* MFTextField.xib */, - D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */, - D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */, - D29DF24921E6A177003B2FB9 /* MFMdnTextField.m */, - D29DF24521E6A176003B2FB9 /* MFDigitTextBox.h */, - D29DF24621E6A176003B2FB9 /* MFDigitTextBox.m */, - D29DF24321E6A176003B2FB9 /* MFDigitTextField.h */, - D29DF24821E6A177003B2FB9 /* MFDigitTextField.m */, - D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */, + 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */, 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */, 0A21DB7E235DECC500C160A2 /* EntryField.swift */, @@ -1190,6 +1173,7 @@ 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */, 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */, 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */, + 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */, ); path = TextFields; sourceTree = ""; @@ -1313,6 +1297,17 @@ path = StringAndMoleculeStack; sourceTree = ""; }; + D29E28DE23D740FC00ACEA85 /* Container */ = { + isa = PBXGroup; + children = ( + 014AA72223C501E2006F3E93 /* ContainerModel.swift */, + D260105823D0A92900764D80 /* ContainerProtocol.swift */, + D243859823A16B1800332775 /* Container.swift */, + D29E28DC23D7404C00ACEA85 /* ContainerHelper.swift */, + ); + path = Container; + sourceTree = ""; + }; D2B18B7D236090D500A9AEDC /* BaseClasses */ = { isa = PBXGroup; children = ( @@ -1556,7 +1551,7 @@ D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */, D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */, 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, - D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, + D2A514672213885800345BFB /* HeaderView.swift in Sources */, D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, @@ -1598,7 +1593,7 @@ 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, 94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */, 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */, - D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, + D274CA332236A78900B01B62 /* FooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, @@ -1686,6 +1681,7 @@ D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, + D29E28DD23D7404C00ACEA85 /* ContainerHelper.swift in Sources */, 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index b480aa2c..26efc82e 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -33,7 +33,7 @@ public class ButtonModel: MoleculeProtocol { self.action = action } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case title case action diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index b2fc5841..6daf2740 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -23,7 +23,7 @@ public class CaretLinkModel: MoleculeProtocol { self.action = action } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case title case action diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index e2fca66c..fd0b17b9 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -21,7 +21,7 @@ public class LinkModel: MoleculeProtocol { self.action = action } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case title case action diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift similarity index 100% rename from MVMCoreUI/Models/Molecules/TextFieldModel.swift rename to MVMCoreUI/Atoms/TextFields/TextFieldModel.swift diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index f26a150f..cee09a40 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -17,7 +17,7 @@ import Foundation public var isOpaque: Bool? public var lineWidth: CGFloat? - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case strokeColor case isHidden diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index 20f49dc0..aae99612 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -38,7 +38,7 @@ public class CircleProgressModel: MoleculeProtocol { public init() {} - enum CircleProgressCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case style case size case diameter @@ -50,7 +50,7 @@ public class CircleProgressModel: MoleculeProtocol { } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CircleProgressCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let style = try typeContainer.decodeIfPresent(GraphStyle.self, forKey: .style) { self.style = style } @@ -76,7 +76,7 @@ public class CircleProgressModel: MoleculeProtocol { } public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CircleProgressCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(style, forKey: .style) try container.encode(size, forKey: .size) try container.encode(diameter, forKey: .diameter) diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index ec6b8a15..662a7cf4 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -19,7 +19,7 @@ import Foundation self.dashColor = dashColor } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case dashColor case isHidden diff --git a/MVMCoreUI/Models/Molecules/DropDownModel.swift b/MVMCoreUI/Atoms/Views/DropDownModel.swift similarity index 100% rename from MVMCoreUI/Models/Molecules/DropDownModel.swift rename to MVMCoreUI/Atoms/Views/DropDownModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label.swift rename to MVMCoreUI/Atoms/Views/Label/Label.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeActionModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeColorModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeColorModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeFontModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeImageModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeImageModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeStrikeThroughModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeStrikeThroughModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeUnderlineModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeUnderlineModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelAttributeUnderlineModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelAttributeUnderlineModel.swift diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift similarity index 98% rename from MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift rename to MVMCoreUI/Atoms/Views/Label/LabelModel.swift index 90c694a0..faf19c22 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -26,7 +26,7 @@ import Foundation public var hero: Int? public var makeWholeViewClickable: Bool? - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case text case accessibilityText diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Atoms/Views/LineModel.swift similarity index 51% rename from MVMCoreUI/Models/Molecules/LineModel.swift rename to MVMCoreUI/Atoms/Views/LineModel.swift index 88e09be0..cf671996 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Atoms/Views/LineModel.swift @@ -41,11 +41,37 @@ import UIKit } public static var identifier: String = "line" - public var type: Style? = .standard + public var type: Style = .standard public var frequency: Frequency? = .allExceptTop public var backgroundColor: Color? public init(type: Style) { self.type = type } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case type + case backgroundColor + case frequency + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let type = try typeContainer.decodeIfPresent(Style.self, forKey: .type) { + self.type = type + } + if let frequency = try typeContainer.decodeIfPresent(Frequency.self, forKey: .frequency) { + self.frequency = frequency + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(type, forKey: .type) + try container.encodeIfPresent(frequency, forKey: .frequency) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index 497fc9d5..abcbd5fd 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -25,7 +25,7 @@ import Foundation public var thickness: CGFloat? public var roundedRect: Bool? - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case progressList case thickness case roundedRect diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 1850c411..396ab8e9 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -16,7 +16,7 @@ import Foundation public var isRounded: Bool? public var thickness: CGFloat? - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case isRounded = "roundRect" case thickness diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 81602c2a..8aa9500b 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -17,7 +17,7 @@ public class ToggleModel: MoleculeProtocol { public var required: Bool? public var fieldKey: String? - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case state case action diff --git a/MVMCoreUI/Containers/Views/Container/Container.swift b/MVMCoreUI/Containers/Views/Container/Container.swift new file mode 100644 index 00000000..065490a0 --- /dev/null +++ b/MVMCoreUI/Containers/Views/Container/Container.swift @@ -0,0 +1,82 @@ +// +// Container.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 12/11/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class Container: View, ContainerProtocol { + public var view: UIView? + let containerHelper = ContainerHelper() + var containerModel: ContainerModelProtocol? { + get { return model as? ContainerModelProtocol } + } + + // MARK:- ModelMoleculeViewProtocol + override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let containerModel = model as? ContainerModelProtocol else { return } + containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol) + } + + // MARK:- ContainerProtocol + public func alignHorizontal(_ alignment: UIStackView.Alignment) { + containerHelper.alignHorizontal(alignment) + } + + public func alignVertical(_ alignment: UIStackView.Alignment) { + containerHelper.alignVertical(alignment) + } + + public func constrainView(_ view: UIView) { + containerHelper.constrainView(view) + } +} + +// MARK: - MVMCoreViewProtocol +public extension Container { + override func updateView(_ size: CGFloat) { + super.updateView(size) + (view as? MVMCoreViewProtocol)?.updateView(size) + containerHelper.updateViewMargins(self, model: containerModel, size: size) + } + + /// Will be called only once. + override func setupView() { + super.setupView() + backgroundColor = .clear + } + + func addAndContain(_ view: UIView) { + view.translatesAutoresizingMaskIntoConstraints = false + addSubview(view) + containerHelper.constrainView(view) + self.view = view + } + + convenience init(andContain view: UIView) { + self.init() + addAndContain(view) + } +} + +// MARK: - MVMCoreUIMoleculeViewProtocol +public extension Container { + override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + guard let view = view else { return } + containerHelper.set(with: json, for: view) + } + + override func reset() { + super.reset() + (view as? MVMCoreUIMoleculeViewProtocol)?.reset?() + } + + override func setAsMolecule() { + (view as? MVMCoreUIMoleculeViewProtocol)?.setAsMolecule?() + } +} diff --git a/MVMCoreUI/Containers/Container.swift b/MVMCoreUI/Containers/Views/Container/ContainerHelper.swift similarity index 76% rename from MVMCoreUI/Containers/Container.swift rename to MVMCoreUI/Containers/Views/Container/ContainerHelper.swift index 42a53848..77226341 100644 --- a/MVMCoreUI/Containers/Container.swift +++ b/MVMCoreUI/Containers/Views/Container/ContainerHelper.swift @@ -1,12 +1,13 @@ // -// Container.swift +// ContainerHelper.swift // MVMCoreUI // -// Created by Scott Pfeil on 12/11/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. +// Created by Scott Pfeil on 1/21/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. // +// A Helper that consolidates some common container logic -import UIKit +import Foundation public class ContainerHelper: NSObject { var leftConstraint: NSLayoutConstraint? @@ -195,76 +196,3 @@ public class ContainerHelper: NSObject { } } } - -open class Container: View, ContainerProtocol { - public var view: UIView? - let containerHelper = ContainerHelper() - var containerModel: ContainerModelProtocol? { - get { return model as? ContainerModelProtocol } - } - - // MARK:- ModelMoleculeViewProtocol - override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.setWithModel(model, delegateObject, additionalData) - guard let containerModel = model as? ContainerModelProtocol else { return } - containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol) - } - - // MARK:- ContainerProtocol - public func alignHorizontal(_ alignment: UIStackView.Alignment) { - containerHelper.alignHorizontal(alignment) - } - - public func alignVertical(_ alignment: UIStackView.Alignment) { - containerHelper.alignVertical(alignment) - } - - public func constrainView(_ view: UIView) { - containerHelper.constrainView(view) - } -} - -// MARK: - MVMCoreViewProtocol -public extension Container { - override func updateView(_ size: CGFloat) { - super.updateView(size) - (view as? MVMCoreViewProtocol)?.updateView(size) - containerHelper.updateViewMargins(self, model: containerModel, size: size) - } - - /// Will be called only once. - override func setupView() { - super.setupView() - backgroundColor = .clear - } - - func addAndContain(_ view: UIView) { - view.translatesAutoresizingMaskIntoConstraints = false - addSubview(view) - containerHelper.constrainView(view) - self.view = view - } - - convenience init(andContain view: UIView) { - self.init() - addAndContain(view) - } -} - -// MARK: - MVMCoreUIMoleculeViewProtocol -public extension Container { - override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - guard let view = view else { return } - containerHelper.set(with: json, for: view) - } - - override func reset() { - super.reset() - (view as? MVMCoreUIMoleculeViewProtocol)?.reset?() - } - - override func setAsMolecule() { - (view as? MVMCoreUIMoleculeViewProtocol)?.setAsMolecule?() - } -} diff --git a/MVMCoreUI/Models/Container/ContainerModel.swift b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift similarity index 98% rename from MVMCoreUI/Models/Container/ContainerModel.swift rename to MVMCoreUI/Containers/Views/Container/ContainerModel.swift index 9930ab5c..1b721183 100644 --- a/MVMCoreUI/Models/Container/ContainerModel.swift +++ b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift @@ -17,7 +17,7 @@ public class ContainerModel: ContainerModelProtocol, Codable { public var topMarginPadding: CGFloat? public var bottomMarginPadding: CGFloat? - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case verticalAlignment case horizontalAlignment case useHorizontalMargins diff --git a/MVMCoreUI/Containers/ContainerProtocol.swift b/MVMCoreUI/Containers/Views/Container/ContainerProtocol.swift similarity index 100% rename from MVMCoreUI/Containers/ContainerProtocol.swift rename to MVMCoreUI/Containers/Views/Container/ContainerProtocol.swift diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift new file mode 100644 index 00000000..96a51a8f --- /dev/null +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -0,0 +1,285 @@ +// +// EntryFieldContainer.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 11/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + + +@objcMembers open class EntryFieldContainer: View { + //-------------------------------------------------- + // MARK: - Drawing Properties + //-------------------------------------------------- + + /// The bottom border line. Height is dynamic based on scenario. + public var bottomBar: CAShapeLayer? = { + let layer = CAShapeLayer() + layer.backgroundColor = UIColor.black.cgColor + layer.drawsAsynchronously = true + layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); + return layer + }() + + /// Total control over the drawn top, bottom, left and right borders. + public var disableAllBorders = false { + didSet { + bottomBar?.isHidden = disableAllBorders + } + } + + private(set) var fieldState: FieldState = .original { + didSet (oldState) { + // Will not update if new state is the same as old. + if fieldState != oldState { + DispatchQueue.main.async { [weak self] in + guard let self = self else { return } + + self.fieldState.setStateUI(for: self) + } + } + } + } + + /// Determines if the top, left, and right borders should be drawn. + private var hideBorders = false + + public var borderStrokeColor: UIColor = .mfSilver() + private var borderPath: UIBezierPath = UIBezierPath() + + //-------------------------------------------------- + // MARK: - Property Observers + //-------------------------------------------------- + + private var _isEnabled: Bool = true + private var _showError: Bool = false + private var _isLocked: Bool = false + private var _isSelected: Bool = false + + public var isEnabled: Bool { + get { return _isEnabled } + set (enabled) { + + _isEnabled = enabled + _isLocked = false + _isSelected = false + _showError = false + + fieldState = enabled ? .original : .disabled + } + } + + public var showError: Bool { + get { return _showError } + set (error) { + + _showError = error + _isEnabled = true + _isLocked = false + _isSelected = false + + fieldState = error ? .error : .original + } + } + + public var isLocked: Bool { + get { return _isLocked } + set (locked) { + + _isLocked = locked + _isEnabled = true + _isSelected = false + _showError = false + + fieldState = locked ? .locked : .original + } + } + + public var isSelected: Bool { + get { return _isSelected } + set (selected) { + + _isSelected = selected + _isLocked = false + _isEnabled = true + + if _showError { + fieldState = selected ? .selectedError : .error + } else { + fieldState = selected ? .selected : .original + } + } + } + + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + + /// Holds reference to delegateObject to inform molecular tableView of an update. + weak var delegateObject: MVMCoreUIDelegateObject? + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + open override func layoutSubviews() { + super.layoutSubviews() + + refreshUI(bottomBarSize: showError ? 4 : 1) + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + + refreshUI() + } + + /// This handles the top, left, and right border lines. + open override func draw(_ rect: CGRect) { + super.draw(rect) + + borderPath.removeAllPoints() + + if !disableAllBorders && !hideBorders { + // Brings the other half of the line inside the view to prevent cropping. + let origin = bounds.origin + let size = frame.size + let insetLean: CGFloat = 0.5 + borderPath.lineWidth = 1 + + borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height)) + borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + size.height)) + + borderStrokeColor.setStroke() + borderPath.stroke() + } + } + + override open func setupView() { + super.setupView() + + isAccessibilityElement = false + isOpaque = false + + if let bottomBar = bottomBar { + layer.addSublayer(bottomBar) + } + } + + //-------------------------------------------------- + // MARK: - Draw States + //-------------------------------------------------- + + public enum FieldState { + case original + case error + case selectedError + case selected + case locked + case disabled + + public func setStateUI(for formField: EntryFieldContainer) { + + switch self { + case .original: + formField.originalUI() + + case .error: + formField.errorUI() + + case .selectedError: + formField.selectedErrorUI() + + case .selected: + formField.selectedUI() + + case .locked: + formField.lockedUI() + + case .disabled: + formField.disabledUI() + } + } + } + + open func originalUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func errorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfPumpkin() + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedErrorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func lockedUI() { + + isUserInteractionEnabled = false + hideBorders = true + borderStrokeColor = .clear + bottomBar?.backgroundColor = UIColor.clear.cgColor + refreshUI(bottomBarSize: 1) + } + + open func disabledUI() { + + isUserInteractionEnabled = false + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.mfSilver().cgColor + refreshUI(bottomBarSize: 1) + } + + open func refreshUI(bottomBarSize: CGFloat? = nil) { + + if !disableAllBorders { + let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) + bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) + + delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + setNeedsDisplay() + layoutIfNeeded() + } + } +} + +// MARK:- MVMCoreUIMoleculeViewProtocol +extension EntryFieldContainer { + + override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + self.delegateObject = delegateObject + + guard let dictionary = json, !dictionary.isEmpty else { return } + } +} diff --git a/MVMCoreUI/Molecules/MoleculeContainer.swift b/MVMCoreUI/Containers/Views/MoleculeContainer.swift similarity index 100% rename from MVMCoreUI/Molecules/MoleculeContainer.swift rename to MVMCoreUI/Containers/Views/MoleculeContainer.swift diff --git a/MVMCoreUI/Models/Container/MoleculeContainerModel.swift b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift similarity index 77% rename from MVMCoreUI/Models/Container/MoleculeContainerModel.swift rename to MVMCoreUI/Containers/Views/MoleculeContainerModel.swift index c29fcd2a..284b91ee 100644 --- a/MVMCoreUI/Models/Container/MoleculeContainerModel.swift +++ b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift @@ -11,7 +11,7 @@ import Foundation public class MoleculeContainerModel: ContainerModel { public var molecule: MoleculeProtocol - enum MoleculeContainerCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case molecule } @@ -21,14 +21,14 @@ public class MoleculeContainerModel: ContainerModel { } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: MoleculeContainerCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecule = try typeContainer.decodeMolecule(codingKey: .molecule) try super.init(from: decoder) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: MoleculeContainerCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModel(molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/CustomPrimitives/Color.swift similarity index 100% rename from MVMCoreUI/Models/Primitive Models/Color.swift rename to MVMCoreUI/CustomPrimitives/Color.swift diff --git a/MVMCoreUI/Atoms/Buttons/ButtonDelegateProtocol.h b/MVMCoreUI/Legacy/Views/ButtonDelegateProtocol.h similarity index 100% rename from MVMCoreUI/Atoms/Buttons/ButtonDelegateProtocol.h rename to MVMCoreUI/Legacy/Views/ButtonDelegateProtocol.h diff --git a/MVMCoreUI/Atoms/Buttons/MFButtonProtocol.h b/MVMCoreUI/Legacy/Views/MFButtonProtocol.h similarity index 100% rename from MVMCoreUI/Atoms/Buttons/MFButtonProtocol.h rename to MVMCoreUI/Legacy/Views/MFButtonProtocol.h diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h b/MVMCoreUI/Legacy/Views/MFCustomButton.h similarity index 100% rename from MVMCoreUI/Atoms/Buttons/MFCustomButton.h rename to MVMCoreUI/Legacy/Views/MFCustomButton.h diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m b/MVMCoreUI/Legacy/Views/MFCustomButton.m similarity index 100% rename from MVMCoreUI/Atoms/Buttons/MFCustomButton.m rename to MVMCoreUI/Legacy/Views/MFCustomButton.m diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextBox.h b/MVMCoreUI/Legacy/Views/MFDigitTextBox.h similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFDigitTextBox.h rename to MVMCoreUI/Legacy/Views/MFDigitTextBox.h diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextBox.m b/MVMCoreUI/Legacy/Views/MFDigitTextBox.m similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFDigitTextBox.m rename to MVMCoreUI/Legacy/Views/MFDigitTextBox.m diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h b/MVMCoreUI/Legacy/Views/MFDigitTextField.h similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFDigitTextField.h rename to MVMCoreUI/Legacy/Views/MFDigitTextField.h diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m b/MVMCoreUI/Legacy/Views/MFDigitTextField.m similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFDigitTextField.m rename to MVMCoreUI/Legacy/Views/MFDigitTextField.m diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.xib b/MVMCoreUI/Legacy/Views/MFDigitTextField.xib similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFDigitTextField.xib rename to MVMCoreUI/Legacy/Views/MFDigitTextField.xib diff --git a/MVMCoreUI/Atoms/Views/MFLoadingSpinner.h b/MVMCoreUI/Legacy/Views/MFLoadingSpinner.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MFLoadingSpinner.h rename to MVMCoreUI/Legacy/Views/MFLoadingSpinner.h diff --git a/MVMCoreUI/Atoms/Views/MFLoadingSpinner.m b/MVMCoreUI/Legacy/Views/MFLoadingSpinner.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MFLoadingSpinner.m rename to MVMCoreUI/Legacy/Views/MFLoadingSpinner.m diff --git a/MVMCoreUI/Atoms/TextFields/MFMdnTextField.h b/MVMCoreUI/Legacy/Views/MFMdnTextField.h similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFMdnTextField.h rename to MVMCoreUI/Legacy/Views/MFMdnTextField.h diff --git a/MVMCoreUI/Atoms/TextFields/MFMdnTextField.m b/MVMCoreUI/Legacy/Views/MFMdnTextField.m similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFMdnTextField.m rename to MVMCoreUI/Legacy/Views/MFMdnTextField.m diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.h b/MVMCoreUI/Legacy/Views/MFTextButton.h similarity index 100% rename from MVMCoreUI/Atoms/Buttons/MFTextButton.h rename to MVMCoreUI/Legacy/Views/MFTextButton.h diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Legacy/Views/MFTextButton.m similarity index 100% rename from MVMCoreUI/Atoms/Buttons/MFTextButton.m rename to MVMCoreUI/Legacy/Views/MFTextButton.m diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Legacy/Views/MFTextField.h similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFTextField.h rename to MVMCoreUI/Legacy/Views/MFTextField.h diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Legacy/Views/MFTextField.m similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFTextField.m rename to MVMCoreUI/Legacy/Views/MFTextField.m diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.xib b/MVMCoreUI/Legacy/Views/MFTextField.xib similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFTextField.xib rename to MVMCoreUI/Legacy/Views/MFTextField.xib diff --git a/MVMCoreUI/Atoms/TextFields/MFTextFieldSubclassExtension.h b/MVMCoreUI/Legacy/Views/MFTextFieldSubclassExtension.h similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MFTextFieldSubclassExtension.h rename to MVMCoreUI/Legacy/Views/MFTextFieldSubclassExtension.h diff --git a/MVMCoreUI/Atoms/Views/MFTextView.h b/MVMCoreUI/Legacy/Views/MFTextView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MFTextView.h rename to MVMCoreUI/Legacy/Views/MFTextView.h diff --git a/MVMCoreUI/Atoms/Views/MFTextView.m b/MVMCoreUI/Legacy/Views/MFTextView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MFTextView.m rename to MVMCoreUI/Legacy/Views/MFTextView.m diff --git a/MVMCoreUI/Atoms/Views/MFTextView.xib b/MVMCoreUI/Legacy/Views/MFTextView.xib similarity index 100% rename from MVMCoreUI/Atoms/Views/MFTextView.xib rename to MVMCoreUI/Legacy/Views/MFTextView.xib diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h similarity index 100% rename from MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h rename to MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUIPageControl.h b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUIPageControl.h rename to MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUIPageControl.m b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUIPageControl.m rename to MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUIPagingProtocol.h b/MVMCoreUI/Legacy/Views/MVMCoreUIPagingProtocol.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUIPagingProtocol.h rename to MVMCoreUI/Legacy/Views/MVMCoreUIPagingProtocol.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.h b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUISwitch.h rename to MVMCoreUI/Legacy/Views/MVMCoreUISwitch.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m rename to MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUITextFieldView.h b/MVMCoreUI/Legacy/Views/MVMCoreUITextFieldView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUITextFieldView.h rename to MVMCoreUI/Legacy/Views/MVMCoreUITextFieldView.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUITextFieldView.m b/MVMCoreUI/Legacy/Views/MVMCoreUITextFieldView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUITextFieldView.m rename to MVMCoreUI/Legacy/Views/MVMCoreUITextFieldView.m diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h b/MVMCoreUI/Legacy/Views/PrimaryButton.h similarity index 100% rename from MVMCoreUI/Atoms/Buttons/PrimaryButton.h rename to MVMCoreUI/Legacy/Views/PrimaryButton.h diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Legacy/Views/PrimaryButton.m similarity index 100% rename from MVMCoreUI/Atoms/Buttons/PrimaryButton.m rename to MVMCoreUI/Legacy/Views/PrimaryButton.m diff --git a/MVMCoreUI/Atoms/Views/TextButtonView.h b/MVMCoreUI/Legacy/Views/TextButtonView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/TextButtonView.h rename to MVMCoreUI/Legacy/Views/TextButtonView.h diff --git a/MVMCoreUI/Atoms/Views/TextButtonView.m b/MVMCoreUI/Legacy/Views/TextButtonView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/TextButtonView.m rename to MVMCoreUI/Legacy/Views/TextButtonView.m diff --git a/MVMCoreUI/Molecules/TopLabelsView.h b/MVMCoreUI/Legacy/Views/TopLabelsView.h similarity index 100% rename from MVMCoreUI/Molecules/TopLabelsView.h rename to MVMCoreUI/Legacy/Views/TopLabelsView.h diff --git a/MVMCoreUI/Molecules/TopLabelsView.m b/MVMCoreUI/Legacy/Views/TopLabelsView.m similarity index 100% rename from MVMCoreUI/Molecules/TopLabelsView.m rename to MVMCoreUI/Legacy/Views/TopLabelsView.m diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h b/MVMCoreUI/Legacy/Views/ViewConstrainingView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/ViewConstrainingView.h rename to MVMCoreUI/Legacy/Views/ViewConstrainingView.h diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Legacy/Views/ViewConstrainingView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/ViewConstrainingView.m rename to MVMCoreUI/Legacy/Views/ViewConstrainingView.m diff --git a/MVMCoreUI/Models/Container/ContainerModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/Container/ContainerModelProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Molecules/FooterModel.swift similarity index 87% rename from MVMCoreUI/Models/Molecules/FooterModel.swift rename to MVMCoreUI/Molecules/FooterModel.swift index e31ec1fc..a534ed87 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Molecules/FooterModel.swift @@ -13,7 +13,7 @@ import Foundation public static var identifier: String = "footer" public var backgroundColor: Color? - enum FooterCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor } @@ -39,7 +39,7 @@ import Foundation } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) setDefaults() @@ -47,7 +47,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: FooterCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/FooterView.swift similarity index 88% rename from MVMCoreUI/Molecules/StandardFooterView.swift rename to MVMCoreUI/Molecules/FooterView.swift index e433ec88..b9113d1d 100644 --- a/MVMCoreUI/Molecules/StandardFooterView.swift +++ b/MVMCoreUI/Molecules/FooterView.swift @@ -1,5 +1,5 @@ // -// StandardFooterView.swift +// FooterView.swift // MVMCoreUI // // Created by Scott Pfeil on 3/11/19. @@ -8,7 +8,7 @@ import UIKit -open class StandardFooterView: MoleculeContainer { +open class FooterView: MoleculeContainer { public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { if let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) { return height + PaddingDefaultVerticalSpacing + PaddingDefaultVerticalSpacing diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Molecules/HeaderModel.swift similarity index 86% rename from MVMCoreUI/Models/Molecules/HeaderModel.swift rename to MVMCoreUI/Molecules/HeaderModel.swift index 4499d313..ab7d5427 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Molecules/HeaderModel.swift @@ -13,7 +13,7 @@ import Foundation public var backgroundColor: Color? public var line: LineModel? - enum HeaderCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case line case backgroundColor @@ -43,14 +43,14 @@ import Foundation required public init(from decoder: Decoder) throws { try super.init(from: decoder) - let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) setDefaults() + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) ?? LineModel(type: .heavy) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: HeaderCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(line, forKey: .line) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/HeaderView.swift similarity index 96% rename from MVMCoreUI/Molecules/StandardHeaderView.swift rename to MVMCoreUI/Molecules/HeaderView.swift index ad231597..f04661e2 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/HeaderView.swift @@ -1,5 +1,5 @@ // -// StandardHeaderView.swift +// HeaderView.swift // MVMCoreUI // // Created by Scott Pfeil on 2/12/19. @@ -8,7 +8,7 @@ import UIKit -public class StandardHeaderView: MoleculeContainer { +public class HeaderView: MoleculeContainer { var line: Line? var headerModel: HeaderModel? { diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift index 0e358871..2cf86858 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -17,7 +17,7 @@ public class TabsModel: MoleculeProtocol { // Must be capped to 0...(tabs.count - 1) public var selectedIndex: Int = 0 - enum TabsCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case tabs case backgroundColor case selectedColor @@ -29,7 +29,7 @@ public class TabsModel: MoleculeProtocol { } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: TabsCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) tabs = try typeContainer.decode([LabelModel].self, forKey: .tabs) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor) { @@ -41,7 +41,7 @@ public class TabsModel: MoleculeProtocol { } public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: TabsCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(tabs, forKey: .tabs) try container.encode(backgroundColor, forKey: .backgroundColor) try container.encode(selectedColor, forKey: .selectedColor) diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift index d5519288..5d88b913 100644 --- a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift @@ -16,7 +16,7 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { public var hideArrow: Bool? = true public var line: LineModel? - enum AccordionListItemCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case molecules case backgroundColor case hideLineWhenExpanded @@ -25,7 +25,7 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: AccordionListItemCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as! [ListItemModelProtocol] backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) @@ -37,7 +37,7 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: AccordionListItemCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModels(molecules, forKey: .molecules) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(hideLineWhenExpanded, forKey: .hideLineWhenExpanded) diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 64e8c69b..86b0ac82 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -22,7 +22,7 @@ import Foundation super.init(with: molecule) } - enum DropDownCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case molecules case dropDown case line @@ -30,7 +30,7 @@ import Foundation } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: DropDownCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { @@ -42,7 +42,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: DropDownCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModels2D(molecules, forKey: .molecules) try container.encode(dropDown, forKey: .dropDown) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 5e54a2e9..c564c214 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -17,7 +17,7 @@ import MVMCore public var line: LineModel? public var style: String? = "standard" - enum ListItemCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case action case hideArrow @@ -47,7 +47,7 @@ import MVMCore } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) @@ -61,7 +61,7 @@ import MVMCore public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: ListItemCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeIfPresent(hideArrow, forKey: .hideArrow) diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift index e2ee337d..0661e907 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift @@ -15,7 +15,7 @@ import Foundation public var percent: Int? public var gone: Bool = false - enum MoleculeStackItemCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case spacing case percent case gone @@ -26,7 +26,7 @@ import Foundation } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent) if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) { @@ -37,7 +37,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(spacing, forKey: .spacing) try container.encodeIfPresent(percent, forKey: .percent) try container.encode(gone, forKey: .gone) diff --git a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift index d27b9097..13dd09e7 100644 --- a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift @@ -17,7 +17,7 @@ public class TabsListItemModel: ContainerModel, ListItemModelProtocol { public var hideArrow: Bool? = true public var line: LineModel? = LineModel(type: .standard) - enum TabsListItemCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case tabs case molecules case backgroundColor @@ -33,7 +33,7 @@ public class TabsListItemModel: ContainerModel, ListItemModelProtocol { } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: TabsListItemCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs) molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) @@ -45,7 +45,7 @@ public class TabsListItemModel: ContainerModel, ListItemModelProtocol { public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: TabsListItemCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(tabs, forKey: .tabs) try container.encodeModels2D(molecules, forKey: .molecules) try container.encode(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift index c61bd408..472be993 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -21,7 +21,7 @@ public class CornerLabelsModel: MoleculeProtocol { self.molecule = molecule } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case topLeftLabel case topRightLabel diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 728ae3a8..857ef7bc 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -13,7 +13,7 @@ import Foundation return "numberedList" } - private enum NumberedListCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case list @@ -21,7 +21,7 @@ import Foundation // Numbered list model comes in the from of list = [MoleculeProtocol] public required init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: NumberedListCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let list = try typeContainer.decodeMolecules(codingKey: .list) var models: [MoleculeStackItemModel] = [] @@ -33,7 +33,7 @@ import Foundation } public override func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: NumberedListCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) var models: [MoleculeProtocol] = [] diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index f2c73cab..23e32218 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -19,7 +19,7 @@ public class StringAndMoleculeModel: MoleculeProtocol { self.molecule = molecule } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case string diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index a905401c..aeb8b34e 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -14,7 +14,7 @@ import Foundation } public var bulletChar = "•" - private enum NumberedListCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case list @@ -23,7 +23,7 @@ import Foundation // Numbered list model comes in the from of list = [MoleculeProtocol] public required init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: NumberedListCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) { self.bulletChar = bulletChar } @@ -38,7 +38,7 @@ import Foundation } public override func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: NumberedListCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(bulletChar, forKey: .bulletChar) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift index 5f33725e..c8922204 100644 --- a/MVMCoreUI/Organisms/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -24,7 +24,7 @@ import Foundation super.init() } - enum StackCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case molecules case axis @@ -32,7 +32,7 @@ import Foundation } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self) + 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 @@ -45,7 +45,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: StackCodingKeys.self) + 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) diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Organisms/StackModel.swift index deea2457..8368ce8c 100644 --- a/MVMCoreUI/Organisms/StackModel.swift +++ b/MVMCoreUI/Organisms/StackModel.swift @@ -20,7 +20,7 @@ import Foundation self.molecules = molecules } - enum StackCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case molecules @@ -29,7 +29,7 @@ import Foundation } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decode([StackItemModel].self, forKey: .molecules) if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) { @@ -41,7 +41,7 @@ import Foundation } public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: StackCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(molecules, forKey: .molecules) try container.encodeIfPresent(axis.rawValueString, forKey: .axis) try container.encodeIfPresent(spacing, forKey: .spacing) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 1eda2454..1e589134 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -30,9 +30,9 @@ @"line": Line.class, @"button": PrimaryButton.class, @"link": MFTextButton.class, - @"header": StandardHeaderView.class, + @"header": HeaderView.class, @"twoButtonView": TwoButtonView.class, - @"footer": StandardFooterView.class, + @"footer": FooterView.class, @"caretView": CaretView.class, @"caretLink": CaretButton.class, @"textField": MFTextField.class, diff --git a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift similarity index 98% rename from MVMCoreUI/Models/Template/ListPageTemplateModel.swift rename to MVMCoreUI/Templates/ListPageTemplateModel.swift index c3b2a120..4a301660 100644 --- a/MVMCoreUI/Models/Template/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -27,7 +27,7 @@ import Foundation self.molecules = molecules } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case pageType case screenHeading diff --git a/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift similarity index 99% rename from MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift rename to MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift index 804103c4..86c09b6d 100644 --- a/MVMCoreUI/Models/Template/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift @@ -11,11 +11,7 @@ import Foundation @objcMembers public class StackCenteredPageTemplateModel: TemplateModelProtocol { public static var identifier: String = "stackCenterTemplate" - public var pageType: String - public var screenHeading: String? - public var isAtomicTabs: Bool? - } diff --git a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift b/MVMCoreUI/Templates/StackPageTemplateModel.swift similarity index 97% rename from MVMCoreUI/Models/Template/StackPageTemplateModel.swift rename to MVMCoreUI/Templates/StackPageTemplateModel.swift index 0e5e4488..db9d632d 100644 --- a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackPageTemplateModel.swift @@ -13,9 +13,7 @@ import Foundation public static var identifier: String = "stack" public var pageType: String - public var screenHeading: String? - public var isAtomicTabs: Bool? public var header: MoleculeProtocol? @@ -27,7 +25,7 @@ import Foundation self.moleculeStack = moleculeStack } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case pageType case screenHeading case header diff --git a/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift similarity index 97% rename from MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift rename to MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index 5d4d1b25..e42ca5f0 100644 --- a/MVMCoreUI/Models/Template/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -12,9 +12,7 @@ import Foundation public static var identifier: String = "threeLayer" public var pageType: String - public var screenHeading: String? - public var isAtomicTabs: Bool? public var header: MoleculeProtocol? @@ -28,7 +26,7 @@ import Foundation self.footer = footer } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case pageType case screenHeading case header diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 9c963693..785d1055 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -26,7 +26,6 @@ import UIKit heightConstraint?.isActive = true } - open override func viewForTop() -> UIView? { guard let headerModel = templateModel?.header, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { From 8e284034804d5c1cec56818844cd52a5cde2f316 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 21 Jan 2020 23:44:31 +0530 Subject: [PATCH 188/272] alignment fixes and progressBar mapping change. --- .../HeadLineBodyCaretLinkImage.swift | 25 +++++++++---------- .../MVMCoreUIMoleculeMappingObject.m | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index 3b52e6bf..d1f0dbf5 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -13,18 +13,15 @@ import Foundation let caretButton = CaretButton(frame: .zero) let backgroundImageView = MFLoadImageView() var spaceBetweenConstant: CGFloat = 104.0 - var leftConstraintHeadline : NSLayoutConstraint? - var leftConstraintCaretView : NSLayoutConstraint? - let padding = MFStyler.defaultHorizontalPaddingForApplicationWidth() let maxWidth : CGFloat = 350.0 // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { - super.updateView(size) - headlineBody.updateView(size) - caretButton.updateView(size) - backgroundImageView.updateView(size) - leftConstraintHeadline?.constant = MFStyler.defaultHorizontalPadding(forSize: size) - leftConstraintCaretView?.constant = MFStyler.defaultHorizontalPadding(forSize: size) + super.updateView(size) + headlineBody.updateView(size) + caretButton.updateView(size) + backgroundImageView.updateView(size) + backgroundImageView.alignFillHorizontal() + backgroundImageView.alignFillVertical() } open override func setupView() { @@ -39,8 +36,7 @@ import Foundation view.addSubview(caretButton) //Headline view - leftConstraintHeadline = headlineBody.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding) - leftConstraintHeadline?.isActive = true + headlineBody.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true headlineBody.topAnchor.constraint(equalTo: view.topAnchor, constant: PaddingDefault).isActive = true let headLineBodyWidth = headlineBody.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.85) @@ -50,8 +46,7 @@ import Foundation //Caret view caretButton.translatesAutoresizingMaskIntoConstraints = false - leftConstraintCaretView = caretButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding) - leftConstraintCaretView?.isActive = true + caretButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true view.bottomAnchor.constraint(equalTo: caretButton.bottomAnchor, constant: PaddingDefault).isActive = true caretButton.topAnchor.constraint(greaterThanOrEqualTo: headlineBody.bottomAnchor, constant: spaceBetweenConstant).isActive = true @@ -59,6 +54,8 @@ import Foundation //Background image view backgroundImageView.translatesAutoresizingMaskIntoConstraints = false backgroundImageView.imageView.contentMode = .scaleAspectFill + backgroundImageView.alignFillHorizontal() + backgroundImageView.alignFillVertical() view.addSubview(backgroundImageView) NSLayoutConstraint.constraintPinSubview(toSuperview: backgroundImageView) view.sendSubviewToBack(backgroundImageView) @@ -88,6 +85,8 @@ import Foundation headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData) caretButton.setWithModel(model.caretLink, delegateObject, additionalData) backgroundImageView.setWithModel(model.image, delegateObject, additionalData) + backgroundImageView.alignFillHorizontal() + backgroundImageView.alignFillVertical() } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 1e589134..b5a39119 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -45,7 +45,7 @@ @"checkbox": Checkbox.class, @"checkboxLabel": CheckboxWithLabelView.class, @"cornerLabels" : CornerLabels.class, - @"progressbar": ProgressBar.class, + @"progressBar": ProgressBar.class, @"circleProgress": GraphView.class, @"multiProgressBar": MultiProgress.class, @"radioButton": RadioButton.class, From 01780e708f71e350684a89adb54c63c9a94bd9c3 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 21 Jan 2020 15:33:10 -0500 Subject: [PATCH 189/272] update link --- MVMCoreUI/Atoms/Buttons/Link.swift | 37 ++++++------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 39187ac8..02778bce 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -30,25 +30,7 @@ import UIKit //-------------------------------------------------- private var delegateObject: MVMCoreUIDelegateObject? - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - public override init(frame: CGRect) { - super.init(frame: frame) - setupView() - } - - public convenience init() { - self.init(frame: .zero) - } - - public required init?(coder: NSCoder) { - super.init(coder: coder) - setupView() - } - + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -95,8 +77,7 @@ extension Link { } public override func setupView() { - - translatesAutoresizingMaskIntoConstraints = false + super.setupView() backgroundColor = .clear contentMode = .redraw setTitleColor(.mfTextButton(), for: .normal) @@ -118,17 +99,17 @@ extension Link: ModelMoleculeViewProtocol { backgroundColor = model.backgroundColor?.uiColor set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } + + + public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 31.0 + } } // MARK: - MVMCoreUIMoleculeViewProtocol extension Link { - public override func reset() { - super.reset() - setTitleColor(.mfTextButton(), for: .normal) - } - public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) self.additionalData = additionalData @@ -164,10 +145,6 @@ extension Link { // MARK: - MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { - public func needsToBeConstrained() -> Bool { - return true - } - public func alignment() -> UIStackView.Alignment { return .leading } From f5ed509a394436810b25e02e1f2dd19fd78bc6aa Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 21 Jan 2020 15:33:27 -0500 Subject: [PATCH 190/272] renaming --- MVMCoreUI.xcodeproj/project.pbxproj | 26 +++++++++---------- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 2 +- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 2 +- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 2 +- .../Buttons/MFTextButton+ModelExtension.swift | 2 +- ...maryButton+MoleculeProtocolExtension.swift | 2 +- .../MFTextField+ModelExtension.swift | 2 +- .../Atoms/TextFields/TextFieldModel.swift | 2 +- MVMCoreUI/Atoms/Views/CaretView.swift | 2 +- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 2 +- .../Atoms/Views/CircleProgressModel.swift | 2 +- MVMCoreUI/Atoms/Views/DashLine.swift | 2 +- MVMCoreUI/Atoms/Views/DashLineModel.swift | 2 +- MVMCoreUI/Atoms/Views/DropDownModel.swift | 2 +- MVMCoreUI/Atoms/Views/GraphView.swift | 2 +- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 2 +- MVMCoreUI/Atoms/Views/Label/Label.swift | 2 +- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 2 +- .../Atoms/Views/LeftRightLabelModel.swift | 2 +- .../Atoms/Views/LeftRightLabelView.swift | 2 +- MVMCoreUI/Atoms/Views/Line.swift | 2 +- MVMCoreUI/Atoms/Views/LineModel.swift | 2 +- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 2 +- .../Atoms/Views/MFView+ModelExtension.swift | 4 +-- .../Atoms/Views/MVMCoreUISwitch+Model.swift | 2 +- MVMCoreUI/Atoms/Views/MultiProgress.swift | 2 +- .../Atoms/Views/MultiProgressModel.swift | 2 +- MVMCoreUI/Atoms/Views/ProgressBar.swift | 2 +- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 2 +- MVMCoreUI/Atoms/Views/Toggle.swift | 2 +- MVMCoreUI/Atoms/Views/ToggleModel.swift | 2 +- MVMCoreUI/BaseClasses/Control.swift | 4 +-- MVMCoreUI/BaseClasses/View.swift | 10 +++---- .../MFViewController+Model.swift | 4 +-- .../Views/Container/Container.swift | 2 +- .../Containers/Views/MoleculeContainer.swift | 8 +++--- .../Views/MoleculeContainerModel.swift | 4 +-- .../Views/MVMCoreUIMoleculeViewProtocol.h | 2 +- .../Extensions/MoleculeModelHelper.swift | 20 +++++++------- ....swift => CarouselItemModelProtocol.swift} | 4 +-- ...wift => CarouselPagingModelProtocol.swift} | 4 +-- .../ListItemModelProtocol.swift | 2 +- ...ocol.swift => MoleculeModelProtocol.swift} | 4 +-- .../Models/Molecules/CarouselItemModel.swift | 2 +- .../Models/Molecules/CarouselModel.swift | 6 ++--- .../Molecules/ModuleMoleculeModel.swift | 2 +- .../Molecules/Doughnut/DoughnutChart.swift | 2 +- .../Doughnut/DoughnutChartModel.swift | 4 +-- .../Doughnut/DoughnutChartView.swift | 6 ++--- MVMCoreUI/Molecules/FooterModel.swift | 4 +-- MVMCoreUI/Molecules/HeaderModel.swift | 4 +-- MVMCoreUI/Molecules/HeaderView.swift | 2 +- .../TabsModel.swift | 2 +- .../TwoButtonView.swift | 2 +- .../TwoButtonViewModel.swift | 2 +- .../Items/DropDownFilterTableViewCell.swift | 2 +- .../Items/DropDownListItemModel.swift | 2 +- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 +- .../Items/MoleculeCollectionViewCell.swift | 4 +-- .../Items/MoleculeStackItemModel.swift | 4 +-- .../Items/MoleculeTableViewCell.swift | 6 ++--- .../Molecules/Items/StackItemModel.swift | 2 +- .../Items/StackItemModelProtocol.swift | 2 +- MVMCoreUI/Molecules/Items/TableViewCell.swift | 6 ++--- .../Molecules/Items/TabsTableViewCell.swift | 2 +- .../LeftRightViews/CornerLabels.swift | 2 +- .../LeftRightViews/CornerLabelsModel.swift | 6 ++--- .../SwitchMolecules/HeadlineBodySwitch.swift | 4 +-- .../SwitchMolecules/LabelSwitch.swift | 2 +- .../SwitchMolecules/LabelToggleModel.swift | 2 +- .../Molecules/ModelMoleculeViewProtocol.swift | 14 +++++----- MVMCoreUI/Molecules/ModuleMolecule.swift | 8 +++--- MVMCoreUI/Molecules/Scroller.swift | 2 +- MVMCoreUI/Molecules/ScrollerModel.swift | 2 +- .../EyebrowHeadlineBodyLink.swift | 6 ++--- .../HeadLineBodyCaretLinkImage.swift | 4 +-- .../HeadlineBody.swift | 2 +- .../HeadlineBodyCaretLinkImageModel.swift | 2 +- .../HeadlineBodyModel.swift | 2 +- .../Lists/NumberedListModel.swift | 4 +-- .../StringAndMoleculeModel.swift | 6 ++--- .../StringAndMoleculeStack.swift | 2 +- .../StringAndMoleculeView.swift | 2 +- .../Lists/UnOrderedListModel.swift | 4 +-- MVMCoreUI/Organisms/Carousel.swift | 8 +++--- MVMCoreUI/Organisms/MoleculeStackModel.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 2 +- MVMCoreUI/Organisms/Stack.swift | 12 ++++----- MVMCoreUI/Organisms/StackModel.swift | 2 +- ...MoleculeMappingObject+ModelExtension.swift | 6 ++--- .../ModelMoleculeDelegateProtocol.swift | 2 +- .../Templates/ListPageTemplateModel.swift | 4 +-- .../Templates/StackPageTemplateModel.swift | 4 +-- .../TemplateProtocol.swift | 0 .../ThreeLayerPageTemplateModel.swift | 8 +++--- 96 files changed, 177 insertions(+), 177 deletions(-) rename MVMCoreUI/Models/ModelProtocols/{CollectionCellMoleculeProtocol.swift => CarouselItemModelProtocol.swift} (62%) rename MVMCoreUI/Models/ModelProtocols/{PagingMoleculeProtocol.swift => CarouselPagingModelProtocol.swift} (62%) rename MVMCoreUI/Models/ModelProtocols/{MoleculeProtocol.swift => MoleculeModelProtocol.swift} (70%) rename MVMCoreUI/{Models/ModelProtocols => Templates}/TemplateProtocol.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2ae882f5..d9591c22 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -17,9 +17,9 @@ 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F323A2CCC80085F53C /* DropDownModel.swift */; }; 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */; }; 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */; }; - 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */; }; + 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */; }; 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */; }; - 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */; }; + 012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C3238D86E600FE3DA1 /* CarouselItemModelProtocol.swift */; }; 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */; }; 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */; }; 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */; }; @@ -52,7 +52,7 @@ 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D223CF9E740021F976 /* LabelToggleModel.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; - 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; + 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; }; 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368B23609801006832FA /* MoleculeStackModel.swift */; }; @@ -320,9 +320,9 @@ 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModelProtocol.swift; sourceTree = ""; }; 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateProtocol.swift; sourceTree = ""; }; 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselModel.swift; sourceTree = ""; }; - 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PagingMoleculeProtocol.swift; sourceTree = ""; }; + 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselPagingModelProtocol.swift; sourceTree = ""; }; 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemModel.swift; sourceTree = ""; }; - 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionCellMoleculeProtocol.swift; sourceTree = ""; }; + 012A88C3238D86E600FE3DA1 /* CarouselItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemModelProtocol.swift; sourceTree = ""; }; 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMoleculeModel.swift; sourceTree = ""; }; 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeDelegateProtocol.swift; sourceTree = ""; }; 012A88EB238F084D00FE3DA1 /* FooterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModel.swift; sourceTree = ""; }; @@ -353,7 +353,7 @@ 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; 01C851D223CF9E740021F976 /* LabelToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggleModel.swift; sourceTree = ""; }; - 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; + 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeModelProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackItemModel.swift; sourceTree = ""; }; @@ -633,10 +633,9 @@ children = ( 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, - 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, - 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, - 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, - 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, + 012A88C3238D86E600FE3DA1 /* CarouselItemModelProtocol.swift */, + 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */, + 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */, 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */, D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */, 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */, @@ -950,6 +949,7 @@ D29DF0DF21E418B2003B2FB9 /* Templates */ = { isa = PBXGroup; children = ( + 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, 014AA72823C5059B006F3E93 /* StackPageTemplateModel.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, 014AA72923C5059B006F3E93 /* StackCenteredPageTemplateModel.swift */, @@ -1533,7 +1533,7 @@ C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */, - 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */, + 012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, @@ -1604,7 +1604,7 @@ D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, - 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */, + 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */, D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, @@ -1629,7 +1629,7 @@ 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */, - 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */, + 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 26efc82e..531859c0 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -18,7 +18,7 @@ public enum ButtonSize: String, Codable { case tiny } -public class ButtonModel: MoleculeProtocol { +public class ButtonModel: MoleculeModelProtocol { public static var identifier: String = "button" public var backgroundColor: Color? public var title: String diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 1574a9e8..3fcf453a 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -141,7 +141,7 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let caretLinkModel = model as? CaretLinkModel else { return } if let color = caretLinkModel.backgroundColor { backgroundColor = color.uiColor diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 6daf2740..3612c1fc 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -9,7 +9,7 @@ import Foundation import MVMCore -public class CaretLinkModel: MoleculeProtocol { +public class CaretLinkModel: MoleculeModelProtocol { public static var identifier: String = "caretLink" public var backgroundColor: Color? public var title: String diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index fd0b17b9..27cbd6c6 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -8,7 +8,7 @@ import UIKit -public class LinkModel: MoleculeProtocol { +public class LinkModel: MoleculeModelProtocol { public static var identifier: String = "link" public var backgroundColor: Color? public var title: String diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift b/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift index a86c072e..dc5399ef 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift @@ -10,7 +10,7 @@ import UIKit // temporary until link is finished extension MFTextButton: ModelMoleculeViewProtocol { - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let model = model as? LinkModel else { return } setTitle(model.title, for: .normal) setTitleColor(model.textColor.uiColor, for: .normal) diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift index 09c94bdf..39b015ae 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift @@ -10,7 +10,7 @@ import Foundation // temporary until link is finished extension PrimaryButton: ModelMoleculeViewProtocol { - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let model = model as? ButtonModel else { return } setTitle(model.title, for: .normal) backgroundColor = model.backgroundColor?.uiColor diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift index e0c5ce0f..a077c285 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift +++ b/MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift @@ -16,7 +16,7 @@ enum TextType: String { } extension MFTextField: ModelMoleculeViewProtocol { // - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { //TODO: Need to create setWithModel in ViewConstraining View #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. diff --git a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift index 3a76bbb3..c538a715 100644 --- a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { +@objcMembers public class TextFieldModel: MoleculeModelProtocol, FormModelProtocol { public static var identifier: String = "textField" public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index 5487f0b9..26573af5 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -188,7 +188,7 @@ open class CaretView: View { } //MARK: - MVMCoreMoleculeViewProtocol - override public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + override public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let caretModel = model as? CaretViewModel else { return diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index cee09a40..58291984 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class CaretViewModel: MoleculeProtocol { +@objcMembers public class CaretViewModel: MoleculeModelProtocol { public static var identifier: String = "caretView" public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift index aae99612..feb69083 100644 --- a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/CircleProgressModel.swift @@ -16,7 +16,7 @@ public enum GraphStyle: String, Codable { case unlimited, safetyMode } -public class CircleProgressModel: MoleculeProtocol { +public class CircleProgressModel: MoleculeModelProtocol { public static var identifier: String = "circleProgress" public var style: GraphStyle = .unlimited { didSet { diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index de4d6d4a..dcfc4270 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -92,7 +92,7 @@ open class DashLine: View { } //MARK: - MVMCoreMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let dashLineModel = dashModel else { return diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 662a7cf4..1346b5c2 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class DashLineModel: MoleculeProtocol { +@objcMembers public class DashLineModel: MoleculeModelProtocol { public static var identifier: String = "dashLine" public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/DropDownModel.swift b/MVMCoreUI/Atoms/Views/DropDownModel.swift index 95caa2b6..8e3e4e10 100644 --- a/MVMCoreUI/Atoms/Views/DropDownModel.swift +++ b/MVMCoreUI/Atoms/Views/DropDownModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class DropDownModel: MoleculeProtocol { +@objcMembers public class DropDownModel: MoleculeModelProtocol { public static var identifier: String = "dropDownModel" public var backgroundColor: Color? public var label: String diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index 1f6ea45b..5818078c 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -26,7 +26,7 @@ import UIKit widthAnchor.constraint(equalTo: heightAnchor).isActive = true } - override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + override open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? CircleProgressModel else { return } createGraphCircle(model) diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 0944c36e..ce46a930 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ImageViewModel: MoleculeProtocol { +@objcMembers public class ImageViewModel: MoleculeModelProtocol { public static var identifier: String = "image" public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index 2188b2a2..b2953227 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -219,7 +219,7 @@ public typealias ActionBlock = () -> () case left } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { clauses = [] guard let labelModel = model as? LabelModel else { return } attributedText = nil diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index faf19c22..b7feefae 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class LabelModel: MoleculeProtocol { +@objcMembers public class LabelModel: MoleculeModelProtocol { public static var identifier: String = "label" public var moleculeName: String? public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index 73abb4d6..325611ec 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers public class LeftRightLabelModel: MoleculeProtocol { +@objcMembers public class LeftRightLabelModel: MoleculeModelProtocol { public static var identifier: String = "leftRightLabelView" public var backgroundColor: Color? public var leftText: LabelModel diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift index c6c87032..1096df37 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift @@ -179,7 +179,7 @@ import Foundation //MARK: - MVMCoreMoleculeViewProtocol - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let leftRightLabelModel = model as? LeftRightLabelModel else { return diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atoms/Views/Line.swift index d7cbc5e8..d6ec5d8a 100644 --- a/MVMCoreUI/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atoms/Views/Line.swift @@ -67,7 +67,7 @@ import UIKit super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let lineModel = model as? LineModel { setStyle(lineModel.type ?? .standard) } diff --git a/MVMCoreUI/Atoms/Views/LineModel.swift b/MVMCoreUI/Atoms/Views/LineModel.swift index cf671996..8f16d22e 100644 --- a/MVMCoreUI/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atoms/Views/LineModel.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers public class LineModel: MoleculeProtocol { +@objcMembers public class LineModel: MoleculeModelProtocol { /* The frequency of the line in a moleculeList. diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 7be1187a..242e299a 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -209,7 +209,7 @@ import UIKit } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let imageModel = model as? ImageViewModel else { return } diff --git a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift index 2ba216d7..d532d7c4 100644 --- a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift @@ -9,7 +9,7 @@ import Foundation extension MFView { - public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setUpDefaultWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor @@ -18,7 +18,7 @@ extension MFView { } extension ModelMoleculeViewProtocol where Self: MFView { - func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { setUpDefaultWithModel(model, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift index e62a8b94..e2ef7b31 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift +++ b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift @@ -10,7 +10,7 @@ import Foundation // temporary until link is finished extension MVMCoreUISwitch: ModelMoleculeViewProtocol { - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let model = model as? ToggleModel else { return } if let castSelf = self as? FormValidationProtocol { diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index 38945134..cee425cc 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -64,7 +64,7 @@ import UIKit } //MARK: - MVMCoreMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let multiProgressModel = multiProgressModel else { return diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index abcbd5fd..6dd05b0b 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -18,7 +18,7 @@ import Foundation } } -@objcMembers public class MultiProgressBarModel: MoleculeProtocol { +@objcMembers public class MultiProgressBarModel: MoleculeModelProtocol { public static var identifier: String = "multiProgressBar" public var progressList: [SingleProgressBarModel] public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index bbf5a5de..17d35c29 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -51,7 +51,7 @@ import Foundation } //MARK: - MVMCoreMoleculeViewProtocol - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let progressBarModel = model as? ProgressBarModel else { return } diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 396ab8e9..2efa0403 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ProgressBarModel: MoleculeProtocol { +@objcMembers public class ProgressBarModel: MoleculeModelProtocol { public static var identifier: String = "progressbar" @Percent public var percent: CGFloat public var progressColor: Color = Color(uiColor: .mfCerulean()) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 366b6b89..899c1edb 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -333,7 +333,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) } } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let toggleModel = model as? ToggleModel else { return } diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 8aa9500b..12706a49 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -8,7 +8,7 @@ import UIKit -public class ToggleModel: MoleculeProtocol { +public class ToggleModel: MoleculeModelProtocol { public static var identifier: String = "toggle" public var moleculeName: String? public var backgroundColor: Color? diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 3eb268e5..dd64932e 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -14,7 +14,7 @@ import UIKit //-------------------------------------------------- public var json: [AnyHashable: Any]? - public var model: MoleculeProtocol? + public var model: MoleculeModelProtocol? private var initialSetupPerformed = false @@ -49,7 +49,7 @@ import UIKit } } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 05cbef15..5dc159d0 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers open class View: UIView, ModelMoleculeViewProtocol { open var json: [AnyHashable: Any]? - open var model: MoleculeProtocol? + open var model: MoleculeModelProtocol? private var initialSetupPerformed = false @@ -40,22 +40,22 @@ import UIKit } } - open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor } } - public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model?.moleculeName } - public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } - public class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } } diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 3468748b..7e250b2a 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -16,10 +16,10 @@ extension MFViewController: MoleculeDelegateProtocol { return loadObject?.modulesJSON?.optionalDictionaryForKey(name) } - public func getModuleWithName(_ moduleName: String) -> MoleculeProtocol? { + public func getModuleWithName(_ moduleName: String) -> MoleculeModelProtocol? { guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moduleName), let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), - let modelType = ModelRegistry.getType(for: moleculeName) as? MoleculeProtocol.Type else { + let modelType = ModelRegistry.getType(for: moleculeName) as? MoleculeModelProtocol.Type else { return nil } do { diff --git a/MVMCoreUI/Containers/Views/Container/Container.swift b/MVMCoreUI/Containers/Views/Container/Container.swift index 065490a0..53abfda3 100644 --- a/MVMCoreUI/Containers/Views/Container/Container.swift +++ b/MVMCoreUI/Containers/Views/Container/Container.swift @@ -16,7 +16,7 @@ open class Container: View, ContainerProtocol { } // MARK:- ModelMoleculeViewProtocol - override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + override open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let containerModel = model as? ContainerModelProtocol else { return } containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol) diff --git a/MVMCoreUI/Containers/Views/MoleculeContainer.swift b/MVMCoreUI/Containers/Views/MoleculeContainer.swift index dc70e38d..9a907222 100644 --- a/MVMCoreUI/Containers/Views/MoleculeContainer.swift +++ b/MVMCoreUI/Containers/Views/MoleculeContainer.swift @@ -30,7 +30,7 @@ open class MoleculeContainer: Container { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let casteModel = model as? MoleculeContainerModel { if view != nil { (view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData) @@ -43,7 +43,7 @@ open class MoleculeContainer: Container { super.setWithModel(model, delegateObject, additionalData) } - public override static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public override static func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let containerModel = model as? MoleculeContainerModel, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, let moleculeName = moleculeClass.nameForReuse(containerModel.molecule, delegateObject) else { @@ -52,7 +52,7 @@ open class MoleculeContainer: Container { return "\(model?.moleculeName ?? "moleculeContainer")<\(moleculeName)>" } - public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let containerModel = molecule as? MoleculeContainerModel else { return 0 } guard let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, let moleculeHeight = moleculeClass.estimatedHeight(forRow: containerModel.molecule, delegateObject: delegateObject) else { @@ -61,7 +61,7 @@ open class MoleculeContainer: Container { return moleculeHeight + (containerModel.topMarginPadding ?? 0) + (containerModel.bottomMarginPadding ?? 0) } - public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + public override class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let containerModel = molecule as? MoleculeContainerModel, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type else { return nil } return moleculeClass.requiredModules(containerModel.molecule, delegateObject: delegateObject, error: error) diff --git a/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift index 284b91ee..0421b3d1 100644 --- a/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift +++ b/MVMCoreUI/Containers/Views/MoleculeContainerModel.swift @@ -9,13 +9,13 @@ import Foundation public class MoleculeContainerModel: ContainerModel { - public var molecule: MoleculeProtocol + public var molecule: MoleculeModelProtocol private enum CodingKeys: String, CodingKey { case molecule } - public init(with moleculeModel: MoleculeProtocol) { + public init(with moleculeModel: MoleculeModelProtocol) { molecule = moleculeModel super.init() } diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h index e67dc964..f11a5002 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h @@ -10,7 +10,7 @@ @import MVMCore.MVMCoreViewProtocol; @class MVMCoreUIDelegateObject; @class MVMCoreErrorObject; -@class MoleculeProtocol; +@class MoleculeModelProtocol; @protocol MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift b/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift index e10fcc38..599851bb 100644 --- a/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/MoleculeModelHelper.swift @@ -14,36 +14,36 @@ extension KeyedDecodingContainer where Key : CodingKey { } /// Decodes the molecule model with the given coding key based on moleculeName - public func decodeMolecule(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { + public func decodeMolecule(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeModelProtocol { return try decodeModel(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } /// Decodes the molecule model with the given coding key based on moleculeName, optional - public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { + public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeModelProtocol? { return try decodeModelIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } /// Decodes the list of molecule models with the given coding key based on moleculeName - public func decodeMolecules(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol] { - guard let models = try decodeModels(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { + public func decodeMolecules(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeModelProtocol] { + guard let models = try decodeModels(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeModelProtocol] else { throw ModelRegistry.Error.decoderError } return models } /// Decodes the list of molecule models with the given coding key based on moleculeName, optional - public func decodeMoleculesIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { - return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] + public func decodeMoleculesIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeModelProtocol]? { + return try decodeModelsIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeModelProtocol] } /// Decodes an array with arrays of molecules based on the identifiers, optional. - public func decodeMolecules2DIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeProtocol]]? { - return try decodeModels2DIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeProtocol]] + public func decodeMolecules2DIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeModelProtocol]]? { + return try decodeModels2DIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeModelProtocol]] } /// Decodes an array with arrays of models based on the identifiers. - public func decodeMolecules2D(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeProtocol]] { - guard let models = try decodeModels2D(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeProtocol]] else { + public func decodeMolecules2D(codingKey: KeyedDecodingContainer.Key) throws -> [[MoleculeModelProtocol]] { + guard let models = try decodeModels2D(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [[MoleculeModelProtocol]] else { throw ModelRegistry.Error.decoderError } return models diff --git a/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift similarity index 62% rename from MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift index 3dbdc694..53a6cc10 100644 --- a/MVMCoreUI/Models/ModelProtocols/CollectionCellMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift @@ -1,5 +1,5 @@ // -// CollectionCellMoleculeProtocol.swift +// CarouselItemModelProtocol.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 11/26/19. @@ -8,7 +8,7 @@ import Foundation -public protocol CollectionCellMoleculeProtocol: ContainerModelProtocol, MoleculeProtocol { +public protocol CarouselItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { var peakingUI: Bool? {get} var peakingArrowColor: Color? {get} } diff --git a/MVMCoreUI/Models/ModelProtocols/PagingMoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift similarity index 62% rename from MVMCoreUI/Models/ModelProtocols/PagingMoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift index af1ce14a..5f593d3b 100644 --- a/MVMCoreUI/Models/ModelProtocols/PagingMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift @@ -1,5 +1,5 @@ // -// PagingMoleculeProtocol.swift +// CarouselPagingModelProtocol.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 11/25/19. @@ -8,6 +8,6 @@ import Foundation -public protocol PagingMoleculeProtocol: MoleculeProtocol { +public protocol CarouselPagingModelProtocol: MoleculeModelProtocol { var position: Float? {get} } diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 7a990d61..857bd060 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeProtocol { +public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { var line: LineModel? { get set } var action: ActionProtocol? { get set } var hideArrow: Bool? { get set } diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift similarity index 70% rename from MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift rename to MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index b8117e60..85a91bcd 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -1,11 +1,11 @@ import Foundation -public protocol MoleculeProtocol: Model { +public protocol MoleculeModelProtocol: Model { var moleculeName: String? { get } var backgroundColor: Color? { get set} } -extension MoleculeProtocol { +extension MoleculeModelProtocol { public var moleculeName: String? { get { return Self.identifier } } diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift index e86b89c3..a5fc0e85 100644 --- a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class CarouselItemModel: MoleculeContainerModel, CollectionCellMoleculeProtocol { +@objcMembers public class CarouselItemModel: MoleculeContainerModel, CarouselItemModelProtocol { public static var identifier: String = "carouselItem" public var backgroundColor: Color? public var peakingUI: Bool? diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift index 9b55f97a..fedb5535 100644 --- a/MVMCoreUI/Models/Molecules/CarouselModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers public class CarouselModel: MoleculeProtocol { +@objcMembers public class CarouselModel: MoleculeModelProtocol { public static var identifier: String = "carousel" public var backgroundColor: Color? public var molecules: [CarouselItemModel] @@ -19,7 +19,7 @@ import UIKit public var height: Float? public var itemWidthPercent: Float? public var itemAlignment: String? - public var pagingMolecule: PagingMoleculeProtocol? + public var pagingMolecule: CarouselPagingModelProtocol? public init(molecules: [CarouselItemModel]){ self.molecules = molecules @@ -48,7 +48,7 @@ import UIKit self.height = try typeContainer.decode(Float.self, forKey: .height) self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent) self.itemAlignment = try typeContainer.decode(String.self, forKey: .itemAlignment) - self.pagingMolecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol + self.pagingMolecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .pagingMolecule) as? CarouselPagingModelProtocol } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift index 56259942..02e319e9 100644 --- a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -8,7 +8,7 @@ import Foundation -open class ModuleMoleculeModel: MoleculeProtocol { +open class ModuleMoleculeModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "moduleMolecule" public var moduleName: String diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift index 130536e4..d3f774a2 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift @@ -94,7 +94,7 @@ open class DoughnutChart: View { doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0) } - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) clearLayers() guard let doughnutChartModel = doughnutChartModel else { diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift index 1f4098e2..42acd2f0 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class DoughnutChartModel: MoleculeProtocol { +@objcMembers public class DoughnutChartModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChart" public var title: LabelModel? @@ -21,7 +21,7 @@ import Foundation } } -@objcMembers public class DoughnutChartItemModel: MoleculeProtocol { +@objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChartItem" public var label: LabelModel diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift index 72aceab7..05b5fd3b 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift @@ -65,7 +65,7 @@ import Foundation colorLablesStack.reset() } - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = doughnutChartModel else { return } @@ -94,7 +94,7 @@ extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { } class ColorViewLabelsStack: MoleculeStackView { - override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + override func createStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { let view = ColorViewWithLabel() @@ -149,7 +149,7 @@ class ColorViewWithLabel: View { label.setAsMolecule() } - override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let chartItemModel = model as? DoughnutChartItemModel else { return diff --git a/MVMCoreUI/Molecules/FooterModel.swift b/MVMCoreUI/Molecules/FooterModel.swift index a534ed87..9f7b002f 100644 --- a/MVMCoreUI/Molecules/FooterModel.swift +++ b/MVMCoreUI/Molecules/FooterModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class FooterModel: MoleculeContainerModel, MoleculeProtocol { +@objcMembers public class FooterModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "footer" public var backgroundColor: Color? @@ -33,7 +33,7 @@ import Foundation } } - public override init(with moleculeModel: MoleculeProtocol) { + public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) setDefaults() } diff --git a/MVMCoreUI/Molecules/HeaderModel.swift b/MVMCoreUI/Molecules/HeaderModel.swift index ab7d5427..b6f3629f 100644 --- a/MVMCoreUI/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Molecules/HeaderModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol { +@objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "header" public var backgroundColor: Color? public var line: LineModel? @@ -36,7 +36,7 @@ import Foundation line?.type = .heavy } - public override init(with moleculeModel: MoleculeProtocol) { + public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) setDefaults() } diff --git a/MVMCoreUI/Molecules/HeaderView.swift b/MVMCoreUI/Molecules/HeaderView.swift index f04661e2..c90be96d 100644 --- a/MVMCoreUI/Molecules/HeaderView.swift +++ b/MVMCoreUI/Molecules/HeaderView.swift @@ -42,7 +42,7 @@ public class HeaderView: MoleculeContainer { } } - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let headerModel = model as? HeaderModel else { diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift index 2cf86858..f45c771d 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -8,7 +8,7 @@ import UIKit -public class TabsModel: MoleculeProtocol { +public class TabsModel: MoleculeModelProtocol { public static var identifier: String = "tabs" public var backgroundColor: Color? public var tabs: [LabelModel] diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 1559e1a5..5c80bd1a 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -303,7 +303,7 @@ extension TwoButtonView { } extension TwoButtonView: ModelMoleculeViewProtocol { - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? TwoButtonViewModel else { return } setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil) setDefaultCustom() diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 50643e1c..04f676ba 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -8,7 +8,7 @@ import UIKit -public class TwoButtonViewModel: MoleculeProtocol { +public class TwoButtonViewModel: MoleculeModelProtocol { public static var identifier: String = "twoButtonView" public var backgroundColor: Color? public var primaryButton: ButtonModel? diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 4df2e7e2..cd18eb04 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -50,7 +50,7 @@ import UIKit dropDown?.updateView(size) } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { dropDownListItemModel = model as? DropDownListItemModel self.delegateObject = delegateObject super.setWithModel(model, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 86b0ac82..c7b9ca75 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -16,7 +16,7 @@ import Foundation public var line: LineModel? = LineModel(type: .none) public var hideArrow: Bool? = true - public init(molecule: MoleculeProtocol, molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { + public init(molecule: MoleculeModelProtocol, molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { self.molecules = molecules self.dropDown = dropDown super.init(with: molecule) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index c564c214..97fef586 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -41,7 +41,7 @@ import MVMCore } } - public override init(with moleculeModel: MoleculeProtocol) { + public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) setDefaults() } diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index 976b6e60..9d56f4cd 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -68,7 +68,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let collectionModel = model as? CarouselItemModel else { return } @@ -114,7 +114,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi backgroundColor = .white } - public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let molecule = (model as? CarouselItemModel)?.molecule, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type, let name = moleculeClass.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else { diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift index 0661e907..970f66f6 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol, StackItemModelProtocol { +@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeModelProtocol, StackItemModelProtocol { public static var identifier: String = "stackItem" public var backgroundColor: Color? public var spacing: CGFloat? @@ -21,7 +21,7 @@ import Foundation case gone } - public override init(with moleculeModel: MoleculeProtocol) { + public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 88531ceb..f55f9645 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -11,7 +11,7 @@ import UIKit @objcMembers open class MoleculeTableViewCell: TableViewCell { // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let moleculeModel = (model as? ListItemModel)?.molecule else { return } if molecule != nil { @@ -21,7 +21,7 @@ import UIKit } } - public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public override class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moleculeModel = (model as? ListItemModel)?.molecule else { return "\(self)<>" } @@ -38,7 +38,7 @@ import UIKit return theClass.requiredModules?(moleculeJSON, delegateObject: delegateObject, error: error) } - public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { guard let moleculeModel = (molecule as? MoleculeContainerModel)?.molecule, let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type, let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else { diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index 9484cd8d..f296986e 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class StackItemModel: StackItemModelProtocol, MoleculeProtocol { +@objcMembers public class StackItemModel: StackItemModelProtocol, MoleculeModelProtocol { public static var identifier: String = "simpleStackItem" public var backgroundColor: Color? public var spacing: CGFloat? diff --git a/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift b/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift index 165cb1ac..170fce69 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol StackItemModelProtocol: MoleculeProtocol { +public protocol StackItemModelProtocol: MoleculeModelProtocol { var spacing: CGFloat? { get set } var percent: Int? { get set } var gone: Bool { get set } diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index dc62ae65..900e6dd0 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -142,7 +142,7 @@ import UIKit } //TODO: Model, Change to model - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? ListItemModelProtocol else { return } @@ -179,11 +179,11 @@ import UIKit backgroundColor = .white } - public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model?.moleculeName } - public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift index 99d2d9ab..cf09eb51 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift @@ -38,7 +38,7 @@ import UIKit // MARK: - MoleculeDelegateProtocol - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) self.delegateObject = delegateObject tabs.reloadData() diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift index ac9fe240..680e7089 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift @@ -166,7 +166,7 @@ import UIKit return 34 } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? CornerLabelsModel else { return } if middleView != nil { diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift index 472be993..ce3796bf 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -8,16 +8,16 @@ import UIKit -public class CornerLabelsModel: MoleculeProtocol { +public class CornerLabelsModel: MoleculeModelProtocol { public static var identifier: String = "cornerLabels" public var backgroundColor: Color? public var topLeftLabel: LabelModel? public var topRightLabel: LabelModel? public var bottomLeftLabel: LabelModel? public var bottomRightLabel: LabelModel? - public var molecule: MoleculeProtocol + public var molecule: MoleculeModelProtocol - init(with molecule: MoleculeProtocol) { + init(with molecule: MoleculeModelProtocol) { self.molecule = molecule } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 1c937df1..79e2a9ec 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -37,11 +37,11 @@ import UIKit //MARK: - MVMCoreMoleculeViewProtocol - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) } - public class override func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public class override func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 30 } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift index 0713d40f..0e87e7c7 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift @@ -41,7 +41,7 @@ import UIKit mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let labelToggleModel = model as? LabelToggleModel else { return } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift index 6ac592d6..7ed5857e 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelToggleModel.swift @@ -8,7 +8,7 @@ import Foundation -public class LabelToggleModel: MoleculeProtocol { +public class LabelToggleModel: MoleculeModelProtocol { public static var identifier: String = "labelToggle" public var backgroundColor: Color? public var label: LabelModel diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift index e35f54e7..972ee175 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift @@ -9,20 +9,20 @@ import Foundation public protocol ModelMoleculeViewProtocol { - func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) - static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? - static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? - static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? + func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) + static func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? + static func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? + static func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? } extension ModelMoleculeViewProtocol { - public static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public static func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model?.moleculeName } - public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public static func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } - public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + public static func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } // Temporary diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index ba0801f3..360410b7 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -19,7 +19,7 @@ open class ModuleMolecule: Container { super.setupView() } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let moduleMoleculeModel = model as? ModuleMoleculeModel, @@ -46,7 +46,7 @@ open class ModuleMolecule: Container { } } - public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let moduleMolecule = molecule as? ModuleMoleculeModel, let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), @@ -58,7 +58,7 @@ open class ModuleMolecule: Container { return height } - public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public override class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moduleMolecule = model as? ModuleMoleculeModel, let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, @@ -69,7 +69,7 @@ open class ModuleMolecule: Container { return name } - public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + public override class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName, let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index 451eba75..8ee77816 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -29,7 +29,7 @@ import UIKit constraint.isActive = true } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let casteModel = model as? ScrollerModel { if view != nil { (view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/ScrollerModel.swift b/MVMCoreUI/Molecules/ScrollerModel.swift index 3fa225fb..f92fe13b 100644 --- a/MVMCoreUI/Molecules/ScrollerModel.swift +++ b/MVMCoreUI/Molecules/ScrollerModel.swift @@ -8,7 +8,7 @@ import UIKit -public class ScrollerModel: MoleculeContainerModel, MoleculeProtocol { +public class ScrollerModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "scroller" public var backgroundColor: Color? } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 01844e07..3f5d13aa 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -8,7 +8,7 @@ import UIKit -struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { +struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { static var identifier: String = "eyebrowHeadlineBodyLink" var backgroundColor: Color? @@ -46,7 +46,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) eyebrow.setWithModel(casteModel?.eyeBrow, delegateObject, additionalData) headline.setWithModel(casteModel?.headline, delegateObject, additionalData) @@ -74,7 +74,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol { body.styleB2(true) } - public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 65 } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index 3b52e6bf..beebe402 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -78,11 +78,11 @@ import Foundation backgroundImageView.reset() } - public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 320 } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? HeadlineBodyCaretLinkImageModel else { return } headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index 1d1f154a..8cdb5633 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -119,7 +119,7 @@ open class HeadlineBody: View { } } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let headlineBodyModel = model as? HeadlineBodyModel else { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift index 76333d08..e57cb369 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift @@ -8,7 +8,7 @@ import UIKit -public class HeadlineBodyCaretLinkImageModel: MoleculeProtocol { +public class HeadlineBodyCaretLinkImageModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyCaretLinkImage" public var backgroundColor: Color? public var caretLink: CaretLinkModel? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index bc63c12c..86151cb6 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class HeadlineBodyModel: MoleculeProtocol { +@objcMembers public class HeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "headlineBody" public var headline: LabelModel? public var body: LabelModel? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 857ef7bc..6cdfa862 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -19,7 +19,7 @@ import Foundation case list } - // Numbered list model comes in the from of list = [MoleculeProtocol] + // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) @@ -36,7 +36,7 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - var models: [MoleculeProtocol] = [] + var models: [MoleculeModelProtocol] = [] for molecule in molecules { models.append(molecule.molecule) } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index 23e32218..caa00021 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -8,13 +8,13 @@ import Foundation -public class StringAndMoleculeModel: MoleculeProtocol { +public class StringAndMoleculeModel: MoleculeModelProtocol { public static var identifier: String = "stringAndMoleculeModel" public var backgroundColor: Color? public var string: String - public var molecule: MoleculeProtocol + public var molecule: MoleculeModelProtocol - public init(string: String, molecule: MoleculeProtocol) { + public init(string: String, molecule: MoleculeModelProtocol) { self.string = string self.molecule = molecule } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift index 2606ecf4..ac6613ea 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift @@ -10,7 +10,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: MoleculeStackView { - override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + override func createStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let model = stackModel else { return } for stackItemModel in model.molecules { guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel, diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index 1874c163..ffd23b0a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -76,7 +76,7 @@ open class StringAndMoleculeView: View { (molecule as? MoleculeViewProtocol)?.reset?() } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? StringAndMoleculeModel else { return } label.text = model.string diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index aeb8b34e..56281c43 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -21,7 +21,7 @@ import Foundation case bulletChar } - // Numbered list model comes in the from of list = [MoleculeProtocol] + // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) { @@ -42,7 +42,7 @@ import Foundation try container.encode(bulletChar, forKey: .bulletChar) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - var models: [MoleculeProtocol] = [] + var models: [MoleculeModelProtocol] = [] for molecule in molecules { models.append(molecule.molecule) } diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 50d55c16..f1aae075 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -29,7 +29,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { var numberOfPages = 0 /// The json for the molecules. - var molecules: [MoleculeProtocol]? + var molecules: [MoleculeModelProtocol]? /// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%. var itemAlignment = UICollectionView.ScrollPosition.left @@ -81,7 +81,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol //TODO: Model, Change to model - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let caroselModel = model as? CarouselModel else { return } @@ -148,7 +148,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { } /// Sets up the paging molecule - open func setupPagingMolecule(_ molecule: PagingMoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) { + open func setupPagingMolecule(_ molecule: CarouselPagingModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) { var pagingView: (UIView & MVMCoreUIPagingProtocol)? = nil if let molecule = molecule { pagingView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(molecule, delegateObject, false) as? (UIView & MVMCoreUIPagingProtocol) @@ -167,7 +167,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { // MARK: - Convenience /// Returns the (identifier, class) of the molecule for the given map. - func getMoleculeInfo(with molecule: MoleculeProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? { + func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? { guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) , let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else { return nil diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift index c8922204..134cc701 100644 --- a/MVMCoreUI/Organisms/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol, StackModelProtocol { +@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeModelProtocol, StackModelProtocol { public class var identifier: String { return "stack" } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index aa81ff80..afc1f954 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -23,7 +23,7 @@ open class MoleculeStackView: Stack { // MARK: - Adding to stack /// Creates all of the stackItems for the stackItemModels - override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + override func createStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegateObject) as? MoleculeStackItem { diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index f67f7a0e..a92d5a2f 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -88,7 +88,7 @@ open class Stack: Container where T: StackModelProtocol { } } - public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { let previousModel = self.model super.setWithModel(model, delegateObject, additionalData) removeAllItemViews() @@ -104,7 +104,7 @@ open class Stack: Container where T: StackModelProtocol { restack() } - public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + public override class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { // This will aggregate names of molecules to make an id. guard let model = model as? T else { return "stack<>" @@ -125,7 +125,7 @@ open class Stack: Container where T: StackModelProtocol { } // Need to update to take into account first spacing flag - public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let model = molecule as? T else { return 0 } let horizontal = model.axis == .horizontal var estimatedHeight: CGFloat = 0 @@ -144,7 +144,7 @@ open class Stack: Container where T: StackModelProtocol { return estimatedHeight } - public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + public override class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let model = molecule as? T else { return nil } var modules: [String] = [] for case let item in model.molecules { @@ -158,11 +158,11 @@ open class Stack: Container where T: StackModelProtocol { // MARK: - Subclassables /// Can be subclassed to create views when we get stack item models and have no views yet - func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + func createStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { } /// Can be subclassed to set stack items with model when we already have views - func setStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + func setStackItemsFromModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let models = stackModel?.molecules else { return } for (index, element) in models.enumerated() { (stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element, delegateObject, additionalData) diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Organisms/StackModel.swift index 8368ce8c..741946c5 100644 --- a/MVMCoreUI/Organisms/StackModel.swift +++ b/MVMCoreUI/Organisms/StackModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class StackModel: StackModelProtocol, MoleculeProtocol { +@objcMembers public class StackModel: StackModelProtocol, MoleculeModelProtocol { public static var identifier: String = "simpleStack" public var backgroundColor: Color? public var molecules: [StackItemModel] diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 45ce1bab..c9bbb7fe 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -10,18 +10,18 @@ import Foundation public extension MVMCoreUIMoleculeMappingObject { - func getMoleculeClass(_ model: MoleculeProtocol) -> AnyClass? { + func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? { if let moleculeName = model.moleculeName { return moleculeMapping.object(forKey: moleculeName) as? AnyClass } return nil } - func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { + func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { return createMolecule(model, delegateObject, false) } - func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { + func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { guard let moleculeName = model.moleculeName, let molecule = createMolecule(forName: moleculeName) else { return nil diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index 1611930a..11e8a154 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -12,7 +12,7 @@ public protocol MoleculeDelegateProtocol { /// returns a module for the corresponding module name. func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? - func getModuleWithName(_ moleculeName: String) -> MoleculeProtocol? + func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) //optional diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index 4a301660..d639d6f1 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -16,9 +16,9 @@ import Foundation public var screenHeading: String? public var isAtomicTabs: Bool? - public var header: MoleculeProtocol? + public var header: MoleculeModelProtocol? public var molecules: [ListItemModelProtocol] - public var footer: MoleculeProtocol? + public var footer: MoleculeModelProtocol? public var line: LineModel? public init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol]) { diff --git a/MVMCoreUI/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Templates/StackPageTemplateModel.swift index db9d632d..b9a54125 100644 --- a/MVMCoreUI/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackPageTemplateModel.swift @@ -16,9 +16,9 @@ import Foundation public var screenHeading: String? public var isAtomicTabs: Bool? - public var header: MoleculeProtocol? + public var header: MoleculeModelProtocol? public var moleculeStack: MoleculeStackModel - public var footer: MoleculeProtocol? + public var footer: MoleculeModelProtocol? public init(pageType: String, moleculeStack: MoleculeStackModel) { self.pageType = pageType diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift b/MVMCoreUI/Templates/TemplateProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/TemplateProtocol.swift rename to MVMCoreUI/Templates/TemplateProtocol.swift diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index e42ca5f0..fa7548f3 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -15,11 +15,11 @@ import Foundation public var screenHeading: String? public var isAtomicTabs: Bool? - public var header: MoleculeProtocol? - public var middle: MoleculeProtocol? - public var footer: MoleculeProtocol? + public var header: MoleculeModelProtocol? + public var middle: MoleculeModelProtocol? + public var footer: MoleculeModelProtocol? - public init(pageType: String, header: MoleculeProtocol?, middle: MoleculeProtocol?, footer: MoleculeProtocol?) { + public init(pageType: String, header: MoleculeModelProtocol?, middle: MoleculeModelProtocol?, footer: MoleculeModelProtocol?) { self.pageType = pageType self.header = header self.middle = middle From 66ee6bbc72df38cbae180b9df91c9d5ab944458d Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 21 Jan 2020 15:35:14 -0500 Subject: [PATCH 191/272] update mftextbutton missing --- MVMCoreUI.xcodeproj/project.pbxproj | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ae599266..6b203dec 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -97,7 +97,6 @@ 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; - C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; }; 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */; }; 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */; }; @@ -107,7 +106,10 @@ 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; }; 94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; }; 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; + 94FB966223D797DA003D482B /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94FB966023D797DA003D482B /* MFTextButton.h */; }; + 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; + C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; }; C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; }; @@ -205,10 +207,8 @@ D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */; }; D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */; }; - D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17221E69E1F003B2FB9 /* MFTextButton.m */; }; D29DF18021E69E49003B2FB9 /* MFView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF17E21E69E2E003B2FB9 /* MFView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF18121E69E50003B2FB9 /* MFView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17F21E69E2E003B2FB9 /* MFView.m */; }; D29DF18221E69E54003B2FB9 /* SeparatorView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF15921E697DA003B2FB9 /* SeparatorView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -392,7 +392,6 @@ 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; - C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = ""; }; 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = ""; }; 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeStrikeThroughModel.swift; sourceTree = ""; }; @@ -400,7 +399,10 @@ 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = ""; }; 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; + 94FB966023D797DA003D482B /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; + 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; + C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = ""; }; C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = ""; }; @@ -509,10 +511,8 @@ D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFCustomButton.h; sourceTree = ""; }; D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonDelegateProtocol.h; sourceTree = ""; }; D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimaryButton.h; sourceTree = ""; }; - D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFCustomButton.m; sourceTree = ""; }; D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrimaryButton.m; sourceTree = ""; }; - D29DF17221E69E1F003B2FB9 /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; D29DF17E21E69E2E003B2FB9 /* MFView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFView.h; sourceTree = ""; }; D29DF17F21E69E2E003B2FB9 /* MFView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFView.m; sourceTree = ""; }; D29DF24221E6A176003B2FB9 /* MFTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextField.m; sourceTree = ""; }; @@ -751,6 +751,8 @@ D213347523842FF5008E41B3 /* Views */ = { isa = PBXGroup; children = ( + 94FB966023D797DA003D482B /* MFTextButton.h */, + 94FB966123D797DA003D482B /* MFTextButton.m */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17F21E69E2E003B2FB9 /* MFView.m */, D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, @@ -778,8 +780,6 @@ D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, - D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, - D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, @@ -1123,8 +1123,6 @@ D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */, D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */, D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */, - D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, - D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, C07065C32395677300FBF997 /* Link.swift */, ); path = Buttons; @@ -1359,6 +1357,7 @@ D29DF2CE21E7C104003B2FB9 /* MFLoadingViewController.h in Headers */, 0A21DB84235E06EF00C160A2 /* MFTextField.h in Headers */, D29DF12A21E6851E003B2FB9 /* MVMCoreUITopAlertView.h in Headers */, + 94FB966223D797DA003D482B /* MFTextButton.h in Headers */, D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */, D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */, D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */, @@ -1371,7 +1370,6 @@ D29DF18221E69E54003B2FB9 /* SeparatorView.h in Headers */, D29DF26E21E6AA0B003B2FB9 /* FLAnimatedImage.h in Headers */, D29DF11621E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h in Headers */, - D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */, 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */, D29DF16221E69996003B2FB9 /* MFViewController.h in Headers */, 0A21DB88235E06EF00C160A2 /* MFMdnTextField.h in Headers */, @@ -1515,7 +1513,6 @@ D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, - D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, @@ -1574,6 +1571,7 @@ D2B18B812360945C00A9AEDC /* View.swift in Sources */, C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, + 94FB966323D797DA003D482B /* MFTextButton.m in Sources */, D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, From cc27b7e6cf2b3b8cd9a023850039945dd863c80c Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 21 Jan 2020 15:36:22 -0500 Subject: [PATCH 192/272] public mftextbutton --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6b203dec..65e1df33 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -106,7 +106,7 @@ 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; }; 94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; }; 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; - 94FB966223D797DA003D482B /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94FB966023D797DA003D482B /* MFTextButton.h */; }; + 94FB966223D797DA003D482B /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94FB966023D797DA003D482B /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; From 25db4b1e1450059cc951b7b0c891e48ae53f537e Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 21 Jan 2020 15:40:45 -0500 Subject: [PATCH 193/272] update link based on naming change --- MVMCoreUI/Atoms/Buttons/Link.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 02778bce..8bef1a2b 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -91,7 +91,8 @@ extension Link { } extension Link: ModelMoleculeViewProtocol { - public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let model = model as? LinkModel else { return } setTitle(model.title, for: .normal) setTitleColor(model.textColor.uiColor, for: .normal) @@ -100,8 +101,7 @@ extension Link: ModelMoleculeViewProtocol { set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } - - public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public static func estimatedHeight(forRow molecule: ModuleMoleculeModel?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 31.0 } } From 74b09fa51dde634a5fddc7fbff3cf046b5fa29a0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 21 Jan 2020 15:47:02 -0500 Subject: [PATCH 194/272] name change --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift | 2 +- MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift | 2 +- MVMCoreUI/Atoms/Views/ToggleModel.swift | 2 +- MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift | 4 ++-- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 531859c0..c9a7f2f8 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -22,13 +22,13 @@ public class ButtonModel: MoleculeModelProtocol { public static var identifier: String = "button" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var style: ButtonStyle? public var size: ButtonSize? = .standard public var required: Bool? public var requiredGroups: [String]? - init(with title: String, action: ActionProtocol) { + init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 3612c1fc..04b5aa07 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -13,12 +13,12 @@ public class CaretLinkModel: MoleculeModelProtocol { public static var identifier: String = "caretLink" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var enabledColor: Color = Color(uiColor: .black) public var disabledColor: Color? = Color(uiColor: .mfSilver()) public var enabled: Bool = true - public init(title: String, action: ActionProtocol) { + public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index 27cbd6c6..0c797b21 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -12,11 +12,11 @@ public class LinkModel: MoleculeModelProtocol { public static var identifier: String = "link" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var enabled = true public var textColor = Color(uiColor: .mfTextButton()) - public init(title: String, action: ActionProtocol) { + public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift index b967db48..d008a7fb 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift @@ -9,7 +9,7 @@ import Foundation public extension MFCustomButton { - func set(with action: ActionProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + func set(with action: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { buttonDelegate = delegateObject?.buttonDelegate add({ [weak self] sender in guard let self = self else { return } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift index 8dd5c562..2ebcb4b4 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift @@ -12,7 +12,7 @@ class LabelAttributeActionModel: LabelAttributeModel { override public class var identifier: String { return "action" } - var action: ActionProtocol + var action: ActionModelProtocol required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 12706a49..75fddd28 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -13,7 +13,7 @@ public class ToggleModel: MoleculeModelProtocol { public var moleculeName: String? public var backgroundColor: Color? public var state: Bool = true - public var action: ActionProtocol? + public var action: ActionModelProtocol? public var required: Bool? public var fieldKey: String? diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 857bd060..9d424a2b 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -10,14 +10,14 @@ import Foundation public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { var line: LineModel? { get set } - var action: ActionProtocol? { get set } + var action: ActionModelProtocol? { get set } var hideArrow: Bool? { get set } var style: String? { get set } } // Not a strict requirement. extension ListItemModelProtocol { - public var action: ActionProtocol? { + public var action: ActionModelProtocol? { get { return nil } diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 97fef586..5356ce25 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -12,7 +12,7 @@ import MVMCore @objcMembers public class ListItemModel: MoleculeContainerModel, ListItemModelProtocol { public static var identifier: String = "listItem" public var backgroundColor: Color? - public var action: ActionProtocol? + public var action: ActionModelProtocol? public var hideArrow: Bool? public var line: LineModel? public var style: String? = "standard" From 117c112b6ba089e77d4a392e8bf73e967bf360c0 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 21 Jan 2020 18:13:42 -0500 Subject: [PATCH 195/272] color --- MVMCoreUI/Atoms/Views/LineModel.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LineModel.swift b/MVMCoreUI/Atoms/Views/LineModel.swift index 8f16d22e..f481d4d5 100644 --- a/MVMCoreUI/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atoms/Views/LineModel.swift @@ -43,6 +43,7 @@ import UIKit public static var identifier: String = "line" public var type: Style = .standard public var frequency: Frequency? = .allExceptTop + public var color: Color? public var backgroundColor: Color? public init(type: Style) { @@ -53,6 +54,7 @@ import UIKit case moleculeName case type case backgroundColor + case color case frequency } @@ -64,7 +66,7 @@ import UIKit if let frequency = try typeContainer.decodeIfPresent(Frequency.self, forKey: .frequency) { self.frequency = frequency } - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) } public func encode(to encoder: Encoder) throws { @@ -72,6 +74,6 @@ import UIKit try container.encode(moleculeName, forKey: .moleculeName) try container.encode(type, forKey: .type) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(color, forKey: .color) } } From 4d155b9f97aceda27904a1d0a90f20e35948e3cc Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 21 Jan 2020 18:23:32 -0500 Subject: [PATCH 196/272] ActionModelProtocol --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift | 2 +- MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift | 2 +- MVMCoreUI/Atoms/Views/ToggleModel.swift | 2 +- MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift | 4 ++-- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 531859c0..c9a7f2f8 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -22,13 +22,13 @@ public class ButtonModel: MoleculeModelProtocol { public static var identifier: String = "button" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var style: ButtonStyle? public var size: ButtonSize? = .standard public var required: Bool? public var requiredGroups: [String]? - init(with title: String, action: ActionProtocol) { + init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 3612c1fc..04b5aa07 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -13,12 +13,12 @@ public class CaretLinkModel: MoleculeModelProtocol { public static var identifier: String = "caretLink" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var enabledColor: Color = Color(uiColor: .black) public var disabledColor: Color? = Color(uiColor: .mfSilver()) public var enabled: Bool = true - public init(title: String, action: ActionProtocol) { + public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index 27cbd6c6..0c797b21 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -12,11 +12,11 @@ public class LinkModel: MoleculeModelProtocol { public static var identifier: String = "link" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var enabled = true public var textColor = Color(uiColor: .mfTextButton()) - public init(title: String, action: ActionProtocol) { + public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift index b967db48..d008a7fb 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift @@ -9,7 +9,7 @@ import Foundation public extension MFCustomButton { - func set(with action: ActionProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + func set(with action: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { buttonDelegate = delegateObject?.buttonDelegate add({ [weak self] sender in guard let self = self else { return } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift index 8dd5c562..2ebcb4b4 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift @@ -12,7 +12,7 @@ class LabelAttributeActionModel: LabelAttributeModel { override public class var identifier: String { return "action" } - var action: ActionProtocol + var action: ActionModelProtocol required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 12706a49..75fddd28 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -13,7 +13,7 @@ public class ToggleModel: MoleculeModelProtocol { public var moleculeName: String? public var backgroundColor: Color? public var state: Bool = true - public var action: ActionProtocol? + public var action: ActionModelProtocol? public var required: Bool? public var fieldKey: String? diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 857bd060..9d424a2b 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -10,14 +10,14 @@ import Foundation public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { var line: LineModel? { get set } - var action: ActionProtocol? { get set } + var action: ActionModelProtocol? { get set } var hideArrow: Bool? { get set } var style: String? { get set } } // Not a strict requirement. extension ListItemModelProtocol { - public var action: ActionProtocol? { + public var action: ActionModelProtocol? { get { return nil } diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 97fef586..5356ce25 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -12,7 +12,7 @@ import MVMCore @objcMembers public class ListItemModel: MoleculeContainerModel, ListItemModelProtocol { public static var identifier: String = "listItem" public var backgroundColor: Color? - public var action: ActionProtocol? + public var action: ActionModelProtocol? public var hideArrow: Bool? public var line: LineModel? public var style: String? = "standard" From 943799d462372e20184f07e03150a06c221acab9 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 21 Jan 2020 23:33:24 -0500 Subject: [PATCH 197/272] more models --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ MVMCoreUI/Atoms/Views/ToggleModel.swift | 4 ++++ .../SwitchMolecules/HeadlineBodySwitch.swift | 20 ++++++++++------- .../HeadlineBodyToggleModel.swift | 22 +++++++++++++++++++ .../HeadlineBodyModel.swift | 3 +-- .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 6 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d9591c22..65129935 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; }; + 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */; }; 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; }; 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; @@ -310,6 +311,7 @@ /* Begin PBXFileReference section */ 01004F2F22721C3800991ECC /* RadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = ""; }; + 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyToggleModel.swift; sourceTree = ""; }; 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; @@ -809,6 +811,7 @@ 01C851D223CF9E740021F976 /* LabelToggleModel.swift */, D22479892314445E003FCCF9 /* LabelSwitch.swift */, D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */, + 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */, ); path = SwitchMolecules; sourceTree = ""; @@ -1540,6 +1543,7 @@ D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, + 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 75fddd28..9cd96f45 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -14,6 +14,7 @@ public class ToggleModel: MoleculeModelProtocol { public var backgroundColor: Color? public var state: Bool = true public var action: ActionModelProtocol? + public var alternateAction: ActionModelProtocol? public var required: Bool? public var fieldKey: String? @@ -24,6 +25,7 @@ public class ToggleModel: MoleculeModelProtocol { case backgroundColor case required case fieldKey + case alternateAction } public init(_ state: Bool) { @@ -36,6 +38,7 @@ public class ToggleModel: MoleculeModelProtocol { self.state = state } action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction, typeCodingKey: ActionCodingKey.actionType) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) @@ -45,6 +48,7 @@ public class ToggleModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) + try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(state, forKey: .state) try container.encodeIfPresent(required, forKey: .required) diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 79e2a9ec..09432dce 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -10,18 +10,18 @@ import UIKit @objcMembers open class HeadlineBodySwitch: View { public let headlineBody = HeadlineBody(frame: .zero) - public let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault() + public let toggle = Toggle() // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) headlineBody.updateView(size) - mvmSwitch.updateView(size) + toggle.updateView(size) } open override func setupView() { super.setupView() - guard mvmSwitch.superview == nil else { + guard toggle.superview == nil else { return } headlineBody.styleListItem() @@ -30,8 +30,8 @@ import UIKit NSLayoutConstraint.constraintPinSubview(toSuperview: view) view.addSubview(headlineBody) - view.addSubview(mvmSwitch) - NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: mvmSwitch) + view.addSubview(toggle) + NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: toggle) } @@ -39,6 +39,10 @@ import UIKit open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) + guard let headlineBodyToggleModel = model as? HeadlineBodyToggleModel else { + return + } + setWithJSON(headlineBodyToggleModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } public class override func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -50,7 +54,7 @@ import UIKit open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) + toggle.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } open class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { @@ -59,14 +63,14 @@ import UIKit open override func setAsMolecule() { headlineBody.setAsMolecule() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() + (toggle as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() headlineBody.styleListItem() } open override func reset() { super.reset() headlineBody.reset() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?() + (toggle as MVMCoreUIMoleculeViewProtocol).reset?() headlineBody.styleListItem() } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift new file mode 100644 index 00000000..dd7c2b1c --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift @@ -0,0 +1,22 @@ +// +// HeadlineBodyToggleModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 1/21/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +open class HeadlineBodyToggleModel: MoleculeModelProtocol { + public static var identifier: String = "headlineBodyToggle" + open var backgroundColor: Color? + open var headlineBody: HeadlineBodyModel + open var toggle: ToggleModel + + public init(_ headlineBody: HeadlineBodyModel, _ toggle: ToggleModel) { + self.headlineBody = headlineBody + self.toggle = toggle + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 86151cb6..fc22f864 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -15,9 +15,8 @@ import Foundation public var style: String? public var backgroundColor: Color? - public init(headline: LabelModel, body: LabelModel) { + public init(headline: LabelModel) { self.headline = headline - self.body = body } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index b12145f2..2e31a757 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -70,5 +70,6 @@ import Foundation ModelRegistry.register(DoughnutChartModel.self) ModelRegistry.register(NumberedListModel.self) ModelRegistry.register(UnOrderedListModel.self) + ModelRegistry.register(HeadlineBodyToggleModel.self) } } From 00d1bf7be6709adebc3987ea215af2ba96be7dec Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 22 Jan 2020 09:11:56 -0500 Subject: [PATCH 198/272] re-organizing --- MVMCoreUI.xcodeproj/project.pbxproj | 14 ++----- .../Molecules/Items/CarouselItemModel.swift | 6 +-- MVMCoreUI/Molecules/ModuleMoleculeModel.swift | 2 +- MVMCoreUI/Organisms/Carousel.swift | 41 ++++++++----------- MVMCoreUI/Organisms/CarouselModel.swift | 2 +- 5 files changed, 24 insertions(+), 41 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 65129935..3371e6ca 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -658,7 +658,6 @@ children = ( 011B58EE23A2AA850085F53C /* ModelProtocols */, 946EE1B5237B663A0036751F /* Extensions */, - 01EB368723609801006832FA /* Molecules */, ); path = Models; sourceTree = ""; @@ -674,16 +673,6 @@ path = FormUIHelpers; sourceTree = ""; }; - 01EB368723609801006832FA /* Molecules */ = { - isa = PBXGroup; - children = ( - 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, - 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, - 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */, - ); - path = Molecules; - sourceTree = ""; - }; 0A5D59C323AD488600EFD9E9 /* Protocols */ = { isa = PBXGroup; children = ( @@ -859,6 +848,7 @@ D260105C23D0BCD400764D80 /* Stack.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */, D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, + 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */, D2A6390022CBB1820052ED1F /* Carousel.swift */, ); path = Organisms; @@ -870,6 +860,7 @@ D2755D7A23689C7500485468 /* TableViewCell.swift */, 01EB368923609801006832FA /* ListItemModel.swift */, 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, + 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */, D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, @@ -998,6 +989,7 @@ 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, D274CA322236A78900B01B62 /* FooterView.swift */, 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */, + 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */, D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */, D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */, diff --git a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift index a5fc0e85..8f7eea64 100644 --- a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift @@ -15,14 +15,14 @@ import Foundation public var peakingUI: Bool? public var peakingArrowColor: Color? - enum CarouselItemCodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case backgroundColor case peakingUI case peakingArrowColor } required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CarouselItemCodingKeys.self) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI) peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor) @@ -31,7 +31,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) - var container = encoder.container(keyedBy: CarouselItemCodingKeys.self) + var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(peakingUI, forKey: .peakingUI) try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) diff --git a/MVMCoreUI/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Molecules/ModuleMoleculeModel.swift index 02e319e9..931e7c04 100644 --- a/MVMCoreUI/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Molecules/ModuleMoleculeModel.swift @@ -13,7 +13,7 @@ open class ModuleMoleculeModel: MoleculeModelProtocol { public static var identifier: String = "moduleMolecule" public var moduleName: String - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moduleName } diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index f1aae075..59911594 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -8,7 +8,7 @@ import UIKit -open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { +open class Carousel: View { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) @@ -47,6 +47,9 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { var loop = false private var dragging = false + // For adding pager + private var bottomPin: NSLayoutConstraint? + // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() @@ -60,7 +63,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { collectionView.backgroundColor = .clear collectionView.isAccessibilityElement = false addSubview(collectionView) - pinView(toSuperView: collectionView) + bottomPin = NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView)?[ConstraintBot] as? NSLayoutConstraint collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) collectionViewHeight?.isActive = false @@ -81,40 +84,28 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol //TODO: Model, Change to model - public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let caroselModel = model as? CarouselModel else { - return - } - - #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") - //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. - setUpDefaultWithModel(model, delegateObject, additionalData) - + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let carouselModel = model as? CarouselModel else { return } collectionView.backgroundColor = backgroundColor collectionView.layer.borderColor = backgroundColor?.cgColor - collectionView.layer.borderWidth = (caroselModel.border ?? false) ? 1 : 0 + collectionView.layer.borderWidth = (carouselModel.border ?? false) ? 1 : 0 backgroundColor = .white - registerCells(with: caroselModel, delegateObject: delegateObject) - setupLayout(with: caroselModel) - prepareMolecules(with: caroselModel) - itemWidthPercent = (caroselModel.itemWidthPercent ?? 100) / 100 - setAlignment(with: caroselModel.itemAlignment) + registerCells(with: carouselModel, delegateObject: delegateObject) + setupLayout(with: carouselModel) + prepareMolecules(with: carouselModel) + itemWidthPercent = (carouselModel.itemWidthPercent ?? 100) / 100 + setAlignment(with: carouselModel.itemAlignment) - if let height = caroselModel.height { + if let height = carouselModel.height { collectionViewHeight?.constant = CGFloat(height) collectionViewHeight?.isActive = true } - setupPagingMolecule(caroselModel.pagingMolecule, delegateObject: delegateObject) + setupPagingMolecule(carouselModel.pagingMolecule, delegateObject: delegateObject) collectionView.reloadData() } - - - open override func shouldSetHorizontalMargins(_ shouldSet: Bool) { - super.shouldSetHorizontalMargins(shouldSet) - updateViewHorizontalDefaults = false - } // MARK: - JSON Setters /// Updates the layout being used diff --git a/MVMCoreUI/Organisms/CarouselModel.swift b/MVMCoreUI/Organisms/CarouselModel.swift index fedb5535..e43e6caa 100644 --- a/MVMCoreUI/Organisms/CarouselModel.swift +++ b/MVMCoreUI/Organisms/CarouselModel.swift @@ -25,7 +25,7 @@ import UIKit self.molecules = molecules } - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case molecules From db0cb77756440d32ce06c0878f850f510f4b3cc0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 22 Jan 2020 09:22:57 -0500 Subject: [PATCH 199/272] Update button to model --- MVMCoreUI/BaseClasses/Button.swift | 40 +++++------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 1d5d743e..e0f098be 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -8,14 +8,11 @@ public typealias ButtonBlock = (Button) -> () - @objcMembers open class Button: UIButton, MFButtonProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - public var json: [AnyHashable: Any]? - public var actionMap: [AnyHashable: Any]? + public var actionModel: ActionModelProtocol? private var initialSetupPerformed = false @@ -71,44 +68,20 @@ public typealias ButtonBlock = (Button) -> () buttonBlock?(self) } - public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.actionMap = actionMap - + public func setWithAction(_ actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + self.actionModel = actionModel buttonDelegate = delegateObject?.buttonDelegate - addBlock(event: .touchUpInside) { [weak self] sender in guard let self = self else { return } - - if self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { + if let data = try? actionModel.encode(using: JSONEncoder()), + let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any], + delegateObject?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } } } -// MARK: - MVMCoreUIMoleculeViewProtocol -extension Button: MVMCoreUIMoleculeViewProtocol { - - public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.json = json - - guard let dictionary = json else { return } - - if let backgroundColorString = dictionary[KeyBackgroundColor] as? String { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) - } - - if let title = dictionary[KeyTitle] as? String { - setTitle(title, for: .normal) - } - } - - public func reset() { - backgroundColor = .clear - } -} - - // MARK: - MVMCoreViewProtocol extension Button: MVMCoreViewProtocol { @@ -116,7 +89,6 @@ extension Button: MVMCoreViewProtocol { /// Will be called only once. public func setupView() { - translatesAutoresizingMaskIntoConstraints = false insetsLayoutMarginsFromSafeArea = false titleLabel?.numberOfLines = 0 From 5534f6ba58226db233c9c6baab9f40407f7b1ca2 Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Wed, 22 Jan 2020 20:27:14 +0530 Subject: [PATCH 200/272] Checkbox models added Label action attribute issue fixed --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atoms/Views/Checkbox.swift | 66 +++++++++++++++ MVMCoreUI/Atoms/Views/CheckboxModel.swift | 83 +++++++++++++++++++ .../Atoms/Views/CheckboxWithLabelView.swift | 13 +++ .../Views/CheckboxWithLabelViewModel.swift | 38 +++++++++ MVMCoreUI/Atoms/Views/Label/Label.swift | 2 +- .../OtherHandlers/MoleculeObjectMapping.swift | 4 + 7 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 MVMCoreUI/Atoms/Views/CheckboxModel.swift create mode 100644 MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3371e6ca..09d66304 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -88,6 +88,8 @@ 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; }; 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; + 31BE15CB23D8924D00452370 /* CheckboxWithLabelViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */; }; + 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -382,6 +384,8 @@ 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = ""; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = ""; }; 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; + 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelViewModel.swift; sourceTree = ""; }; + 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.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 = ""; }; @@ -1143,7 +1147,9 @@ DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, 94C2D9822386F3E30006CF46 /* Label */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, + 31BE15CA23D8924C00452370 /* CheckboxModel.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, + 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, 943784F3236B77BB006A1E82 /* GraphView.swift */, @@ -1473,6 +1479,7 @@ files = ( 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */, 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, + 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */, 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, @@ -1555,6 +1562,7 @@ DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, + 31BE15CB23D8924D00452370 /* CheckboxWithLabelViewModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 50571e30..0c7ca537 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -458,6 +458,72 @@ import MVMCore actionBlock = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let checkboxModel = model as? CheckboxModel else { + return + } + self.delegateObject = delegateObject + FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol) + + groupName = checkboxModel.groupName + fieldValue = checkboxModel.value + if let fieldKey = checkboxModel.fieldKey { + self.fieldKey = fieldKey + } + + if let isRequired = checkboxModel.required { + self.isRequired = isRequired + } + + if let borderColorHex = checkboxModel.borderColor { + layer.borderColor = UIColor.mfGet(forHex: borderColorHex).cgColor + } + + if let borderWidth = checkboxModel.borderWidth { + layer.borderWidth = borderWidth + } + + if let isChecked = checkboxModel.isChecked, isChecked { + updateSelectionOnly = true + isSelected = isChecked + updateSelectionOnly = false + } + + if let checkColorHex = checkboxModel.checkColor { + checkColor = UIColor.mfGet(forHex: checkColorHex) + } + + if let unCheckedBackgroundColorHex = checkboxModel.unCheckedBackgroundColor { + unCheckedBackgroundColor = UIColor.mfGet(forHex: unCheckedBackgroundColorHex) + } + + if let checkedBackgroundColorHex = checkboxModel.checkedBackgroundColor { + checkedBackgroundColor = UIColor.mfGet(forHex: checkedBackgroundColorHex) + } + + if let isAnimated = checkboxModel.isAnimated { + self.isAnimated = isAnimated + } + + if let isRound = checkboxModel.isRound { + self.isRound = isRound + } + + if let enabled = checkboxModel.isEnabled { + isEnabled(enabled) + } + + guard let action = checkboxModel.action else { return } + actionBlock = { + if let data = try? action.encode(using: JSONEncoder()), + let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + + } + } + } } // MARK:- FormValidationProtocol diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift new file mode 100644 index 00000000..4ad1bade --- /dev/null +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -0,0 +1,83 @@ +// +// CheckboxModel.swift +// MVMCoreUI +// +// Created by Chintakrinda, Arun Kumar (Arun) on 21/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class CheckboxModel: MoleculeModelProtocol { + public static var identifier: String = "checkbox" + public var backgroundColor: Color? + + public var groupName: String? + public var value: String? + public var fieldKey: String? + public var required: Bool? + public var borderColor: String? + public var borderWidth: CGFloat? + public var isChecked: Bool? + public var checkColor: String? + public var unCheckedBackgroundColor: String? + public var checkedBackgroundColor: String? + public var isAnimated: Bool? + public var isRound: Bool? + public var isEnabled: Bool? + public var action: ActionModelProtocol? + + + enum CodingKeys: String, CodingKey { + case groupName + case value + case fieldKey + case required + case borderColor + case borderWidth + case isChecked + case checkColor + case unCheckedBackgroundColor + case checkedBackgroundColor + case isAnimated + case isRound + case isEnabled + case action + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) + self.value = try typeContainer.decodeIfPresent(String.self, forKey: .value) + self.fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + self.required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) + self.borderColor = try typeContainer.decodeIfPresent(String.self, forKey: .borderColor) + self.borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) + self.isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) + self.checkColor = try typeContainer.decodeIfPresent(String.self, forKey: .checkColor) + self.unCheckedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .unCheckedBackgroundColor) + self.checkedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .checkedBackgroundColor) + self.isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) + self.isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) + self.isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) + self.action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(value, forKey: .value) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(required, forKey: .required) + try container.encodeIfPresent(borderColor, forKey: .borderColor) + try container.encodeIfPresent(borderColor, forKey: .borderColor) + try container.encodeIfPresent(isChecked, forKey: .isChecked) + try container.encodeIfPresent(checkColor, forKey: .checkColor) + try container.encodeIfPresent(unCheckedBackgroundColor, forKey: .unCheckedBackgroundColor) + try container.encodeIfPresent(checkedBackgroundColor, forKey: .checkedBackgroundColor) + try container.encodeIfPresent(isAnimated, forKey: .isAnimated) + try container.encodeIfPresent(isRound, forKey: .isRound) + try container.encodeIfPresent(isEnabled, forKey: .isEnabled) + try container.encodeModelIfPresent(action, forKey: .action) + } +} diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift index 229efe2a..27256aa3 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift @@ -120,6 +120,19 @@ checkboxCenterYConstraint?.isActive = false } } + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let checkBoxWithLabelModel = model as? CheckboxWithLabelViewModel else { + return + } + + if let checkboxAlignment = checkBoxWithLabelModel.checkboxAlignment, let position = CheckboxPosition(rawValue: checkboxAlignment) { + alignCheckbox(position) + } + + checkbox.setWithModel(checkBoxWithLabelModel.checkbox, delegateObject, additionalData) + label.setWithModel(checkBoxWithLabelModel.label, delegateObject, additionalData) + } } // MARK: - Molecular diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift new file mode 100644 index 00000000..81d64361 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift @@ -0,0 +1,38 @@ +// +// CheckboxWithLabelViewModel.swift +// MVMCoreUI +// +// Created by Chintakrinda, Arun Kumar (Arun) on 21/01/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class CheckboxWithLabelViewModel: MoleculeModelProtocol { + public static var identifier: String = "checkboxLabel" + public var backgroundColor: Color? + + public var checkboxAlignment: String? + public var checkbox: CheckboxModel + public var label: LabelModel + + enum CodingKeys: String, CodingKey { + case checkboxAlignment + case checkbox + case label + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.checkboxAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .checkboxAlignment) + self.checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox) + self.label = try typeContainer.decode(LabelModel.self, forKey: .label) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(checkboxAlignment, forKey: .checkboxAlignment) + try container.encode(checkbox, forKey: .checkbox) + try container.encode(label, forKey: .label) + } +} diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index b2953227..208676df 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -315,7 +315,7 @@ public typealias ActionBlock = () -> () } case let actionAtt as LabelAttributeActionModel: addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) { - if let data = try? actionAtt.encode(using: JSONEncoder()), let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] { + if let data = try? actionAtt.action.encode(using: JSONEncoder()), let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 2e31a757..76d4ba20 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -71,5 +71,9 @@ import Foundation ModelRegistry.register(NumberedListModel.self) ModelRegistry.register(UnOrderedListModel.self) ModelRegistry.register(HeadlineBodyToggleModel.self) + + //Checkbox + ModelRegistry.register(CheckboxModel.self) + ModelRegistry.register(CheckboxWithLabelViewModel.self) } } From cd231746cf3aa4eabbf6fcb534403b00a837fc35 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 22 Jan 2020 10:16:18 -0500 Subject: [PATCH 201/272] update link model --- MVMCoreUI/Atoms/Buttons/Link.swift | 21 +++++---------------- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 9 ++++++++- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 8bef1a2b..685ba233 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -16,15 +16,6 @@ import UIKit private var additionalData: [AnyHashable: Any]? - public var titleColor: (enabled: UIColor?, disabled: UIColor?) = (.mfTextButton(), .mfSilver()) - - public override var isEnabled: Bool { - didSet { - setTitleColor(isEnabled ? titleColor.enabled : titleColor.disabled, for: .normal) - setNeedsDisplay() - } - } - //-------------------------------------------------- // MARK: - Delegate //-------------------------------------------------- @@ -80,9 +71,8 @@ extension Link { super.setupView() backgroundColor = .clear contentMode = .redraw - setTitleColor(.mfTextButton(), for: .normal) - setTitleColor(.mfCharcoal(), for: .highlighted) - titleColor = (.mfTextButton(), .mfSilver()) + setTitleColor(.mvmBlack, for: .normal) + setTitleColor(.mvmCoolGray6, for: .disabled) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left @@ -96,6 +86,7 @@ extension Link: ModelMoleculeViewProtocol { guard let model = model as? LinkModel else { return } setTitle(model.title, for: .normal) setTitleColor(model.textColor.uiColor, for: .normal) + setTitleColor(model.disabledColor.uiColor, for: .disabled) isEnabled = model.enabled backgroundColor = model.backgroundColor?.uiColor set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) @@ -120,18 +111,16 @@ extension Link { actionMap = dictionary if let disabledColorHex = dictionary["disabledColor"] as? String { - titleColor.disabled = .mfGet(forHex: disabledColorHex) + setTitleColor(.mfGet(forHex: disabledColorHex), for: .disabled) } if let colorHex = dictionary[KeyTextColor] as? String { - titleColor.enabled = .mfGet(forHex: colorHex) - setTitleColor(titleColor.enabled, for: .normal) + setTitleColor(.mfGet(forHex: colorHex), for: .normal) } if let title = dictionary.optionalStringForKey(KeyTitle) { setTitle(title, for: .normal) } - if let enabled = dictionary[KeyEnabled] as? Bool { isEnabled = enabled } diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index 27cbd6c6..2f348310 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -14,7 +14,8 @@ public class LinkModel: MoleculeModelProtocol { public var title: String public var action: ActionProtocol public var enabled = true - public var textColor = Color(uiColor: .mfTextButton()) + public var textColor = Color(uiColor: .mvmBlack) + public var disabledColor = Color(uiColor: .mvmCoolGray6) public init(title: String, action: ActionProtocol) { self.title = title @@ -27,6 +28,7 @@ public class LinkModel: MoleculeModelProtocol { case action case enabled case textColor + case disabledColor } required public init(from decoder: Decoder) throws { @@ -40,6 +42,10 @@ public class LinkModel: MoleculeModelProtocol { if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) { textColor = color } + + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) { + disabledColor = color + } } public func encode(to encoder: Encoder) throws { @@ -49,5 +55,6 @@ public class LinkModel: MoleculeModelProtocol { try container.encodeModel(action, forKey: .action) try container.encode(enabled, forKey: .enabled) try container.encode(textColor, forKey: .textColor) + try container.encode(disabledColor, forKey: .disabledColor) } } From 016c6edc06bd16cc793bb5c2e6844280d4da0a70 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 22 Jan 2020 10:24:04 -0500 Subject: [PATCH 202/272] Cleanup --- MVMCoreUI/BaseClasses/Button.swift | 31 +++++++++++++++-- MVMCoreUI/BaseClasses/Control.swift | 33 +++++++++++-------- MVMCoreUI/BaseClasses/View.swift | 2 +- ...MoleculeMappingObject+ModelExtension.swift | 5 +++ .../OtherHandlers/MoleculeObjectMapping.swift | 29 +++++++--------- 5 files changed, 66 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index e0f098be..d0ce4c1b 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -8,10 +8,11 @@ public typealias ButtonBlock = (Button) -> () -@objcMembers open class Button: UIButton, MFButtonProtocol { +@objcMembers open class Button: UIButton, MFButtonProtocol, ModelMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + public var model: MoleculeModelProtocol? public var actionModel: ActionModelProtocol? private var initialSetupPerformed = false @@ -80,6 +81,26 @@ public typealias ButtonBlock = (Button) -> () } } } + + // MARK:- ModelMoleculeViewProtocol + public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + self.model = model + if let backgroundColor = model?.backgroundColor { + self.backgroundColor = backgroundColor.uiColor + } + } + + public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + return model?.moleculeName + } + + public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return nil + } + + public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + return nil + } } // MARK: - MVMCoreViewProtocol @@ -96,9 +117,15 @@ extension Button: MVMCoreViewProtocol { } } +// MARK: - MVMCoreUIMoleculeViewProtocol +extension Button: MVMCoreUIMoleculeViewProtocol { + public func reset() { + backgroundColor = .clear + } +} + // MARK: AppleGuidelinesProtocol extension Button: AppleGuidelinesProtocol { - override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { return Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index dd64932e..8f0e9edb 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -12,8 +12,7 @@ import UIKit //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - public var json: [AnyHashable: Any]? + open var json: [AnyHashable: Any]? public var model: MoleculeModelProtocol? private var initialSetupPerformed = false @@ -42,13 +41,13 @@ import UIKit //-------------------------------------------------- public func initialSetup() { - if !initialSetupPerformed { initialSetupPerformed = true setupView() } } + // MARK:- ModelMoleculeViewProtocol public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { @@ -56,13 +55,22 @@ import UIKit } } + public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + return model?.moleculeName + } + + public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return nil + } + + public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + return nil + } } // MARK: - AppleGuidelinesProtocol extension Control: AppleGuidelinesProtocol { - override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { - return Self.acceptablyOutsideBounds(point: point, bounds: bounds) } } @@ -81,15 +89,14 @@ extension Control: MVMCoreViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol extension Control: MVMCoreUIMoleculeViewProtocol { + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + self.json = json + + if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { + backgroundColor = UIColor.mfGet(forHex: backgroundColorString) + } + } - public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.json = json - - if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) - } - } - public func reset() { backgroundColor = .clear } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 5dc159d0..d641490e 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -33,13 +33,13 @@ import UIKit } public func initialSetup() { - if !initialSetupPerformed { initialSetupPerformed = true setupView() } } + // MARK:- ModelMoleculeViewProtocol open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index c9bbb7fe..4796b2a2 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -9,6 +9,11 @@ import Foundation public extension MVMCoreUIMoleculeMappingObject { + + func register(viewClass: V.Type, viewModelClass: M.Type) { + ModelRegistry.register(viewModelClass) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(viewClass, forKey: viewModelClass.identifier as NSString) + } func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? { if let moleculeName = model.moleculeName { diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 2e31a757..b9a847ac 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -10,24 +10,17 @@ import Foundation @objcMembers public class MoleculeObjectMapping: NSObject { public static func registerObjects() { - let mapping = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping - ModelRegistry.register(MoleculeStackModel.self) - mapping?.setObject(MoleculeStackView.self, forKey: MoleculeStackModel.identifier as NSString) - ModelRegistry.register(StackModel.self) - mapping?.setObject(Stack.self, forKey: StackModel.identifier as NSString) - ModelRegistry.register(StackItemModel.self) - mapping?.setObject(StackItem.self, forKey: StackItemModel.identifier as NSString) - ModelRegistry.register(StringAndMoleculeModel.self) - mapping?.setObject(StringAndMoleculeView.self, forKey: StringAndMoleculeModel.identifier as NSString) - ModelRegistry.register(UnOrderedListModel.self) - mapping?.setObject(UnOrderedList.self, forKey: UnOrderedListModel.identifier as NSString) - ModelRegistry.register(NumberedListModel.self) - mapping?.setObject(NumberedList.self, forKey: NumberedListModel.identifier as NSString) - - ModelRegistry.register(LabelModel.self) - ModelRegistry.register(HeaderModel.self) - ModelRegistry.register(FooterModel.self) - ModelRegistry.register(HeadlineBodyModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeStackView.self, viewModelClass: MoleculeStackModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Stack.self, viewModelClass: StackModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeStackItem.self, viewModelClass: MoleculeStackItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeaderView.self, viewModelClass: HeaderModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: FooterView.self, viewModelClass: FooterModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) ModelRegistry.register(MoleculeStackItemModel.self) ModelRegistry.register(TextFieldModel.self) ModelRegistry.register(ProgressBarModel.self) From ab66cfae3c8800ddd9b3811853649592ee939a15 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 22 Jan 2020 10:42:01 -0500 Subject: [PATCH 203/272] update method --- MVMCoreUI/Atoms/Buttons/Link.swift | 65 +++++++----------------------- MVMCoreUI/BaseClasses/Button.swift | 2 +- 2 files changed, 15 insertions(+), 52 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 685ba233..6abcd48a 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -47,6 +47,20 @@ import UIKit context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) context?.strokePath() } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? LinkModel else { return } + setTitle(model.title, for: .normal) + setTitleColor(model.textColor.uiColor, for: .normal) + setTitleColor(model.disabledColor.uiColor, for: .disabled) + isEnabled = model.enabled + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) + } + + public static func estimatedHeight(forRow molecule: ModuleMoleculeModel?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 31.0 + } } // MARK: - MVMCoreViewProtocol @@ -80,57 +94,6 @@ extension Link { } } -extension Link: ModelMoleculeViewProtocol { - - public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let model = model as? LinkModel else { return } - setTitle(model.title, for: .normal) - setTitleColor(model.textColor.uiColor, for: .normal) - setTitleColor(model.disabledColor.uiColor, for: .disabled) - isEnabled = model.enabled - backgroundColor = model.backgroundColor?.uiColor - set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) - } - - public static func estimatedHeight(forRow molecule: ModuleMoleculeModel?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 31.0 - } -} - - -// MARK: - MVMCoreUIMoleculeViewProtocol -extension Link { - - public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - self.additionalData = additionalData - self.delegateObject = delegateObject - buttonDelegate = delegateObject?.buttonDelegate - - guard let dictionary = json else { return } - actionMap = dictionary - - if let disabledColorHex = dictionary["disabledColor"] as? String { - setTitleColor(.mfGet(forHex: disabledColorHex), for: .disabled) - } - - if let colorHex = dictionary[KeyTextColor] as? String { - setTitleColor(.mfGet(forHex: colorHex), for: .normal) - } - - if let title = dictionary.optionalStringForKey(KeyTitle) { - setTitle(title, for: .normal) - } - if let enabled = dictionary[KeyEnabled] as? Bool { - isEnabled = enabled - } - } - - public static func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 31 - } -} - // MARK: - MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index e50e492f..7909d1dd 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -69,7 +69,7 @@ public typealias ButtonAction = (Button) -> () buttonAction?(self) } - public func setWithAction(_ actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + public func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.actionModel = actionModel buttonDelegate = delegateObject?.buttonDelegate From b512db7b923c5f992f5b63137fcde76a26d66fb7 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 22 Jan 2020 10:52:57 -0500 Subject: [PATCH 204/272] remove space --- MVMCoreUI/Atoms/Buttons/Link.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 6abcd48a..b314dd5c 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -68,15 +68,12 @@ extension Link { public override func updateView(_ size: CGFloat) { super.updateView(size) - DispatchQueue.main.async { [weak self] in guard let self = self else { return } - var width = size if MVMCoreGetterUtility.fequal(a: Float(CGFloat.leastNormalMagnitude), b: Float(size)) { width = MVMCoreUIUtility.getWidth() } - self.titleLabel?.font = MFStyler.fontB2(forWidth: width) } } From 712d18d123745dcd2d425851ab3ceac28afabc53 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 22 Jan 2020 11:12:07 -0500 Subject: [PATCH 205/272] Model organizing --- .../MVMCoreUIMoleculeMappingObject.m | 52 +------- .../OtherHandlers/MoleculeObjectMapping.swift | 116 +++++++++++------- 2 files changed, 76 insertions(+), 92 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index b5a39119..ccaa9115 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -25,57 +25,7 @@ static dispatch_once_t onceToken; static NSMutableDictionary *mapping; dispatch_once(&onceToken, ^{ - mapping = [@{ - @"label": Label.class, - @"line": Line.class, - @"button": PrimaryButton.class, - @"link": MFTextButton.class, - @"header": HeaderView.class, - @"twoButtonView": TwoButtonView.class, - @"footer": FooterView.class, - @"caretView": CaretView.class, - @"caretLink": CaretButton.class, - @"textField": MFTextField.class, - @"dropDown": DropDown.class, - @"digitTextField": MFDigitTextField.class, - @"digitEntryField": DigitEntryField.class, - @"textEntryField": TextEntryField.class, - @"itemDropdownEntryField": ItemDropdownEntryField.class, - @"dateDropdownEntryField": DateDropdownEntryField.class, - @"checkbox": Checkbox.class, - @"checkboxLabel": CheckboxWithLabelView.class, - @"cornerLabels" : CornerLabels.class, - @"progressBar": ProgressBar.class, - @"circleProgress": GraphView.class, - @"multiProgressBar": MultiProgress.class, - @"radioButton": RadioButton.class, - @"radioButtonLabel": RadioButtonLabel.class, - @"listItem": MoleculeTableViewCell.class, - @"accordionListItem": AccordionMoleculeTableViewCell.class, - @"toggle": Toggle.class, - @"leftRightLabelView": LeftRightLabelView.class, - @"actionDetailWithImage": ActionDetailWithImage.class, - @"image": MFLoadImageView.class, - @"moduleMolecule": ModuleMolecule.class, - @"headlineBody": HeadlineBody.class, - @"carousel": Carousel.class, - @"carouselItem": MoleculeCollectionViewCell.class, - @"barsPager": MVMCoreUIPageControl.class, - @"scroller": Scroller.class, - @"imageHeadlineBody": ImageHeadlineBody.class, - @"labelToggle": LabelSwitch.class, - @"headlineBodyToggle": HeadlineBodySwitch.class, - @"headlineBodyLink": HeadlineBodyTextButton.class, - @"headlineBodyLinkToggle": HeadlineBodyTextButtonSwitch.class, - @"tabsListItem": TabsTableViewCell.class, - @"dropDownListItem": DropDownFilterTableViewCell.class, - @"headlineBodyButton": HeadlineBodyButton.class, - @"stackItem": MoleculeStackItem.class, - @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, - @"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class, - @"doughnutChart": DoughnutChartView.class, - @"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class - } mutableCopy]; + mapping = [@{} mutableCopy]; }); return mapping; } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index b9a847ac..308e8cf6 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -10,42 +10,14 @@ import Foundation @objcMembers public class MoleculeObjectMapping: NSObject { public static func registerObjects() { + // Stacks MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeStackView.self, viewModelClass: MoleculeStackModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Stack.self, viewModelClass: StackModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeStackItem.self, viewModelClass: MoleculeStackItemModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) + + // Label MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeaderView.self, viewModelClass: HeaderModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: FooterView.self, viewModelClass: FooterModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) - ModelRegistry.register(MoleculeStackItemModel.self) - ModelRegistry.register(TextFieldModel.self) - ModelRegistry.register(ProgressBarModel.self) - ModelRegistry.register(MultiProgressBarModel.self) - ModelRegistry.register(CaretViewModel.self) - ModelRegistry.register(DashLineModel.self) - ModelRegistry.register(ImageViewModel.self) - ModelRegistry.register(TabsModel.self) - ModelRegistry.register(ScrollerModel.self) - ModelRegistry.register(CornerLabelsModel.self) - ModelRegistry.register(LineModel.self) - ModelRegistry.register(CircleProgressModel.self) - ModelRegistry.register(HeadlineBodyCaretLinkImageModel.self) - ModelRegistry.register(ToggleModel.self) - // buttons - ModelRegistry.register(ButtonModel.self) - ModelRegistry.register(TwoButtonViewModel.self) - ModelRegistry.register(LinkModel.self) - ModelRegistry.register(CaretLinkModel.self) - // list items - ModelRegistry.register(ListItemModel.self) - ModelRegistry.register(DropDownListItemModel.self) - ModelRegistry.register(AccordionListItemModel.self) - ModelRegistry.register(TabsListItemModel.self) - //need to move labelattributemodel to different method ModelRegistry.register(LabelAttributeFontModel.self) ModelRegistry.register(LabelAttributeColorModel.self) @@ -53,16 +25,78 @@ import Foundation ModelRegistry.register(LabelAttributeUnderlineModel.self) ModelRegistry.register(LabelAttributeStrikeThroughModel.self) ModelRegistry.register(LabelAttributeActionModel.self) + + // Buttons + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PrimaryButton.self, viewModelClass: ButtonModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MFTextButton.self, viewModelClass: LinkModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretButton.self, viewModelClass: CaretLinkModel.self) + + // Other Atoms + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextFieldModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DropDown.self, viewModelClass: DropDownModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ProgressBar.self, viewModelClass: ProgressBarModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MultiProgress.self, viewModelClass: MultiProgressBarModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretView.self, viewModelClass: CaretViewModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DashLine.self, viewModelClass: DashLineModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MFLoadImageView.self, viewModelClass: ImageViewModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Line.self, viewModelClass: LineModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: GraphView.self, viewModelClass: CircleProgressModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self) - // - //ModelRegistry.register(ModuleMoleculeModel.self) - ModelRegistry.register(LeftRightLabelModel.self) - ModelRegistry.register(CaretViewModel.self) - ModelRegistry.register(CaretLinkModel.self) - ModelRegistry.register(LabelToggleModel.self) - ModelRegistry.register(DoughnutChartModel.self) - ModelRegistry.register(NumberedListModel.self) - ModelRegistry.register(UnOrderedListModel.self) - ModelRegistry.register(HeadlineBodyToggleModel.self) + // Horizontal Combination Molecules + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) + + // Vertical Combination Molecules + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadLineBodyCaretLinkImage.self, viewModelClass: HeadlineBodyCaretLinkImageModel.self) + + // Left Right Molecules + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: LeftRightLabelView.self, viewModelClass: LeftRightLabelModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: LabelSwitch.self, viewModelClass: LabelToggleModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodySwitch.self, viewModelClass: HeadlineBodyToggleModel.self) + + // List items + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: ListItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DropDownFilterTableViewCell.self, viewModelClass: DropDownListItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: AccordionMoleculeTableViewCell.self, viewModelClass: AccordionListItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TabsTableViewCell.self, viewModelClass: TabsListItemModel.self) + + // Other Items + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeStackItem.self, viewModelClass: MoleculeStackItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeCollectionViewCell.self, viewModelClass: CarouselItemModel.self) + + // Other Container Molecules + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeaderView.self, viewModelClass: HeaderModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: FooterView.self, viewModelClass: FooterModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Scroller.self, viewModelClass: ScrollerModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ModuleMolecule.self, viewModelClass: ModuleMoleculeModel.self) + + // Other Molecules + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self) + + // Other Organisms + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self) + + // TODO: Need model + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DigitEntryField.self, forKey: "digitTextField" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DateDropdownEntryField.self, forKey: "dateDropdownEntryField" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(Checkbox.self, forKey: "checkbox" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(CheckboxWithLabelView.self, forKey: "checkboxLabel" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButton.self, forKey: "radioButton" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButtonLabel.self, forKey: "radioButtonLabel" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(ActionDetailWithImage.self, forKey: "actionDetailWithImage" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(ImageHeadlineBody.self, forKey: "imageHeadlineBody" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyTextButton.self, forKey: "headlineBodyLink" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyTextButtonSwitch.self, forKey: "headlineBodyLinkToggle" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyButton.self, forKey: "headlineBodyButton" as NSString) + MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(EyebrowHeadlineBodyLink.self, forKey: "eyebrowHeadlineBodyLink" as NSString) + + // TODO: Need View + ModelRegistry.register(TabsModel.self) } } From 70c3da70d5fcc7466c93c8368ecba74b686f632c Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Wed, 22 Jan 2020 21:53:07 +0530 Subject: [PATCH 206/272] Fixing for comments --- MVMCoreUI/Atoms/Views/Checkbox.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 0c7ca537..ae9b3354 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -515,12 +515,11 @@ import MVMCore isEnabled(enabled) } - guard let action = checkboxModel.action else { return } - actionBlock = { - if let data = try? action.encode(using: JSONEncoder()), - let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] { - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) - + if let action = checkboxModel.action { + actionBlock = { + if let actionMap = action.toJSON() { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } } } } From d30f6314a563134c92c2de61273b155ed7012251 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 22 Jan 2020 11:27:24 -0500 Subject: [PATCH 207/272] remove unneeded property --- MVMCoreUI/Atoms/Buttons/Link.swift | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index b314dd5c..4a498fdd 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -10,18 +10,6 @@ import UIKit @objcMembers open class Link: Button { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - private var additionalData: [AnyHashable: Any]? - - //-------------------------------------------------- - // MARK: - Delegate - //-------------------------------------------------- - - private var delegateObject: MVMCoreUIDelegateObject? - //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- From d22715585e3d0ec1163a73237c68f125fb5fcdb5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 22 Jan 2020 11:44:02 -0500 Subject: [PATCH 208/272] Eyebrow headline body to link --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++---- .../Buttons/MFTextButton+ModelExtension.swift | 21 ------------------- .../EyebrowHeadlineBodyLink.swift | 12 +---------- .../EyebrowHeadlineBodyLinkModel.swift | 19 +++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 5 files changed, 25 insertions(+), 37 deletions(-) delete mode 100644 MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f7070766..3dbc59de 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -167,7 +167,6 @@ D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */; }; D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */; }; D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; }; - D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */; }; D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; }; D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */; }; D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */; }; @@ -300,6 +299,7 @@ D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; + D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A98223D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift */; }; D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; }; D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */; }; DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; }; @@ -460,7 +460,6 @@ D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionListItemModel.swift; sourceTree = ""; }; D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleProgressModel.swift; sourceTree = ""; }; D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = ""; }; - D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextButton+ModelExtension.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 = ""; }; D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimaryButton+MoleculeProtocolExtension.swift"; sourceTree = ""; }; @@ -608,6 +607,7 @@ D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; + D2E2A98223D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyLinkModel.swift; sourceTree = ""; }; D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainer.swift; sourceTree = ""; }; D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackItem.swift; sourceTree = ""; }; @@ -814,6 +814,7 @@ 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, + D2E2A98223D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift */, D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */, D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */, C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, @@ -1116,7 +1117,6 @@ D282AACA2243C61700C46919 /* ButtonView.swift */, D28A838823CCCFCB00DFE4FC /* LinkModel.swift */, D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */, - D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */, D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */, C07065C32395677300FBF997 /* Link.swift */, ); @@ -1511,6 +1511,7 @@ 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, + D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, @@ -1527,7 +1528,6 @@ D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, - D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */, C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift b/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift deleted file mode 100644 index dc5399ef..00000000 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton+ModelExtension.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// MFTextButton_ModelExtension.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 1/13/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import UIKit - -// temporary until link is finished -extension MFTextButton: ModelMoleculeViewProtocol { - public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let model = model as? LinkModel else { return } - setTitle(model.title, for: .normal) - setTitleColor(model.textColor.uiColor, for: .normal) - isEnabled = model.enabled - backgroundColor = model.backgroundColor?.uiColor - set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) - } -} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 3f5d13aa..77a479c5 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -8,22 +8,12 @@ import UIKit -struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { - static var identifier: String = "eyebrowHeadlineBodyLink" - var backgroundColor: Color? - - public var eyeBrow: LabelModel? - public var headline: LabelModel? - public var body: LabelModel? - public var link: LineModel? -} - @objcMembers open class EyebrowHeadlineBodyLink: Container { let stack = Stack(frame: .zero) let eyebrow = Label.commonLabelB3(true) let headline = Label.commonLabelB1(true) let body = Label.commonLabelB2(true) - let link = MFTextButton(nil, constrainHeight: false, forWidth: MVMCoreUIUtility.getWidth()) + let link = Link() var casteModel: EyebrowHeadlineBodyLinkModel? { get { return model as? EyebrowHeadlineBodyLinkModel } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift new file mode 100644 index 00000000..e9341535 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -0,0 +1,19 @@ +// +// EyebrowHeadlineBodyLinkModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +struct EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { + static var identifier: String = "eyebrowHeadlineBodyLink" + var backgroundColor: Color? + + public var eyeBrow: LabelModel? + public var headline: LabelModel? + public var body: LabelModel? + public var link: LinkModel? +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 528351d3..59e7cdef 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -51,6 +51,7 @@ import Foundation // Vertical Combination Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadLineBodyCaretLinkImage.self, viewModelClass: HeadlineBodyCaretLinkImageModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: EyebrowHeadlineBodyLink.self, viewModelClass: EyebrowHeadlineBodyLinkModel.self) // Left Right Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) @@ -94,7 +95,6 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyTextButton.self, forKey: "headlineBodyLink" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyTextButtonSwitch.self, forKey: "headlineBodyLinkToggle" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyButton.self, forKey: "headlineBodyButton" as NSString) - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(EyebrowHeadlineBodyLink.self, forKey: "eyebrowHeadlineBodyLink" as NSString) // TODO: Need View ModelRegistry.register(TabsModel.self) From f7ce81874e2a7d5ff98a9eb3be0161a873881ee1 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 22 Jan 2020 11:47:21 -0500 Subject: [PATCH 209/272] EntryField Models. Updated dropdown for new dropdown. --- MVMCoreUI.xcodeproj/project.pbxproj | 36 +++++++-- .../TextFields/BaseDropdownEntryField.swift | 6 ++ .../BaseDropdownEntryFieldModel.swift | 18 +++++ .../TextFields/DateDropdownEntryField.swift | 10 +++ .../DateDropdownEntryFieldModel.swift | 43 +++++++++++ .../Atoms/TextFields/DigitEntryField.swift | 16 ++++ .../TextFields/DigitEntryFieldModel.swift | 49 ++++++++++++ MVMCoreUI/Atoms/TextFields/EntryField.swift | 37 ++++++++++ .../Atoms/TextFields/EntryFieldModel.swift | 74 +++++++++++++++++++ .../TextFields/ItemDropdownEntryField.swift | 15 +++- .../ItemDropdownEntryFieldModel.swift | 43 +++++++++++ .../Atoms/TextFields/MdnEntryFieldModel.swift | 17 +++++ .../Atoms/TextFields/TextEntryField.swift | 56 ++++++++++++++ .../TextFields/TextEntryFieldModel.swift | 65 ++++++++++++++++ MVMCoreUI/Atoms/Views/DropDown.swift | 55 -------------- MVMCoreUI/Atoms/Views/DropDownModel.swift | 22 ------ .../views/EntryFieldContainer.swift | 10 ++- .../Items/DropDownFilterTableViewCell.swift | 36 +++++---- .../Items/DropDownListItemModel.swift | 6 +- .../MVMCoreUIMoleculeMappingObject.m | 2 +- 20 files changed, 505 insertions(+), 111 deletions(-) create mode 100644 MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift create mode 100644 MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift create mode 100644 MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift create mode 100644 MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift create mode 100644 MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift create mode 100644 MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift create mode 100644 MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift delete mode 100644 MVMCoreUI/Atoms/Views/DropDown.swift delete mode 100644 MVMCoreUI/Atoms/Views/DropDownModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3371e6ca..6fa69289 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -15,7 +15,6 @@ 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */; }; 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */; }; - 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F323A2CCC80085F53C /* DropDownModel.swift */; }; 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */; }; 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */; }; 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */; }; @@ -83,6 +82,13 @@ 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; + 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */; }; + 0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */; }; + 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */; }; + 0A7EF86123D8AC2500B2AAD1 /* DigitEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86023D8AC2500B2AAD1 /* DigitEntryFieldModel.swift */; }; + 0A7EF86323D8AFA000B2AAD1 /* BaseDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86223D8AFA000B2AAD1 /* BaseDropdownEntryFieldModel.swift */; }; + 0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */; }; + 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */; }; 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; }; 0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */; }; 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; @@ -148,7 +154,6 @@ D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; - D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; D274CA332236A78900B01B62 /* FooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* FooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -318,7 +323,6 @@ 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModelProtocol.swift; sourceTree = ""; }; 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownListItemModel.swift; sourceTree = ""; }; - 011B58F323A2CCC80085F53C /* DropDownModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownModel.swift; sourceTree = ""; }; 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModelProtocol.swift; sourceTree = ""; }; 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateProtocol.swift; sourceTree = ""; }; 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselModel.swift; sourceTree = ""; }; @@ -375,6 +379,13 @@ 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; + 0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldModel.swift; sourceTree = ""; }; + 0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryFieldModel.swift; sourceTree = ""; }; + 0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MdnEntryFieldModel.swift; sourceTree = ""; }; + 0A7EF86023D8AC2500B2AAD1 /* DigitEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitEntryFieldModel.swift; sourceTree = ""; }; + 0A7EF86223D8AFA000B2AAD1 /* BaseDropdownEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryFieldModel.swift; sourceTree = ""; }; + 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryFieldModel.swift; sourceTree = ""; }; + 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryFieldModel.swift; sourceTree = ""; }; 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = ""; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; @@ -440,7 +451,6 @@ D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = ""; }; D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; - D268C711238D6699007F2C1C /* DropDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDown.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; D2755D7A23689C7500485468 /* TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; }; D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = ""; }; @@ -1138,8 +1148,6 @@ D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */, D213347623843825008E41B3 /* Line.swift */, - 011B58F323A2CCC80085F53C /* DropDownModel.swift */, - D268C711238D6699007F2C1C /* DropDown.swift */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, 94C2D9822386F3E30006CF46 /* Label */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, @@ -1161,13 +1169,20 @@ children = ( 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */, + 0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */, 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */, 0A21DB7E235DECC500C160A2 /* EntryField.swift */, + 0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */, 0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */, + 0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */, 0A21DB93235E24ED00C160A2 /* DigitEntryField.swift */, + 0A7EF86023D8AC2500B2AAD1 /* DigitEntryFieldModel.swift */, 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */, + 0A7EF86223D8AFA000B2AAD1 /* BaseDropdownEntryFieldModel.swift */, 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */, + 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */, 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */, + 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */, 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */, ); path = TextFields; @@ -1500,6 +1515,7 @@ 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */, + 0A7EF86123D8AC2500B2AAD1 /* DigitEntryFieldModel.swift in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, @@ -1554,24 +1570,29 @@ D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, + 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, + 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */, 0A21DB8B235E06EF00C160A2 /* MFDigitTextBox.m in Sources */, D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, D2B18B812360945C00A9AEDC /* View.swift in Sources */, C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, + 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */, D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, + 0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D260105D23D0BCD400764D80 /* Stack.swift in Sources */, + 0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, @@ -1651,7 +1672,6 @@ D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, - 011B58F423A2CCC80085F53C /* DropDownModel.swift in Sources */, D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, @@ -1662,12 +1682,12 @@ DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */, - D268C712238D6699007F2C1C /* DropDown.swift in Sources */, 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */, C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */, + 0A7EF86323D8AFA000B2AAD1 /* BaseDropdownEntryFieldModel.swift in Sources */, 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift index 05e64f70..6cb0c96a 100644 --- a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift @@ -68,6 +68,12 @@ import UIKit container.trailingAnchor.constraint(equalTo: dropDownCaretView.trailingAnchor, constant: 16).isActive = true dropDownCaretView.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + + dropDownCaretView.setWithModel(model, delegateObject, additionalData) + } } // MARK: - MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift new file mode 100644 index 00000000..3dffa669 --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift @@ -0,0 +1,18 @@ +// +// BaseDropdownEntryFieldModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +@objcMembers public class BaseDropdownEntryFieldModel: TextEntryFieldModel { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { + return "" + } +} diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift index feddfd6b..6fde6b45 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift @@ -112,6 +112,16 @@ import UIKit return formatter } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + + guard let model = model as? DateDropdownEntryFieldModel else { return } + + if let dateFormat = model.dateFormat { + self.dateFormat = dateFormat + } + } } // MARK: - MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift new file mode 100644 index 00000000..d2c9d747 --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift @@ -0,0 +1,43 @@ +// +// DateDropdownEntryFieldModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +@objcMembers public class DateDropdownEntryFieldModel: BaseDropdownEntryFieldModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { + return "DateDropdownEntryField" + } + + public var dateFormat: String? + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case dateFormat + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + dateFormat = try typeContainer.decodeIfPresent(String.self, forKey: .dateFormat) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(dateFormat, forKey: .dateFormat) + } +} diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index 4cd9b67a..ce741346 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -327,6 +327,22 @@ import UIKit } } } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + + guard let model = model as? DigitEntryFieldModel else { return } + + numberOfDigits = model.digits ?? 4 + + if let secureEntry = model.secureEntry, secureEntry { + setAsSecureTextEntry(true) + } + + for digitBox in digitBoxes { + MVMCoreUICommonViewsUtility.addDismissToolbar(digitBox.digitField, delegate: delegateObject as? UITextFieldDelegate) + } + } } // MARK: - TextField Delegate diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift new file mode 100644 index 00000000..bab3f81b --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift @@ -0,0 +1,49 @@ +// +// DigitEntryFieldModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + + +@objcMembers public class DigitEntryFieldModel: TextEntryFieldModel { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { + return "DigitEntryField" + } + + public var digits: Int? + public var secureEntry: Bool? + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case digits + case secureEntry + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + digits = try typeContainer.decodeIfPresent(Int.self, forKey: .digits) + secureEntry = try typeContainer.decodeIfPresent(Bool.self, forKey: .secureEntry) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(digits, forKey: .digits) + try container.encodeIfPresent(secureEntry, forKey: .secureEntry) + } +} diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atoms/TextFields/EntryField.swift index 7e40feba..25b8b670 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryField.swift @@ -238,6 +238,43 @@ import UIKit feedbackLabel.textColor = .black entryFieldContainer.reset() } + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + self.delegateObject = delegateObject + + guard let model = model as? EntryFieldModel else { return } + + entryFieldContainer.setWithModel(model, delegateObject, additionalData) + + if let title = model.title { + self.title = title + } + + if let isDisabled = model.isDisabled { + self.isEnabled = isDisabled + } + + if let feedback = model.feedback { + self.feedback = feedback + } + + if let errorMessage = model.errorMessage { + self.errorMessage = errorMessage + } + + if let isLocked = model.isLocked { + self.isLocked = isLocked + } + + if let isSelected = model.isSelected { + self.isSelected = isSelected + } + + if let fieldKey = model.fieldKey { + self.fieldKey = fieldKey + } + } } // MARK: - MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift new file mode 100644 index 00000000..ce6d2207 --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -0,0 +1,74 @@ +// +// EntryFieldModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class EntryFieldModel: MoleculeModelProtocol { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public class var identifier: String { + return "" + } + + public var backgroundColor: Color? + public var title: String? + public var feedback: String? + public var errorMessage: String? + public var isDisabled: Bool? + public var isLocked: Bool? + public var isSelected: Bool? + + public var fieldKey: String? + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case backgroundColor + case title + case isDisabled + case feedback + case errorMessage + case isLocked + case isSelected + case fieldKey + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) + errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) + isDisabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isDisabled) + isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked) + isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(title, forKey: .title) + try container.encodeIfPresent(feedback, forKey: .feedback) + try container.encodeIfPresent(errorMessage, forKey: .errorMessage) + try container.encodeIfPresent(isDisabled, forKey: .isDisabled) + try container.encodeIfPresent(isLocked, forKey: .isLocked) + try container.encodeIfPresent(isSelected, forKey: .isSelected) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + } +} diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift index 7eaf6c5c..440ad5fc 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift @@ -21,7 +21,7 @@ open class ItemDropdownEntryField: BaseDropdownEntryField { public var setInitialValueInTextField = true /// Closure passed here will run as picker changes items. - public var observeDropdownChange: ((String)->())? + public var observeDropdownChange: ((String, String)->())? /// Closure passed here will run upon dismissing the selection picker. public var observeDropdownSelection: ((String)->())? @@ -90,6 +90,17 @@ open class ItemDropdownEntryField: BaseDropdownEntryField { observeDropdownSelection?(pickerData[pickerIndex]) } } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + + guard let model = model as? ItemDropdownEntryFieldModel else { return } + + if let options = model.options { + pickerData = options + setPickerDelegates(delegate: self) + } + } } // MARK:- Base Picker Delegate @@ -108,8 +119,8 @@ extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource { } @objc public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + observeDropdownChange?(text ?? "", pickerData[row]) text = pickerData[row] - observeDropdownChange?(pickerData[row]) } } diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift new file mode 100644 index 00000000..1d110c57 --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift @@ -0,0 +1,43 @@ +// +// ItemDropdownEntryFieldModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +@objcMembers public class ItemDropdownEntryFieldModel: BaseDropdownEntryFieldModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { + return "ItemDropdownEntryField" + } + + public var options: [String]? + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case options + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + options = try typeContainer.decodeIfPresent([String].self, forKey: .options) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(options, forKey: .options) + } +} diff --git a/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift new file mode 100644 index 00000000..d07c7524 --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift @@ -0,0 +1,17 @@ +// +// MdnEntryFieldModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +@objcMembers public class MdnEntryFieldModel: TextEntryFieldModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { + return "MdnEntryField" + } +} diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index 5ff12679..a2a9631f 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -270,6 +270,62 @@ import UIKit resignFirstResponder() } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + + guard let model = model as? TextEntryFieldModel else { return } + + FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol) + + if let enabledTextColor = model.enabledTextColor { + textColor.enabled = enabledTextColor.uiColor + } + + if let disabledTextColor = model.disabledTextColor { + textColor.disabled = disabledTextColor.uiColor + } + + if let text = model.text { + self.text = text + } + + if let placeholder = model.placeholder { + self.placeholder = placeholder + } + + switch model.type { + case "password": + textField.isSecureTextEntry = true + + case "number": + textField.keyboardType = .numberPad + + case "email": + textField.keyboardType = .emailAddress + + default: + break + } + + let regex = model.regex ?? "" + + if !regex.isEmpty { + validationBlock = { enteredValue in + guard let value = enteredValue else { return false } + return MVMCoreUIUtility.validate(value, withRegularExpression: regex) + } + } else { + defaultValidationBlock() + } + + if let formValidationProtocol = delegateObject?.formValidationProtocol { + observingTextFieldDelegate = FormValidator.getFormValidatorFor(delegate: formValidationProtocol) + } + + uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate + MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) + } } // MARK: - MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift new file mode 100644 index 00000000..bd69c908 --- /dev/null +++ b/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift @@ -0,0 +1,65 @@ +// +// TextEntryFieldModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + + +@objcMembers public class TextEntryFieldModel: EntryFieldModel { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { + return "TextEntryField" + } + + public var text: String? + public var placeholder: String? + public var enabledTextColor: Color? + public var disabledTextColor: Color? + public var type: String? + public var regex: String? + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case text + case placeholder + case enabledTextColor + case disabledTextColor + case type + case regex + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + text = try typeContainer.decodeIfPresent(String.self, forKey: .text) + placeholder = try typeContainer.decodeIfPresent(String.self, forKey: .placeholder) + enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledTextColor) + disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor) + type = try typeContainer.decodeIfPresent(String.self, forKey: .type) + regex = try typeContainer.decodeIfPresent(String.self, forKey: .regex) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(text, forKey: .text) + try container.encodeIfPresent(placeholder, forKey: .placeholder) + try container.encodeIfPresent(enabledTextColor, forKey: .enabledTextColor) + try container.encodeIfPresent(disabledTextColor, forKey: .disabledTextColor) + try container.encodeIfPresent(type, forKey: .type) + try container.encodeIfPresent(regex, forKey: .regex) + } +} diff --git a/MVMCoreUI/Atoms/Views/DropDown.swift b/MVMCoreUI/Atoms/Views/DropDown.swift deleted file mode 100644 index 929bd67f..00000000 --- a/MVMCoreUI/Atoms/Views/DropDown.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// DropDown.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 11/26/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -@objcMembers public class DropDown: MFTextField { - let picker = MVMCoreUICommonViewsUtility.commonPickerView()! - - public override func getNib() -> UINib? { - return UINib(nibName: String(describing: MFTextField.self), bundle: MVMCoreUIUtility.bundleForMVMCoreUI()) - } - - public override func setupView() { - super.setupView() - dropDownCarrotWidth?.isActive = false - errorHeightConstraint?.constant = 0 - } - - override public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - guard let textField = textField, textField.inputView == nil else { return } - picker.delegate = self - picker.dataSource = self - picker.tag = textField.tag - textField.inputView = picker - picker.reloadAllComponents() - MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: delegateObject?.uiTextFieldDelegate) - textField.text = json?.stringWithChainOfKeysOrIndexes(["options",picker.selectedRow(inComponent: 0)]) - } -} - -extension DropDown: UIPickerViewDelegate { - public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - return json?.stringWithChainOfKeysOrIndexes(["options",row]) - } - - public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - textField?.text = json?.stringWithChainOfKeysOrIndexes(["options",row]) - } -} - -extension DropDown: UIPickerViewDataSource { - public func numberOfComponents(in pickerView: UIPickerView) -> Int { - return 1 - } - - public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { - return json?.optionalArrayForKey("options")?.count ?? 0 - } -} diff --git a/MVMCoreUI/Atoms/Views/DropDownModel.swift b/MVMCoreUI/Atoms/Views/DropDownModel.swift deleted file mode 100644 index 8e3e4e10..00000000 --- a/MVMCoreUI/Atoms/Views/DropDownModel.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// DropDownModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 12/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - - -@objcMembers public class DropDownModel: MoleculeModelProtocol { - public static var identifier: String = "dropDownModel" - public var backgroundColor: Color? - public var label: String - public var options: [String] - - public init(label: String, options: [String]) { - self.label = label - self.options = options - } -} diff --git a/MVMCoreUI/Containers/views/EntryFieldContainer.swift b/MVMCoreUI/Containers/views/EntryFieldContainer.swift index 96a51a8f..98e3d661 100644 --- a/MVMCoreUI/Containers/views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/views/EntryFieldContainer.swift @@ -271,9 +271,17 @@ import UIKit layoutIfNeeded() } } + + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + self.delegateObject = delegateObject + } } -// MARK:- MVMCoreUIMoleculeViewProtocol extension EntryFieldContainer { override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index cd18eb04..abf6f711 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -9,37 +9,35 @@ import UIKit @objcMembers public class DropDownFilterTableViewCell: TableViewCell { + var dropDownListItemModel: DropDownListItemModel? - let dropDown = DropDown(forDropDownWithBothDelegates: nil) + let dropDown = ItemDropdownEntryField() var delegateObject: MVMCoreUIDelegateObject? var previousIndex = NSNotFound var dropDownSelectionObservation: NSKeyValueObservation? - + // MARK: - MFViewProtocol override public func setupView() { super.setupView() - guard let dropDown = dropDown, dropDown.superview == nil else { - return - } + guard dropDown.superview == nil else { return } dropDown.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(dropDown) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: dropDown, useMargins: true).values)) - #warning("Once we have the state manager, we will need to change this logic to only add or remove on user selection...Want to avoid re-use crashes from array size differences") - dropDownSelectionObservation = observe( - \.dropDown?.textField?.text, - options: [.old, .new] - ) { [weak self] object, change in - guard change.newValue != change.oldValue, let self = self, - let options = self.dropDown?.json?.optionalArrayForKey("options") as? [NSString], - let index = options.firstIndex(of: change.newValue!! as NSString), + dropDown.observeDropdownChange = { [weak self] oldValue, newValue in + + guard newValue != oldValue, + let self = self, + let options = self.dropDown.json?.optionalArrayForKey("options") as? [NSString], + let index = options.firstIndex(of: newValue as NSString), let molecules = self.dropDownListItemModel?.molecules else { return } if self.previousIndex != NSNotFound { self.delegateObject?.moleculeDelegate?.removeMolecules(molecules[self.previousIndex], sender: self, animation: .fade) } + self.delegateObject?.moleculeDelegate?.addMolecules(molecules[index], sender: self, animation: .fade) self.previousIndex = index } @@ -47,17 +45,17 @@ import UIKit public override func updateView(_ size: CGFloat) { super.updateView(size) - dropDown?.updateView(size) + dropDown.updateView(size) } - + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { dropDownListItemModel = model as? DropDownListItemModel self.delegateObject = delegateObject super.setWithModel(model, delegateObject, additionalData) - - dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate - dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate - dropDown?.setWithModel(dropDownListItemModel, delegateObject, additionalData) + + dropDown.observingTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? ObservingTextFieldDelegate + dropDown.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate + dropDown.setWithModel(dropDownListItemModel, delegateObject, additionalData) } public override func reset() { diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index c7b9ca75..47ea71c5 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -11,12 +11,12 @@ import Foundation @objcMembers public class DropDownListItemModel: MoleculeContainerModel, ListItemModelProtocol { public static var identifier: String = "dropDownListItem" public var molecules: [[ListItemModelProtocol]] - public var dropDown: DropDownModel + public var dropDown: ItemDropdownEntryFieldModel public var backgroundColor: Color? public var line: LineModel? = LineModel(type: .none) public var hideArrow: Bool? = true - public init(molecule: MoleculeModelProtocol, molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { + public init(molecule: MoleculeModelProtocol, molecules: [[ListItemModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { self.molecules = molecules self.dropDown = dropDown super.init(with: molecule) @@ -32,7 +32,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] - dropDown = try typeContainer.decode(DropDownModel.self, forKey: .dropDown) + dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { line = lineModel } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index b5a39119..4f2d6e3c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -36,10 +36,10 @@ @"caretView": CaretView.class, @"caretLink": CaretButton.class, @"textField": MFTextField.class, - @"dropDown": DropDown.class, @"digitTextField": MFDigitTextField.class, @"digitEntryField": DigitEntryField.class, @"textEntryField": TextEntryField.class, + @"mdnEntryField": MdnEntryField.class, @"itemDropdownEntryField": ItemDropdownEntryField.class, @"dateDropdownEntryField": DateDropdownEntryField.class, @"checkbox": Checkbox.class, From 1eec90e8e12e5f86e6f1e5e5fceefbc398e8792d Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 22 Jan 2020 11:57:16 -0500 Subject: [PATCH 210/272] align model. --- MVMCoreUI/Containers/Views/EntryFieldContainer.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index 96a51a8f..98e3d661 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -271,9 +271,17 @@ import UIKit layoutIfNeeded() } } + + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + self.delegateObject = delegateObject + } } -// MARK:- MVMCoreUIMoleculeViewProtocol extension EntryFieldContainer { override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { From f816081d8e965b9db76095344a5e8bacbfc96e4e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 13:58:56 -0500 Subject: [PATCH 211/272] check box --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++---- MVMCoreUI/Atoms/Views/Checkbox.swift | 8 ++++---- ...xWithLabelViewModel.swift => CheckboxLabelModel.swift} | 2 +- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 8 ++++---- MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift | 2 +- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) rename MVMCoreUI/Atoms/Views/{CheckboxWithLabelViewModel.swift => CheckboxLabelModel.swift} (94%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 09d66304..314ae317 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -88,7 +88,7 @@ 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; }; 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; - 31BE15CB23D8924D00452370 /* CheckboxWithLabelViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */; }; + 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; @@ -384,7 +384,7 @@ 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = ""; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = ""; }; 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; - 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelViewModel.swift; sourceTree = ""; }; + 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = ""; }; 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; @@ -1149,7 +1149,7 @@ 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 31BE15CA23D8924C00452370 /* CheckboxModel.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, - 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */, + 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, 943784F3236B77BB006A1E82 /* GraphView.swift */, @@ -1562,7 +1562,7 @@ DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, - 31BE15CB23D8924D00452370 /* CheckboxWithLabelViewModel.swift in Sources */, + 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index ae9b3354..fe5add9b 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -485,14 +485,14 @@ import MVMCore layer.borderWidth = borderWidth } - if let isChecked = checkboxModel.isChecked, isChecked { + if checkboxModel.isChecked { updateSelectionOnly = true - isSelected = isChecked + isSelected = checkboxModel.isChecked updateSelectionOnly = false } - if let checkColorHex = checkboxModel.checkColor { - checkColor = UIColor.mfGet(forHex: checkColorHex) + if let uiCheckColor = checkboxModel.checkColor?.uiColor { + checkColor = uiCheckColor } if let unCheckedBackgroundColorHex = checkboxModel.unCheckedBackgroundColor { diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift similarity index 94% rename from MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift rename to MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift index 81d64361..088f7d9e 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class CheckboxWithLabelViewModel: MoleculeModelProtocol { +@objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { public static var identifier: String = "checkboxLabel" public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 4ad1bade..4b854951 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -18,8 +18,8 @@ import Foundation public var required: Bool? public var borderColor: String? public var borderWidth: CGFloat? - public var isChecked: Bool? - public var checkColor: String? + public var isChecked: Bool = false + public var checkColor: Color? public var unCheckedBackgroundColor: String? public var checkedBackgroundColor: String? public var isAnimated: Bool? @@ -53,8 +53,8 @@ import Foundation self.required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) self.borderColor = try typeContainer.decodeIfPresent(String.self, forKey: .borderColor) self.borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) - self.isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) - self.checkColor = try typeContainer.decodeIfPresent(String.self, forKey: .checkColor) + self.isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) ?? false + self.checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) self.unCheckedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .unCheckedBackgroundColor) self.checkedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .checkedBackgroundColor) self.isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift index 27256aa3..69141210 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift @@ -122,7 +122,7 @@ } open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let checkBoxWithLabelModel = model as? CheckboxWithLabelViewModel else { + guard let checkBoxWithLabelModel = model as? CheckboxLabelModel else { return } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 76d4ba20..6c623572 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -74,6 +74,6 @@ import Foundation //Checkbox ModelRegistry.register(CheckboxModel.self) - ModelRegistry.register(CheckboxWithLabelViewModel.self) + ModelRegistry.register(CheckboxLabelModel.self) } } From 5dafbe6a8532b8062c10d4e6642280a172abb68d Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 14:21:48 -0500 Subject: [PATCH 212/272] more color --- MVMCoreUI/Atoms/Views/Checkbox.swift | 6 +++--- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 12 ++++++------ .../OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 2 -- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 11 +++++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index fe5add9b..6b125e82 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -478,7 +478,7 @@ import MVMCore } if let borderColorHex = checkboxModel.borderColor { - layer.borderColor = UIColor.mfGet(forHex: borderColorHex).cgColor + layer.borderColor = borderColorHex.uiColor.cgColor } if let borderWidth = checkboxModel.borderWidth { @@ -496,11 +496,11 @@ import MVMCore } if let unCheckedBackgroundColorHex = checkboxModel.unCheckedBackgroundColor { - unCheckedBackgroundColor = UIColor.mfGet(forHex: unCheckedBackgroundColorHex) + unCheckedBackgroundColor = unCheckedBackgroundColorHex.uiColor } if let checkedBackgroundColorHex = checkboxModel.checkedBackgroundColor { - checkedBackgroundColor = UIColor.mfGet(forHex: checkedBackgroundColorHex) + checkedBackgroundColor = checkedBackgroundColorHex.uiColor } if let isAnimated = checkboxModel.isAnimated { diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 4b854951..72c6dbfd 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -16,12 +16,12 @@ import Foundation public var value: String? public var fieldKey: String? public var required: Bool? - public var borderColor: String? + public var borderColor: Color? public var borderWidth: CGFloat? public var isChecked: Bool = false public var checkColor: Color? - public var unCheckedBackgroundColor: String? - public var checkedBackgroundColor: String? + public var unCheckedBackgroundColor: Color? + public var checkedBackgroundColor: Color? public var isAnimated: Bool? public var isRound: Bool? public var isEnabled: Bool? @@ -51,12 +51,12 @@ import Foundation self.value = try typeContainer.decodeIfPresent(String.self, forKey: .value) self.fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) self.required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) - self.borderColor = try typeContainer.decodeIfPresent(String.self, forKey: .borderColor) + self.borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) self.borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) self.isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) ?? false self.checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) - self.unCheckedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .unCheckedBackgroundColor) - self.checkedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .checkedBackgroundColor) + self.unCheckedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .unCheckedBackgroundColor) + self.checkedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkedBackgroundColor) self.isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) self.isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) self.isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index b5a39119..687f3cd9 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -42,8 +42,6 @@ @"textEntryField": TextEntryField.class, @"itemDropdownEntryField": ItemDropdownEntryField.class, @"dateDropdownEntryField": DateDropdownEntryField.class, - @"checkbox": Checkbox.class, - @"checkboxLabel": CheckboxWithLabelView.class, @"cornerLabels" : CornerLabels.class, @"progressBar": ProgressBar.class, @"circleProgress": GraphView.class, diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 6c623572..0e53282e 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -24,6 +24,13 @@ import Foundation ModelRegistry.register(NumberedListModel.self) mapping?.setObject(NumberedList.self, forKey: NumberedListModel.identifier as NSString) + //Checkbox + ModelRegistry.register(CheckboxModel.self) + mapping?.setObject(Checkbox.self, forKey: CheckboxModel.identifier as NSString) + + ModelRegistry.register(CheckboxLabelModel.self) + mapping?.setObject(CheckboxWithLabelView.self, forKey: CheckboxLabelModel.identifier as NSString) + ModelRegistry.register(LabelModel.self) ModelRegistry.register(HeaderModel.self) ModelRegistry.register(FooterModel.self) @@ -71,9 +78,5 @@ import Foundation ModelRegistry.register(NumberedListModel.self) ModelRegistry.register(UnOrderedListModel.self) ModelRegistry.register(HeadlineBodyToggleModel.self) - - //Checkbox - ModelRegistry.register(CheckboxModel.self) - ModelRegistry.register(CheckboxLabelModel.self) } } From c6ba48397c8790dc4b24c762d437397de6597e16 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 22 Jan 2020 14:31:33 -0500 Subject: [PATCH 213/272] Add some missing models --- MVMCoreUI.xcodeproj/project.pbxproj | 26 +++++++- .../ImageHeadlineBody.swift | 55 +++++++---------- .../ImageHeadlineBodyModel.swift | 16 +++++ .../TwoButtonViewModel.swift | 2 +- .../ActionDetailWithImage.swift | 27 +++------ .../ActionDetailWithImageModel.swift | 16 +++++ .../HeadlineBodyLinkToggleModel.swift | 20 +++++++ .../HeadlineBodyTextButtonSwitch.swift | 60 ++++++++----------- .../EyebrowHeadlineBodyLink.swift | 23 +++---- .../HeadLineBodyCaretLinkImage.swift | 1 + .../HeadlineBodyButton.swift | 31 +++------- .../HeadlineBodyButtonModel.swift | 18 ++++++ .../HeadlineBodyLinkModel.swift | 22 +++++++ .../HeadlineBodyTextButton.swift | 50 ++++++++-------- MVMCoreUI/Organisms/Carousel.swift | 1 - .../OtherHandlers/MoleculeObjectMapping.swift | 12 ++-- 16 files changed, 221 insertions(+), 159 deletions(-) create mode 100644 MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift rename MVMCoreUI/Molecules/{ => LeftRightViews}/ActionDetailWithImage.swift (81%) create mode 100644 MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift create mode 100644 MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyLinkToggleModel.swift rename MVMCoreUI/Molecules/{ => VerticalCombinationViews}/HeadlineBodyButton.swift (77%) create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift create mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3dbc59de..b47d64d3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -300,6 +300,11 @@ D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A98223D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift */; }; + D2E2A99423D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99323D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift */; }; + D2E2A99623D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99523D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift */; }; + D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */; }; + D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */; }; + D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */; }; D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; }; D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */; }; DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; }; @@ -608,6 +613,11 @@ D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; D2E2A98223D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyLinkModel.swift; sourceTree = ""; }; + D2E2A99323D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyLinkModel.swift; sourceTree = ""; }; + D2E2A99523D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyLinkToggleModel.swift; sourceTree = ""; }; + D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImageModel.swift; sourceTree = ""; }; + D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButtonModel.swift; sourceTree = ""; }; + D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageHeadlineBodyModel.swift; sourceTree = ""; }; D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainer.swift; sourceTree = ""; }; D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackItem.swift; sourceTree = ""; }; @@ -798,11 +808,12 @@ D224798823142BF2003FCCF9 /* SwitchMolecules */ = { isa = PBXGroup; children = ( + D2E2A99523D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift */, 01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */, 01C851D223CF9E740021F976 /* LabelToggleModel.swift */, D22479892314445E003FCCF9 /* LabelSwitch.swift */, - D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */, 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */, + D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */, ); path = SwitchMolecules; sourceTree = ""; @@ -813,11 +824,14 @@ D29E28D423D1FFFA00ACEA85 /* Lists */, 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, + D2E2A99323D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift */, D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, D2E2A98223D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift */, D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */, D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */, C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, + D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */, + 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, ); path = VerticalCombinationViews; sourceTree = ""; @@ -825,6 +839,7 @@ D224798E2316A995003FCCF9 /* HorizontalCombinationViews */ = { isa = PBXGroup; children = ( + D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */, D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */, D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */, D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */, @@ -836,6 +851,8 @@ D224798F2316A99F003FCCF9 /* LeftRightViews */ = { isa = PBXGroup; children = ( + D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */, + 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */, 01509D902327ECE600EF99AA /* CornerLabels.swift */, D224798823142BF2003FCCF9 /* SwitchMolecules */, @@ -986,7 +1003,6 @@ D224798F2316A99F003FCCF9 /* LeftRightViews */, D224798E2316A995003FCCF9 /* HorizontalCombinationViews */, D224798D2316A988003FCCF9 /* VerticalCombinationViews */, - 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, D2A514662213885800345BFB /* HeaderView.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, @@ -996,7 +1012,6 @@ D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */, D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */, - 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, @@ -1495,6 +1510,7 @@ D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, + D2E2A99423D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */, 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, @@ -1515,6 +1531,7 @@ 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, + D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, @@ -1533,6 +1550,7 @@ D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, + D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, @@ -1548,6 +1566,7 @@ 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, D213347723843825008E41B3 /* Line.swift in Sources */, D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */, + D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */, D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */, 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, D2A514672213885800345BFB /* HeaderView.swift in Sources */, @@ -1600,6 +1619,7 @@ 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, + D2E2A99623D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift in Sources */, C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift index 6e10a1a0..089352c7 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class ImageHeadlineBody: ViewConstrainingView { +@objcMembers open class ImageHeadlineBody: View { let headlineBody = HeadlineBody(frame: .zero) let imageView = MFLoadImageView() var constraintBetweenImageLabelsConstant: CGFloat = 16 @@ -23,27 +23,24 @@ import UIKit headlineBody.headlineLabel.styleB1(true) headlineBody.spaceBetweenLabelsConstant = 0 - let view = MVMCoreUICommonViewsUtility.commonView() - addSubview(view) - pinView(toSuperView: view) - view.addSubview(headlineBody) - view.addSubview(imageView) + addSubview(headlineBody) + addSubview(imageView) - headlineBody.topAnchor.constraint(equalTo: view.topAnchor).isActive = true - view.rightAnchor.constraint(equalTo: headlineBody.rightAnchor).isActive = true - view.bottomAnchor.constraint(greaterThanOrEqualTo: headlineBody.bottomAnchor).isActive = true - var constraint = view.bottomAnchor.constraint(equalTo: headlineBody.bottomAnchor) + headlineBody.topAnchor.constraint(equalTo: topAnchor).isActive = true + rightAnchor.constraint(equalTo: headlineBody.rightAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: headlineBody.bottomAnchor).isActive = true + var constraint = bottomAnchor.constraint(equalTo: headlineBody.bottomAnchor) constraint.priority = .defaultLow constraint.isActive = true - imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true - imageView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - imageView.topAnchor.constraint(greaterThanOrEqualTo: view.topAnchor).isActive = true - view.bottomAnchor.constraint(greaterThanOrEqualTo: imageView.bottomAnchor).isActive = true - constraint = view.bottomAnchor.constraint(equalTo: imageView.bottomAnchor) + imageView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true + imageView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true + imageView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: imageView.bottomAnchor).isActive = true + constraint = bottomAnchor.constraint(equalTo: imageView.bottomAnchor) constraint.priority = UILayoutPriority(rawValue: 200) constraint.isActive = true - constraint = imageView.topAnchor.constraint(equalTo: view.topAnchor) + constraint = imageView.topAnchor.constraint(equalTo: topAnchor) constraint.priority = UILayoutPriority(rawValue: 200) constraint.isActive = true @@ -58,22 +55,6 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol - - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - - let imageJSON = json?.optionalDictionaryForKey("image") - imageView.setWithJSON(imageJSON, delegateObject: delegateObject, additionalData: additionalData) - constraintBetweenImageLabels?.constant = imageJSON != nil ? constraintBetweenImageLabelsConstant : 0 - } - - open override func setAsMolecule() { - super.setAsMolecule() - headlineBody.setAsMolecule() - imageView.setAsMolecule() - } - open override func reset() { super.reset() headlineBody.reset() @@ -82,7 +63,15 @@ import UIKit imageView.reset() } - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + // MARK:- ModelMoleculeViewProtocol + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 95 } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ImageHeadlineBodyModel else { return } + headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData) + imageView.setWithModel(model.image, delegateObject, additionalData) + } } diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift new file mode 100644 index 00000000..4966ce58 --- /dev/null +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift @@ -0,0 +1,16 @@ +// +// File.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public struct ImageHeadlineBodyModel: MoleculeModelProtocol { + public static var identifier: String = "imageHeadlineBody" + public var backgroundColor: Color? + public var image: ImageViewModel + public var headlineBody: HeadlineBodyModel +} diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 04f676ba..a7abde9f 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -8,7 +8,7 @@ import UIKit -public class TwoButtonViewModel: MoleculeModelProtocol { +public struct TwoButtonViewModel: MoleculeModelProtocol { public static var identifier: String = "twoButtonView" public var backgroundColor: Color? public var primaryButton: ButtonModel? diff --git a/MVMCoreUI/Molecules/ActionDetailWithImage.swift b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImage.swift similarity index 81% rename from MVMCoreUI/Molecules/ActionDetailWithImage.swift rename to MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImage.swift index 4811f20d..bde18777 100644 --- a/MVMCoreUI/Molecules/ActionDetailWithImage.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImage.swift @@ -9,7 +9,7 @@ import UIKit -@objcMembers open class ActionDetailWithImage: ViewConstrainingView { +@objcMembers open class ActionDetailWithImage: View { //------------------------------------------------------ // MARK: - Outlets //------------------------------------------------------ @@ -91,10 +91,6 @@ import UIKit imageLoader.updateView(size) } - public override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 197 - } - //------------------------------------------------------ // MARK: - Methods //------------------------------------------------------ @@ -117,20 +113,15 @@ import UIKit setDefaultState() } - open override func setAsMolecule() { - super.setAsMolecule() - - headlineBodyButton.setAsMolecule() - imageLoader.setAsMolecule() - setDefaultState() + // MARK:- ModelMoleculeViewProtocol + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 197 } - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let dictionary = json else { return } - - headlineBodyButton.setWithJSON(dictionary.optionalDictionaryForKey("headlineBodyButton"), delegateObject: delegateObject, additionalData: additionalData) - imageLoader.setWithJSON(dictionary.optionalDictionaryForKey("image"), delegateObject: delegateObject, additionalData: additionalData) + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ActionDetailWithImageModel else { return } + headlineBodyButton.setWithModel(model.headlineBodyButton, delegateObject, additionalData) + imageLoader.setWithModel(model.image, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift new file mode 100644 index 00000000..a397c1a1 --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift @@ -0,0 +1,16 @@ +// +// ActionDetailWithImageModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public struct ActionDetailWithImageModel: MoleculeModelProtocol { + public static var identifier: String = "actionDetailWithImage" + public var backgroundColor: Color? + public var headlineBodyButton: HeadlineBodyButtonModel + public var image: ImageViewModel +} diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyLinkToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyLinkToggleModel.swift new file mode 100644 index 00000000..5ce04f9c --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyLinkToggleModel.swift @@ -0,0 +1,20 @@ +// +// HeadlineBodyLinkToggleModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public struct HeadlineBodyLinkToggleModel: MoleculeModelProtocol { + public static var identifier: String = "headlineBodyLinkToggle" + public var backgroundColor: Color? + public var headlineBodyLink: HeadlineBodyLinkModel + public var toggle: ToggleModel + + public init(_ headlineBodyLink: HeadlineBodyLinkModel, _ toggle: ToggleModel) { + self.headlineBodyLink = headlineBodyLink + self.toggle = toggle + } +} diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift index 5ee9c41f..aa9e1a76 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift @@ -8,55 +8,45 @@ import UIKit -@objcMembers public class HeadlineBodyTextButtonSwitch: ViewConstrainingView { - let headlineBodyTextButton = HeadlineBodyTextButton(frame: .zero) - let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault() +@objcMembers public class HeadlineBodyTextButtonSwitch: View { + let headlineBodyLink = HeadlineBodyTextButton(frame: .zero) + let toggle = Toggle() // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) - headlineBodyTextButton.updateView(size) - mvmSwitch.updateView(size) + headlineBodyLink.updateView(size) + toggle.updateView(size) } public override func setupView() { super.setupView() - guard mvmSwitch.superview == nil else { + guard toggle.superview == nil else { return } - let view = MVMCoreUICommonViewsUtility.commonView() - addSubview(view) - pinView(toSuperView: view) - - headlineBodyTextButton.headlineBody.styleListItem() - view.addSubview(headlineBodyTextButton) - view.addSubview(mvmSwitch) - NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBodyTextButton, rightView: mvmSwitch) - } - - // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyLink"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) - } - - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return HeadlineBodyTextButton.estimatedHeight(forRow: json, delegateObject: delegateObject) - } - - public override func setAsMolecule() { - super.setAsMolecule() - headlineBodyTextButton.setAsMolecule() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() - headlineBodyTextButton.headlineBody.styleListItem() + headlineBodyLink.headlineBody.styleListItem() + addSubview(headlineBodyLink) + addSubview(toggle) + NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBodyLink, rightView: toggle) } + // MARK: - MVMCoreUIMoleculeViewProtoco public override func reset() { super.reset() - headlineBodyTextButton.reset() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?() - headlineBodyTextButton.headlineBody.styleListItem() + headlineBodyLink.reset() + toggle.reset() + } + + // MARK:- ModelMoleculeViewProtocol + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? HeadlineBodyLinkToggleModel else { return } + headlineBodyLink.setWithModel(model.headlineBodyLink, delegateObject, additionalData) + toggle.setWithModel(model.toggle, delegateObject, additionalData) + } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return HeadlineBodyTextButton.estimatedHeight(forRow: (molecule as? HeadlineBodyLinkToggleModel)?.headlineBodyLink, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 77a479c5..ff8e6cfa 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -35,7 +35,16 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol + open override func reset() { + super.reset() + stack.reset() + stack.stackModel?.spacing = 0 + eyebrow.styleB3(true) + headline.styleB1(true) + body.styleB2(true) + } + // MARK:- ModelMoleculeViewProtocol open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.setWithModel(model, delegateObject, additionalData) eyebrow.setWithModel(casteModel?.eyeBrow, delegateObject, additionalData) @@ -50,20 +59,6 @@ import UIKit stack.restack() } - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: EyebrowHeadlineBodyLinkModel.self) else { return } - setWithModel(model, delegateObject, additionalData) - } - - open override func reset() { - super.reset() - stack.reset() - stack.stackModel?.spacing = 0 - eyebrow.styleB3(true) - headline.styleB1(true) - body.styleB2(true) - } - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 65 } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index a9321637..01325da9 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -75,6 +75,7 @@ import Foundation backgroundImageView.reset() } + // MARK:- ModelMoleculeViewProtocol public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 320 } diff --git a/MVMCoreUI/Molecules/HeadlineBodyButton.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift similarity index 77% rename from MVMCoreUI/Molecules/HeadlineBodyButton.swift rename to MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift index 7ce80e94..a0f22f34 100644 --- a/MVMCoreUI/Molecules/HeadlineBodyButton.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift @@ -107,29 +107,16 @@ import UIKit defaultState() } - open override func setAsMolecule() { - super.setAsMolecule() - - headlineBody.setAsMolecule() - button.setAsMolecule() - defaultState() + // MARK:- ModelMoleculeViewProtocol + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 320 } - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let dictionary = json else { return } - - if let padding = dictionary.optionalCGFloatForKey("buttonHeadlinePadding") { - buttonHeadlinePadding = padding - } - - headlineBody.setWithJSON(dictionary.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - - if let buttonDictionary = dictionary.optionalDictionaryForKey("button") { - button.setWithJSON(buttonDictionary, delegateObject: delegateObject, additionalData: additionalData) - } else { - button.isHidden = true - } + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? HeadlineBodyButtonModel else { return } + buttonHeadlinePadding = model.buttonHeadlinePadding + headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData) + button.setWithModel(model.button, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift new file mode 100644 index 00000000..74e85ea9 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -0,0 +1,18 @@ +// +// HeadlineBodyButtonModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public struct HeadlineBodyButtonModel: MoleculeModelProtocol { + public static var identifier: String = "headlineBodyButton" + public var backgroundColor: Color? + + public var headlineBody: HeadlineBodyModel + public var button: ButtonModel + public var buttonHeadlinePadding: CGFloat +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift new file mode 100644 index 00000000..9eae8e03 --- /dev/null +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift @@ -0,0 +1,22 @@ +// +// HeadlineBodyLinkModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public struct HeadlineBodyLinkModel: MoleculeModelProtocol { + public static var identifier: String = "headlineBodyLink" + public var headlineBody: HeadlineBodyModel + public var link: LinkModel + public var backgroundColor: Color? + + public init(headlineBody: HeadlineBodyModel, link: LinkModel) { + self.headlineBody = headlineBody + self.link = link + } +} + diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift index ca696f1a..55c3e795 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift @@ -8,10 +8,10 @@ import UIKit -@objcMembers public class HeadlineBodyTextButton: ViewConstrainingView { +@objcMembers public class HeadlineBodyTextButton: View { let headlineBody = HeadlineBody(frame: .zero) - let textButton = MFTextButton(nil, constrainHeight: true, forWidth: MVMCoreUIUtility.getWidth()) + let link = Link() var spaceBetweenConstant: CGFloat = 0.0 var spaceBetween: NSLayoutConstraint? @@ -19,7 +19,7 @@ import UIKit open override func updateView(_ size: CGFloat) { super.updateView(size) headlineBody.updateView(size) - textButton.updateView(size) + link.updateView(size) setSpacing() } @@ -28,34 +28,30 @@ import UIKit guard subviews.count == 0 else { return } - let view = MVMCoreUICommonViewsUtility.commonView() - addSubview(view) - pinView(toSuperView: view) - - view.addSubview(headlineBody) - view.addSubview(textButton) + addSubview(headlineBody) + addSubview(link) headlineBody.styleListItem() - headlineBody.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true - headlineBody.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - var constraint = view.rightAnchor.constraint(equalTo: headlineBody.rightAnchor) + headlineBody.topAnchor.constraint(equalTo: topAnchor, constant: 0).isActive = true + headlineBody.leftAnchor.constraint(equalTo: leftAnchor).isActive = true + var constraint = rightAnchor.constraint(equalTo: headlineBody.rightAnchor) constraint.priority = .defaultHigh constraint.isActive = true - spaceBetween = textButton.topAnchor.constraint(equalTo: headlineBody.bottomAnchor, constant: spaceBetweenConstant) + spaceBetween = link.topAnchor.constraint(equalTo: headlineBody.bottomAnchor, constant: spaceBetweenConstant) spaceBetween?.isActive = true - textButton.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - view.bottomAnchor.constraint(equalTo: textButton.bottomAnchor).isActive = true - view.rightAnchor.constraint(greaterThanOrEqualTo: textButton.rightAnchor).isActive = true - constraint = view.rightAnchor.constraint(equalTo: textButton.rightAnchor) + link.leftAnchor.constraint(equalTo: leftAnchor).isActive = true + bottomAnchor.constraint(equalTo: link.bottomAnchor).isActive = true + rightAnchor.constraint(greaterThanOrEqualTo: link.rightAnchor).isActive = true + constraint = rightAnchor.constraint(equalTo: link.rightAnchor) constraint.priority = .defaultHigh constraint.isActive = true } // MARK: - Constraining public func setSpacing() { - if headlineBody.hasText() && (textButton.titleLabel?.text?.count ?? 0) > 0 { + if headlineBody.hasText() && (link.titleLabel?.text?.count ?? 0) > 0 { spaceBetween?.constant = spaceBetweenConstant } else { spaceBetween?.constant = 0 @@ -63,20 +59,22 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - textButton.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData) - } - open override func reset() { super.reset() headlineBody.reset() headlineBody.styleListItem() - textButton.reset() + link.reset() } - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + // MARK:- ModelMoleculeViewProtocol + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? HeadlineBodyLinkModel else { return } + headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData) + link.setWithModel(model.link, delegateObject, additionalData) + } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 60 } } diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 59911594..7262e122 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -83,7 +83,6 @@ open class Carousel: View { } // MARK: - MVMCoreUIMoleculeViewProtocol - //TODO: Model, Change to model public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let carouselModel = model as? CarouselModel else { return } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 59e7cdef..f7cf5c57 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -47,17 +47,22 @@ import Foundation // Horizontal Combination Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) - + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ImageHeadlineBody.self, viewModelClass: ImageHeadlineBodyModel.self) + // Vertical Combination Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadLineBodyCaretLinkImage.self, viewModelClass: HeadlineBodyCaretLinkImageModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: EyebrowHeadlineBodyLink.self, viewModelClass: EyebrowHeadlineBodyLinkModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyTextButton.self, viewModelClass: HeadlineBodyLinkModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyButton.self, viewModelClass: HeadlineBodyButtonModel.self) // Left Right Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: LeftRightLabelView.self, viewModelClass: LeftRightLabelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: LabelSwitch.self, viewModelClass: LabelToggleModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodySwitch.self, viewModelClass: HeadlineBodyToggleModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyTextButtonSwitch.self, viewModelClass: HeadlineBodyLinkToggleModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: ListItemModel.self) @@ -89,12 +94,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(CheckboxWithLabelView.self, forKey: "checkboxLabel" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButton.self, forKey: "radioButton" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButtonLabel.self, forKey: "radioButtonLabel" as NSString) - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(ActionDetailWithImage.self, forKey: "actionDetailWithImage" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(ImageHeadlineBody.self, forKey: "imageHeadlineBody" as NSString) - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyTextButton.self, forKey: "headlineBodyLink" as NSString) - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyTextButtonSwitch.self, forKey: "headlineBodyLinkToggle" as NSString) - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(HeadlineBodyButton.self, forKey: "headlineBodyButton" as NSString) // TODO: Need View ModelRegistry.register(TabsModel.self) From f438e25556a3d22a518a6f6a2d5210432f53d72c Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 14:34:50 -0500 Subject: [PATCH 214/272] new registation --- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 59e7cdef..cdf64335 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -44,6 +44,8 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Line.self, viewModelClass: LineModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: GraphView.self, viewModelClass: CircleProgressModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxWithLabelView.self, viewModelClass: CheckboxLabelModel.self) // Horizontal Combination Molecules MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) From 791138c34580c3d563f127124c5a86cf252a945c Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 14:36:12 -0500 Subject: [PATCH 215/272] private --- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 72c6dbfd..6bf9ae1a 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -28,7 +28,7 @@ import Foundation public var action: ActionModelProtocol? - enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey { case groupName case value case fieldKey From d78bc7aa584005af3e83749e4ddb0997743ca553 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 14:38:54 -0500 Subject: [PATCH 216/272] moving top --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 185e8d09..61b009b2 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1149,10 +1149,10 @@ D268C711238D6699007F2C1C /* DropDown.swift */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, 94C2D9822386F3E30006CF46 /* Label */, - 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 31BE15CA23D8924C00452370 /* CheckboxModel.swift */, - 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, + 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */, + 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, 943784F3236B77BB006A1E82 /* GraphView.swift */, From 61edfcc747751ab9bd8811dd214f7b437a0759b7 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 14:51:17 -0500 Subject: [PATCH 217/272] fixes --- MVMCoreUI/Atoms/Views/Checkbox.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 6b125e82..07628416 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -477,8 +477,8 @@ import MVMCore self.isRequired = isRequired } - if let borderColorHex = checkboxModel.borderColor { - layer.borderColor = borderColorHex.uiColor.cgColor + if let borderColor = checkboxModel.borderColor { + layer.borderColor = borderColor.cgColor } if let borderWidth = checkboxModel.borderWidth { @@ -495,12 +495,12 @@ import MVMCore checkColor = uiCheckColor } - if let unCheckedBackgroundColorHex = checkboxModel.unCheckedBackgroundColor { - unCheckedBackgroundColor = unCheckedBackgroundColorHex.uiColor + if let unCheckedBackgroundColor = checkboxModel.unCheckedBackgroundColor { + self.unCheckedBackgroundColor = unCheckedBackgroundColor.uiColor } - if let checkedBackgroundColorHex = checkboxModel.checkedBackgroundColor { - checkedBackgroundColor = checkedBackgroundColorHex.uiColor + if let checkedBackgroundColor = checkboxModel.checkedBackgroundColor { + self.checkedBackgroundColor = checkedBackgroundColor.uiColor } if let isAnimated = checkboxModel.isAnimated { From 86ce3c9d4f9f216a1a12f66fa7e8b1fb426e412e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 22 Jan 2020 14:51:27 -0500 Subject: [PATCH 218/272] modeling entryField --- .../TextFields/DateDropdownEntryFieldModel.swift | 2 +- MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift | 3 +-- MVMCoreUI/Atoms/TextFields/EntryField.swift | 1 + MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift | 11 ++++++++--- .../TextFields/ItemDropdownEntryFieldModel.swift | 2 +- MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift | 2 +- MVMCoreUI/Atoms/TextFields/TextEntryField.swift | 4 +--- MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift | 3 +-- .../BaseControllers/MFViewController+Model.swift | 4 ++++ .../OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 8 +++----- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 2 +- MVMCoreUI/Templates/MoleculeListTemplate.swift | 2 +- 12 files changed, 24 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift index d2c9d747..ebccffcd 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift @@ -12,7 +12,7 @@ //-------------------------------------------------- public override class var identifier: String { - return "DateDropdownEntryField" + return "dateDropdownEntryField" } public var dateFormat: String? diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift index bab3f81b..a798eebb 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift @@ -8,13 +8,12 @@ @objcMembers public class DigitEntryFieldModel: TextEntryFieldModel { - //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- public override class var identifier: String { - return "DigitEntryField" + return "digitTextField" } public var digits: Int? diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atoms/TextFields/EntryField.swift index 25b8b670..57d1b0bf 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryField.swift @@ -119,6 +119,7 @@ import UIKit feedbackLabel.text = newFeedback feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true entryFieldContainer.refreshUI() + delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) } } diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index ce6d2207..dbf240ee 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -10,7 +10,6 @@ import Foundation @objcMembers public class EntryFieldModel: MoleculeModelProtocol { - //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -28,7 +27,9 @@ import Foundation public var isSelected: Bool? public var fieldKey: String? - + public var isValid: Bool? + public var isRequired: Bool? + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -38,10 +39,12 @@ import Foundation case title case isDisabled case feedback - case errorMessage + case errorMessage = "errorMsg" case isLocked case isSelected case fieldKey + case isValid + case isRequired = "required" } //-------------------------------------------------- @@ -58,6 +61,7 @@ import Foundation isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked) isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid) } public func encode(to encoder: Encoder) throws { @@ -70,5 +74,6 @@ import Foundation try container.encodeIfPresent(isLocked, forKey: .isLocked) try container.encodeIfPresent(isSelected, forKey: .isSelected) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(isValid, forKey: .isValid) } } diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift index 1d110c57..e1313086 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift @@ -12,7 +12,7 @@ //-------------------------------------------------- public override class var identifier: String { - return "ItemDropdownEntryField" + return "dropDown" } public var options: [String]? diff --git a/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift index d07c7524..ea367447 100644 --- a/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift @@ -12,6 +12,6 @@ //-------------------------------------------------- public override class var identifier: String { - return "MdnEntryField" + return "mdnEntryField" } } diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index a2a9631f..f4381faf 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -308,9 +308,7 @@ import UIKit break } - let regex = model.regex ?? "" - - if !regex.isEmpty { + if let regex = model.regex, !regex.isEmpty { validationBlock = { enteredValue in guard let value = enteredValue else { return false } return MVMCoreUIUtility.validate(value, withRegularExpression: regex) diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift index bd69c908..d890d918 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift @@ -8,13 +8,12 @@ @objcMembers public class TextEntryFieldModel: EntryFieldModel { - //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- public override class var identifier: String { - return "TextEntryField" + return "textField" } public var text: String? diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index 7e250b2a..f503d0b5 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -29,6 +29,10 @@ extension MFViewController: MoleculeDelegateProtocol { } return nil } + + @objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + + } } public extension MFViewController { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 4f2d6e3c..e0c83569 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -35,12 +35,10 @@ @"footer": FooterView.class, @"caretView": CaretView.class, @"caretLink": CaretButton.class, - @"textField": MFTextField.class, - @"digitTextField": MFDigitTextField.class, - @"digitEntryField": DigitEntryField.class, - @"textEntryField": TextEntryField.class, + @"digitTextField": DigitEntryField.class, + @"textField": TextEntryField.class, @"mdnEntryField": MdnEntryField.class, - @"itemDropdownEntryField": ItemDropdownEntryField.class, + @"dropDown": ItemDropdownEntryField.class, @"dateDropdownEntryField": DateDropdownEntryField.class, @"checkbox": Checkbox.class, @"checkboxLabel": CheckboxWithLabelView.class, diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 54ec832c..3972002d 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -33,7 +33,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretButton.self, viewModelClass: CaretLinkModel.self) // Entry Field - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextFieldModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextEntryFieldModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MdnEntryField.self, viewModelClass: MdnEntryFieldModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DigitEntryField.self, viewModelClass: DigitEntryFieldModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ItemDropdownEntryField.self, viewModelClass: ItemDropdownEntryFieldModel.self) diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 61e1121c..920439a1 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -123,7 +123,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } // MARK: - MoleculeDelegateProtocol - open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + open override func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { if let tableView = tableView { let point = molecule.convert(molecule.bounds.origin, to: tableView) if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { From 50f573688fc7e9f64203fafe63f7638d8e6bffb4 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 15:15:13 -0500 Subject: [PATCH 219/272] position --- MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift | 10 ++++++++-- MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift | 10 ++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift index 088f7d9e..79d2ecb3 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift @@ -8,11 +8,17 @@ import Foundation +public enum CheckboxPosition: String, Codable { + case center + case top + case bottom +} + @objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { public static var identifier: String = "checkboxLabel" public var backgroundColor: Color? - public var checkboxAlignment: String? + public var checkboxAlignment: CheckboxPosition? public var checkbox: CheckboxModel public var label: LabelModel @@ -24,7 +30,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.checkboxAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .checkboxAlignment) + self.checkboxAlignment = try typeContainer.decodeIfPresent(CheckboxPosition.self, forKey: .checkboxAlignment) self.checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox) self.label = try typeContainer.decode(LabelModel.self, forKey: .label) } diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift index 69141210..1e0c5590 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift @@ -21,12 +21,6 @@ public var checkboxPosition: CheckboxPosition = .center - public enum CheckboxPosition: String { - case center - case top - case bottom - } - //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -126,8 +120,8 @@ return } - if let checkboxAlignment = checkBoxWithLabelModel.checkboxAlignment, let position = CheckboxPosition(rawValue: checkboxAlignment) { - alignCheckbox(position) + if let checkboxAlignment = checkBoxWithLabelModel.checkboxAlignment { + alignCheckbox(checkboxAlignment) } checkbox.setWithModel(checkBoxWithLabelModel.checkbox, delegateObject, additionalData) From 7c70b0a4a10813fd4e9ed1035935120118cf98c5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 15:32:31 -0500 Subject: [PATCH 220/272] remove methods --- .../Atoms/Views/CheckboxLabelModel.swift | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift index 79d2ecb3..d7ceae36 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift @@ -9,6 +9,7 @@ import Foundation public enum CheckboxPosition: String, Codable { + case left case center case top case bottom @@ -21,24 +22,4 @@ public enum CheckboxPosition: String, Codable { public var checkboxAlignment: CheckboxPosition? public var checkbox: CheckboxModel public var label: LabelModel - - enum CodingKeys: String, CodingKey { - case checkboxAlignment - case checkbox - case label - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.checkboxAlignment = try typeContainer.decodeIfPresent(CheckboxPosition.self, forKey: .checkboxAlignment) - self.checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox) - self.label = try typeContainer.decode(LabelModel.self, forKey: .label) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(checkboxAlignment, forKey: .checkboxAlignment) - try container.encode(checkbox, forKey: .checkbox) - try container.encode(label, forKey: .label) - } } From 9e7df20877031e81e49aa8558a1a180786b431c9 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 15:37:37 -0500 Subject: [PATCH 221/272] left --- MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift index 1e0c5590..fadf3687 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift @@ -112,6 +112,8 @@ checkboxBottomConstraint?.isActive = true checkboxTopConstraint?.isActive = false checkboxCenterYConstraint?.isActive = false + case .left: break + } } From ccb8a2cf524254f1eb5efd5956bda47a3038c8f7 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 22 Jan 2020 15:39:39 -0500 Subject: [PATCH 222/272] weak change --- .../Views/EntryFieldContainer.swift | 2 +- .../views/EntryFieldContainer.swift | 293 ------------------ 2 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 MVMCoreUI/Containers/views/EntryFieldContainer.swift diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index 98e3d661..3f80006a 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -118,7 +118,7 @@ import UIKit //-------------------------------------------------- /// Holds reference to delegateObject to inform molecular tableView of an update. - weak var delegateObject: MVMCoreUIDelegateObject? + var delegateObject: MVMCoreUIDelegateObject? //-------------------------------------------------- // MARK: - Lifecycle diff --git a/MVMCoreUI/Containers/views/EntryFieldContainer.swift b/MVMCoreUI/Containers/views/EntryFieldContainer.swift deleted file mode 100644 index 98e3d661..00000000 --- a/MVMCoreUI/Containers/views/EntryFieldContainer.swift +++ /dev/null @@ -1,293 +0,0 @@ -// -// EntryFieldContainer.swift -// MVMCoreUI -// -// Created by Kevin Christiano on 11/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - - -@objcMembers open class EntryFieldContainer: View { - //-------------------------------------------------- - // MARK: - Drawing Properties - //-------------------------------------------------- - - /// The bottom border line. Height is dynamic based on scenario. - public var bottomBar: CAShapeLayer? = { - let layer = CAShapeLayer() - layer.backgroundColor = UIColor.black.cgColor - layer.drawsAsynchronously = true - layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); - return layer - }() - - /// Total control over the drawn top, bottom, left and right borders. - public var disableAllBorders = false { - didSet { - bottomBar?.isHidden = disableAllBorders - } - } - - private(set) var fieldState: FieldState = .original { - didSet (oldState) { - // Will not update if new state is the same as old. - if fieldState != oldState { - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - self.fieldState.setStateUI(for: self) - } - } - } - } - - /// Determines if the top, left, and right borders should be drawn. - private var hideBorders = false - - public var borderStrokeColor: UIColor = .mfSilver() - private var borderPath: UIBezierPath = UIBezierPath() - - //-------------------------------------------------- - // MARK: - Property Observers - //-------------------------------------------------- - - private var _isEnabled: Bool = true - private var _showError: Bool = false - private var _isLocked: Bool = false - private var _isSelected: Bool = false - - public var isEnabled: Bool { - get { return _isEnabled } - set (enabled) { - - _isEnabled = enabled - _isLocked = false - _isSelected = false - _showError = false - - fieldState = enabled ? .original : .disabled - } - } - - public var showError: Bool { - get { return _showError } - set (error) { - - _showError = error - _isEnabled = true - _isLocked = false - _isSelected = false - - fieldState = error ? .error : .original - } - } - - public var isLocked: Bool { - get { return _isLocked } - set (locked) { - - _isLocked = locked - _isEnabled = true - _isSelected = false - _showError = false - - fieldState = locked ? .locked : .original - } - } - - public var isSelected: Bool { - get { return _isSelected } - set (selected) { - - _isSelected = selected - _isLocked = false - _isEnabled = true - - if _showError { - fieldState = selected ? .selectedError : .error - } else { - fieldState = selected ? .selected : .original - } - } - } - - //-------------------------------------------------- - // MARK: - Delegate - //-------------------------------------------------- - - /// Holds reference to delegateObject to inform molecular tableView of an update. - weak var delegateObject: MVMCoreUIDelegateObject? - - //-------------------------------------------------- - // MARK: - Lifecycle - //-------------------------------------------------- - - open override func layoutSubviews() { - super.layoutSubviews() - - refreshUI(bottomBarSize: showError ? 4 : 1) - } - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - - refreshUI() - } - - /// This handles the top, left, and right border lines. - open override func draw(_ rect: CGRect) { - super.draw(rect) - - borderPath.removeAllPoints() - - if !disableAllBorders && !hideBorders { - // Brings the other half of the line inside the view to prevent cropping. - let origin = bounds.origin - let size = frame.size - let insetLean: CGFloat = 0.5 - borderPath.lineWidth = 1 - - borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height)) - borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean)) - borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean)) - borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + size.height)) - - borderStrokeColor.setStroke() - borderPath.stroke() - } - } - - override open func setupView() { - super.setupView() - - isAccessibilityElement = false - isOpaque = false - - if let bottomBar = bottomBar { - layer.addSublayer(bottomBar) - } - } - - //-------------------------------------------------- - // MARK: - Draw States - //-------------------------------------------------- - - public enum FieldState { - case original - case error - case selectedError - case selected - case locked - case disabled - - public func setStateUI(for formField: EntryFieldContainer) { - - switch self { - case .original: - formField.originalUI() - - case .error: - formField.errorUI() - - case .selectedError: - formField.selectedErrorUI() - - case .selected: - formField.selectedUI() - - case .locked: - formField.lockedUI() - - case .disabled: - formField.disabledUI() - } - } - } - - open func originalUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.black.cgColor - refreshUI(bottomBarSize: 1) - } - - open func errorUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .mfPumpkin() - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor - refreshUI(bottomBarSize: 4) - } - - open func selectedErrorUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor - refreshUI(bottomBarSize: 4) - } - - open func selectedUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.black.cgColor - refreshUI(bottomBarSize: 1) - } - - open func lockedUI() { - - isUserInteractionEnabled = false - hideBorders = true - borderStrokeColor = .clear - bottomBar?.backgroundColor = UIColor.clear.cgColor - refreshUI(bottomBarSize: 1) - } - - open func disabledUI() { - - isUserInteractionEnabled = false - hideBorders = false - borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.mfSilver().cgColor - refreshUI(bottomBarSize: 1) - } - - open func refreshUI(bottomBarSize: CGFloat? = nil) { - - if !disableAllBorders { - let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) - bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) - - delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) - setNeedsDisplay() - layoutIfNeeded() - } - } - - //-------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol - //-------------------------------------------------- - - open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.setWithModel(model, delegateObject, additionalData) - self.delegateObject = delegateObject - } -} - -extension EntryFieldContainer { - - override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - self.delegateObject = delegateObject - - guard let dictionary = json, !dictionary.isEmpty else { return } - } -} From 822180ec9f8e9247d0843f0777e1bd333ddfcd7e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 16:09:36 -0500 Subject: [PATCH 223/272] code fixes --- MVMCoreUI/Atoms/Views/Checkbox.swift | 4 ++-- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 07628416..af039435 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -478,11 +478,11 @@ import MVMCore } if let borderColor = checkboxModel.borderColor { - layer.borderColor = borderColor.cgColor + self.borderColor = borderColor.uiColor } if let borderWidth = checkboxModel.borderWidth { - layer.borderWidth = borderWidth + self.borderWidth = borderWidth } if checkboxModel.isChecked { diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 6bf9ae1a..9be83e91 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -71,7 +71,7 @@ import Foundation try container.encodeIfPresent(required, forKey: .required) try container.encodeIfPresent(borderColor, forKey: .borderColor) try container.encodeIfPresent(borderColor, forKey: .borderColor) - try container.encodeIfPresent(isChecked, forKey: .isChecked) + try container.encode(isChecked, forKey: .isChecked) try container.encodeIfPresent(checkColor, forKey: .checkColor) try container.encodeIfPresent(unCheckedBackgroundColor, forKey: .unCheckedBackgroundColor) try container.encodeIfPresent(checkedBackgroundColor, forKey: .checkedBackgroundColor) From 611246cb14adb3573aa5cac4c878bc8021da171b Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 17:14:08 -0500 Subject: [PATCH 224/272] remove left --- MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift | 1 - MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift | 1 - 2 files changed, 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift index d7ceae36..5a9d09f0 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift @@ -9,7 +9,6 @@ import Foundation public enum CheckboxPosition: String, Codable { - case left case center case top case bottom diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift index fadf3687..e559069d 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift @@ -112,7 +112,6 @@ checkboxBottomConstraint?.isActive = true checkboxTopConstraint?.isActive = false checkboxCenterYConstraint?.isActive = false - case .left: break } } From 15a943d2e7da5e1593f0e0347bc3543cc83566e5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 23 Jan 2020 09:31:33 -0500 Subject: [PATCH 225/272] Changed stack to use a percent modifier to compensate for spacing. --- MVMCoreUI/Organisms/MoleculeStackView.swift | 20 +++++++++---- MVMCoreUI/Organisms/Stack.swift | 33 +++++++++++++++------ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index afc1f954..d6f934a7 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -14,11 +14,21 @@ open class MoleculeStackView: Stack { } /// Convenience function, adds a molecule to a MoleculeStackItem to the MoleculeStack - func addMolecule(_ view: View, lastItem: Bool) { - guard let model = view.model else { return } - let stackItemModel = MoleculeStackItemModel(with: model) - let stackItem = MoleculeStackItem(andContain: view) - addView(stackItem, stackItemModel, lastItem: lastItem) + 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 diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index a92d5a2f..2ab77421 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -31,8 +31,10 @@ open class Stack: Container where T: StackModelProtocol { let lastItemIndex = stackModel.molecules.lastIndex(where: { (item) -> Bool in return !item.gone }) + + // Adds the views for (index, view) in stackItems.enumerated() { - addView(view, stackModel.molecules[index], lastItem: lastItemIndex == index) + addView(view, stackModel.molecules[index], percentModifier: getPercentModifier(), lastItem: lastItemIndex == index) } } @@ -170,15 +172,28 @@ open class Stack: Container where T: StackModelProtocol { } // MARK: - Adding to stack - /// Convenience function, adds a view to a StackItem to the Stack - func addViewToItemToStack(_ view: UIView, lastItem: Bool) { - let stackItemModel = StackItemModel() - let stackItem = StackItem(andContain: view) - addView(stackItem, stackItemModel, lastItem: lastItem) + /// Gets the percent modifier. This value is used to help properly calculate percent for stack items when spacing is involved. + private func getPercentModifier() -> CGFloat { + guard let stackModel = stackModel else { return 0.0 } + var totalSpace: CGFloat = 0.0 + var totalViews = 0 + var firstMoleculeFound = false + for stackItemModel in stackModel.molecules { + guard !stackItemModel.gone else { continue } + totalViews += 1 + let spacing = stackItemModel.spacing ?? stackModel.spacing + if firstMoleculeFound { + totalSpace += spacing + } else { + firstMoleculeFound = true + totalSpace += (stackModel.useStackSpacingBeforeFirstItem ? spacing : stackItemModel.spacing ?? 0) + } + } + return (totalViews > 0 ? -(totalSpace / CGFloat(totalViews)) : 0) } /// Adds the stack item view - func addView(_ view: UIView,_ model: StackItemModelProtocol, lastItem: Bool) { + private func addView(_ view: UIView,_ model: StackItemModelProtocol, percentModifier: CGFloat, lastItem: Bool) { guard let stackModel = self.stackModel else { return } guard !model.gone else { // Gone views do not show @@ -208,7 +223,7 @@ open class Stack: Container where T: StackModelProtocol { pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0) if let percent = model.percent { - view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true + view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0, constant: percentModifier).isActive = true } if lastItem { pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) @@ -225,7 +240,7 @@ open class Stack: Container where T: StackModelProtocol { pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) if let percent = model.percent { - view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true + view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0, constant: percentModifier).isActive = true } if lastItem { pinView(contentView, toView: view, attribute: .right, relation: .equal, priority: .required, constant: 0) From b80cd421cfc19a224028945ccf19bb201fd3d603 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 23 Jan 2020 10:24:11 -0500 Subject: [PATCH 226/272] height fixes --- MVMCoreUI/Atoms/Views/Toggle.swift | 5 +++ .../SwitchMolecules/HeadlineBodySwitch.swift | 28 ++++----------- .../SwitchMolecules/LabelSwitch.swift | 36 +++++++------------ .../HeadlineBody.swift | 5 +++ 4 files changed, 28 insertions(+), 46 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 899c1edb..73a8ec2f 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -333,6 +333,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) } } + // MARK:- ModelMoleculeViewProtocol public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let toggleModel = model as? ToggleModel else { return @@ -341,6 +342,10 @@ public typealias ActionBlockConfirmation = () -> (Bool) let toggleModelJSON = toggleModel.toJSON() setWithJSON(toggleModelJSON, delegateObject: delegateObject, additionalData: additionalData) } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return Self.getContainerHeight() + } } // MARK: - Accessibility diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 09432dce..597f1059 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -34,9 +34,7 @@ import UIKit NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: toggle) } - - //MARK: - MVMCoreMoleculeViewProtocol - + // MARK:- ModelMoleculeViewProtocol open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let headlineBodyToggleModel = model as? HeadlineBodyToggleModel else { @@ -46,31 +44,17 @@ import UIKit } public class override func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 30 + guard let model = molecule as? HeadlineBodyToggleModel, + let toggleHeight = Toggle.estimatedHeight(forRow: model.toggle, delegateObject: delegateObject), + let headlineBody = HeadlineBody.estimatedHeight(forRow: model.headlineBody, delegateObject: delegateObject) else { return nil } + return max(toggleHeight, headlineBody) } - // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - toggle.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) - } - - open class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 30 - } - - open override func setAsMolecule() { - headlineBody.setAsMolecule() - (toggle as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() - headlineBody.styleListItem() - } - open override func reset() { super.reset() headlineBody.reset() - (toggle as MVMCoreUIMoleculeViewProtocol).reset?() + toggle.reset() headlineBody.styleListItem() } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift index 0e87e7c7..dcb8dd58 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers public class LabelSwitch: ViewConstrainingView, ModelMoleculeViewProtocol { +@objcMembers public class LabelSwitch: View { let label = Label.commonLabelB1(true) let mvmSwitch = Toggle() @@ -24,24 +24,22 @@ import UIKit guard mvmSwitch.superview == nil else { return } - let view = MVMCoreUICommonViewsUtility.commonView() - addSubview(view) - pinView(toSuperView: view) - view.addSubview(label) - view.addSubview(mvmSwitch) + addSubview(label) + addSubview(mvmSwitch) label.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) NSLayoutConstraint.pinSubviewsCenter(leftView: label, rightView: mvmSwitch) } - // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) + // MARK:- ModelMoleculeViewProtocol + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + guard let model = molecule as? LabelToggleModel, + let toggleHeight = Toggle.estimatedHeight(forRow: model.toggle, delegateObject: delegateObject), + let labelHeight = Label.estimatedHeight(forRow: model.label, delegateObject: delegateObject) else { return nil } + return max(toggleHeight, labelHeight) } - - public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let labelToggleModel = model as? LabelToggleModel else { return } @@ -49,17 +47,7 @@ import UIKit mvmSwitch.setWithModel(labelToggleModel.toggle, delegateObject, additionalData) } - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return MVMCoreUISwitch.estimatedHeight(forRow: json, delegateObject: delegateObject) - } - - public override func setAsMolecule() { - super.setAsMolecule() - label.setAsMolecule() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() - label.styleB1(true) - } - + // MARK: - MVMCoreUIMoleculeViewProtocol public override func reset() { super.reset() label.reset() diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index 8cdb5633..3a270ad5 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -119,6 +119,11 @@ open class HeadlineBody: View { } } + // MARK:- ModelMoleculeViewProtocol + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 58 + } + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) From 8a09424dbe9cef6761de8514ffe16ff554998746 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 10:27:36 -0500 Subject: [PATCH 227/272] Removed and added file back. Something was corrupted with the path name. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 83a1815f..9b80960e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -90,9 +90,9 @@ 0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */; }; 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */; }; 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; }; - 0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */; }; 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; }; + 0ACDF26723D9F177002044B2 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ACDF26623D9F177002044B2 /* EntryFieldContainer.swift */; }; 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; @@ -390,9 +390,9 @@ 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = ""; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; - 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = ""; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = ""; }; + 0ACDF26623D9F177002044B2 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; @@ -696,8 +696,8 @@ 0ABD1369237B18EE0081388D /* Views */ = { isa = PBXGroup; children = ( + 0ACDF26623D9F177002044B2 /* EntryFieldContainer.swift */, D29E28DE23D740FC00ACEA85 /* Container */, - 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */, 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */, D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, ); @@ -1493,6 +1493,7 @@ 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, + 0ACDF26723D9F177002044B2 /* EntryFieldContainer.swift in Sources */, D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, @@ -1696,7 +1697,6 @@ D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, - 0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, From a2b62767bd5657df05b2ccfe732e71ecd971caf5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 23 Jan 2020 10:33:56 -0500 Subject: [PATCH 228/272] base classes open ModelMoleculeViewProtocol functions --- MVMCoreUI/BaseClasses/Button.swift | 8 ++++---- MVMCoreUI/BaseClasses/Control.swift | 8 ++++---- MVMCoreUI/BaseClasses/View.swift | 6 +++--- .../SwitchMolecules/HeadlineBodySwitch.swift | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 7909d1dd..0c5d4bec 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -84,22 +84,22 @@ public typealias ButtonAction = (Button) -> () } // MARK:- ModelMoleculeViewProtocol - public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor } } - public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + open class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model?.moleculeName } - public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } - public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + open class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } } diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 8f0e9edb..ed1c1874 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -48,22 +48,22 @@ import UIKit } // MARK:- ModelMoleculeViewProtocol - public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor } } - public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + open class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model?.moleculeName } - public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } - public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + open class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index d641490e..a117d60a 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -47,15 +47,15 @@ import UIKit } } - public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + open class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model?.moleculeName } - public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } - public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + open class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 597f1059..1dbefcfe 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -43,7 +43,7 @@ import UIKit setWithJSON(headlineBodyToggleModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } - public class override func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open class override func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let model = molecule as? HeadlineBodyToggleModel, let toggleHeight = Toggle.estimatedHeight(forRow: model.toggle, delegateObject: delegateObject), let headlineBody = HeadlineBody.estimatedHeight(forRow: model.headlineBody, delegateObject: delegateObject) else { return nil } From e0abe4c8cd6ed62f6d6107f4de8dad5ca460758d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 23 Jan 2020 10:40:17 -0500 Subject: [PATCH 229/272] More opening --- .../SwitchMolecules/LabelSwitch.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift index dcb8dd58..b2cb5069 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift @@ -8,9 +8,9 @@ import UIKit -@objcMembers public class LabelSwitch: View { - let label = Label.commonLabelB1(true) - let mvmSwitch = Toggle() +@objcMembers open class LabelSwitch: View { + public let label = Label.commonLabelB1(true) + public let mvmSwitch = Toggle() // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { @@ -19,7 +19,7 @@ import UIKit mvmSwitch.updateView(size) } - public override func setupView() { + open override func setupView() { super.setupView() guard mvmSwitch.superview == nil else { return @@ -32,14 +32,14 @@ import UIKit } // MARK:- ModelMoleculeViewProtocol - public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let model = molecule as? LabelToggleModel, let toggleHeight = Toggle.estimatedHeight(forRow: model.toggle, delegateObject: delegateObject), let labelHeight = Label.estimatedHeight(forRow: model.label, delegateObject: delegateObject) else { return nil } return max(toggleHeight, labelHeight) } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let labelToggleModel = model as? LabelToggleModel else { return } @@ -48,7 +48,7 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol - public override func reset() { + open override func reset() { super.reset() label.reset() (mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?() From d3edf62a943af8c3448ef478c2ce2e93db64ae28 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 23 Jan 2020 10:42:39 -0500 Subject: [PATCH 230/272] toggle name change --- .../SwitchMolecules/LabelSwitch.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift index b2cb5069..a7688121 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift @@ -10,25 +10,25 @@ import UIKit @objcMembers open class LabelSwitch: View { public let label = Label.commonLabelB1(true) - public let mvmSwitch = Toggle() + public let toggle = Toggle() // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) label.updateView(size) - mvmSwitch.updateView(size) + toggle.updateView(size) } open override func setupView() { super.setupView() - guard mvmSwitch.superview == nil else { + guard toggle.superview == nil else { return } addSubview(label) - addSubview(mvmSwitch) + addSubview(toggle) label.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) - NSLayoutConstraint.pinSubviewsCenter(leftView: label, rightView: mvmSwitch) + NSLayoutConstraint.pinSubviewsCenter(leftView: label, rightView: toggle) } // MARK:- ModelMoleculeViewProtocol @@ -44,14 +44,14 @@ import UIKit return } label.setWithModel(labelToggleModel.label, delegateObject, additionalData) - mvmSwitch.setWithModel(labelToggleModel.toggle, delegateObject, additionalData) + toggle.setWithModel(labelToggleModel.toggle, delegateObject, additionalData) } // MARK: - MVMCoreUIMoleculeViewProtocol open override func reset() { super.reset() label.reset() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?() + toggle.reset() label.styleB1(true) } } From abc854e152222889403ed365ae0a5044890bb637 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 23 Jan 2020 11:01:36 -0500 Subject: [PATCH 231/272] List template change to molecules not required (for now) --- MVMCoreUI/Templates/ListPageTemplateModel.swift | 10 +++------- MVMCoreUI/Templates/MoleculeListTemplate.swift | 13 +++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index d639d6f1..fe9c12c5 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -17,7 +17,7 @@ import Foundation public var isAtomicTabs: Bool? public var header: MoleculeModelProtocol? - public var molecules: [ListItemModelProtocol] + public var molecules: [ListItemModelProtocol]? public var footer: MoleculeModelProtocol? public var line: LineModel? @@ -42,11 +42,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) pageType = try typeContainer.decode(String.self, forKey: .pageType) screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) - - guard let molecules = try typeContainer.decodeMolecules(codingKey: .molecules) as? [ListItemModelProtocol] else { - throw JSONError.pathNotFound - } - self.molecules = molecules + molecules = try typeContainer.decodeMoleculesIfPresent(codingKey: .molecules) as? [ListItemModelProtocol] isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header) footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer) @@ -57,7 +53,7 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(pageType, forKey: .pageType) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) - try container.encodeModels(molecules, forKey: .molecules) + try container.encodeModelsIfPresent(molecules, forKey: .molecules) try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) try container.encodeModelIfPresent(header, forKey: .header) try container.encodeModelIfPresent(footer, forKey: .footer) diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 61e1121c..26310021 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -53,6 +53,19 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol return molecule } + open override func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { + let shouldFinish = super.shouldFinishProcessingLoad(loadObject, error: error) + // This template requires atleast one of the three layers. + if templateModel?.header == nil, + templateModel?.molecules?.count ?? 0 == 0, + templateModel?.footer == nil, + let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), messageToLog: "List template requires atleast one of the following: header, footer, molecules", code: CoreUIErrorCode.ErrorCodeListMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { + error.pointee = errorObject + return false + } + return shouldFinish + } + open override func newDataBuildScreen() { super.newDataBuildScreen() setup() From ac17015a09bb3dc8a0726546d69535d0a52e5772 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 23 Jan 2020 11:10:28 -0500 Subject: [PATCH 232/272] container model --- MVMCoreUI/Molecules/Items/DropDownListItemModel.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index c7b9ca75..7fb8e59e 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class DropDownListItemModel: MoleculeContainerModel, ListItemModelProtocol { +@objcMembers public class DropDownListItemModel: ContainerModel, ListItemModelProtocol { public static var identifier: String = "dropDownListItem" public var molecules: [[ListItemModelProtocol]] public var dropDown: DropDownModel @@ -16,10 +16,10 @@ import Foundation public var line: LineModel? = LineModel(type: .none) public var hideArrow: Bool? = true - public init(molecule: MoleculeModelProtocol, molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { + public init(molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { self.molecules = molecules self.dropDown = dropDown - super.init(with: molecule) + super.init() } private enum CodingKeys: String, CodingKey { From 4cc5a15db96c48476867a76901e3ff6ceb343bb0 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 12:12:45 -0500 Subject: [PATCH 233/272] checkbox modeling. Strange issue with EntryFieldContainer. To be observed. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +- MVMCoreUI/Atoms/Views/Checkbox.swift | 128 +++----- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 48 +-- .../views/EntryFieldContainer.swift | 285 ------------------ 4 files changed, 76 insertions(+), 393 deletions(-) delete mode 100644 MVMCoreUI/Containers/views/EntryFieldContainer.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 61b009b2..f36a6094 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -84,9 +84,9 @@ 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; }; - 0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */; }; 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; }; + 0ACDF26B23DA0AC2002044B2 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ACDF26A23DA0AC2002044B2 /* EntryFieldContainer.swift */; }; 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; @@ -381,9 +381,9 @@ 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = ""; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; - 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = ""; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = ""; }; + 0ACDF26A23DA0AC2002044B2 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = ""; }; 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; @@ -691,7 +691,7 @@ isa = PBXGroup; children = ( D29E28DE23D740FC00ACEA85 /* Container */, - 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */, + 0ACDF26A23DA0AC2002044B2 /* EntryFieldContainer.swift */, 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */, D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, ); @@ -1603,6 +1603,7 @@ 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */, D274CA332236A78900B01B62 /* FooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, + 0ACDF26B23DA0AC2002044B2 /* EntryFieldContainer.swift in Sources */, 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, @@ -1684,7 +1685,6 @@ D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, - 0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index af039435..a5820271 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -76,6 +76,24 @@ import MVMCore } } + open override var isEnabled: Bool { + didSet { + + isUserInteractionEnabled = isEnabled + + if isEnabled { + layer.borderColor = borderColor.cgColor + backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor + setShapeLayerStrokeColor(checkColor) + } else { + layer.borderColor = UIColor.mfSilver().cgColor + backgroundColor = .clear + setShapeLayerStrokeColor(UIColor.mfSilver()) + } + } + } + // public var disabledColor: (check: UIColor?, background: UIColor?, border: UIColor?) + /// Color of the check mark. public var checkColor: UIColor = .black { didSet { @@ -107,7 +125,6 @@ import MVMCore if !updateSelectionOnly { layoutIfNeeded() shapeLayer?.removeAllAnimations() - updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated) FormValidator.enableByValidationWith(delegate: delegateObject?.formValidationProtocol) updateAccessibilityLabel() @@ -154,16 +171,12 @@ import MVMCore public convenience init(isChecked: Bool) { self.init(frame: .zero) - updateSelectionOnly = true - isSelected = isChecked - updateSelectionOnly = false + checkAndBypassAnimations(selected: isChecked) } public convenience init(checkedBackgroundColor: UIColor, unCheckedBackgroundColor: UIColor, isChecked: Bool = false) { self.init(frame: .zero) - updateSelectionOnly = true - isSelected = isChecked - updateSelectionOnly = false + checkAndBypassAnimations(selected: isChecked) self.checkedBackgroundColor = checkedBackgroundColor self.unCheckedBackgroundColor = unCheckedBackgroundColor } @@ -177,8 +190,6 @@ import MVMCore drawShapeLayer() layer.cornerRadius = isRound ? cornerRadiusValue : 0 - layer.borderWidth = borderWidth - layer.borderColor = borderColor.cgColor } open override func setupView() { @@ -268,9 +279,7 @@ import MVMCore DispatchQueue.main.async { - self.updateSelectionOnly = true - self.isSelected = selected - self.updateSelectionOnly = false + self.checkAndBypassAnimations(selected: selected) self.drawShapeLayer() self.shapeLayer?.removeAllAnimations() self.updateCheckboxUI(isSelected: selected, isAnimated: animated) @@ -313,23 +322,6 @@ import MVMCore } } - func isEnabled(_ enabled: Bool) { - - isUserInteractionEnabled = enabled - - if enabled { - layer.borderColor = borderColor.cgColor - backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor - alpha = 1.0 - setShapeLayerStrokeColor(checkColor) - } else { - layer.borderColor = UIColor.mfSilver().cgColor - backgroundColor = .clear - alpha = DisableOppacity - setShapeLayerStrokeColor(UIColor.mfSilver()) - } - } - private func setShapeLayerStrokeColor(_ color: UIColor) { if let shapeLayer = shapeLayer { @@ -345,13 +337,19 @@ import MVMCore widthConstraint?.isActive = isActive } + private func checkAndBypassAnimations(selected: Bool) { + updateSelectionOnly = true + isSelected = selected + updateSelectionOnly = false + } + //-------------------------------------------------- // MARK: - UITouch //-------------------------------------------------- open override func touchesEnded(_ touches: Set, with event: UIEvent?) { - sendActions(for: .touchUpInside) + sendActions(for: .touchUpInside) } override open func accessibilityActivate() -> Bool { @@ -370,7 +368,7 @@ import MVMCore open override func reset() { super.reset() - isEnabled(true) + isEnabled = true shapeLayer?.removeAllAnimations() shapeLayer?.removeFromSuperlayer() shapeLayer = nil @@ -379,9 +377,7 @@ import MVMCore borderWidth = 1.0 checkColor = .black checkWidth = 2.0 - updateSelectionOnly = true - isSelected = false - updateSelectionOnly = false + checkAndBypassAnimations(selected: false) } open func setAsMolecule() { @@ -425,9 +421,7 @@ import MVMCore } if let isChecked = dictionary["isChecked"] as? Bool, isChecked { - updateSelectionOnly = true - isSelected = isChecked - updateSelectionOnly = false + checkAndBypassAnimations(selected: isChecked) } if let checkColorHex = dictionary["checkColor"] as? String { @@ -451,7 +445,7 @@ import MVMCore } if let enabled = dictionary["isEnabled"] as? Bool { - isEnabled(enabled) + isEnabled = enabled } if let actionMap = dictionary.optionalDictionaryForKey("action") { @@ -459,61 +453,35 @@ import MVMCore } } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let checkboxModel = model as? CheckboxModel else { - return - } + + guard let checkboxModel = model as? CheckboxModel else { return } + self.delegateObject = delegateObject FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol) - + groupName = checkboxModel.groupName fieldValue = checkboxModel.value + isRequired = checkboxModel.required + if let fieldKey = checkboxModel.fieldKey { self.fieldKey = fieldKey } - if let isRequired = checkboxModel.required { - self.isRequired = isRequired - } - - if let borderColor = checkboxModel.borderColor { - self.borderColor = borderColor.uiColor - } - - if let borderWidth = checkboxModel.borderWidth { - self.borderWidth = borderWidth - } + borderColor = checkboxModel.borderColor.uiColor + borderWidth = checkboxModel.borderWidth if checkboxModel.isChecked { - updateSelectionOnly = true - isSelected = checkboxModel.isChecked - updateSelectionOnly = false + checkAndBypassAnimations(selected: checkboxModel.isChecked) } - if let uiCheckColor = checkboxModel.checkColor?.uiColor { - checkColor = uiCheckColor - } - - if let unCheckedBackgroundColor = checkboxModel.unCheckedBackgroundColor { - self.unCheckedBackgroundColor = unCheckedBackgroundColor.uiColor - } - - if let checkedBackgroundColor = checkboxModel.checkedBackgroundColor { - self.checkedBackgroundColor = checkedBackgroundColor.uiColor - } - - if let isAnimated = checkboxModel.isAnimated { - self.isAnimated = isAnimated - } - - if let isRound = checkboxModel.isRound { - self.isRound = isRound - } - - if let enabled = checkboxModel.isEnabled { - isEnabled(enabled) - } + checkColor = checkboxModel.checkColor.uiColor + unCheckedBackgroundColor = checkboxModel.unCheckedBackgroundColor.uiColor + checkedBackgroundColor = checkboxModel.checkedBackgroundColor.uiColor + isAnimated = checkboxModel.isAnimated + isRound = checkboxModel.isRound + isEnabled = checkboxModel.isEnabled if let action = checkboxModel.action { actionBlock = { diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 9be83e91..91a14a90 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -15,16 +15,16 @@ import Foundation public var groupName: String? public var value: String? public var fieldKey: String? - public var required: Bool? - public var borderColor: Color? - public var borderWidth: CGFloat? + public var required: Bool + public var borderColor: Color + public var borderWidth: CGFloat = 1 public var isChecked: Bool = false - public var checkColor: Color? - public var unCheckedBackgroundColor: Color? - public var checkedBackgroundColor: Color? - public var isAnimated: Bool? - public var isRound: Bool? - public var isEnabled: Bool? + public var checkColor: Color + public var unCheckedBackgroundColor: Color + public var checkedBackgroundColor: Color + public var isAnimated: Bool = true + public var isRound: Bool = false + public var isEnabled: Bool = true public var action: ActionModelProtocol? @@ -47,20 +47,20 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) - self.value = try typeContainer.decodeIfPresent(String.self, forKey: .value) - self.fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - self.required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) - self.borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) - self.borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) - self.isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) ?? false - self.checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) - self.unCheckedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .unCheckedBackgroundColor) - self.checkedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkedBackgroundColor) - self.isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) - self.isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) - self.isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) - self.action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) + value = try typeContainer.decodeIfPresent(String.self, forKey: .value) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) ?? false + borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) ?? 1 + borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) ?? Color(uiColor: .black) + checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) ?? Color(uiColor: .black) + unCheckedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .unCheckedBackgroundColor) ?? Color(uiColor: .clear) + checkedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkedBackgroundColor) ?? Color(uiColor: .clear) + isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) ?? false + isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) ?? true + isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) ?? false + isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? true + action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) } public func encode(to encoder: Encoder) throws { @@ -70,7 +70,7 @@ import Foundation try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(required, forKey: .required) try container.encodeIfPresent(borderColor, forKey: .borderColor) - try container.encodeIfPresent(borderColor, forKey: .borderColor) + try container.encode(borderWidth, forKey: .borderWidth) try container.encode(isChecked, forKey: .isChecked) try container.encodeIfPresent(checkColor, forKey: .checkColor) try container.encodeIfPresent(unCheckedBackgroundColor, forKey: .unCheckedBackgroundColor) diff --git a/MVMCoreUI/Containers/views/EntryFieldContainer.swift b/MVMCoreUI/Containers/views/EntryFieldContainer.swift deleted file mode 100644 index 96a51a8f..00000000 --- a/MVMCoreUI/Containers/views/EntryFieldContainer.swift +++ /dev/null @@ -1,285 +0,0 @@ -// -// EntryFieldContainer.swift -// MVMCoreUI -// -// Created by Kevin Christiano on 11/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - - -@objcMembers open class EntryFieldContainer: View { - //-------------------------------------------------- - // MARK: - Drawing Properties - //-------------------------------------------------- - - /// The bottom border line. Height is dynamic based on scenario. - public var bottomBar: CAShapeLayer? = { - let layer = CAShapeLayer() - layer.backgroundColor = UIColor.black.cgColor - layer.drawsAsynchronously = true - layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); - return layer - }() - - /// Total control over the drawn top, bottom, left and right borders. - public var disableAllBorders = false { - didSet { - bottomBar?.isHidden = disableAllBorders - } - } - - private(set) var fieldState: FieldState = .original { - didSet (oldState) { - // Will not update if new state is the same as old. - if fieldState != oldState { - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - self.fieldState.setStateUI(for: self) - } - } - } - } - - /// Determines if the top, left, and right borders should be drawn. - private var hideBorders = false - - public var borderStrokeColor: UIColor = .mfSilver() - private var borderPath: UIBezierPath = UIBezierPath() - - //-------------------------------------------------- - // MARK: - Property Observers - //-------------------------------------------------- - - private var _isEnabled: Bool = true - private var _showError: Bool = false - private var _isLocked: Bool = false - private var _isSelected: Bool = false - - public var isEnabled: Bool { - get { return _isEnabled } - set (enabled) { - - _isEnabled = enabled - _isLocked = false - _isSelected = false - _showError = false - - fieldState = enabled ? .original : .disabled - } - } - - public var showError: Bool { - get { return _showError } - set (error) { - - _showError = error - _isEnabled = true - _isLocked = false - _isSelected = false - - fieldState = error ? .error : .original - } - } - - public var isLocked: Bool { - get { return _isLocked } - set (locked) { - - _isLocked = locked - _isEnabled = true - _isSelected = false - _showError = false - - fieldState = locked ? .locked : .original - } - } - - public var isSelected: Bool { - get { return _isSelected } - set (selected) { - - _isSelected = selected - _isLocked = false - _isEnabled = true - - if _showError { - fieldState = selected ? .selectedError : .error - } else { - fieldState = selected ? .selected : .original - } - } - } - - //-------------------------------------------------- - // MARK: - Delegate - //-------------------------------------------------- - - /// Holds reference to delegateObject to inform molecular tableView of an update. - weak var delegateObject: MVMCoreUIDelegateObject? - - //-------------------------------------------------- - // MARK: - Lifecycle - //-------------------------------------------------- - - open override func layoutSubviews() { - super.layoutSubviews() - - refreshUI(bottomBarSize: showError ? 4 : 1) - } - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - - refreshUI() - } - - /// This handles the top, left, and right border lines. - open override func draw(_ rect: CGRect) { - super.draw(rect) - - borderPath.removeAllPoints() - - if !disableAllBorders && !hideBorders { - // Brings the other half of the line inside the view to prevent cropping. - let origin = bounds.origin - let size = frame.size - let insetLean: CGFloat = 0.5 - borderPath.lineWidth = 1 - - borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height)) - borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean)) - borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean)) - borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + size.height)) - - borderStrokeColor.setStroke() - borderPath.stroke() - } - } - - override open func setupView() { - super.setupView() - - isAccessibilityElement = false - isOpaque = false - - if let bottomBar = bottomBar { - layer.addSublayer(bottomBar) - } - } - - //-------------------------------------------------- - // MARK: - Draw States - //-------------------------------------------------- - - public enum FieldState { - case original - case error - case selectedError - case selected - case locked - case disabled - - public func setStateUI(for formField: EntryFieldContainer) { - - switch self { - case .original: - formField.originalUI() - - case .error: - formField.errorUI() - - case .selectedError: - formField.selectedErrorUI() - - case .selected: - formField.selectedUI() - - case .locked: - formField.lockedUI() - - case .disabled: - formField.disabledUI() - } - } - } - - open func originalUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.black.cgColor - refreshUI(bottomBarSize: 1) - } - - open func errorUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .mfPumpkin() - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor - refreshUI(bottomBarSize: 4) - } - - open func selectedErrorUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor - refreshUI(bottomBarSize: 4) - } - - open func selectedUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.black.cgColor - refreshUI(bottomBarSize: 1) - } - - open func lockedUI() { - - isUserInteractionEnabled = false - hideBorders = true - borderStrokeColor = .clear - bottomBar?.backgroundColor = UIColor.clear.cgColor - refreshUI(bottomBarSize: 1) - } - - open func disabledUI() { - - isUserInteractionEnabled = false - hideBorders = false - borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.mfSilver().cgColor - refreshUI(bottomBarSize: 1) - } - - open func refreshUI(bottomBarSize: CGFloat? = nil) { - - if !disableAllBorders { - let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) - bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) - - delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) - setNeedsDisplay() - layoutIfNeeded() - } - } -} - -// MARK:- MVMCoreUIMoleculeViewProtocol -extension EntryFieldContainer { - - override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - self.delegateObject = delegateObject - - guard let dictionary = json, !dictionary.isEmpty else { return } - } -} From 2100468899550ab04fa08fc86cfb9abf6389f8a7 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 12:32:33 -0500 Subject: [PATCH 234/272] disabled colors --- MVMCoreUI/Atoms/Views/Checkbox.swift | 8 ++++--- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 24 +++++++++++++++---- .../Atoms/Views/CheckboxWithLabelView.swift | 7 ++---- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index a5820271..796496c8 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -86,13 +86,15 @@ import MVMCore backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor setShapeLayerStrokeColor(checkColor) } else { - layer.borderColor = UIColor.mfSilver().cgColor - backgroundColor = .clear + layer.borderColor = disabledBorderColor.cgColor + backgroundColor = disabledBackgroundColor setShapeLayerStrokeColor(UIColor.mfSilver()) } } } - // public var disabledColor: (check: UIColor?, background: UIColor?, border: UIColor?) + + public var disabledBackgroundColor: UIColor = .clear + public var disabledBorderColor: UIColor = .mvmCoolGray3 /// Color of the check mark. public var checkColor: UIColor = .black { diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 91a14a90..6ff55696 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -9,24 +9,34 @@ import Foundation @objcMembers public class CheckboxModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "checkbox" public var backgroundColor: Color? public var groupName: String? public var value: String? public var fieldKey: String? - public var required: Bool - public var borderColor: Color + public var required: Bool = false + public var borderColor: Color = Color(uiColor: .black) public var borderWidth: CGFloat = 1 public var isChecked: Bool = false - public var checkColor: Color - public var unCheckedBackgroundColor: Color - public var checkedBackgroundColor: Color + public var checkColor: Color = Color(uiColor: .black) + public var unCheckedBackgroundColor: Color = Color(uiColor: .clear) + public var checkedBackgroundColor: Color = Color(uiColor: .clear) public var isAnimated: Bool = true public var isRound: Bool = false public var isEnabled: Bool = true public var action: ActionModelProtocol? + + public var disabledBackgroundColor: Color = Color(uiColor: .black) + public var disabledBorderColor: Color = Color(uiColor: .black) + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case groupName @@ -45,6 +55,10 @@ import Foundation case action } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift index e559069d..bc23db73 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift @@ -112,14 +112,11 @@ checkboxBottomConstraint?.isActive = true checkboxTopConstraint?.isActive = false checkboxCenterYConstraint?.isActive = false - } } - open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let checkBoxWithLabelModel = model as? CheckboxLabelModel else { - return - } + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let checkBoxWithLabelModel = model as? CheckboxLabelModel else { return } if let checkboxAlignment = checkBoxWithLabelModel.checkboxAlignment { alignCheckbox(checkboxAlignment) From 5d23b8329fff94bff735607731cf971c0d23e253 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 23 Jan 2020 12:54:34 -0500 Subject: [PATCH 235/272] list item fix --- MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift | 8 +++++--- MVMCoreUI/Molecules/Items/TableViewCell.swift | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index f55f9645..56ff1ca9 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -13,12 +13,14 @@ import UIKit // MARK: - MVMCoreUIMoleculeViewProtocol public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let moleculeModel = (model as? ListItemModel)?.molecule else { return } + guard let model = model as? ListItemModel else { return } if molecule != nil { - (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData) - } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, false) { + (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model.molecule, delegateObject, additionalData) + } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model.molecule, delegateObject, false) { addMolecule(moleculeView) } + + containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) } public override class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 900e6dd0..9daec27d 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -168,9 +168,6 @@ import UIKit addSeparatorsIfNeeded() bottomSeparatorView?.setWithModel(separator, nil, nil) } - - guard let molecule = molecule else { return } - containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) } open func reset() { From ea40da2c90a66284292671a2ad8771669654c5ce Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 12:55:21 -0500 Subject: [PATCH 236/272] diabled functionality --- MVMCoreUI/Atoms/Views/Checkbox.swift | 50 +++++++++++++---------- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 15 +++++-- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 796496c8..27bed31e 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -88,13 +88,14 @@ import MVMCore } else { layer.borderColor = disabledBorderColor.cgColor backgroundColor = disabledBackgroundColor - setShapeLayerStrokeColor(UIColor.mfSilver()) + setShapeLayerStrokeColor(disabledCheckColor) } } } public var disabledBackgroundColor: UIColor = .clear public var disabledBorderColor: UIColor = .mvmCoolGray3 + public var disabledCheckColor: UIColor = .mvmCoolGray3 /// Color of the check mark. public var checkColor: UIColor = .black { @@ -241,7 +242,7 @@ import MVMCore self.shapeLayer = shapeLayer shapeLayer.frame = bounds layer.addSublayer(shapeLayer) - shapeLayer.strokeColor = checkColor.cgColor + shapeLayer.strokeColor = isEnabled ? checkColor.cgColor : disabledCheckColor.cgColor shapeLayer.fillColor = UIColor.clear.cgColor shapeLayer.path = checkMarkPath() shapeLayer.lineJoin = .miter @@ -422,14 +423,14 @@ import MVMCore layer.borderWidth = borderWidth } - if let isChecked = dictionary["isChecked"] as? Bool, isChecked { - checkAndBypassAnimations(selected: isChecked) - } - if let checkColorHex = dictionary["checkColor"] as? String { checkColor = UIColor.mfGet(forHex: checkColorHex) } + if let isChecked = dictionary["isChecked"] as? Bool, isChecked { + checkAndBypassAnimations(selected: isChecked) + } + if let unCheckedBackgroundColorHex = dictionary["unCheckedBackgroundColor"] as? String { unCheckedBackgroundColor = UIColor.mfGet(forHex: unCheckedBackgroundColorHex) } @@ -458,34 +459,39 @@ import MVMCore public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) - guard let checkboxModel = model as? CheckboxModel else { return } + guard let model = model as? CheckboxModel else { return } self.delegateObject = delegateObject FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol) - groupName = checkboxModel.groupName - fieldValue = checkboxModel.value - isRequired = checkboxModel.required + groupName = model.groupName + fieldValue = model.value + isRequired = model.required - if let fieldKey = checkboxModel.fieldKey { + if let fieldKey = model.fieldKey { self.fieldKey = fieldKey } - borderColor = checkboxModel.borderColor.uiColor - borderWidth = checkboxModel.borderWidth + borderColor = model.borderColor.uiColor + borderWidth = model.borderWidth - if checkboxModel.isChecked { - checkAndBypassAnimations(selected: checkboxModel.isChecked) + checkColor = model.checkColor.uiColor + unCheckedBackgroundColor = model.unCheckedBackgroundColor.uiColor + checkedBackgroundColor = model.checkedBackgroundColor.uiColor + disabledCheckColor = model.disabledCheckColor.uiColor + disabledBorderColor = model.disabledBorderColor.uiColor + disabledBackgroundColor = model.disabledBackgroundColor.uiColor + + isAnimated = model.isAnimated + isRound = model.isRound + + if model.isChecked { + checkAndBypassAnimations(selected: model.isChecked) } - checkColor = checkboxModel.checkColor.uiColor - unCheckedBackgroundColor = checkboxModel.unCheckedBackgroundColor.uiColor - checkedBackgroundColor = checkboxModel.checkedBackgroundColor.uiColor - isAnimated = checkboxModel.isAnimated - isRound = checkboxModel.isRound - isEnabled = checkboxModel.isEnabled + isEnabled = model.isEnabled - if let action = checkboxModel.action { + if let action = model.action { actionBlock = { if let actionMap = action.toJSON() { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 6ff55696..aa5dedb4 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -30,10 +30,10 @@ import Foundation public var isRound: Bool = false public var isEnabled: Bool = true public var action: ActionModelProtocol? + public var disabledBackgroundColor: Color = Color(uiColor: .clear) + public var disabledBorderColor: Color = Color(uiColor: .mvmCoolGray3) + public var disabledCheckColor: Color = Color(uiColor: .mvmCoolGray3) - public var disabledBackgroundColor: Color = Color(uiColor: .black) - public var disabledBorderColor: Color = Color(uiColor: .black) - //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -49,6 +49,9 @@ import Foundation case checkColor case unCheckedBackgroundColor case checkedBackgroundColor + case disabledBackgroundColor + case disabledCheckColor + case disabledBorderColor case isAnimated case isRound case isEnabled @@ -70,6 +73,9 @@ import Foundation checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) ?? Color(uiColor: .black) unCheckedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .unCheckedBackgroundColor) ?? Color(uiColor: .clear) checkedBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkedBackgroundColor) ?? Color(uiColor: .clear) + disabledBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledBackgroundColor) ?? Color(uiColor: .clear) + disabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledBorderColor) ?? Color(uiColor: .mvmCoolGray3) + disabledCheckColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledCheckColor) ?? Color(uiColor: .mvmCoolGray3) isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) ?? false isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) ?? true isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) ?? false @@ -89,6 +95,9 @@ import Foundation try container.encodeIfPresent(checkColor, forKey: .checkColor) try container.encodeIfPresent(unCheckedBackgroundColor, forKey: .unCheckedBackgroundColor) try container.encodeIfPresent(checkedBackgroundColor, forKey: .checkedBackgroundColor) + try container.encodeIfPresent(disabledBorderColor, forKey: .disabledBorderColor) + try container.encodeIfPresent(disabledBackgroundColor, forKey: .disabledBackgroundColor) + try container.encodeIfPresent(disabledCheckColor, forKey: .disabledCheckColor) try container.encodeIfPresent(isAnimated, forKey: .isAnimated) try container.encodeIfPresent(isRound, forKey: .isRound) try container.encodeIfPresent(isEnabled, forKey: .isEnabled) From e143c75215d2bcf91863356422aeacb052f38b3e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 13:10:57 -0500 Subject: [PATCH 237/272] redirect type --- MVMCoreUI/Molecules/Items/DropDownListItemModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index ca78c3fa..28bc373b 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -16,7 +16,7 @@ import Foundation public var line: LineModel? = LineModel(type: .none) public var hideArrow: Bool? = true - public init(molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { + public init(molecules: [[ListItemModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { self.molecules = molecules self.dropDown = dropDown super.init() From 2f68dcb695ddf215830f9afb24590f060aaf6ec2 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Thu, 23 Jan 2020 14:05:36 -0500 Subject: [PATCH 238/272] update horizontal alignment --- MVMCoreUI/Atoms/Buttons/Link.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 4a498fdd..8cb9bb49 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -82,7 +82,7 @@ extension Link { // MARK: - MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { - public func alignment() -> UIStackView.Alignment { + public func horizontalAlignment() -> UIStackView.Alignment { return .leading } } From 0069f38d4e89666e086b30291481b3c1cf11f8c5 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Thu, 23 Jan 2020 14:06:25 -0500 Subject: [PATCH 239/272] update toggle alignment --- MVMCoreUI/Atoms/Views/Toggle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 73a8ec2f..80425054 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -424,7 +424,7 @@ extension Toggle { return true } - public func alignment() -> UIStackView.Alignment { + public func horizontalAlignment() -> UIStackView.Alignment { return .trailing } } From 0c7a2940d985e170604b5763a789ee6f1a823beb Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 14:26:04 -0500 Subject: [PATCH 240/272] Fixing issues for model reuse. --- .../TextFields/DateDropdownEntryField.swift | 36 +-- .../DateDropdownEntryFieldModel.swift | 4 +- .../Atoms/TextFields/DigitEntryField.swift | 6 +- .../TextFields/DigitEntryFieldModel.swift | 8 +- MVMCoreUI/Atoms/TextFields/EntryField.swift | 29 +- .../Atoms/TextFields/EntryFieldModel.swift | 21 +- .../TextFields/ItemDropdownEntryField.swift | 4 + .../ItemDropdownEntryFieldModel.swift | 24 -- .../Atoms/TextFields/TextEntryField.swift | 8 +- .../views/EntryFieldContainer.swift | 293 ++++++++++++++++++ .../Items/DropDownFilterTableViewCell.swift | 10 +- .../Items/DropDownListItemModel.swift | 3 + 12 files changed, 349 insertions(+), 97 deletions(-) create mode 100644 MVMCoreUI/Containers/views/EntryFieldContainer.swift diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift index 6fde6b45..7051239c 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift @@ -22,7 +22,20 @@ import UIKit return calendar }() - public var dateFormat: String? + public var dateFormatter: DateFormatter = { + let formatter = DateFormatter() + formatter.dateStyle = .medium + formatter.timeZone = NSTimeZone.system + formatter.locale = .current + formatter.formatterBehavior = .default + return formatter + }() + + public var dateFormat: String = "MMM d, y" { + didSet { + dateFormatter.dateFormat = dateFormat + } + } //-------------------------------------------------- // MARK: - Initializers @@ -83,7 +96,7 @@ import UIKit if calendar.isDate(date, inSameDayAs: Date()) { text = MVMCoreUIUtility.hardcodedString(withKey: "textfield_today_string") } else { - text = dateFormatter().string(from: date) + text = dateFormatter.string(from: date) } } @@ -98,29 +111,12 @@ import UIKit setTextWith(date: datePicker?.date) } - public func dateFormatter() -> DateFormatter { - - let formatter = DateFormatter() - formatter.dateStyle = .medium - formatter.timeZone = NSTimeZone.system - formatter.locale = .current - formatter.formatterBehavior = .default - - if let dateFormat = dateFormat { - formatter.dateFormat = dateFormat - } - - return formatter - } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) guard let model = model as? DateDropdownEntryFieldModel else { return } - if let dateFormat = model.dateFormat { - self.dateFormat = dateFormat - } + self.dateFormat = model.dateFormat } } diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift index ebccffcd..c226660b 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift @@ -15,7 +15,7 @@ return "dateDropdownEntryField" } - public var dateFormat: String? + public var dateFormat: String = "MMM d, y" //-------------------------------------------------- // MARK: - Keys @@ -32,7 +32,7 @@ required public init(from decoder: Decoder) throws { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - dateFormat = try typeContainer.decodeIfPresent(String.self, forKey: .dateFormat) + dateFormat = try typeContainer.decodeIfPresent(String.self, forKey: .dateFormat) ?? "MMM d, y" } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index ce741346..c7888041 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -333,11 +333,9 @@ import UIKit guard let model = model as? DigitEntryFieldModel else { return } - numberOfDigits = model.digits ?? 4 + numberOfDigits = model.digits - if let secureEntry = model.secureEntry, secureEntry { - setAsSecureTextEntry(true) - } + setAsSecureTextEntry(model.secureEntry) for digitBox in digitBoxes { MVMCoreUICommonViewsUtility.addDismissToolbar(digitBox.digitField, delegate: delegateObject as? UITextFieldDelegate) diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift index a798eebb..3b139e9b 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift @@ -16,8 +16,8 @@ return "digitTextField" } - public var digits: Int? - public var secureEntry: Bool? + public var digits: Int = 4 + public var secureEntry: Bool = false //-------------------------------------------------- // MARK: - Keys @@ -35,8 +35,8 @@ required public init(from decoder: Decoder) throws { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - digits = try typeContainer.decodeIfPresent(Int.self, forKey: .digits) - secureEntry = try typeContainer.decodeIfPresent(Bool.self, forKey: .secureEntry) + digits = try typeContainer.decodeIfPresent(Int.self, forKey: .digits) ?? 4 + secureEntry = try typeContainer.decodeIfPresent(Bool.self, forKey: .secureEntry) ?? false } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atoms/TextFields/EntryField.swift index 57d1b0bf..e70a2df0 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryField.swift @@ -248,29 +248,12 @@ import UIKit entryFieldContainer.setWithModel(model, delegateObject, additionalData) - if let title = model.title { - self.title = title - } - - if let isDisabled = model.isDisabled { - self.isEnabled = isDisabled - } - - if let feedback = model.feedback { - self.feedback = feedback - } - - if let errorMessage = model.errorMessage { - self.errorMessage = errorMessage - } - - if let isLocked = model.isLocked { - self.isLocked = isLocked - } - - if let isSelected = model.isSelected { - self.isSelected = isSelected - } + title = model.title + isEnabled = model.isEnabled + feedback = model.feedback + errorMessage = model.errorMessage + isLocked = model.isLocked + isSelected = model.isSelected if let fieldKey = model.fieldKey { self.fieldKey = fieldKey diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index dbf240ee..adb2b58c 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -21,11 +21,10 @@ import Foundation public var backgroundColor: Color? public var title: String? public var feedback: String? - public var errorMessage: String? - public var isDisabled: Bool? - public var isLocked: Bool? - public var isSelected: Bool? - + public var errorMessage: String = "" + public var isEnabled: Bool = true + public var isLocked: Bool = false + public var isSelected: Bool = false public var fieldKey: String? public var isValid: Bool? public var isRequired: Bool? @@ -37,7 +36,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case backgroundColor case title - case isDisabled + case isEnabled case feedback case errorMessage = "errorMsg" case isLocked @@ -56,10 +55,10 @@ import Foundation backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) - errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) - isDisabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isDisabled) - isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked) - isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) + 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) ?? false + isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) ?? false fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid) } @@ -70,7 +69,7 @@ import Foundation try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(feedback, forKey: .feedback) try container.encodeIfPresent(errorMessage, forKey: .errorMessage) - try container.encodeIfPresent(isDisabled, forKey: .isDisabled) + try container.encodeIfPresent(isEnabled, forKey: .isEnabled) try container.encodeIfPresent(isLocked, forKey: .isLocked) try container.encodeIfPresent(isSelected, forKey: .isSelected) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift index 440ad5fc..962ff89b 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift @@ -115,10 +115,14 @@ extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource { } @objc public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + guard !pickerData.isEmpty else { return nil } + return pickerData[row] } @objc public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + guard !pickerData.isEmpty else { return } + observeDropdownChange?(text ?? "", pickerData[row]) text = pickerData[row] } diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift index e1313086..a12d6b80 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift @@ -16,28 +16,4 @@ } public var options: [String]? - - //-------------------------------------------------- - // MARK: - Keys - //-------------------------------------------------- - - private enum CodingKeys: String, CodingKey { - case options - } - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - required public init(from decoder: Decoder) throws { - try super.init(from: decoder) - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - options = try typeContainer.decodeIfPresent([String].self, forKey: .options) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(options, forKey: .options) - } } diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index f4381faf..1230a485 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -286,13 +286,9 @@ import UIKit textColor.disabled = disabledTextColor.uiColor } - if let text = model.text { - self.text = text - } + text = model.text + placeholder = model.placeholder - if let placeholder = model.placeholder { - self.placeholder = placeholder - } switch model.type { case "password": diff --git a/MVMCoreUI/Containers/views/EntryFieldContainer.swift b/MVMCoreUI/Containers/views/EntryFieldContainer.swift new file mode 100644 index 00000000..3f80006a --- /dev/null +++ b/MVMCoreUI/Containers/views/EntryFieldContainer.swift @@ -0,0 +1,293 @@ +// +// EntryFieldContainer.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 11/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + + +@objcMembers open class EntryFieldContainer: View { + //-------------------------------------------------- + // MARK: - Drawing Properties + //-------------------------------------------------- + + /// The bottom border line. Height is dynamic based on scenario. + public var bottomBar: CAShapeLayer? = { + let layer = CAShapeLayer() + layer.backgroundColor = UIColor.black.cgColor + layer.drawsAsynchronously = true + layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); + return layer + }() + + /// Total control over the drawn top, bottom, left and right borders. + public var disableAllBorders = false { + didSet { + bottomBar?.isHidden = disableAllBorders + } + } + + private(set) var fieldState: FieldState = .original { + didSet (oldState) { + // Will not update if new state is the same as old. + if fieldState != oldState { + DispatchQueue.main.async { [weak self] in + guard let self = self else { return } + + self.fieldState.setStateUI(for: self) + } + } + } + } + + /// Determines if the top, left, and right borders should be drawn. + private var hideBorders = false + + public var borderStrokeColor: UIColor = .mfSilver() + private var borderPath: UIBezierPath = UIBezierPath() + + //-------------------------------------------------- + // MARK: - Property Observers + //-------------------------------------------------- + + private var _isEnabled: Bool = true + private var _showError: Bool = false + private var _isLocked: Bool = false + private var _isSelected: Bool = false + + public var isEnabled: Bool { + get { return _isEnabled } + set (enabled) { + + _isEnabled = enabled + _isLocked = false + _isSelected = false + _showError = false + + fieldState = enabled ? .original : .disabled + } + } + + public var showError: Bool { + get { return _showError } + set (error) { + + _showError = error + _isEnabled = true + _isLocked = false + _isSelected = false + + fieldState = error ? .error : .original + } + } + + public var isLocked: Bool { + get { return _isLocked } + set (locked) { + + _isLocked = locked + _isEnabled = true + _isSelected = false + _showError = false + + fieldState = locked ? .locked : .original + } + } + + public var isSelected: Bool { + get { return _isSelected } + set (selected) { + + _isSelected = selected + _isLocked = false + _isEnabled = true + + if _showError { + fieldState = selected ? .selectedError : .error + } else { + fieldState = selected ? .selected : .original + } + } + } + + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + + /// Holds reference to delegateObject to inform molecular tableView of an update. + var delegateObject: MVMCoreUIDelegateObject? + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + open override func layoutSubviews() { + super.layoutSubviews() + + refreshUI(bottomBarSize: showError ? 4 : 1) + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + + refreshUI() + } + + /// This handles the top, left, and right border lines. + open override func draw(_ rect: CGRect) { + super.draw(rect) + + borderPath.removeAllPoints() + + if !disableAllBorders && !hideBorders { + // Brings the other half of the line inside the view to prevent cropping. + let origin = bounds.origin + let size = frame.size + let insetLean: CGFloat = 0.5 + borderPath.lineWidth = 1 + + borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height)) + borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + size.height)) + + borderStrokeColor.setStroke() + borderPath.stroke() + } + } + + override open func setupView() { + super.setupView() + + isAccessibilityElement = false + isOpaque = false + + if let bottomBar = bottomBar { + layer.addSublayer(bottomBar) + } + } + + //-------------------------------------------------- + // MARK: - Draw States + //-------------------------------------------------- + + public enum FieldState { + case original + case error + case selectedError + case selected + case locked + case disabled + + public func setStateUI(for formField: EntryFieldContainer) { + + switch self { + case .original: + formField.originalUI() + + case .error: + formField.errorUI() + + case .selectedError: + formField.selectedErrorUI() + + case .selected: + formField.selectedUI() + + case .locked: + formField.lockedUI() + + case .disabled: + formField.disabledUI() + } + } + } + + open func originalUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func errorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfPumpkin() + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedErrorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func lockedUI() { + + isUserInteractionEnabled = false + hideBorders = true + borderStrokeColor = .clear + bottomBar?.backgroundColor = UIColor.clear.cgColor + refreshUI(bottomBarSize: 1) + } + + open func disabledUI() { + + isUserInteractionEnabled = false + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.mfSilver().cgColor + refreshUI(bottomBarSize: 1) + } + + open func refreshUI(bottomBarSize: CGFloat? = nil) { + + if !disableAllBorders { + let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) + bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) + + delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + setNeedsDisplay() + layoutIfNeeded() + } + } + + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + self.delegateObject = delegateObject + } +} + +extension EntryFieldContainer { + + override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + self.delegateObject = delegateObject + + guard let dictionary = json, !dictionary.isEmpty else { return } + } +} diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index abf6f711..bf67a5bc 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -9,21 +9,25 @@ import UIKit @objcMembers public class DropDownFilterTableViewCell: TableViewCell { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- var dropDownListItemModel: DropDownListItemModel? let dropDown = ItemDropdownEntryField() var delegateObject: MVMCoreUIDelegateObject? var previousIndex = NSNotFound - var dropDownSelectionObservation: NSKeyValueObservation? + //-------------------------------------------------- // MARK: - MFViewProtocol + //-------------------------------------------------- + override public func setupView() { super.setupView() + guard dropDown.superview == nil else { return } - dropDown.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(dropDown) - NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: dropDown, useMargins: true).values)) dropDown.observeDropdownChange = { [weak self] oldValue, newValue in diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 28bc373b..9b9a66f1 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -9,6 +9,7 @@ import Foundation @objcMembers public class DropDownListItemModel: ContainerModel, ListItemModelProtocol { + public static var identifier: String = "dropDownListItem" public var molecules: [[ListItemModelProtocol]] public var dropDown: ItemDropdownEntryFieldModel @@ -33,9 +34,11 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) + if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { line = lineModel } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) } From 31c148de97a9b70bdc9b96fa88ecb599c831dc78 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 23 Jan 2020 14:46:32 -0500 Subject: [PATCH 241/272] fixes --- MVMCoreUI/Atoms/Buttons/Link.swift | 2 +- MVMCoreUI/Atoms/Views/LineModel.swift | 8 +++++--- MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 4a498fdd..8cb9bb49 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -82,7 +82,7 @@ extension Link { // MARK: - MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { - public func alignment() -> UIStackView.Alignment { + public func horizontalAlignment() -> UIStackView.Alignment { return .leading } } diff --git a/MVMCoreUI/Atoms/Views/LineModel.swift b/MVMCoreUI/Atoms/Views/LineModel.swift index f481d4d5..53bc1f4c 100644 --- a/MVMCoreUI/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atoms/Views/LineModel.swift @@ -43,7 +43,9 @@ import UIKit public static var identifier: String = "line" public var type: Style = .standard public var frequency: Frequency? = .allExceptTop - public var color: Color? + + //TODO: use color insted of backgroundColor. Needs server changes +// public var color: Color? public var backgroundColor: Color? public init(type: Style) { @@ -66,7 +68,7 @@ import UIKit if let frequency = try typeContainer.decodeIfPresent(Frequency.self, forKey: .frequency) { self.frequency = frequency } - color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) } public func encode(to encoder: Encoder) throws { @@ -74,6 +76,6 @@ import UIKit try container.encode(moleculeName, forKey: .moleculeName) try container.encode(type, forKey: .type) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(color, forKey: .color) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 2efa0403..dd53afac 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeModelProtocol { - public static var identifier: String = "progressbar" + public static var identifier: String = "progressBar" @Percent public var percent: CGFloat public var progressColor: Color = Color(uiColor: .mfCerulean()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) From 83d5721e683c8675c494b7e7d8c78d2584cd2bde Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 19:59:05 -0500 Subject: [PATCH 242/272] temp fix for arch issue --- .../BaseDropdownEntryFieldModel.swift | 8 +++ .../DateDropdownEntryFieldModel.swift | 2 +- .../TextFields/DigitEntryFieldModel.swift | 4 +- .../Atoms/TextFields/EntryFieldModel.swift | 8 +-- .../TextFields/ItemDropdownEntryField.swift | 8 ++- .../ItemDropdownEntryFieldModel.swift | 26 +++++++- .../MFViewController+Model.swift | 8 +++ .../Items/DropDownFilterTableViewCell.swift | 36 +++++------ .../Items/DropDownListItemModel.swift | 35 ++++++++++- .../ModelMoleculeDelegateProtocol.swift | 8 ++- .../Templates/MoleculeListTemplate.swift | 59 +++++++++++++++++++ 11 files changed, 171 insertions(+), 31 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift index 3dffa669..1fefd42f 100644 --- a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift @@ -15,4 +15,12 @@ public override class var identifier: String { return "" } + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + } } diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift index c226660b..4e916268 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift @@ -38,6 +38,6 @@ public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(dateFormat, forKey: .dateFormat) + try container.encode(dateFormat, forKey: .dateFormat) } } diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift index 3b139e9b..46171e41 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift @@ -42,7 +42,7 @@ public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(digits, forKey: .digits) - try container.encodeIfPresent(secureEntry, forKey: .secureEntry) + try container.encode(digits, forKey: .digits) + try container.encode(secureEntry, forKey: .secureEntry) } } diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index adb2b58c..14a57f4c 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -68,10 +68,10 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(feedback, forKey: .feedback) - try container.encodeIfPresent(errorMessage, forKey: .errorMessage) - try container.encodeIfPresent(isEnabled, forKey: .isEnabled) - try container.encodeIfPresent(isLocked, forKey: .isLocked) - try container.encodeIfPresent(isSelected, forKey: .isSelected) + 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) } diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift index 962ff89b..d1728b46 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift @@ -96,9 +96,11 @@ open class ItemDropdownEntryField: BaseDropdownEntryField { guard let model = model as? ItemDropdownEntryFieldModel else { return } - if let options = model.options { - pickerData = options - setPickerDelegates(delegate: self) + pickerData = model.options + setPickerDelegates(delegate: self) + + if let pickerView = pickerView { + self.pickerView(pickerView, didSelectRow: 0, inComponent: 0) } } } diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift index a12d6b80..b913f976 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift @@ -15,5 +15,29 @@ return "dropDown" } - public var options: [String]? + public var options: [String] = [] + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case options + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + options = try typeContainer.decodeIfPresent([String].self, forKey: .options) ?? [] + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(options, forKey: .options) + } } diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index f503d0b5..6cedf93c 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -33,6 +33,14 @@ extension MFViewController: MoleculeDelegateProtocol { @objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { } + + @objc public func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothing + } + + @objc public func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothing + } } public extension MFViewController { diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index bf67a5bc..bc8edf18 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -19,47 +19,49 @@ import UIKit var previousIndex = NSNotFound //-------------------------------------------------- - // MARK: - MFViewProtocol + // MARK: - Lifecycle //-------------------------------------------------- override public func setupView() { super.setupView() guard dropDown.superview == nil else { return } - - contentView.addSubview(dropDown) - NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: dropDown, useMargins: true).values)) - + addMolecule(dropDown) dropDown.observeDropdownChange = { [weak self] oldValue, newValue in guard newValue != oldValue, let self = self, - let options = self.dropDown.json?.optionalArrayForKey("options") as? [NSString], - let index = options.firstIndex(of: newValue as NSString), - let molecules = self.dropDownListItemModel?.molecules else { return } + let index = self.dropDown.pickerData.firstIndex(of: newValue), + let molecules = self.dropDownListItemModel?.molecules + else { return } - if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(molecules[self.previousIndex], sender: self, animation: .fade) + var json2d = [[[AnyHashable: Any]]]() + + for moleculeList in molecules { + var json1d = [[AnyHashable: Any]]() + for molecule in moleculeList { + json1d.append((molecule as? ListItemModel)!.toJSON()!) + } + json2d.append(json1d) } - self.delegateObject?.moleculeDelegate?.addMolecules(molecules[index], sender: self, animation: .fade) + if self.previousIndex != NSNotFound { + self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) + } + + self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], sender: self, animation: .fade) self.previousIndex = index } } - public override func updateView(_ size: CGFloat) { - super.updateView(size) - dropDown.updateView(size) - } - public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { dropDownListItemModel = model as? DropDownListItemModel self.delegateObject = delegateObject super.setWithModel(model, delegateObject, additionalData) + dropDown.setWithModel(dropDownListItemModel?.dropDown, delegateObject, additionalData) dropDown.observingTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? ObservingTextFieldDelegate dropDown.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate - dropDown.setWithModel(dropDownListItemModel, delegateObject, additionalData) } public override func reset() { diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 9b9a66f1..13af4278 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -9,6 +9,9 @@ import Foundation @objcMembers public class DropDownListItemModel: ContainerModel, ListItemModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- public static var identifier: String = "dropDownListItem" public var molecules: [[ListItemModelProtocol]] @@ -16,12 +19,37 @@ import Foundation public var backgroundColor: Color? public var line: LineModel? = LineModel(type: .none) public var hideArrow: Bool? = true + + /// Defaults to set + func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } + if topMarginPadding == nil { + topMarginPadding = 24 + } + if bottomMarginPadding == nil { + bottomMarginPadding = 0 + } + } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(molecules: [[ListItemModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { self.molecules = molecules self.dropDown = dropDown super.init() + setDefaults() } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case molecules @@ -29,10 +57,14 @@ import Foundation case line case backgroundColor } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] + molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as? [[ListItemModelProtocol]] ?? [[]] dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { @@ -41,6 +73,7 @@ import Foundation backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) try super.init(from: decoder) + setDefaults() } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index 11e8a154..8fe1caa5 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -31,15 +31,19 @@ extension MoleculeDelegateProtocol { public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { // Do Nothing } + public func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - // Do nothpublic ing + // Do nothing } + public func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { // Do nothing } + public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { - // Do nothpublic ing + // Do nothing } + public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // Do nothing } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index c21a770b..a7b8d6ba 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -146,6 +146,64 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } + public override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + + var tmpMolecules = [ListItemModelProtocol]() + + molecules.forEach { molecule in + + let data = try? JSONSerialization.data(withJSONObject: molecule) + let decoder = JSONDecoder() + let listItemModel = try? decoder.decode(ListItemModel.self, from: data!) + + tmpMolecules.append(listItemModel!) + } + + DispatchQueue.main.async { + guard let indexPath = self.tableView?.indexPath(for: sender) else { return } + var indexPaths: [IndexPath] = [] + for molecule in molecules { + if let info = self.getMoleculeInfo(with: tmpMolecules as! ListItemModelProtocol) { + self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier) + let index = indexPath.row + 1 + indexPaths.count + self.moleculesInfo?.insert(info, at: index) + indexPaths.append(IndexPath(row: index, section: 0)) + } + } + self.tableView?.insertRows(at: indexPaths, with: animation) + self.updateViewConstraints() + self.view.layoutIfNeeded() + } + } + + public override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + + var tmpMolecules = [ListItemModelProtocol]() + + molecules.forEach { molecule in + + let data = try? JSONSerialization.data(withJSONObject: molecule) + let decoder = JSONDecoder() + let listItemModel = try? decoder.decode(ListItemModel.self, from: data!) + + tmpMolecules.append(listItemModel!) + } + + var indexPaths: [IndexPath] = [] + //TODO: cehck for molecule protocola eqality + for molecule in tmpMolecules { + if let removeIndex = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in + return molecule.toJSONString() == moleculeInfo.molecule.toJSONString() + }) { + moleculesInfo?.remove(at: removeIndex) + indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) + } + } + self.tableView?.deleteRows(at: indexPaths, with: animation) + self.updateViewConstraints() + self.view.layoutIfNeeded() + } + public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // This dispatch is needed to fix a race condition that can occur if this function is called during the table setup. DispatchQueue.main.async { @@ -164,6 +222,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol self.view.layoutIfNeeded() } } + public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality From c5e80d602efbf52ddbae597391a650c490dc9799 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 21:04:48 -0500 Subject: [PATCH 243/272] temp fix for arch issue --- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 ++ MVMCoreUI/Templates/MoleculeListTemplate.swift | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 5356ce25..ff9f056d 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -18,6 +18,7 @@ import MVMCore public var style: String? = "standard" private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case action case hideArrow @@ -62,6 +63,7 @@ import MVMCore 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(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeIfPresent(hideArrow, forKey: .hideArrow) diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index a7b8d6ba..c4542898 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -153,8 +153,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol molecules.forEach { molecule in let data = try? JSONSerialization.data(withJSONObject: molecule) - let decoder = JSONDecoder() - let listItemModel = try? decoder.decode(ListItemModel.self, from: data!) + let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data!) tmpMolecules.append(listItemModel!) } @@ -162,8 +161,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol DispatchQueue.main.async { guard let indexPath = self.tableView?.indexPath(for: sender) else { return } var indexPaths: [IndexPath] = [] - for molecule in molecules { - if let info = self.getMoleculeInfo(with: tmpMolecules as! ListItemModelProtocol) { + for molecule in tmpMolecules { + if let info = self.getMoleculeInfo(with: molecule) { self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier) let index = indexPath.row + 1 + indexPaths.count self.moleculesInfo?.insert(info, at: index) From 6139f31e54f791b5e5782d6cfb4d54dbc28873ce Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 23 Jan 2020 22:42:19 -0500 Subject: [PATCH 244/272] wring label --- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index b7feefae..b0ad442f 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -66,7 +66,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) - try container.encode(text, forKey: .moleculeName) + try container.encode(text, forKey: .text) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(textColor, forKey: .textColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) @@ -75,9 +75,9 @@ import Foundation try container.encodeIfPresent(fontSize, forKey: .fontSize) try container.encodeIfPresent(textAlignment, forKey: .textAlignment) var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes) - try attributes?.forEach({ (attributeModel) in + try attributes?.forEach { attributeModel in try attributeContainer.encode(attributeModel) - }) + } try container.encodeIfPresent(html, forKey: .html) try container.encodeIfPresent(hero, forKey: .hero) try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable) From 1b4646df31109eb89a78b34fe2bf1708e9d4ae52 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 08:49:04 -0500 Subject: [PATCH 245/272] cleaning --- MVMCoreUI.xcodeproj/project.pbxproj | 2 ++ MVMCoreUI/Atoms/Views/ProgressBarModel.swift | 2 +- MVMCoreUI/BaseClasses/Button.swift | 21 ++++++++++--------- MVMCoreUI/BaseClasses/Control.swift | 8 +++---- .../UIStackViewAlignment+Extension.swift | 21 +++++++++++++++++++ 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b47d64d3..1c561bdd 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -305,6 +305,7 @@ D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */; }; D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */; }; D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */; }; + D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; }; D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; }; D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */; }; DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; }; @@ -1532,6 +1533,7 @@ D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, + D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift index 2efa0403..dd53afac 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBarModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class ProgressBarModel: MoleculeModelProtocol { - public static var identifier: String = "progressbar" + public static var identifier: String = "progressBar" @Percent public var percent: CGFloat public var progressColor: Color = Color(uiColor: .mfCerulean()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 0c5d4bec..0a382705 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -12,8 +12,8 @@ public typealias ButtonAction = (Button) -> () //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public var model: MoleculeModelProtocol? - public var actionModel: ActionModelProtocol? + open var model: MoleculeModelProtocol? + open var actionModel: ActionModelProtocol? private var initialSetupPerformed = false @@ -23,7 +23,7 @@ public typealias ButtonAction = (Button) -> () // MARK: - Delegate //-------------------------------------------------- - public weak var buttonDelegate: ButtonDelegateProtocol? + open weak var buttonDelegate: ButtonDelegateProtocol? //-------------------------------------------------- // MARK: - Initializers @@ -48,6 +48,7 @@ public typealias ButtonAction = (Button) -> () // MARK: - Setup //-------------------------------------------------- + /// Required to be called any init. Ensures setupView() only gets called once public func initialSetup() { if !initialSetupPerformed { @@ -60,16 +61,17 @@ public typealias ButtonAction = (Button) -> () // MARK: - Methods //-------------------------------------------------- - public func addActionBlock( event: Event, _ buttonBlock: @escaping ButtonAction) { + /// Adds a block to be performed for the given event. + open func addActionBlock(event: Event, _ buttonBlock: @escaping ButtonAction) { self.buttonAction = buttonBlock addTarget(self, action: #selector(callActionBlock(_:)), for: event) } - func callActionBlock(_ sender: Button) { + @objc private func callActionBlock(_ sender: Button) { buttonAction?(self) } - public func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + open func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.actionModel = actionModel buttonDelegate = delegateObject?.buttonDelegate @@ -104,14 +106,13 @@ public typealias ButtonAction = (Button) -> () } } - // MARK: - MVMCoreViewProtocol extension Button: MVMCoreViewProtocol { - public func updateView(_ size: CGFloat) {} + open func updateView(_ size: CGFloat) {} /// Will be called only once. - public func setupView() { + open func setupView() { translatesAutoresizingMaskIntoConstraints = false insetsLayoutMarginsFromSafeArea = false titleLabel?.numberOfLines = 0 @@ -121,7 +122,7 @@ extension Button: MVMCoreViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol extension Button: MVMCoreUIMoleculeViewProtocol { - public func reset() { + open func reset() { backgroundColor = .clear } } diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index ed1c1874..d73e0fef 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -13,7 +13,7 @@ import UIKit // MARK: - Properties //-------------------------------------------------- open var json: [AnyHashable: Any]? - public var model: MoleculeModelProtocol? + open var model: MoleculeModelProtocol? private var initialSetupPerformed = false @@ -78,10 +78,10 @@ extension Control: AppleGuidelinesProtocol { // MARK: - MVMCoreViewProtocol extension Control: MVMCoreViewProtocol { - public func updateView(_ size: CGFloat) {} + open func updateView(_ size: CGFloat) {} /// Will be called only once. - public func setupView() { + open func setupView() { translatesAutoresizingMaskIntoConstraints = false insetsLayoutMarginsFromSafeArea = false } @@ -97,7 +97,7 @@ extension Control: MVMCoreUIMoleculeViewProtocol { } } - public func reset() { + open func reset() { backgroundColor = .clear } } diff --git a/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift b/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift index 18afca83..b2c4b82b 100644 --- a/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift +++ b/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift @@ -30,6 +30,11 @@ import Foundation try container.encode(alignment.rawValueString, forKey: .alignment) } */ + +enum AlignmentError: Error { + case notAnAlignment +} + extension UIStackView.Alignment: RawRepresentable { init?(rawValue: String) { @@ -70,3 +75,19 @@ extension UIStackView.Alignment: RawRepresentable { } } } + +extension UIStackView.Alignment: Codable { + public init(from decoder: Decoder) throws { + let typeContainer = try decoder.singleValueContainer() + let string = try typeContainer.decode(String.self) + guard let alignment = UIStackView.Alignment(rawValue: string) else { + throw AlignmentError.notAnAlignment + } + self = alignment + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(rawValueString) + } +} From 633bcf9fd0bb1394520607568c5debad5cce0236 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 09:21:03 -0500 Subject: [PATCH 246/272] dash line update --- MVMCoreUI/Atoms/Views/DashLine.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index dcfc4270..20f8fa9d 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -19,8 +19,6 @@ open class DashLine: View { get { return model as? DashLineModel } } - // Legacy - @objc public var dashColor: UIColor? @objc private var dashLayer: CAShapeLayer? //------------------------------------------------------ @@ -70,7 +68,7 @@ open class DashLine: View { dashLayer.lineCap = .round dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)] dashLayer.path = path.cgPath - dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor + dashLayer.strokeColor = dashModel?.dashColor.cgColor dashLayer.fillColor = UIColor.clear.cgColor dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor self.dashLayer = dashLayer From c0c5eef9e14dad4c0212737cab48b7d9f464c656 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 09:22:45 -0500 Subject: [PATCH 247/272] dash update --- MVMCoreUI/Atoms/Views/DashLine.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 20f8fa9d..cbee1eb8 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -79,7 +79,7 @@ open class DashLine: View { //------------------------------------------------------ // Default values for view. - @objc open override func setAsMolecule() { + @objc open override func reset() { backgroundColor = .clear isHidden = false } From d6a7e9871857790a664da64a125ddfa38b64f660 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Fri, 24 Jan 2020 09:25:09 -0500 Subject: [PATCH 248/272] remove conflicts file --- MVMCoreUI/Containers/Container.swift.orig | 265 ------------------ .../Models/Molecules/FooterModel.swift.orig | 37 --- .../Molecules/Items/StackItem.swift.orig | 100 ------- MVMCoreUI/Molecules/ModuleMolecule.swift.orig | 116 -------- .../Molecules/StandardHeaderView.swift.orig | 90 ------ 5 files changed, 608 deletions(-) delete mode 100644 MVMCoreUI/Containers/Container.swift.orig delete mode 100644 MVMCoreUI/Models/Molecules/FooterModel.swift.orig delete mode 100644 MVMCoreUI/Molecules/Items/StackItem.swift.orig delete mode 100644 MVMCoreUI/Molecules/ModuleMolecule.swift.orig delete mode 100644 MVMCoreUI/Molecules/StandardHeaderView.swift.orig diff --git a/MVMCoreUI/Containers/Container.swift.orig b/MVMCoreUI/Containers/Container.swift.orig deleted file mode 100644 index f5ef4a69..00000000 --- a/MVMCoreUI/Containers/Container.swift.orig +++ /dev/null @@ -1,265 +0,0 @@ -// -// Container.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 12/11/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -public protocol ContainerModelProtocol: Model { - var horizontalAlignment: UIStackView.Alignment? { get set } - var verticalAlignment: UIStackView.Alignment? { get set } - var useHorizontalMargins: Bool? { get set } - var useVerticalMargins: Bool? { get set } -} - -public class ContainerHelper: NSObject { - var leftConstraint: NSLayoutConstraint? - var topConstraint: NSLayoutConstraint? - var bottomConstraint: NSLayoutConstraint? - var rightConstraint: NSLayoutConstraint? - - var alignCenterHorizontalConstraint: NSLayoutConstraint? - var alignCenterLeftConstraint: NSLayoutConstraint? - var alignCenterRightConstraint: NSLayoutConstraint? - - var alignCenterVerticalConstraint: NSLayoutConstraint? - var alignCenterTopConstraint: NSLayoutConstraint? - var alignCenterBottomConstraint: NSLayoutConstraint? - - var leftLowConstraint: NSLayoutConstraint? - var topLowConstraint: NSLayoutConstraint? - var bottomLowConstraint: NSLayoutConstraint? - var rightLowConstraint: NSLayoutConstraint? - - func constrainView(_ view: UIView) { - guard let margins = view.superview?.layoutMarginsGuide else { return } - leftConstraint = view.leftAnchor.constraint(equalTo: margins.leftAnchor) - leftConstraint?.isActive = true - - topConstraint = view.topAnchor.constraint(equalTo: margins.topAnchor) - topConstraint?.isActive = true - - rightConstraint = margins.rightAnchor.constraint(equalTo: view.rightAnchor) - rightConstraint?.isActive = true - - bottomConstraint = margins.bottomAnchor.constraint(equalTo: view.bottomAnchor) - bottomConstraint?.isActive = true - - alignCenterHorizontalConstraint = view.centerXAnchor.constraint(equalTo: margins.centerXAnchor) - alignCenterLeftConstraint = view.leftAnchor.constraint(greaterThanOrEqualTo: margins.leftAnchor) - alignCenterRightConstraint = margins.rightAnchor.constraint(greaterThanOrEqualTo: view.rightAnchor) - - alignCenterVerticalConstraint = view.centerYAnchor.constraint(equalTo: margins.centerYAnchor) - alignCenterTopConstraint = view.topAnchor.constraint(greaterThanOrEqualTo: margins.topAnchor) - alignCenterBottomConstraint = margins.bottomAnchor.constraint(greaterThanOrEqualTo: view.bottomAnchor) - - leftLowConstraint = view.leftAnchor.constraint(equalTo: margins.leftAnchor) - leftLowConstraint?.priority = UILayoutPriority(rawValue: 200) - leftLowConstraint?.isActive = true - - topLowConstraint = view.topAnchor.constraint(equalTo: margins.topAnchor) - topLowConstraint?.priority = UILayoutPriority(rawValue: 200) - topLowConstraint?.isActive = true - - rightLowConstraint = margins.rightAnchor.constraint(equalTo: view.rightAnchor) - rightLowConstraint?.priority = UILayoutPriority(rawValue: 200) - rightLowConstraint?.isActive = true - - bottomLowConstraint = margins.bottomAnchor.constraint(equalTo: view.bottomAnchor) - bottomLowConstraint?.priority = UILayoutPriority(rawValue: 200) - bottomLowConstraint?.isActive = true - - setAccessibility(view) - } - - func setAccessibility(_ view: UIView) { - guard let superView = view.superview else { return } - superView.isAccessibilityElement = false - if let elements = view.accessibilityElements { - superView.accessibilityElements = elements - } else { - superView.accessibilityElements = [view] - } - } - - func alignHorizontal(_ alignment: UIStackView.Alignment) { - switch alignment { - case .center: - alignCenterHorizontalConstraint?.isActive = true - alignCenterLeftConstraint?.isActive = true - alignCenterRightConstraint?.isActive = true - leftConstraint?.isActive = false - rightConstraint?.isActive = false - case .leading: - alignCenterHorizontalConstraint?.isActive = false - alignCenterLeftConstraint?.isActive = false - alignCenterRightConstraint?.isActive = true - leftConstraint?.isActive = true - rightConstraint?.isActive = false - case .trailing: - alignCenterHorizontalConstraint?.isActive = false - alignCenterLeftConstraint?.isActive = true - alignCenterRightConstraint?.isActive = false - leftConstraint?.isActive = false - rightConstraint?.isActive = true - case .fill: - alignCenterHorizontalConstraint?.isActive = false - alignCenterLeftConstraint?.isActive = false - alignCenterRightConstraint?.isActive = false - leftConstraint?.isActive = true - rightConstraint?.isActive = true - default: break - } - } - - func alignVertical(_ alignment: UIStackView.Alignment) { - switch alignment { - case .center: - alignCenterVerticalConstraint?.isActive = true - alignCenterTopConstraint?.isActive = true - alignCenterBottomConstraint?.isActive = true - topConstraint?.isActive = false - bottomConstraint?.isActive = false - case .leading: - alignCenterVerticalConstraint?.isActive = false - alignCenterTopConstraint?.isActive = false - alignCenterBottomConstraint?.isActive = true - topConstraint?.isActive = true - bottomConstraint?.isActive = false - case .trailing: - alignCenterVerticalConstraint?.isActive = false - alignCenterTopConstraint?.isActive = true - alignCenterBottomConstraint?.isActive = false - topConstraint?.isActive = false - bottomConstraint?.isActive = true - case .fill: - alignCenterVerticalConstraint?.isActive = false - alignCenterTopConstraint?.isActive = false - alignCenterBottomConstraint?.isActive = false - topConstraint?.isActive = true - bottomConstraint?.isActive = true - default: break - } - } - - func set(with model: ContainerModelProtocol) { - if let horizontalAlignment = model.horizontalAlignment { - alignHorizontal(horizontalAlignment) - } - if let verticalAlignment = model.verticalAlignment { - alignVertical(verticalAlignment) - } - } - - static func getAlignment(for string: String) -> UIStackView.Alignment? { - switch string { - case "leading": - return .leading - case "trailing": - return .trailing - case "center": - return .center - case "fill": - return .fill - default: - return nil - } - } - - static func getAlignmentString(for alignment: UIStackView.Alignment?) -> String? { - switch alignment { - case .leading: - return "leading" - case .trailing: - return "trailing" - case .center: - return "center" - case .fill: - return "fill" - default: - return nil - } - } - - func set(with JSON: [AnyHashable: Any]?, for contained: UIView) { - if let horizontalAlignmentString = JSON?.optionalStringForKey("horizontalAlignment"), let alignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() { - alignHorizontal(alignment) - } else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() { - alignHorizontal(alignment) - } - - if let verticalAlignmentString = JSON?.optionalStringForKey("verticalAlignment"), let alignment = ContainerHelper.getAlignment(for: verticalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() { - alignVertical(alignment) - } else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() { - alignVertical(alignment) - } - } -} - -open class Container: View { -<<<<<<< HEAD -======= - var containerModel: ContainerModelProtocol? ->>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c - var view: UIView? - let containerHelper = ContainerHelper() - var containerModel: ContainerModelProtocol? { - get { return model as? ContainerModelProtocol } - } - var topMarginPadding: CGFloat = 0 - var bottomMarginPadding: CGFloat = 0 - - override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - super.setWithModel(model, delegateObject, additionalData) - guard let containerModel = model as? ContainerModelProtocol else { return } - containerHelper.set(with: containerModel) - } -} - -// MARK: - MVMCoreViewProtocol -public extension Container { - override func updateView(_ size: CGFloat) { - super.updateView(size) - (view as? MVMCoreViewProtocol)?.updateView(size) - MFStyler.setMarginsFor(self, size: size, defaultHorizontal: containerModel?.useHorizontalMargins ?? true, top: containerModel?.useHorizontalMargins ?? true ? topMarginPadding : 0, bottom: containerModel?.useHorizontalMargins ?? true ? bottomMarginPadding : 0) - } - - /// Will be called only once. - override func setupView() { - super.setupView() - backgroundColor = .clear - } - - func addAndContain(_ view: UIView) { - view.translatesAutoresizingMaskIntoConstraints = false - addSubview(view) - containerHelper.constrainView(view) - self.view = view - } - - convenience init(andContain view: UIView) { - self.init() - addAndContain(view) - } -} - -// MARK: - MVMCoreUIMoleculeViewProtocol -public extension Container { - override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - guard let view = view else { return } - containerHelper.set(with: json, for: view) - } - - override func reset() { - super.reset() - (view as? MVMCoreUIMoleculeViewProtocol)?.reset?() - } - - func setAsMolecule() { - (view as? MVMCoreUIMoleculeViewProtocol)?.setAsMolecule?() - } -} diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift.orig b/MVMCoreUI/Models/Molecules/FooterModel.swift.orig deleted file mode 100644 index 077c6b8c..00000000 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift.orig +++ /dev/null @@ -1,37 +0,0 @@ -// -// FooterModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 11/27/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - - -@objcMembers public class FooterModel: MoleculeContainerModel, MoleculeProtocol { - public static var identifier: String = "footer" - public var backgroundColor: Color? - - enum FooterCodingKeys: String, CodingKey { - case backgroundColor - } - - required public init(from decoder: Decoder) throws { -<<<<<<< HEAD - let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - try super.init(from: decoder) -======= - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule) ->>>>>>> 83b0a554049f764888ce9db27dbd7fa503fddf01 - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: FooterCodingKeys.self) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - } -} diff --git a/MVMCoreUI/Molecules/Items/StackItem.swift.orig b/MVMCoreUI/Molecules/Items/StackItem.swift.orig deleted file mode 100644 index 10288002..00000000 --- a/MVMCoreUI/Molecules/Items/StackItem.swift.orig +++ /dev/null @@ -1,100 +0,0 @@ -// -// StackItem.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 12/13/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class StackItemModel: ContainerModelProtocol, MoleculeProtocol { - public static var identifier: String = "stackItem" - public var backgroundColor: String? - public var view: StackItem? - - public var molecule: MoleculeProtocol - public var spacing: CGFloat? = 16 - public var percentage: Int? = 0 - public var verticalAlignment: UIStackView.Alignment? - public var horizontalAlignment: UIStackView.Alignment? - public var useHorizontalMargins: Bool? = false - public var useVerticalMargins: Bool? = false - public var gone: Bool? = false - -<<<<<<< HEAD - enum CodingKeys: String, CodingKey { - case molecule - case spacing - case percentage - case verticalAlignment - case horizontalAlignment - case useHorizontalMargins - case useVerticalMargins - case gone - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) - spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) - percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage) - if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) { - verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString) - } - if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) { - horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) - } - useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins) - useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins) - gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModel(molecule, forKey: .molecule) - try container.encodeIfPresent(spacing, forKey: .spacing) - try container.encodeIfPresent(percentage, forKey: .percentage) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment) - try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins) - try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins) - try container.encodeIfPresent(gone, forKey: .gone) -======= - init(with view: StackItem) { - self.view = view - view.containerModel = self - } - - init(with view: StackItem, json: [AnyHashable: Any]?) { - self.view = view - view.containerModel = self - update(with: json) ->>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c - } - - func update(with json: [AnyHashable: Any]?) { - gone = json?.boolForKey("gone") ?? (json == nil) - spacing = json?.optionalCGFloatForKey("spacing") - percentage = json?["percent"] as? Int - if let horizontalAlignmentString = json?.optionalStringForKey("horizontalAlignment") { - horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) - } else { - horizontalAlignment = nil - } - - if let verticalAlignmentString = json?.optionalStringForKey("verticalAlignment") { - verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString) - } else { - verticalAlignment = nil - } - - useHorizontalMargins = json?.optionalBoolForKey("useHorizontalMargins") ?? false - useVerticalMargins = json?.optionalBoolForKey("useVerticalMargins") ?? false - } -} - -open class StackItem: MoleculeContainer { - - -} diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift.orig b/MVMCoreUI/Molecules/ModuleMolecule.swift.orig deleted file mode 100644 index d350171a..00000000 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift.orig +++ /dev/null @@ -1,116 +0,0 @@ -// -// ModuleMolecule.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 6/25/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class ModuleMoleculeModel: ContainerModelProtocol { - public static var identifier: String = "moduleMolecule" - - public var molecule: MoleculeProtocol? - public var moduleName: String - public var horizontalAlignment: UIStackView.Alignment? = .fill - public var verticalAlignment: UIStackView.Alignment? = .fill - public var useHorizontalMargins: Bool? = false - public var useVerticalMargins: Bool? = false - - enum CodingKeys: String, CodingKey { - case molecule - case moduleName - case horizontalAlignment - case verticalAlignment - case useHorizontalMargins - case useVerticalMargins - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moduleName = try typeContainer.decode(String.self, forKey:.moduleName) - if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) { - verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString) - } - if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) { - horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) - } - useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins) - useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moduleName, forKey: .moduleName) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment) - try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment) - try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins) - try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins) - } -} - -open class ModuleMolecule: Container { -<<<<<<< HEAD - var moduleMoleculeModel: ModuleMoleculeModel? { - get { return model as? ModuleMoleculeModel } -======= - public override func setupView() { - super.setupView() - containerModel = ModuleMoleculeModel() ->>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c - } - - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - #warning("need to change getter to get moduleModel instead to use.") - super.setWithModel(model, delegateObject, additionalData) - } - - // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { - // Critical error - return - } - - if view == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: false) { - addAndContain(moleculeView) - } - } else { - (view as? MVMCoreUIMoleculeViewProtocol)?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData) - } - } - - public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { - // Critical error - return 0 - } - return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.estimatedHeight?(forRow: module, delegateObject: delegateObject) ?? 0 - } - - public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let moduleName = molecule?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { - // Critical error - return "moduleMolecule<>" - } - return "moduleMolecule<" + (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.name?(forReuse: module, delegateObject: delegateObject) ?? module.stringForkey(KeyMoleculeName)) + ">" - } - - public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { - let moduleName = json?.optionalStringForKey("moduleName") - if moduleName == nil || delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) == nil { - if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { - error?.pointee = errorObject - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) - } - } - if let moduleName = moduleName { - return [moduleName] - } - return nil - } -} diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift.orig b/MVMCoreUI/Molecules/StandardHeaderView.swift.orig deleted file mode 100644 index 1eee69b8..00000000 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift.orig +++ /dev/null @@ -1,90 +0,0 @@ -// -// StandardHeaderView.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 2/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -public class StandardHeaderView: MoleculeContainer { - var line: Line? - - // MARK: - MVMCoreViewProtocol - open override func updateView(_ size: CGFloat) { - super.updateView(size) - line?.updateView(size) - } - - public override func setupView() { - super.setupView() - topMarginPadding = PaddingDefaultVerticalSpacing - bottomMarginPadding = PaddingDefaultVerticalSpacing - - guard line == nil else { return } - let line = Line() - line.style = .heavy - addSubview(line) - NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true - NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true - NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true - self.line = line - } - - // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - if let separatorJSON = json?.optionalDictionaryForKey("separator") { - line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) - } - } - -<<<<<<< HEAD - open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { - super.setWithModel(model, delegateObject, additionalData) - - guard let headerModel = model as? HeaderModel else { - return - } - - if let seperatorModel = headerModel.seperator as? LineModel { - line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) - } - } -======= -// open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { -// //TODO: Need to create setWithModel in ViewConstraining View -// -// #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") -// //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. -// setUpWithModel(model, delegateObject, additionalData) -// -// // This molecule will by default handle margins. -// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false) -// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false) -// -// guard let headerModel = model as? HeaderModel else { -// return -// } -// -// if let seperatorModel = headerModel.seperator as? LineModel { -// line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) -// } -// } ->>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c - - open override func reset() { - super.reset() - line?.style = .heavy - topMarginPadding = PaddingDefaultVerticalSpacing - bottomMarginPadding = PaddingDefaultVerticalSpacing - } - - public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - if let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) { - return height + PaddingDefaultVerticalSpacing + PaddingDefaultVerticalSpacing - } - return 121 - } -} From d7f955c991bd8d81a0ed5ae1b602a207d701ba68 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 09:35:38 -0500 Subject: [PATCH 249/272] fix to error check --- MVMCoreUI/Templates/MoleculeListTemplate.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 26310021..f362e595 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -54,7 +54,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } open override func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { - let shouldFinish = super.shouldFinishProcessingLoad(loadObject, error: error) + guard super.shouldFinishProcessingLoad(loadObject, error: error) else { return false } // This template requires atleast one of the three layers. if templateModel?.header == nil, templateModel?.molecules?.count ?? 0 == 0, @@ -63,7 +63,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol error.pointee = errorObject return false } - return shouldFinish + return true } open override func newDataBuildScreen() { From 304b4cbc4c38d7163ba7ab108c58c0c9d216df13 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 09:41:34 -0500 Subject: [PATCH 250/272] models encode properly --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 5 +++++ .../Atoms/TextFields/DateDropdownEntryFieldModel.swift | 2 ++ MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift | 2 ++ .../Atoms/TextFields/ItemDropdownEntryFieldModel.swift | 2 ++ MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift | 2 ++ MVMCoreUI/Molecules/FooterModel.swift | 2 ++ MVMCoreUI/Molecules/Items/AccordionListItemModel.swift | 4 ++++ MVMCoreUI/Molecules/Items/CarouselItemModel.swift | 2 ++ MVMCoreUI/Molecules/Items/DropDownListItemModel.swift | 3 ++- MVMCoreUI/Molecules/Items/ListItemModel.swift | 4 ++++ MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift | 2 ++ MVMCoreUI/Molecules/Items/TabsListItemModel.swift | 2 ++ .../VerticalCombinationViews/HeadlineBodyModel.swift | 1 + .../Lists/NumberedListModel.swift | 1 + .../Lists/UnOrderedListModel.swift | 1 + MVMCoreUI/Templates/MoleculeListTemplate.swift | 9 +++------ 16 files changed, 37 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index c9a7f2f8..61e3ca3e 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -20,6 +20,7 @@ public enum ButtonSize: String, Codable { public class ButtonModel: MoleculeModelProtocol { public static var identifier: String = "button" + public var moleculeName: String? public var backgroundColor: Color? public var title: String public var action: ActionModelProtocol @@ -34,6 +35,7 @@ public class ButtonModel: MoleculeModelProtocol { } private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case title case action @@ -45,6 +47,8 @@ public class ButtonModel: MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) @@ -60,6 +64,7 @@ public class ButtonModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(title, forKey: .title) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModel(action, forKey: .action) diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift index 4e916268..cdafc9e9 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift @@ -22,6 +22,7 @@ //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case dateFormat } @@ -38,6 +39,7 @@ 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.encode(dateFormat, forKey: .dateFormat) } } diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift index 46171e41..0291066c 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift @@ -24,6 +24,7 @@ //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case digits case secureEntry } @@ -42,6 +43,7 @@ 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.encode(digits, forKey: .digits) try container.encode(secureEntry, forKey: .secureEntry) } diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift index b913f976..c247a644 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift @@ -22,6 +22,7 @@ //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case options } @@ -38,6 +39,7 @@ 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.encode(options, forKey: .options) } } diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift index d890d918..27b0e933 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift @@ -28,6 +28,7 @@ //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case text case placeholder case enabledTextColor @@ -54,6 +55,7 @@ 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(text, forKey: .text) try container.encodeIfPresent(placeholder, forKey: .placeholder) try container.encodeIfPresent(enabledTextColor, forKey: .enabledTextColor) diff --git a/MVMCoreUI/Molecules/FooterModel.swift b/MVMCoreUI/Molecules/FooterModel.swift index 9f7b002f..d61d1194 100644 --- a/MVMCoreUI/Molecules/FooterModel.swift +++ b/MVMCoreUI/Molecules/FooterModel.swift @@ -14,6 +14,7 @@ import Foundation public var backgroundColor: Color? private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor } @@ -48,6 +49,7 @@ import Foundation 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(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift index 5d88b913..c8124b3c 100644 --- a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift @@ -17,7 +17,9 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { public var line: LineModel? private enum CodingKeys: String, CodingKey { + case moleculeName case molecules + case molecule case backgroundColor case hideLineWhenExpanded case hideArrow @@ -38,9 +40,11 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { 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.encodeModels(molecules, forKey: .molecules) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(hideLineWhenExpanded, forKey: .hideLineWhenExpanded) try container.encodeIfPresent(line, forKey: .line) + try container.encodeModel(molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift index 8f7eea64..726d4846 100644 --- a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift @@ -19,6 +19,7 @@ import Foundation case backgroundColor case peakingUI case peakingArrowColor + case molecule } required public init(from decoder: Decoder) throws { @@ -35,5 +36,6 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(peakingUI, forKey: .peakingUI) try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) + try container.encodeModel(molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 13af4278..5120eb0f 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -53,6 +53,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case molecules + case molecule case dropDown case line case backgroundColor @@ -79,7 +80,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModels2D(molecules, forKey: .molecules) + try container.encodeModels2D(molecules, forKey: .molecules) try container.encode(dropDown, forKey: .dropDown) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(line, forKey: .line) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index ff9f056d..a5490651 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -10,6 +10,7 @@ import Foundation import MVMCore @objcMembers public class ListItemModel: MoleculeContainerModel, ListItemModelProtocol { + public static var identifier: String = "listItem" public var backgroundColor: Color? public var action: ActionModelProtocol? @@ -20,6 +21,7 @@ import MVMCore private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor + case molecule case action case hideArrow case line @@ -63,6 +65,8 @@ import MVMCore public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeModel(molecule, forKey: .molecule) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift index 970f66f6..4731ef34 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift @@ -16,6 +16,7 @@ import Foundation public var gone: Bool = false private enum CodingKeys: String, CodingKey { + case moleculeName case spacing case percent case gone @@ -38,6 +39,7 @@ import Foundation 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(spacing, forKey: .spacing) try container.encodeIfPresent(percent, forKey: .percent) try container.encode(gone, forKey: .gone) diff --git a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift index 13dd09e7..0158774a 100644 --- a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/TabsListItemModel.swift @@ -18,6 +18,7 @@ public class TabsListItemModel: ContainerModel, ListItemModelProtocol { public var line: LineModel? = LineModel(type: .standard) private enum CodingKeys: String, CodingKey { + case moleculeName case tabs case molecules case backgroundColor @@ -46,6 +47,7 @@ public class TabsListItemModel: ContainerModel, ListItemModelProtocol { 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.encode(tabs, forKey: .tabs) try container.encodeModels2D(molecules, forKey: .molecules) try container.encode(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index fc22f864..62199654 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -10,6 +10,7 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "headlineBody" + public var moleculeName: String? public var headline: LabelModel? public var body: LabelModel? public var style: String? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 53bec673..795eec7d 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -35,6 +35,7 @@ import Foundation public override func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(moleculeName, forKey: .moleculeName) var models: [MoleculeModelProtocol] = [] for molecule in molecules { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 56281c43..87d57927 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -41,6 +41,7 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(bulletChar, forKey: .bulletChar) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(moleculeName, forKey: .moleculeName) var models: [MoleculeModelProtocol] = [] for molecule in molecules { diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index c4542898..d3a9f779 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -151,10 +151,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol var tmpMolecules = [ListItemModelProtocol]() molecules.forEach { molecule in - let data = try? JSONSerialization.data(withJSONObject: molecule) let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data!) - +  let jsonData = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) + let json = String(data: data!, encoding: String.Encoding.utf8) tmpMolecules.append(listItemModel!) } @@ -180,11 +180,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol var tmpMolecules = [ListItemModelProtocol]() molecules.forEach { molecule in - let data = try? JSONSerialization.data(withJSONObject: molecule) - let decoder = JSONDecoder() - let listItemModel = try? decoder.decode(ListItemModel.self, from: data!) - + let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data!) tmpMolecules.append(listItemModel!) } From 86f60bccf8a400b312c57d5ea3a66951bf2d359a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 10:11:42 -0500 Subject: [PATCH 251/272] adding height override --- MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index bc8edf18..0826b4b5 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -68,4 +68,8 @@ import UIKit super.reset() bottomSeparatorView?.setStyle(.none) } + + public override static func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 80 + } } From 4a194d4e6fc312a16afe1215578a3a80ba06d703 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 10:21:42 -0500 Subject: [PATCH 252/272] fixes for the banner --- .../HeadLineBodyCaretLinkImage.swift | 37 ++++++------ .../HeadlineBodyCaretLinkImageModel.swift | 56 ++++++++++++++++++- 2 files changed, 76 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index 01325da9..78aa5c8f 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -7,13 +7,15 @@ // import Foundation -@objcMembers public class HeadLineBodyCaretLinkImage: View { - +@objcMembers public class HeadLineBodyCaretLinkImage: Container { let headlineBody = HeadlineBody(frame: .zero) let caretButton = CaretButton(frame: .zero) - let backgroundImageView = MFLoadImageView() + let backgroundImageView = MFLoadImageView(pinnedEdges: .all) var spaceBetweenConstant: CGFloat = 104.0 - let maxWidth : CGFloat = 350.0 + let maxWidth: CGFloat = 350.0 + static let heightConstant: CGFloat = 320.0 + var heightConstraint: NSLayoutConstraint? + // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) @@ -29,25 +31,28 @@ import Foundation guard subviews.count == 0 else { return } - let view = MVMCoreUICommonViewsUtility.commonView() - addSubview(view) - NSLayoutConstraint.constraintPinSubview(toSuperview: view) - view.addSubview(headlineBody) - view.addSubview(caretButton) + heightConstraint = heightAnchor.constraint(equalToConstant: Self.heightConstant) + heightConstraint?.isActive = true + + let container = MVMCoreUICommonViewsUtility.commonView() + addAndContain(container) + + container.addSubview(headlineBody) + container.addSubview(caretButton) //Headline view - headlineBody.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true - headlineBody.topAnchor.constraint(equalTo: view.topAnchor, constant: PaddingDefault).isActive = true + headlineBody.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 0).isActive = true + headlineBody.topAnchor.constraint(equalTo: container.topAnchor, constant: 0).isActive = true - let headLineBodyWidth = headlineBody.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.85) + let headLineBodyWidth = headlineBody.widthAnchor.constraint(equalTo: container.widthAnchor, multiplier: 0.85) headLineBodyWidth.priority = .defaultHigh headLineBodyWidth.isActive = true headlineBody.widthAnchor.constraint(lessThanOrEqualToConstant: maxWidth).isActive = true //Caret view caretButton.translatesAutoresizingMaskIntoConstraints = false - caretButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true - view.bottomAnchor.constraint(equalTo: caretButton.bottomAnchor, constant: PaddingDefault).isActive = true + caretButton.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 0).isActive = true + container.bottomAnchor.constraint(equalTo: caretButton.bottomAnchor, constant: 0).isActive = true caretButton.topAnchor.constraint(greaterThanOrEqualTo: headlineBody.bottomAnchor, constant: spaceBetweenConstant).isActive = true @@ -56,9 +61,9 @@ import Foundation backgroundImageView.imageView.contentMode = .scaleAspectFill backgroundImageView.alignFillHorizontal() backgroundImageView.alignFillVertical() - view.addSubview(backgroundImageView) + addSubview(backgroundImageView) NSLayoutConstraint.constraintPinSubview(toSuperview: backgroundImageView) - view.sendSubviewToBack(backgroundImageView) + sendSubviewToBack(backgroundImageView) } // MARK: - MVMCoreUIMoleculeViewProtocol diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift index e57cb369..eb8d7c60 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift @@ -8,10 +8,64 @@ import UIKit -public class HeadlineBodyCaretLinkImageModel: MoleculeModelProtocol { +public class HeadlineBodyCaretLinkImageModel: ContainerModel, MoleculeModelProtocol { public static var identifier: String = "headlineBodyCaretLinkImage" public var backgroundColor: Color? public var caretLink: CaretLinkModel? public var headlineBody: HeadlineBodyModel public var image: ImageViewModel + + init(headlineBody: HeadlineBodyModel, image: ImageViewModel) { + self.headlineBody = headlineBody + self.image = image + super.init() + setDefaults() + } + + /// Defaults to set + func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } + if topMarginPadding == nil { + topMarginPadding = PaddingDefault + } + if bottomMarginPadding == nil { + bottomMarginPadding = PaddingDefault + } + if image.height == nil { + image.height = HeadLineBodyCaretLinkImage.heightConstant + } + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case headlineBody + case image + case caretLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) + image = try typeContainer.decode(ImageViewModel.self, forKey: .image) + caretLink = try typeContainer.decodeIfPresent(CaretLinkModel.self, forKey: .caretLink) + try super.init(from: decoder) + setDefaults() + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(HeadlineBodyCaretLinkImageModel.identifier, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(headlineBody, forKey: .headlineBody) + try container.encode(image, forKey: .image) + try container.encodeIfPresent(caretLink, forKey: .caretLink) + } } From 8b8ec937b1693687eeebc3c3f35fcbf4b6689940 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 10:24:49 -0500 Subject: [PATCH 253/272] caret link hiding --- .../VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index 78aa5c8f..fc19749a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -90,6 +90,7 @@ import Foundation guard let model = model as? HeadlineBodyCaretLinkImageModel else { return } headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData) caretButton.setWithModel(model.caretLink, delegateObject, additionalData) + caretButton.isHidden = model.caretLink == nil backgroundImageView.setWithModel(model.image, delegateObject, additionalData) backgroundImageView.alignFillHorizontal() backgroundImageView.alignFillVertical() From 9384e28eb819539c70f8e7b5c0b8dd9fda237bfa Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 10:29:36 -0500 Subject: [PATCH 254/272] fix on rotate margin issue --- MVMCoreUI/Molecules/Items/TableViewCell.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 9daec27d..cd8a3cdf 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -137,6 +137,7 @@ import UIKit open func setupView() { selectionStyle = .none insetsLayoutMarginsFromSafeArea = false + preservesSuperviewLayoutMargins = false contentView.insetsLayoutMarginsFromSafeArea = false contentView.preservesSuperviewLayoutMargins = false } From 5a1aad63c7b7bb6cb3df8d2aebd08e719e64658c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 10:33:16 -0500 Subject: [PATCH 255/272] remove axis property wrapper --- .../NSLayoutConstraintAxis+Extension.swift | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift b/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift index f989e17b..9e82f9f9 100644 --- a/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift +++ b/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift @@ -60,28 +60,18 @@ extension NSLayoutConstraint.Axis: RawRepresentable { } } -@propertyWrapper -public struct Axis { - public var wrappedValue: NSLayoutConstraint.Axis - - public init(wrappedValue value: NSLayoutConstraint.Axis) { - self.wrappedValue = value - } -} - -extension Axis: Codable { +extension NSLayoutConstraint.Axis: Codable { public init(from decoder: Decoder) throws { let typeContainer = try decoder.singleValueContainer() let string = try typeContainer.decode(String.self) guard let axis = NSLayoutConstraint.Axis(rawValue: string) else { throw AxisError.notAnAxis } - wrappedValue = axis + self = axis } public func encode(to encoder: Encoder) throws { - let string = wrappedValue.rawValueString var container = encoder.singleValueContainer() - try container.encode(string) + try container.encode(rawValueString) } } From f43e018e2117abf5ccb3c4a4c8f6bebc22cc64fe Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 10:38:38 -0500 Subject: [PATCH 256/272] model reuse --- MVMCoreUI/Containers/views/EntryFieldContainer.swift | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Containers/views/EntryFieldContainer.swift b/MVMCoreUI/Containers/views/EntryFieldContainer.swift index 3f80006a..96a51a8f 100644 --- a/MVMCoreUI/Containers/views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/views/EntryFieldContainer.swift @@ -118,7 +118,7 @@ import UIKit //-------------------------------------------------- /// Holds reference to delegateObject to inform molecular tableView of an update. - var delegateObject: MVMCoreUIDelegateObject? + weak var delegateObject: MVMCoreUIDelegateObject? //-------------------------------------------------- // MARK: - Lifecycle @@ -271,17 +271,9 @@ import UIKit layoutIfNeeded() } } - - //-------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol - //-------------------------------------------------- - - open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.setWithModel(model, delegateObject, additionalData) - self.delegateObject = delegateObject - } } +// MARK:- MVMCoreUIMoleculeViewProtocol extension EntryFieldContainer { override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { From af20b0a8a46d8cb6cbf1d150df3d371a4d21192d Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Fri, 24 Jan 2020 10:41:04 -0500 Subject: [PATCH 257/272] remove entryfieldcontainer for odd behavior --- MVMCoreUI.xcodeproj/project.pbxproj | 4 - .../Views/EntryFieldContainer.swift | 285 ------------------ 2 files changed, 289 deletions(-) delete mode 100644 MVMCoreUI/Containers/Views/EntryFieldContainer.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f395d21b..21e90897 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -86,7 +86,6 @@ 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; }; 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; }; - 0ACDF26B23DA0AC2002044B2 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ACDF26A23DA0AC2002044B2 /* EntryFieldContainer.swift */; }; 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; @@ -389,7 +388,6 @@ 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = ""; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = ""; }; - 0ACDF26A23DA0AC2002044B2 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = ""; }; 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = ""; }; 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; @@ -702,7 +700,6 @@ isa = PBXGroup; children = ( D29E28DE23D740FC00ACEA85 /* Container */, - 0ACDF26A23DA0AC2002044B2 /* EntryFieldContainer.swift */, 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */, D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, ); @@ -1624,7 +1621,6 @@ 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */, D274CA332236A78900B01B62 /* FooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, - 0ACDF26B23DA0AC2002044B2 /* EntryFieldContainer.swift in Sources */, 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift deleted file mode 100644 index 96a51a8f..00000000 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ /dev/null @@ -1,285 +0,0 @@ -// -// EntryFieldContainer.swift -// MVMCoreUI -// -// Created by Kevin Christiano on 11/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - - -@objcMembers open class EntryFieldContainer: View { - //-------------------------------------------------- - // MARK: - Drawing Properties - //-------------------------------------------------- - - /// The bottom border line. Height is dynamic based on scenario. - public var bottomBar: CAShapeLayer? = { - let layer = CAShapeLayer() - layer.backgroundColor = UIColor.black.cgColor - layer.drawsAsynchronously = true - layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); - return layer - }() - - /// Total control over the drawn top, bottom, left and right borders. - public var disableAllBorders = false { - didSet { - bottomBar?.isHidden = disableAllBorders - } - } - - private(set) var fieldState: FieldState = .original { - didSet (oldState) { - // Will not update if new state is the same as old. - if fieldState != oldState { - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - self.fieldState.setStateUI(for: self) - } - } - } - } - - /// Determines if the top, left, and right borders should be drawn. - private var hideBorders = false - - public var borderStrokeColor: UIColor = .mfSilver() - private var borderPath: UIBezierPath = UIBezierPath() - - //-------------------------------------------------- - // MARK: - Property Observers - //-------------------------------------------------- - - private var _isEnabled: Bool = true - private var _showError: Bool = false - private var _isLocked: Bool = false - private var _isSelected: Bool = false - - public var isEnabled: Bool { - get { return _isEnabled } - set (enabled) { - - _isEnabled = enabled - _isLocked = false - _isSelected = false - _showError = false - - fieldState = enabled ? .original : .disabled - } - } - - public var showError: Bool { - get { return _showError } - set (error) { - - _showError = error - _isEnabled = true - _isLocked = false - _isSelected = false - - fieldState = error ? .error : .original - } - } - - public var isLocked: Bool { - get { return _isLocked } - set (locked) { - - _isLocked = locked - _isEnabled = true - _isSelected = false - _showError = false - - fieldState = locked ? .locked : .original - } - } - - public var isSelected: Bool { - get { return _isSelected } - set (selected) { - - _isSelected = selected - _isLocked = false - _isEnabled = true - - if _showError { - fieldState = selected ? .selectedError : .error - } else { - fieldState = selected ? .selected : .original - } - } - } - - //-------------------------------------------------- - // MARK: - Delegate - //-------------------------------------------------- - - /// Holds reference to delegateObject to inform molecular tableView of an update. - weak var delegateObject: MVMCoreUIDelegateObject? - - //-------------------------------------------------- - // MARK: - Lifecycle - //-------------------------------------------------- - - open override func layoutSubviews() { - super.layoutSubviews() - - refreshUI(bottomBarSize: showError ? 4 : 1) - } - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - - refreshUI() - } - - /// This handles the top, left, and right border lines. - open override func draw(_ rect: CGRect) { - super.draw(rect) - - borderPath.removeAllPoints() - - if !disableAllBorders && !hideBorders { - // Brings the other half of the line inside the view to prevent cropping. - let origin = bounds.origin - let size = frame.size - let insetLean: CGFloat = 0.5 - borderPath.lineWidth = 1 - - borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height)) - borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean)) - borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean)) - borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + size.height)) - - borderStrokeColor.setStroke() - borderPath.stroke() - } - } - - override open func setupView() { - super.setupView() - - isAccessibilityElement = false - isOpaque = false - - if let bottomBar = bottomBar { - layer.addSublayer(bottomBar) - } - } - - //-------------------------------------------------- - // MARK: - Draw States - //-------------------------------------------------- - - public enum FieldState { - case original - case error - case selectedError - case selected - case locked - case disabled - - public func setStateUI(for formField: EntryFieldContainer) { - - switch self { - case .original: - formField.originalUI() - - case .error: - formField.errorUI() - - case .selectedError: - formField.selectedErrorUI() - - case .selected: - formField.selectedUI() - - case .locked: - formField.lockedUI() - - case .disabled: - formField.disabledUI() - } - } - } - - open func originalUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.black.cgColor - refreshUI(bottomBarSize: 1) - } - - open func errorUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .mfPumpkin() - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor - refreshUI(bottomBarSize: 4) - } - - open func selectedErrorUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor - refreshUI(bottomBarSize: 4) - } - - open func selectedUI() { - - isUserInteractionEnabled = true - hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.black.cgColor - refreshUI(bottomBarSize: 1) - } - - open func lockedUI() { - - isUserInteractionEnabled = false - hideBorders = true - borderStrokeColor = .clear - bottomBar?.backgroundColor = UIColor.clear.cgColor - refreshUI(bottomBarSize: 1) - } - - open func disabledUI() { - - isUserInteractionEnabled = false - hideBorders = false - borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.mfSilver().cgColor - refreshUI(bottomBarSize: 1) - } - - open func refreshUI(bottomBarSize: CGFloat? = nil) { - - if !disableAllBorders { - let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) - bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) - - delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) - setNeedsDisplay() - layoutIfNeeded() - } - } -} - -// MARK:- MVMCoreUIMoleculeViewProtocol -extension EntryFieldContainer { - - override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - self.delegateObject = delegateObject - - guard let dictionary = json, !dictionary.isEmpty else { return } - } -} From af7e813e1842eda760e283aee65bee91f226a096 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 10:41:38 -0500 Subject: [PATCH 258/272] model reuse again --- MVMCoreUI/Atoms/TextFields/TextEntryField.swift | 13 +++---------- .../Containers/views/EntryFieldContainer.swift | 12 ++++++++++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index 1230a485..66f3ecd4 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -277,19 +277,12 @@ import UIKit guard let model = model as? TextEntryFieldModel else { return } FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol) - - if let enabledTextColor = model.enabledTextColor { - textColor.enabled = enabledTextColor.uiColor - } - - if let disabledTextColor = model.disabledTextColor { - textColor.disabled = disabledTextColor.uiColor - } - + + textColor.enabled = model.enabledTextColor?.uiColor + textColor.disabled = model.disabledTextColor?.uiColor text = model.text placeholder = model.placeholder - switch model.type { case "password": textField.isSecureTextEntry = true diff --git a/MVMCoreUI/Containers/views/EntryFieldContainer.swift b/MVMCoreUI/Containers/views/EntryFieldContainer.swift index 96a51a8f..3f80006a 100644 --- a/MVMCoreUI/Containers/views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/views/EntryFieldContainer.swift @@ -118,7 +118,7 @@ import UIKit //-------------------------------------------------- /// Holds reference to delegateObject to inform molecular tableView of an update. - weak var delegateObject: MVMCoreUIDelegateObject? + var delegateObject: MVMCoreUIDelegateObject? //-------------------------------------------------- // MARK: - Lifecycle @@ -271,9 +271,17 @@ import UIKit layoutIfNeeded() } } + + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + self.delegateObject = delegateObject + } } -// MARK:- MVMCoreUIMoleculeViewProtocol extension EntryFieldContainer { override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { From 5e4f976a1cbf75ec2bb8be9384328ed7eb326eed Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Fri, 24 Jan 2020 10:42:13 -0500 Subject: [PATCH 259/272] re add entry field container for fixing odd behavior --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + .../Views/EntryFieldContainer.swift | 293 ++++++++++++++++++ 2 files changed, 297 insertions(+) create mode 100644 MVMCoreUI/Containers/Views/EntryFieldContainer.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 21e90897..aec00c53 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -89,6 +89,7 @@ 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.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 */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -392,6 +393,7 @@ 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = ""; }; 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.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 = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; @@ -699,6 +701,7 @@ 0ABD1369237B18EE0081388D /* Views */ = { isa = PBXGroup; children = ( + 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */, D29E28DE23D740FC00ACEA85 /* Container */, 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */, D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */, @@ -1666,6 +1669,7 @@ D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, + 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, 0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */, diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift new file mode 100644 index 00000000..3f80006a --- /dev/null +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -0,0 +1,293 @@ +// +// EntryFieldContainer.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 11/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + + +@objcMembers open class EntryFieldContainer: View { + //-------------------------------------------------- + // MARK: - Drawing Properties + //-------------------------------------------------- + + /// The bottom border line. Height is dynamic based on scenario. + public var bottomBar: CAShapeLayer? = { + let layer = CAShapeLayer() + layer.backgroundColor = UIColor.black.cgColor + layer.drawsAsynchronously = true + layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); + return layer + }() + + /// Total control over the drawn top, bottom, left and right borders. + public var disableAllBorders = false { + didSet { + bottomBar?.isHidden = disableAllBorders + } + } + + private(set) var fieldState: FieldState = .original { + didSet (oldState) { + // Will not update if new state is the same as old. + if fieldState != oldState { + DispatchQueue.main.async { [weak self] in + guard let self = self else { return } + + self.fieldState.setStateUI(for: self) + } + } + } + } + + /// Determines if the top, left, and right borders should be drawn. + private var hideBorders = false + + public var borderStrokeColor: UIColor = .mfSilver() + private var borderPath: UIBezierPath = UIBezierPath() + + //-------------------------------------------------- + // MARK: - Property Observers + //-------------------------------------------------- + + private var _isEnabled: Bool = true + private var _showError: Bool = false + private var _isLocked: Bool = false + private var _isSelected: Bool = false + + public var isEnabled: Bool { + get { return _isEnabled } + set (enabled) { + + _isEnabled = enabled + _isLocked = false + _isSelected = false + _showError = false + + fieldState = enabled ? .original : .disabled + } + } + + public var showError: Bool { + get { return _showError } + set (error) { + + _showError = error + _isEnabled = true + _isLocked = false + _isSelected = false + + fieldState = error ? .error : .original + } + } + + public var isLocked: Bool { + get { return _isLocked } + set (locked) { + + _isLocked = locked + _isEnabled = true + _isSelected = false + _showError = false + + fieldState = locked ? .locked : .original + } + } + + public var isSelected: Bool { + get { return _isSelected } + set (selected) { + + _isSelected = selected + _isLocked = false + _isEnabled = true + + if _showError { + fieldState = selected ? .selectedError : .error + } else { + fieldState = selected ? .selected : .original + } + } + } + + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + + /// Holds reference to delegateObject to inform molecular tableView of an update. + var delegateObject: MVMCoreUIDelegateObject? + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + open override func layoutSubviews() { + super.layoutSubviews() + + refreshUI(bottomBarSize: showError ? 4 : 1) + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + + refreshUI() + } + + /// This handles the top, left, and right border lines. + open override func draw(_ rect: CGRect) { + super.draw(rect) + + borderPath.removeAllPoints() + + if !disableAllBorders && !hideBorders { + // Brings the other half of the line inside the view to prevent cropping. + let origin = bounds.origin + let size = frame.size + let insetLean: CGFloat = 0.5 + borderPath.lineWidth = 1 + + borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height)) + borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + size.height)) + + borderStrokeColor.setStroke() + borderPath.stroke() + } + } + + override open func setupView() { + super.setupView() + + isAccessibilityElement = false + isOpaque = false + + if let bottomBar = bottomBar { + layer.addSublayer(bottomBar) + } + } + + //-------------------------------------------------- + // MARK: - Draw States + //-------------------------------------------------- + + public enum FieldState { + case original + case error + case selectedError + case selected + case locked + case disabled + + public func setStateUI(for formField: EntryFieldContainer) { + + switch self { + case .original: + formField.originalUI() + + case .error: + formField.errorUI() + + case .selectedError: + formField.selectedErrorUI() + + case .selected: + formField.selectedUI() + + case .locked: + formField.lockedUI() + + case .disabled: + formField.disabledUI() + } + } + } + + open func originalUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func errorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfPumpkin() + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedErrorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func lockedUI() { + + isUserInteractionEnabled = false + hideBorders = true + borderStrokeColor = .clear + bottomBar?.backgroundColor = UIColor.clear.cgColor + refreshUI(bottomBarSize: 1) + } + + open func disabledUI() { + + isUserInteractionEnabled = false + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.mfSilver().cgColor + refreshUI(bottomBarSize: 1) + } + + open func refreshUI(bottomBarSize: CGFloat? = nil) { + + if !disableAllBorders { + let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) + bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) + + delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + setNeedsDisplay() + layoutIfNeeded() + } + } + + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + self.delegateObject = delegateObject + } +} + +extension EntryFieldContainer { + + override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + self.delegateObject = delegateObject + + guard let dictionary = json, !dictionary.isEmpty else { return } + } +} From 851d5b57ff3c70940175703b8f06c03023c2a9f0 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 10:58:03 -0500 Subject: [PATCH 260/272] remvoe explicit unwrapping --- .../Items/DropDownFilterTableViewCell.swift | 4 +- .../Templates/MoleculeListTemplate.swift | 60 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 0826b4b5..ed2294a5 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -40,7 +40,9 @@ import UIKit for moleculeList in molecules { var json1d = [[AnyHashable: Any]]() for molecule in moleculeList { - json1d.append((molecule as? ListItemModel)!.toJSON()!) + if let moleculeDictionary = (molecule as? ListItemModel)?.toJSON() { + json1d.append(moleculeDictionary) + } } json2d.append(json1d) } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 159589eb..75ef7d2f 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -9,10 +9,10 @@ import UIKit open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol { - + public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? var observer: NSKeyValueObservation? - + public var templateModel: ListPageTemplateModel? @objc public override func parsePageJSON() throws { try parseTemplateJSON() @@ -31,11 +31,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } } - + open override func viewForTop() -> UIView { guard let headerModel = templateModel?.header, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { - return super.viewForTop() + return super.viewForTop() } // Temporary, Default the horizontal padding @@ -48,7 +48,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol override open func viewForBottom() -> UIView { guard let footerModel = templateModel?.footer, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else { - return super.viewForBottom() + return super.viewForBottom() } return molecule } @@ -97,7 +97,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { guard let moleculeInfo = moleculesInfo?[indexPath.row], let cell = tableView.dequeueReusableCell(withIdentifier: moleculeInfo.identifier) else { - return UITableViewCell() + return UITableViewCell() } let delegate = delegateObject() as? MVMCoreUIDelegateObject let moleculeCell = cell as? MVMCoreUIMoleculeViewProtocol @@ -145,17 +145,15 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } } - + public override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol]() molecules.forEach { molecule in - let data = try? JSONSerialization.data(withJSONObject: molecule) - let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data!) -  let jsonData = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) - let json = String(data: data!, encoding: String.Encoding.utf8) - tmpMolecules.append(listItemModel!) + if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data) { + tmpMolecules.append(listItemModel) + } } DispatchQueue.main.async { @@ -180,9 +178,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol var tmpMolecules = [ListItemModelProtocol]() molecules.forEach { molecule in - let data = try? JSONSerialization.data(withJSONObject: molecule) - let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data!) - tmpMolecules.append(listItemModel!) + if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(ListItemModel.self, from: data) { + tmpMolecules.append(listItemModel) + } } var indexPaths: [IndexPath] = [] @@ -202,21 +200,21 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // This dispatch is needed to fix a race condition that can occur if this function is called during the table setup. - DispatchQueue.main.async { - guard let indexPath = self.tableView?.indexPath(for: sender) else { return } - var indexPaths: [IndexPath] = [] - for molecule in molecules { - if let info = self.getMoleculeInfo(with: molecule) { - self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier) - let index = indexPath.row + 1 + indexPaths.count - self.moleculesInfo?.insert(info, at: index) - indexPaths.append(IndexPath(row: index, section: 0)) - } - } - self.tableView?.insertRows(at: indexPaths, with: animation) - self.updateViewConstraints() - self.view.layoutIfNeeded() - } + DispatchQueue.main.async { + guard let indexPath = self.tableView?.indexPath(for: sender) else { return } + var indexPaths: [IndexPath] = [] + for molecule in molecules { + if let info = self.getMoleculeInfo(with: molecule) { + self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier) + let index = indexPath.row + 1 + indexPaths.count + self.moleculesInfo?.insert(info, at: index) + indexPaths.append(IndexPath(row: index, section: 0)) + } + } + self.tableView?.insertRows(at: indexPaths, with: animation) + self.updateViewConstraints() + self.view.layoutIfNeeded() + } } public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { @@ -241,7 +239,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol guard let listItem = listItem, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else { - return nil + return nil } return (moleculeName, moleculeClass, listItem) } From f41ad328d2f783f8cc739342d319450eed13aafa Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Fri, 24 Jan 2020 11:44:48 -0500 Subject: [PATCH 261/272] remove conflict files --- .../Items/DropDownListItemModel.swift.orig | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig deleted file mode 100644 index e702000b..00000000 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig +++ /dev/null @@ -1,55 +0,0 @@ -// -// DropDownListItemModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 12/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers public class DropDownListItemModel: ContainerModel, ListItemModelProtocol { - public static var identifier: String = "dropDownListItem" - public var molecules: [[ListItemModelProtocol]] - public var dropDown: ItemDropdownEntryFieldModel - public var backgroundColor: Color? - public var line: LineModel? = LineModel(type: .none) - public var hideArrow: Bool? = true - -<<<<<<< HEAD - public init(molecule: MoleculeModelProtocol, molecules: [[ListItemModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { -======= - public init(molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { ->>>>>>> remotes/origin/feature/coding - self.molecules = molecules - self.dropDown = dropDown - super.init() - } - - private enum CodingKeys: String, CodingKey { - case molecules - case dropDown - case line - case backgroundColor - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] - dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) - if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { - line = lineModel - } - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - 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.encodeModels2D(molecules, forKey: .molecules) - try container.encode(dropDown, forKey: .dropDown) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(line, forKey: .line) - } -} From 451e28cdfd4cf315aeb5b362016a200f30200093 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 11:47:25 -0500 Subject: [PATCH 262/272] removed conflict file --- .../Items/DropDownListItemModel.swift.orig | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig deleted file mode 100644 index e702000b..00000000 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift.orig +++ /dev/null @@ -1,55 +0,0 @@ -// -// DropDownListItemModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 12/12/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers public class DropDownListItemModel: ContainerModel, ListItemModelProtocol { - public static var identifier: String = "dropDownListItem" - public var molecules: [[ListItemModelProtocol]] - public var dropDown: ItemDropdownEntryFieldModel - public var backgroundColor: Color? - public var line: LineModel? = LineModel(type: .none) - public var hideArrow: Bool? = true - -<<<<<<< HEAD - public init(molecule: MoleculeModelProtocol, molecules: [[ListItemModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { -======= - public init(molecules: [[ListItemModelProtocol]], dropDown: DropDownModel) { ->>>>>>> remotes/origin/feature/coding - self.molecules = molecules - self.dropDown = dropDown - super.init() - } - - private enum CodingKeys: String, CodingKey { - case molecules - case dropDown - case line - case backgroundColor - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeMolecules2D(codingKey: .molecules) as! [[ListItemModelProtocol]] - dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) - if let lineModel = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { - line = lineModel - } - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - 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.encodeModels2D(molecules, forKey: .molecules) - try container.encode(dropDown, forKey: .dropDown) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(line, forKey: .line) - } -} From 7019bdaa7802f3170999440e2ec1a8b1bb009db8 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 11:54:23 -0500 Subject: [PATCH 263/272] no longer needed. --- .../MVMCoreUIMoleculeMappingObject.m | 50 +------------------ 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index e0c83569..ccaa9115 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -25,55 +25,7 @@ static dispatch_once_t onceToken; static NSMutableDictionary *mapping; dispatch_once(&onceToken, ^{ - mapping = [@{ - @"label": Label.class, - @"line": Line.class, - @"button": PrimaryButton.class, - @"link": MFTextButton.class, - @"header": HeaderView.class, - @"twoButtonView": TwoButtonView.class, - @"footer": FooterView.class, - @"caretView": CaretView.class, - @"caretLink": CaretButton.class, - @"digitTextField": DigitEntryField.class, - @"textField": TextEntryField.class, - @"mdnEntryField": MdnEntryField.class, - @"dropDown": ItemDropdownEntryField.class, - @"dateDropdownEntryField": DateDropdownEntryField.class, - @"checkbox": Checkbox.class, - @"checkboxLabel": CheckboxWithLabelView.class, - @"cornerLabels" : CornerLabels.class, - @"progressBar": ProgressBar.class, - @"circleProgress": GraphView.class, - @"multiProgressBar": MultiProgress.class, - @"radioButton": RadioButton.class, - @"radioButtonLabel": RadioButtonLabel.class, - @"listItem": MoleculeTableViewCell.class, - @"accordionListItem": AccordionMoleculeTableViewCell.class, - @"toggle": Toggle.class, - @"leftRightLabelView": LeftRightLabelView.class, - @"actionDetailWithImage": ActionDetailWithImage.class, - @"image": MFLoadImageView.class, - @"moduleMolecule": ModuleMolecule.class, - @"headlineBody": HeadlineBody.class, - @"carousel": Carousel.class, - @"carouselItem": MoleculeCollectionViewCell.class, - @"barsPager": MVMCoreUIPageControl.class, - @"scroller": Scroller.class, - @"imageHeadlineBody": ImageHeadlineBody.class, - @"labelToggle": LabelSwitch.class, - @"headlineBodyToggle": HeadlineBodySwitch.class, - @"headlineBodyLink": HeadlineBodyTextButton.class, - @"headlineBodyLinkToggle": HeadlineBodyTextButtonSwitch.class, - @"tabsListItem": TabsTableViewCell.class, - @"dropDownListItem": DropDownFilterTableViewCell.class, - @"headlineBodyButton": HeadlineBodyButton.class, - @"stackItem": MoleculeStackItem.class, - @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class, - @"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class, - @"doughnutChart": DoughnutChartView.class, - @"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class - } mutableCopy]; + mapping = [@{} mutableCopy]; }); return mapping; } From a16a362c03dc514958301e6be0fa2f3de72fd66b Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 24 Jan 2020 12:10:43 -0500 Subject: [PATCH 264/272] dash color --- MVMCoreUI/Atoms/Views/DashLine.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index cbee1eb8..fc8f8bc3 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -19,6 +19,9 @@ open class DashLine: View { get { return model as? DashLineModel } } + //TODO: Need this for BAU. Can remove once we fix BAU + public var dashColor: UIColor? + @objc private var dashLayer: CAShapeLayer? //------------------------------------------------------ @@ -68,7 +71,7 @@ open class DashLine: View { dashLayer.lineCap = .round dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)] dashLayer.path = path.cgPath - dashLayer.strokeColor = dashModel?.dashColor.cgColor + dashLayer.strokeColor = dashModel?.dashColor.cgColor ?? dashColor?.cgColor dashLayer.fillColor = UIColor.clear.cgColor dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor self.dashLayer = dashLayer From e5948e05e5d80c26d653b556aebcdc92d5d0fbf8 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 12:33:22 -0500 Subject: [PATCH 265/272] pr fixes --- .../TextFields/BaseDropdownEntryField.swift | 4 +++- .../BaseDropdownEntryFieldModel.swift | 21 ++++++++++++++++++- .../TextFields/DateDropdownEntryField.swift | 2 +- .../Atoms/TextFields/EntryFieldModel.swift | 4 ++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift index 6cb0c96a..3290c744 100644 --- a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift @@ -72,7 +72,9 @@ import UIKit public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) - dropDownCaretView.setWithModel(model, delegateObject, additionalData) + guard let model = model as? BaseDropdownEntryFieldModel else { return } + + dropDownCaretView.setWithModel(model.caretView, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift index 1fefd42f..e6e7cb24 100644 --- a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift @@ -7,20 +7,39 @@ // @objcMembers public class BaseDropdownEntryFieldModel: TextEntryFieldModel { - //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + public var caretView: CaretViewModel? + public override class var identifier: String { return "" } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case caretView + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { try super.init(from: decoder) + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + caretView = try typeContainer.decodeIfPresent(CaretViewModel.self, forKey: .caretView) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(caretView, forKey: .caretView) } } diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift index 7051239c..acfe0a42 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift @@ -116,7 +116,7 @@ import UIKit guard let model = model as? DateDropdownEntryFieldModel else { return } - self.dateFormat = model.dateFormat + dateFormat = model.dateFormat } } diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index 14a57f4c..70c1c0e3 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -19,6 +19,7 @@ import Foundation } public var backgroundColor: Color? + public var moleculeName: String? public var title: String? public var feedback: String? public var errorMessage: String = "" @@ -34,6 +35,7 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case title case isEnabled @@ -52,6 +54,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) @@ -65,6 +68,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(feedback, forKey: .feedback) From 7b8b2a059f1c6dc8e270d9d91eefa502bf41e696 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 12:43:38 -0500 Subject: [PATCH 266/272] no need for val --- MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift | 2 +- MVMCoreUI/Molecules/Items/AccordionListItemModel.swift | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift index c247a644..03c1cf40 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift @@ -33,7 +33,7 @@ required public init(from decoder: Decoder) throws { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - options = try typeContainer.decodeIfPresent([String].self, forKey: .options) ?? [] + options = try typeContainer.decode([String].self, forKey: .options) } public override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift index c8124b3c..0e2fa531 100644 --- a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift @@ -19,7 +19,6 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { private enum CodingKeys: String, CodingKey { case moleculeName case molecules - case molecule case backgroundColor case hideLineWhenExpanded case hideArrow @@ -45,6 +44,5 @@ class AccordionListItemModel: MoleculeContainerModel, ListItemModelProtocol { try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(hideLineWhenExpanded, forKey: .hideLineWhenExpanded) try container.encodeIfPresent(line, forKey: .line) - try container.encodeModel(molecule, forKey: .molecule) } } From c250769620e7c0c1c48cbf2627c78c2e18c53319 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 13:20:02 -0500 Subject: [PATCH 267/272] using existing model encoding func --- .../Molecules/Items/CarouselItemModel.swift | 4 ++++ .../Items/DropDownFilterTableViewCell.swift | 17 +++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift index 726d4846..4f4c3b58 100644 --- a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift @@ -14,8 +14,10 @@ import Foundation public var backgroundColor: Color? public var peakingUI: Bool? public var peakingArrowColor: Color? + public var moleculeName: String? private enum CodingKeys: String, CodingKey { + case moleculeName case backgroundColor case peakingUI case peakingArrowColor @@ -24,6 +26,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI) peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor) @@ -33,6 +36,7 @@ import Foundation 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(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(peakingUI, forKey: .peakingUI) try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index ed2294a5..46139a37 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -32,21 +32,10 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let molecules = self.dropDownListItemModel?.molecules + let dropListItemJSON = self.dropDownListItemModel.toJSON(), + let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]] else { return } - - var json2d = [[[AnyHashable: Any]]]() - - for moleculeList in molecules { - var json1d = [[AnyHashable: Any]]() - for molecule in moleculeList { - if let moleculeDictionary = (molecule as? ListItemModel)?.toJSON() { - json1d.append(moleculeDictionary) - } - } - json2d.append(json1d) - } - + if self.previousIndex != NSNotFound { self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) } From 11aaedfa6b6b54d54e2a979ee65ee7cf81daf14c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 13:25:59 -0500 Subject: [PATCH 268/272] pr fixes --- MVMCoreUI/Molecules/Items/CarouselItemModel.swift | 2 -- MVMCoreUI/Molecules/Items/DropDownListItemModel.swift | 3 ++- MVMCoreUI/Molecules/Items/ListItemModel.swift | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift index 4f4c3b58..f2c88e9b 100644 --- a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Molecules/Items/CarouselItemModel.swift @@ -21,7 +21,6 @@ import Foundation case backgroundColor case peakingUI case peakingArrowColor - case molecule } required public init(from decoder: Decoder) throws { @@ -40,6 +39,5 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(peakingUI, forKey: .peakingUI) try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor) - try container.encodeModel(molecule, forKey: .molecule) } } diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 5120eb0f..35f69b51 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -52,8 +52,8 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case moleculeName case molecules - case molecule case dropDown case line case backgroundColor @@ -80,6 +80,7 @@ import Foundation 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.encodeModels2D(molecules, forKey: .molecules) try container.encode(dropDown, forKey: .dropDown) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index a5490651..ffb0eb35 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -21,7 +21,6 @@ import MVMCore private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor - case molecule case action case hideArrow case line @@ -65,8 +64,6 @@ import MVMCore public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeModel(molecule, forKey: .molecule) - try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) From 3eb97d65c92a33264c0e0149228e7c461f0de144 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 15:06:45 -0500 Subject: [PATCH 269/272] fixing reuse error in setWithModel --- MVMCoreUI/Atoms/TextFields/EntryField.swift | 11 ++++++++--- MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atoms/TextFields/EntryField.swift index e70a2df0..82cc69f6 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryField.swift @@ -249,11 +249,16 @@ import UIKit entryFieldContainer.setWithModel(model, delegateObject, additionalData) title = model.title - isEnabled = model.isEnabled feedback = model.feedback errorMessage = model.errorMessage - isLocked = model.isLocked - isSelected = model.isSelected + isEnabled = model.isEnabled + + if let isLocked = model.isLocked { + self.isLocked = isLocked + + } else if let isSelected = model.isSelected{ + self.isSelected = isSelected + } if let fieldKey = model.fieldKey { self.fieldKey = fieldKey diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index 70c1c0e3..5f60081e 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -24,8 +24,8 @@ import Foundation public var feedback: String? public var errorMessage: String = "" public var isEnabled: Bool = true - public var isLocked: Bool = false - public var isSelected: Bool = false + public var isLocked: Bool? + public var isSelected: Bool? public var fieldKey: String? public var isValid: Bool? public var isRequired: Bool? @@ -60,8 +60,8 @@ import Foundation 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) ?? false - isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) ?? false + isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked) + isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid) } From a3a3d4b66a914f1b0bcf1c12ac15c64af44b1e91 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Fri, 24 Jan 2020 15:14:02 -0500 Subject: [PATCH 270/272] add file back --- .../Views/EntryFieldContainer.swift | 293 ++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 MVMCoreUI/Containers/Views/EntryFieldContainer.swift diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift new file mode 100644 index 00000000..3f80006a --- /dev/null +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -0,0 +1,293 @@ +// +// EntryFieldContainer.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 11/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + + +@objcMembers open class EntryFieldContainer: View { + //-------------------------------------------------- + // MARK: - Drawing Properties + //-------------------------------------------------- + + /// The bottom border line. Height is dynamic based on scenario. + public var bottomBar: CAShapeLayer? = { + let layer = CAShapeLayer() + layer.backgroundColor = UIColor.black.cgColor + layer.drawsAsynchronously = true + layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); + return layer + }() + + /// Total control over the drawn top, bottom, left and right borders. + public var disableAllBorders = false { + didSet { + bottomBar?.isHidden = disableAllBorders + } + } + + private(set) var fieldState: FieldState = .original { + didSet (oldState) { + // Will not update if new state is the same as old. + if fieldState != oldState { + DispatchQueue.main.async { [weak self] in + guard let self = self else { return } + + self.fieldState.setStateUI(for: self) + } + } + } + } + + /// Determines if the top, left, and right borders should be drawn. + private var hideBorders = false + + public var borderStrokeColor: UIColor = .mfSilver() + private var borderPath: UIBezierPath = UIBezierPath() + + //-------------------------------------------------- + // MARK: - Property Observers + //-------------------------------------------------- + + private var _isEnabled: Bool = true + private var _showError: Bool = false + private var _isLocked: Bool = false + private var _isSelected: Bool = false + + public var isEnabled: Bool { + get { return _isEnabled } + set (enabled) { + + _isEnabled = enabled + _isLocked = false + _isSelected = false + _showError = false + + fieldState = enabled ? .original : .disabled + } + } + + public var showError: Bool { + get { return _showError } + set (error) { + + _showError = error + _isEnabled = true + _isLocked = false + _isSelected = false + + fieldState = error ? .error : .original + } + } + + public var isLocked: Bool { + get { return _isLocked } + set (locked) { + + _isLocked = locked + _isEnabled = true + _isSelected = false + _showError = false + + fieldState = locked ? .locked : .original + } + } + + public var isSelected: Bool { + get { return _isSelected } + set (selected) { + + _isSelected = selected + _isLocked = false + _isEnabled = true + + if _showError { + fieldState = selected ? .selectedError : .error + } else { + fieldState = selected ? .selected : .original + } + } + } + + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + + /// Holds reference to delegateObject to inform molecular tableView of an update. + var delegateObject: MVMCoreUIDelegateObject? + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + open override func layoutSubviews() { + super.layoutSubviews() + + refreshUI(bottomBarSize: showError ? 4 : 1) + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + + refreshUI() + } + + /// This handles the top, left, and right border lines. + open override func draw(_ rect: CGRect) { + super.draw(rect) + + borderPath.removeAllPoints() + + if !disableAllBorders && !hideBorders { + // Brings the other half of the line inside the view to prevent cropping. + let origin = bounds.origin + let size = frame.size + let insetLean: CGFloat = 0.5 + borderPath.lineWidth = 1 + + borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height)) + borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean)) + borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + size.height)) + + borderStrokeColor.setStroke() + borderPath.stroke() + } + } + + override open func setupView() { + super.setupView() + + isAccessibilityElement = false + isOpaque = false + + if let bottomBar = bottomBar { + layer.addSublayer(bottomBar) + } + } + + //-------------------------------------------------- + // MARK: - Draw States + //-------------------------------------------------- + + public enum FieldState { + case original + case error + case selectedError + case selected + case locked + case disabled + + public func setStateUI(for formField: EntryFieldContainer) { + + switch self { + case .original: + formField.originalUI() + + case .error: + formField.errorUI() + + case .selectedError: + formField.selectedErrorUI() + + case .selected: + formField.selectedUI() + + case .locked: + formField.lockedUI() + + case .disabled: + formField.disabledUI() + } + } + } + + open func originalUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func errorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .mfPumpkin() + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedErrorUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + refreshUI(bottomBarSize: 4) + } + + open func selectedUI() { + + isUserInteractionEnabled = true + hideBorders = false + borderStrokeColor = .black + bottomBar?.backgroundColor = UIColor.black.cgColor + refreshUI(bottomBarSize: 1) + } + + open func lockedUI() { + + isUserInteractionEnabled = false + hideBorders = true + borderStrokeColor = .clear + bottomBar?.backgroundColor = UIColor.clear.cgColor + refreshUI(bottomBarSize: 1) + } + + open func disabledUI() { + + isUserInteractionEnabled = false + hideBorders = false + borderStrokeColor = .mfSilver() + bottomBar?.backgroundColor = UIColor.mfSilver().cgColor + refreshUI(bottomBarSize: 1) + } + + open func refreshUI(bottomBarSize: CGFloat? = nil) { + + if !disableAllBorders { + let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) + bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) + + delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + setNeedsDisplay() + layoutIfNeeded() + } + } + + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + self.delegateObject = delegateObject + } +} + +extension EntryFieldContainer { + + override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + self.delegateObject = delegateObject + + guard let dictionary = json, !dictionary.isEmpty else { return } + } +} From a932e554d517432d8bec5ec69a7793c8ecee029e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 24 Jan 2020 15:32:40 -0500 Subject: [PATCH 271/272] timing fix --- MVMCoreUI/Atoms/TextFields/DigitEntryField.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index c7888041..9febf0c1 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -329,7 +329,7 @@ import UIKit } public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? DigitEntryFieldModel else { return } @@ -340,6 +340,8 @@ import UIKit for digitBox in digitBoxes { MVMCoreUICommonViewsUtility.addDismissToolbar(digitBox.digitField, delegate: delegateObject as? UITextFieldDelegate) } + + super.setWithModel(model, delegateObject, additionalData) } } From fe10b40148a04d922ec68e4f028a54d64efbe97b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 24 Jan 2020 16:48:28 -0500 Subject: [PATCH 272/272] reorg --- MVMCoreUI.xcodeproj/project.pbxproj | 18 +++++++++--------- .../Atoms/TextFields/TextFieldModel.swift | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6bdf72f6..2323285f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1192,22 +1192,22 @@ D29DF22B21E6A0FA003B2FB9 /* TextFields */ = { isa = PBXGroup; children = ( - 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, - 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */, 0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */, - 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */, - 0A21DB7E235DECC500C160A2 /* EntryField.swift */, + 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */, 0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */, - 0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */, + 0A21DB7E235DECC500C160A2 /* EntryField.swift */, 0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */, - 0A21DB93235E24ED00C160A2 /* DigitEntryField.swift */, + 0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */, + 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */, 0A7EF86023D8AC2500B2AAD1 /* DigitEntryFieldModel.swift */, - 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */, + 0A21DB93235E24ED00C160A2 /* DigitEntryField.swift */, 0A7EF86223D8AFA000B2AAD1 /* BaseDropdownEntryFieldModel.swift */, - 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */, + 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */, 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */, - 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */, + 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */, 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */, + 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */, + 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */, ); path = TextFields; diff --git a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift index c538a715..6caa70b0 100644 --- a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift @@ -12,7 +12,7 @@ import UIKit public static var identifier: String = "textField" public var backgroundColor: Color? - + public var moleculeName: String public var editable: Bool? public var disabled: Bool? public var errorMsg: String?