From b5bbce6294ed1a0dd8e97dfb10ad82d5a4d98b93 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Mon, 9 Mar 2020 11:31:46 +0530 Subject: [PATCH 001/244] List - One Column - Text With Whitespace - Divider - Tall Molecule implemented --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ ...eColumnTextWithWhitespaceDividerTall.swift | 59 +++++++++++++++++++ ...mnTextWithWhitespaceDividerTallModel.swift | 48 +++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 116 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8de69762..00d8106f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -154,6 +154,8 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; + BB47A58224161003002BB23C /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A58124161003002BB23C /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */; }; + BB47A5842416101D002BB23C /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A5832416101D002BB23C /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; 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 */; }; @@ -505,6 +507,8 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; + BB47A58124161003002BB23C /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTallModel.swift; sourceTree = ""; }; + BB47A5832416101D002BB23C /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; 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 = ""; }; @@ -821,6 +825,8 @@ 52267A0523FFE0A900906CBA /* OneColumn */ = { isa = PBXGroup; children = ( + BB47A58124161003002BB23C /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */, + BB47A5832416101D002BB23C /* ListOneColumnTextWithWhitespaceDividerTall.swift */, 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */, 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, ); @@ -1764,6 +1770,7 @@ 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, + BB47A58224161003002BB23C /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, @@ -1824,6 +1831,7 @@ D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, + BB47A5842416101D002BB23C /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift new file mode 100644 index 00000000..f264bc44 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -0,0 +1,59 @@ +// +// ListOneColumnTextWithWhitespaceDividerTall.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 09/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers public class ListOneColumnTextWithWhitespaceDividerTall: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + var stack: Stack + let headline = Label.commonLabelH3(true) + let body = Label.commonLabelB2(true) + + + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)),(view: body, model: StackItemModel(spacing: 5,horizontalAlignment: .leading))],axis: .vertical) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + + + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return } + headline.setOptional(with: model.headline, delegateObject, additionalData) + body.setOptional(with: model.body, delegateObject, additionalData) + + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + headline.styleH3(true) + body.styleB2(true) + + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift new file mode 100644 index 00000000..f93f601b --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -0,0 +1,48 @@ +// +// ListOneColumnTextWithWhitespaceDividerTallModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 09/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel,MoleculeModelProtocol{ + public static var identifier: String = "list1CTxtDiv2" + public var headline: LabelModel + public var body: LabelModel + + public init(headline: LabelModel, body: LabelModel) { + self.headline = headline + self.body = body + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case headline + case body + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + body = try typeContainer.decode(LabelModel.self, forKey: .body) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(headline, forKey: .headline) + try container.encode(body, forKey: .body) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 003b5d03..45ff06c0 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -105,6 +105,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) // Designed Section Dividers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) From 25e0651eee8f20cc51f9fd2e5a888d0229db52e6 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 11 Mar 2020 12:07:20 -0400 Subject: [PATCH 002/244] images and links and stuff --- .../Atoms/Buttons/Link/ExternalLink.swift | 6 +++--- MVMCoreUI/Atoms/Views/Label/Label.swift | 19 +++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link/ExternalLink.swift b/MVMCoreUI/Atoms/Buttons/Link/ExternalLink.swift index 3cd601b6..c311b435 100644 --- a/MVMCoreUI/Atoms/Buttons/Link/ExternalLink.swift +++ b/MVMCoreUI/Atoms/Buttons/Link/ExternalLink.swift @@ -47,11 +47,11 @@ open class ExternalLink: Link { trailingAnchor.constraint(greaterThanOrEqualTo: exportIcon.trailingAnchor).isActive = true if let titleLabel = titleLabel { - let dimension = round(0.6 * titleLabel.font.pointSize) + let dimension = titleLabel.font.pointSize exportIcon.heightAnchor.constraint(equalToConstant: dimension).isActive = true exportIcon.widthAnchor.constraint(equalToConstant: dimension).isActive = true - exportIcon.leadingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: PaddingOne).isActive = true - exportIcon.bottomAnchor.constraint(equalTo: titleLabel.lastBaselineAnchor).isActive = true + exportIcon.leadingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: 4).isActive = true + exportIcon.bottomAnchor.constraint(equalTo: titleLabel.lastBaselineAnchor, constant: 3).isActive = true } } } diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index c7e72204..3a7d1f93 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -755,7 +755,7 @@ public typealias ActionBlock = () -> () */ static func getTextAttachmentImage(name: String = "externalLink", dimension: CGFloat) -> NSTextAttachment { - let dimension = round(dimension * 0.8) +// let dimension = round(dimension * 0.8) let imageAttachment = NSTextAttachment() imageAttachment.image = MVMCoreUIUtility.imageNamed(name) @@ -766,23 +766,18 @@ public typealias ActionBlock = () -> () static func getTextAttachmentFrom(url: String, dimension: CGFloat, label: Label) -> NSTextAttachment { - let dimension = round(dimension * 0.8) - let imageAttachment = NSTextAttachment() imageAttachment.bounds = CGRect(x: 0, y: 0, width: dimension, height: dimension) DispatchQueue.global(qos: .default).async { - - guard let url = URL(string: url), - let data = try? Data(contentsOf: url) - else { return } - - DispatchQueue.main.sync { - imageAttachment.image = UIImage(data: data) - label.setNeedsDisplay() + MVMCoreCache.shared()?.getImage(url, useWidth: false, widthForS7: 0, useHeight: false, heightForS7: 0, localFallbackImageName: nil) { image, data, _ in + + DispatchQueue.main.sync { + imageAttachment.image = image + label.setNeedsDisplay() + } } } - return imageAttachment } From 1b3766e2b79463d405266849c479f85b7a769102 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Fri, 13 Mar 2020 13:57:38 +0530 Subject: [PATCH 003/244] code refactoring --- ...istOneColumnTextWithWhitespaceDividerTall.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index f264bc44..fdc660fb 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -7,7 +7,7 @@ // import Foundation -@objcMembers public class ListOneColumnTextWithWhitespaceDividerTall: TableViewCell { +@objcMembers open class ListOneColumnTextWithWhitespaceDividerTall: TableViewCell { //----------------------------------------------------- // MARK: - Outlets @@ -16,10 +16,11 @@ import Foundation let headline = Label.commonLabelH3(true) let body = Label.commonLabelB2(true) - // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)),(view: body, model: StackItemModel(spacing: 5,horizontalAlignment: .leading))],axis: .vertical) + stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), + (view: body, model: StackItemModel(spacing: 5,horizontalAlignment: .leading))], + axis: .vertical) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -34,16 +35,13 @@ import Foundation super.setupView() addMolecule(stack) stack.restack() - - } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ super.set(with: model, delegateObject, additionalData) guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return } - headline.setOptional(with: model.headline, delegateObject, additionalData) - body.setOptional(with: model.body, delegateObject, additionalData) - + headline.set(with: model.headline, delegateObject, additionalData) + body.set(with: model.body, delegateObject, additionalData) } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { From 335ec160b506f33d81550a128956485a5c23b2da Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 13 Mar 2020 10:04:47 -0400 Subject: [PATCH 004/244] swift --- MVMCoreUI.xcodeproj/project.pbxproj | 52 ++-- .../Atoms/TextFields/TextEntryField.swift | 2 +- .../ProgrammaticScrollViewController.swift | 56 ++++ .../ProgrammaticTableViewController.swift | 81 +++++ .../ScrollingViewController.swift | 109 +++++++ .../ThreeLayerTableViewController.swift | 27 +- .../ThreeLayerViewController.swift | 27 +- .../BaseControllers/ViewController.swift | 286 +++++++++++++++++- ...MVMCoreUITabBarPageControlViewController.m | 2 +- .../New/FormHolderProtocol.swift | 2 - .../MFProgrammaticScrollViewController.h} | 4 +- .../MFProgrammaticScrollViewController.m} | 8 +- .../MFProgrammaticTableViewController.h | 0 .../MFProgrammaticTableViewController.m | 0 .../Controllers}/MFScrollingViewController.h | 0 .../Controllers}/MFScrollingViewController.m | 0 .../Controllers}/MFViewController+Form.swift | 0 .../Controllers}/MFViewController+Model.swift | 0 .../Controllers}/MFViewController.h | 0 .../Controllers}/MFViewController.m | 0 .../MVMCoreUIStackableViewController.h | 4 +- .../MVMCoreUIStackableViewController.m | 0 MVMCoreUI/MVMCoreUI.h | 2 +- .../ModelProtocols/PageModelProtocol.swift | 1 + .../Items/DropDownFilterTableViewCell.swift | 7 +- .../NavigationItemModelProtocol.swift | 17 ++ .../OtherHandlers/MVMCoreUILoggingHandler.h | 6 +- .../OtherHandlers/MVMCoreUILoggingHandler.m | 6 +- .../Templates/ListPageTemplateModel.swift | 1 + .../Templates/ModalMoleculeListTemplate.swift | 8 +- .../ModalMoleculeStackTemplate.swift | 8 +- .../Templates/MoleculeListTemplate.swift | 51 +--- .../Templates/MoleculeStackTemplate.swift | 27 +- .../StackCenteredPageTemplateModel.swift | 1 + .../Templates/StackPageTemplateModel.swift | 1 + MVMCoreUI/Templates/TemplateProtocol.swift | 2 +- .../ThreeLayerPageTemplateModel.swift | 1 + MVMCoreUI/Templates/ThreeLayerTemplate.swift | 15 +- 38 files changed, 639 insertions(+), 175 deletions(-) create mode 100644 MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift create mode 100644 MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift create mode 100644 MVMCoreUI/BaseControllers/ScrollingViewController.swift rename MVMCoreUI/{BaseControllers/ProgrammaticScrollViewController.h => Legacy/Controllers/MFProgrammaticScrollViewController.h} (61%) rename MVMCoreUI/{BaseControllers/ProgrammaticScrollViewController.m => Legacy/Controllers/MFProgrammaticScrollViewController.m} (92%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFProgrammaticTableViewController.h (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFProgrammaticTableViewController.m (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFScrollingViewController.h (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFScrollingViewController.m (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController+Form.swift (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController+Model.swift (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController.h (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController.m (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MVMCoreUIStackableViewController.h (95%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MVMCoreUIStackableViewController.m (100%) create mode 100644 MVMCoreUI/Molecules/NavigationItemModelProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b5985e36..7aa2b2dd 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -178,6 +178,7 @@ C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* ListRVWheel.swift */; }; C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* ListRVWheelModel.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; + D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelToggle.swift */; }; @@ -285,11 +286,11 @@ 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 */; }; + D29DF29521E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28D21E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.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, ); }; }; + D29DF29921E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29121E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.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 */; }; @@ -342,6 +343,9 @@ 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 */; }; + D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */; }; + D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */; }; + D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A92885241ACD99004E01C6 /* ProgrammaticTableViewController.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 */; }; @@ -539,6 +543,7 @@ C7F8012023E8303200396FBD /* ListRVWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRVWheel.swift; sourceTree = ""; }; C7F8012223E846C300396FBD /* ListRVWheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRVWheelModel.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; + D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggle.swift; sourceTree = ""; }; @@ -666,11 +671,11 @@ 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 = ""; }; + D29DF28D21E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFProgrammaticScrollViewController.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 = ""; }; + D29DF29121E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFProgrammaticScrollViewController.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 = ""; }; @@ -717,6 +722,9 @@ 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 = ""; }; + D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollingViewController.swift; sourceTree = ""; }; + D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticScrollViewController.swift; sourceTree = ""; }; + D2A92885241ACD99004E01C6 /* ProgrammaticTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticTableViewController.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 = ""; }; @@ -927,8 +935,20 @@ D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( + D29DF16021E69996003B2FB9 /* MFViewController.h */, + D29DF15F21E69996003B2FB9 /* MFViewController.m */, + 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */, + 011D9627240EFA1E000E3791 /* MFViewController+Form.swift */, + D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */, + D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */, + D29DF29121E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h */, + D29DF28D21E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m */, D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */, D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */, + D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */, + D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */, + D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */, + D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */, D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */, D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */, D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */, @@ -1269,6 +1289,7 @@ 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, D260105723CF9CC500764D80 /* Doughnut */, + D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */, ); path = Molecules; sourceTree = ""; @@ -1276,23 +1297,14 @@ D29DF10F21E67A7D003B2FB9 /* BaseControllers */ = { isa = PBXGroup; children = ( - D29DF16021E69996003B2FB9 /* MFViewController.h */, - D29DF15F21E69996003B2FB9 /* MFViewController.m */, - 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */, - 011D9627240EFA1E000E3791 /* MFViewController+Form.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 */, D2C521A823EDE79E00CA2634 /* ViewController.swift */, + D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */, + D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */, + D2A92885241ACD99004E01C6 /* ProgrammaticTableViewController.swift */, ); path = BaseControllers; sourceTree = ""; @@ -1618,7 +1630,7 @@ D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */, 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */, D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */, - D29DF29921E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h in Headers */, + D29DF29921E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h in Headers */, D29DF11C21E684A9003B2FB9 /* MVMCoreUISplitViewController.h in Headers */, D29DF29B21E7ADB9003B2FB9 /* StackableViewController.h in Headers */, D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */, @@ -1821,6 +1833,7 @@ D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, + D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, D2E2A99F23E07F8A000B42E6 /* PillButton.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, @@ -1874,6 +1887,7 @@ D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, + D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, @@ -1946,7 +1960,7 @@ D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, - D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, + D29DF29521E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, @@ -1956,9 +1970,11 @@ D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */, 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */, + D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */, DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, 0A21DB89235E06EF00C160A2 /* MFMdnTextField.m in Sources */, D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */, + D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index 993aed59..c3aa19c6 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -311,7 +311,7 @@ import UIKit uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate - MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) + //MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) } } diff --git a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift new file mode 100644 index 00000000..10583b14 --- /dev/null +++ b/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift @@ -0,0 +1,56 @@ +// +// ProgrammaticScrollViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class ProgrammaticScrollViewController: ScrollingViewController { + public var topConstraint: NSLayoutConstraint? + public var bottomConstraint: NSLayoutConstraint? + + public override init(with scrollView: UIScrollView) { + super.init(with: scrollView) + } + + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + } + + open override func loadView() { + + let view = UIView() + view.backgroundColor = .white + + let scrollView = UIScrollView() + scrollView.backgroundColor = .clear + scrollView.translatesAutoresizingMaskIntoConstraints = true + view.addSubview(scrollView) + + // Sets the constraints for the scroll view + let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: scrollView) + topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint + bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint + + let contentView = MVMCoreUICommonViewsUtility.commonView() + scrollView.addSubview(contentView) + + // Sets the constraints for the content view + NSLayoutConstraint.constraintPinSubview(toSuperview: contentView) + + // Super will set later. + contentWidthConstraint = contentView.widthAnchor.constraint(equalToConstant: 320.0) + contentWidthConstraint?.isActive = true + + self.contentView = contentView + self.scrollView = scrollView + self.view = view + } +} diff --git a/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift new file mode 100644 index 00000000..4e262398 --- /dev/null +++ b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift @@ -0,0 +1,81 @@ +// +// ProgrammaticTableViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UITableViewDelegate, UITableViewDataSource { + @IBOutlet public var tableView: UITableView! + + public init(with tableView: UITableView) { + self.tableView = tableView + super.init(with: tableView) + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + } + + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + open override func loadView() { + let view = UIView() + view.backgroundColor = .white + + let tableView = createTableView() + tableView.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(tableView) + + // Sets the constraints for the scroll view + let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: tableView) + topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint + bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint + + self.tableView = tableView + scrollView = tableView + self.view = view + } + + /// This class should create the table view that will be used here. Subclass this for different table styles. + open func createTableView() -> UITableView { + let tableView = UITableView(frame: .zero, style: .grouped) + tableView.backgroundColor = .clear + tableView.separatorStyle = UITableViewCell.SeparatorStyle.none + tableView.delegate = self + tableView.dataSource = self + tableView.insetsContentViewsToSafeArea = false + return tableView + } + + // Registers classes and nibs. Can subclass for different nibs. Can call super and then add new ones after as well. + open func registerWithTable() {} + + /// Sets the table to have no section headers or footers. + open func setNoSectionHeadersFooters() { + tableView.sectionHeaderHeight = CGFloat.leastNormalMagnitude + tableView.sectionFooterHeight = CGFloat.leastNormalMagnitude + } + + /// For subclassing, returns the number of sections for table. This function calls numberOfSectionsForTableview aftre ensuring the table is setup properly. + open func getNumberOfSections() -> Int { + return 1 + } + + open func numberOfSections(in tableView: UITableView) -> Int { + return tableView.bounds.width > 1 ? getNumberOfSections() : 0 + } + + open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 0 + } + + open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } +} diff --git a/MVMCoreUI/BaseControllers/ScrollingViewController.swift b/MVMCoreUI/BaseControllers/ScrollingViewController.swift new file mode 100644 index 00000000..2e4eceef --- /dev/null +++ b/MVMCoreUI/BaseControllers/ScrollingViewController.swift @@ -0,0 +1,109 @@ +// +// ScrollingViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class ScrollingViewController: ViewController { + public var dismissKeyboardTapGesture: UITapGestureRecognizer? + @IBOutlet public var scrollView: UIScrollView! + public var contentView: UIView? + public var contentWidthConstraint: NSLayoutConstraint? + + private var keyboardNotificationsAdded = false + private var keyboardIsShowing = false + private var preKeyboardContentInset: UIEdgeInsets? + + public init(with scrollView: UIScrollView) { + self.scrollView = scrollView + super.init(nibName: nil, bundle: nil) + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + } + + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + // MARK: - View Life Cycle + open override func viewDidLoad() { + super.viewDidLoad() + + // Adds the tap gesture to dismiss the keyboard. + dismissKeyboardTapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissFieldInput(sender:))) + view.addGestureRecognizer(dismissKeyboardTapGesture!) + dismissKeyboardTapGesture?.isEnabled = false + scrollView.alwaysBounceVertical = false + scrollView.delegate = self + } + + open override func updateViewConstraints() { + super.updateViewConstraints() + // Sets the width of the content to the width of the screen. + contentWidthConstraint?.constant = view.bounds.width - scrollView.contentInset.left - scrollView.contentInset.right + } + + open override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + view.setNeedsUpdateConstraints() + view.layoutSubviews() + } + + open override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + registerForKeyboardNotifications() + } + + // MARK: - Keyboard Handling + open func registerForKeyboardNotifications() { + if !keyboardNotificationsAdded { + keyboardNotificationsAdded = true + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillBeHidden(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil) + } + } + + open func unregisterForKeyboardNotifications() { + if keyboardNotificationsAdded { + NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil) + keyboardNotificationsAdded = false + } + } + + @objc open func keyboardWillShow(notification: Notification) { + // Stores the current scroll insets if the keyboard was hidden. + if !keyboardIsShowing { + preKeyboardContentInset = scrollView.contentInset + } + keyboardIsShowing = true + + // Enables the tap gesture. + dismissKeyboardTapGesture?.isEnabled = true + + MVMCoreUIUtility.setScrollViewInsetForKeyboardShow(notification, scrollView: scrollView, viewController: self) { [weak self] () -> CGRect in + return self?.rectToScrollToWhenKeyboardPopsUp() ?? .zero + } + } + + @objc open func keyboardWillBeHidden(notification: Notification) { + keyboardIsShowing = false + + // Disables the tap gesture. + dismissKeyboardTapGesture?.isEnabled = false + + MVMCoreUIUtility.setScrollViewInsetForKeyboardHide(notification, scrollView: scrollView, viewController: self, contentInset: preKeyboardContentInset ?? scrollView.contentInset) + } + + open func rectToScrollToWhenKeyboardPopsUp() -> CGRect? { + guard let field = selectedField, + let parent = selectedField?.superview else { return nil } + return scrollView.convert(field.frame, from: parent) + } +} diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index ae3d2fac..2fba0e07 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -9,7 +9,7 @@ import UIKit import MVMAnimationFramework -open class ThreeLayerTableViewController: MFProgrammaticTableViewController { +open class ThreeLayerTableViewController: ProgrammaticTableViewController { // The three main views private var topView: UIView? private var bottomView: UIView? @@ -36,17 +36,17 @@ open class ThreeLayerTableViewController: MFProgrammaticTableViewController { self.tableView?.reloadData() } - open override func newDataBuildScreen() { - super.newDataBuildScreen() + open override func handleNewData() { createViewForTableHeader() createViewForTableFooter() tableView?.reloadData() + super.handleNewData() } override open func viewDidLoad() { super.viewDidLoad() - setToHaveNoSectionHeadersFooters() // Do any additional setup after loading the view. + setNoSectionHeadersFooters() } //MARK: - Spacing @@ -227,26 +227,7 @@ open class ThreeLayerTableViewController: MFProgrammaticTableViewController { return view } - //MARK: - Scrollview - open override func scrollViewDidScroll(_ scrollView: UIScrollView) { - // To stop handscroll animation if animating after scroll - stopHandScrollAnimation(true) - } - deinit { tableView?.delegate = nil } - - //MARK: - Animation - open override func setupIntroAnimations() { - if let topView = topView, topView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: topView)) - } - if let tableView = tableView { - introAnimationManager?.addAnimation(animation: MVMAnimations.animateTableViewFadeInCells(tableView: tableView)) - } - if let bottomView = bottomView, bottomView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: bottomView)) - } - } } diff --git a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift index ea6923c5..bf557814 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift @@ -61,21 +61,25 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController { } } - open override func newDataBuildScreen() { - super.newDataBuildScreen() - + open override func handleNewData() { // Removes the views topView?.removeFromSuperview() middleView?.removeFromSuperview() bottomView?.removeFromSuperview() safeAreaView?.removeFromSuperview() - MVMCoreUIStackableViewController.remove(contentView?.subviews) + if let subViews = contentView?.subviews { + for view in subViews { + view.removeFromSuperview() + } + } // Reset constraints bottomConstraint?.isActive = true heightConstraint?.isActive = false setupLayers() + + super.handleNewData() } //MARK:-Functions to subclass @@ -241,18 +245,3 @@ extension ThreeLayerViewController { } } } - -//MARK:-Animation -extension ThreeLayerViewController { - open override func setupIntroAnimations() { - if let topView = topView, topView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: topView)) - } - if let middleView = middleView, middleView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: middleView)) - } - if let bottomView = bottomView, bottomView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: bottomView)) - } - } -} diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 1bb06324..96b56ce4 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -8,19 +8,110 @@ import UIKit -@objcMembers open class ViewController: UIViewController, MVMCoreViewControllerProtocol { +open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate { public var pageType: String? public var loadObject: MVMCoreLoadObject? public var pageModel: PageModelProtocol? + + /// Set if this page is containted in a manager. + public var manager: (UIViewController & MVMCoreViewManagerProtocol)? + + public var selfDelegateObject: MVMCoreUIDelegateObject? + public func delegateObject() -> DelegateObject? { + if selfDelegateObject == nil { + selfDelegateObject = MVMCoreUIDelegateObject.create(withDelegateForAll: self) + } + return selfDelegateObject + } + + public var formValidator: FormValidator? + + public var needsUpdateUI = true + private var observingForResponses = false + private var initialLoadFinished = false + private var previousScreenSize = CGSize.zero + + public var selectedField: UIView? - // MARK: Response handling - public func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { + /// Checks if the screen width has changed + open func screenSizeChanged() -> Bool { + return MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) + } + + // MARK: - Response handling + open func observeForResponseJSONUpdates() { + guard !observingForResponses, + (pagesToListenFor()?.count ?? 0 > 0 || modulesToListenFor()?.count ?? 0 > 0) else { return } + observingForResponses = true + NotificationCenter.default.addObserver(self, selector: #selector(responseJSONUpdated(notification:)), name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil) + } + + open func stopObservingForResponseJSONUpdates() { + guard observingForResponses else { return } + NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil) + observingForResponses = false + } + + open func pagesToListenFor() -> [String]? { + guard let pageType = loadObject?.pageType else { return nil } + return [pageType] + } + + open func modulesToListenFor() -> [String]? { + return loadObject?.requestParameters?.modules as? [String] + } + + @objc open func responseJSONUpdated(notification: Notification) { + // Checks for a page we are listening for. + var newData = false + if let pagesLoaded = notification.userInfo?.optionalDictionaryForKey(KeyPageMap), + let pageType = pagesToListenFor()?.first(where: { (pageTypeListened) -> Bool in + guard let page = pagesLoaded.optionalDictionaryForKey(pageTypeListened), + let pageType = page.optionalStringForKey(KeyPageType), + pageType == pageTypeListened else { return false } + return true + }) { + newData = true + loadObject?.pageJSON = pagesLoaded.optionalDictionaryForKey(pageType) + } + + // Checks for modules we are listening for. + if let modulesLoaded = notification.userInfo?.optionalDictionaryForKey(KeyModuleMap), + let modulesListened = modulesToListenFor() { + for moduleName in modulesListened { + if let module = modulesLoaded.optionalDictionaryForKey(moduleName) { + newData = true + var currentModules = loadObject?.modulesJSON ?? [:] + currentModules.updateValue(module, forKey: moduleName) + loadObject?.modulesJSON = currentModules + } + } + } + + guard newData else { return } + do { + try parsePageJSON() + MVMCoreDispatchUtility.performBlock(onMainThread: { + self.handleNewDataAndUpdateUI() + }) + } catch { + if let coreError = MVMCoreErrorObject.createErrorObject(for: error, location: "updateJSON for pageType: \(String(describing: pageType))") { + MVMCoreLoggingHandler.shared()?.addError(toLog: coreError) + } + } + } + + open func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { pageType = loadObject.pageType self.loadObject = loadObject + // Verifies all modules needed are loaded. + guard MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) else { return false } + // Parse the model for the page. do { try parsePageJSON() + return true } catch let parsingError { // Log all parsing errors and fail load. if let errorObject = MVMCoreErrorObject.createErrorObject(for: parsingError, location: MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: loadObject)) { @@ -29,15 +120,12 @@ import UIKit } return false } - - // Verifies all modules needed are loaded. - return MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) } - @objc func parsePageJSON() throws { + open func parsePageJSON() throws { } - public class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool { + open class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool { guard let pageType = loadObject?.pageType, var modulesRequired = MVMCoreUIViewControllerMappingObject.shared()?.modulesRequired(forPageType: pageType) else { return true } guard let loadedModules = loadObject?.modulesJSON else { return false } @@ -58,17 +146,28 @@ import UIKit return true } - open func setNavigationItem() { + open func set(navigationItem: UINavigationItem) { navigationItem.title = pageModel?.screenHeading navigationItem.accessibilityLabel = pageModel?.screenHeading } - - open func newDataBuildScreen() { - // TODO atomize the navigation item - setNavigationItem() + + /// Calls processNewData and then sets the ui to update with updateView + open func handleNewDataAndUpdateUI() { + handleNewData() + self.needsUpdateUI = true + self.view.setNeedsLayout() } + /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, + open func handleNewData() { + // TODO atomize the navigation item + set(navigationItem: navigationItem) + formValidator?.validate() + } + + // MARK: - View lifecycle open func initialLoad() { + observeForResponseJSONUpdates() } open func updateViews() { @@ -78,5 +177,166 @@ import UIKit super.viewDidLoad() // Do any additional setup after loading the view. + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "View Controller Loaded : \(self)") + + viewRespectsSystemMinimumLayoutMargins = false + + // Presents from the bottom. + modalPresentationStyle = MVMCoreGetterUtility.isOnIPad() ? UIModalPresentationStyle.formSheet : UIModalPresentationStyle.overCurrentContext + + // Do some initial loading. + if !initialLoadFinished { + initialLoadFinished = true + initialLoad() + } + + // Handle data on load + handleNewData() + + view.setNeedsLayout() + } + + open override func viewDidLayoutSubviews() { + // Add to fix a constraint bug where the width is zero and things get messed up. + guard isViewLoaded, + view.bounds.width > 1 else { + super.viewDidLayoutSubviews() + return + } + if needsUpdateUI || screenSizeChanged() { + updateViews() + needsUpdateUI = false + } + super.viewDidLayoutSubviews() + } + + open override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + // Update the navigation bar ui when view is appearing unless in a manager. The manager is expected to handle. + if manager == nil { + set(navigationItem: navigationItem) + } + } + + open override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + if manager == nil { + MVMCoreUISession.sharedGlobal()?.currentPageType = pageType + MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + } + } + + deinit { + stopObservingForResponseJSONUpdates() + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "View Controller Deallocated : \(self)") + } + + open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + return MVMCoreGetterUtility.isOnIPad() ? UIInterfaceOrientationMask.all : UIInterfaceOrientationMask.portrait + } + + open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + + // Updates the detail view width + coordinator.animate(alongsideTransition: { (UIViewControllerTransitionCoordinatorContext) in + }) { (UIViewControllerTransitionCoordinatorContext) in + self.view.setNeedsLayout() + } + } + + // MARK: - MVMCoreViewManagerViewControllerProtocol + open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) { + if initialLoadFinished { + set(navigationItem: manager.navigationItem) + } + MVMCoreUISession.sharedGlobal()?.currentPageType = pageType + MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + } + + // MARK: - MVMCoreActionDelegateProtocol + open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { + formValidator?.addFormParams(requestParameters: requestParameters) + requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") + MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: selfDelegateObject) + } + + // MARK: - MoleculeDelegateProtocol + open func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? { + guard let name = name else { return nil } + return loadObject?.modulesJSON?.optionalDictionaryForKey(name) + } + + open func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? { + guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName), + let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), + let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self) + else { return nil } + do { + return try modelType.decode(jsonDict: moduleJSON) as? MoleculeModelProtocol + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + } + + return nil + } + + // Test to see if needed. + open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + + } + open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + + } + open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + + } + + // MARK: - UITextFieldDelegate (Check if this is still needed) + // To Remove TextFields Bug: Keyboard is not dismissing after reaching textfield max length limit + open func textFieldShouldReturn(_ textField: UITextField) -> Bool { + textField.resignFirstResponder() + return true + } + + open func textFieldDidBeginEditing(_ textField: UITextField) { + selectedField = textField + + // TODO: Make this into a protocol + if UIAccessibility.isVoiceOverRunning { + if let toolBar = textField.inputAccessoryView as? UIToolbar, let _ = toolBar.items?.last, let pickerView = textField.inputView as? UIPickerView { + view.accessibilityElements = [pickerView, toolBar] + } + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: textField.inputView) + } + } + } + + open func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) { + if textField === selectedField { + if UIAccessibility.isVoiceOverRunning { + view.accessibilityElements = nil + UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: textField) + } + selectedField = nil + } + } + + @objc open func dismissFieldInput(sender: Any?) { + selectedField?.resignFirstResponder() + } + + // MARK: - UITextViewDelegate (Check if this is still needed) + open func textViewDidBeginEditing(_ textView: UITextView) { + selectedField = textView + } + + open func textViewDidEndEditing(_ textView: UITextView) { + if textView === selectedField { + selectedField = nil + } } } diff --git a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m index cb48eb54..d700e57f 100644 --- a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m +++ b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m @@ -227,7 +227,7 @@ self.selectedIndex = i; [tabbar selectIndex:self.selectedIndex animated:NO]; - if ([self.viewController respondsToSelector:@selector(shouldCacheInManager)] && [((UIViewController *)self.viewController) shouldCacheInManager]) { + if (![self.viewController respondsToSelector:@selector(shouldCacheInManager)] || [((UIViewController *)self.viewController) shouldCacheInManager]) { [viewControllers addObject:self.viewController]; } else { [viewControllers addObject:[NSNull null]]; diff --git a/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift b/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift index 57c41a21..1e2f5522 100644 --- a/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift @@ -12,6 +12,4 @@ import Foundation //Protocol for Validation public protocol FormHolderProtocol: NSObjectProtocol { var formValidator: FormValidator? { get set } - /// Should call formValidator's validate method - func validate() } diff --git a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.h b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.h similarity index 61% rename from MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.h rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.h index 9e486066..f152b932 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.h +++ b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.h @@ -1,5 +1,5 @@ // -// ProgrammaticScrollViewController.h +// MFProgrammaticScrollViewController.h // myverizon // // Created by Scott Pfeil on 1/26/16. @@ -8,7 +8,7 @@ #import -@interface ProgrammaticScrollViewController : MFScrollingViewController +@interface MFProgrammaticScrollViewController : MFScrollingViewController @end diff --git a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.m b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.m similarity index 92% rename from MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.m rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.m index 2bfeb35d..5152ec79 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.m +++ b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.m @@ -1,21 +1,21 @@ // -// ProgrammaticScrollViewController.m +// MFProgrammaticScrollViewController.m // myverizon // // Created by Scott Pfeil on 1/26/16. // Copyright © 2016 Verizon Wireless. All rights reserved. // -#import "ProgrammaticScrollViewController.h" +#import "MFProgrammaticScrollViewController.h" @import MVMCore.NSDictionary_MFConvenience; #import "NSLayoutConstraint+MFConvenience.h" #import "MVMCoreUICommonViewsUtility.h" -@interface ProgrammaticScrollViewController () +@interface MFProgrammaticScrollViewController () @end -@implementation ProgrammaticScrollViewController +@implementation MFProgrammaticScrollViewController - (void)loadView { diff --git a/MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.h b/MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.h similarity index 100% rename from MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.h rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.h diff --git a/MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.m b/MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.m rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.m diff --git a/MVMCoreUI/BaseControllers/MFScrollingViewController.h b/MVMCoreUI/Legacy/Controllers/MFScrollingViewController.h similarity index 100% rename from MVMCoreUI/BaseControllers/MFScrollingViewController.h rename to MVMCoreUI/Legacy/Controllers/MFScrollingViewController.h diff --git a/MVMCoreUI/BaseControllers/MFScrollingViewController.m b/MVMCoreUI/Legacy/Controllers/MFScrollingViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MFScrollingViewController.m rename to MVMCoreUI/Legacy/Controllers/MFScrollingViewController.m diff --git a/MVMCoreUI/BaseControllers/MFViewController+Form.swift b/MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController+Form.swift rename to MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController+Model.swift rename to MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/Legacy/Controllers/MFViewController.h similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController.h rename to MVMCoreUI/Legacy/Controllers/MFViewController.h diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/Legacy/Controllers/MFViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController.m rename to MVMCoreUI/Legacy/Controllers/MFViewController.m diff --git a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h b/MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.h similarity index 95% rename from MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h rename to MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.h index 0c702925..12d02f43 100644 --- a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h +++ b/MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.h @@ -6,9 +6,9 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -#import +#import -@interface MVMCoreUIStackableViewController : ProgrammaticScrollViewController +@interface MVMCoreUIStackableViewController : MFProgrammaticScrollViewController // An array of ui elements that will be spaced out on the screen top to bottom from index 0 to formUIArray.count. @property (nullable, strong, nonatomic) NSArray *formUIArray; diff --git a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m b/MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m rename to MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.m diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 5e8c92cc..22707550 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -48,7 +48,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #pragma mark - BaseControllers #import #import -#import +#import #import #import #import diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift index 34b58818..7f50873e 100644 --- a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift @@ -13,4 +13,5 @@ public protocol PageModelProtocol { var pageType: String { get set } var screenHeading: String? { get set } var isAtomicTabs: Bool? { get set } + var navigationItem: NavigationItemModelProtocol? { get set } } diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index f9b9d976..0661e3ed 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,15 +29,14 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), - let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]] + let molecules2D = (self.listItemModel as? DropDownListItemModel)?.molecules else { return } if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(molecules2D[self.previousIndex], sender: self, animation: .fade) } - self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.addMolecules(molecules2D[index], sender: self, animation: .fade) self.previousIndex = index } } diff --git a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift new file mode 100644 index 00000000..acddb931 --- /dev/null +++ b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift @@ -0,0 +1,17 @@ +// +// NavigationItemModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol NavigationItemModelProtocol: ModelProtocol { + +} + +public protocol NavigationItemButtonModelProtocol { + +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h index 003d67f8..9fec90f5 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h @@ -14,11 +14,11 @@ NS_ASSUME_NONNULL_BEGIN @interface MVMCoreUILoggingHandler : MVMCoreLoggingHandler // Page State Logging -- (void)defaultLogPageStateForController:(nonnull MFViewController *)controller; +- (void)defaultLogPageStateForController:(nonnull id )controller; // Action Logging -- (void)defaultLogActionForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; -- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; +- (void)defaultLogActionForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; +- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; @end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m index 6395fbcc..0c694cce 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m @@ -10,13 +10,13 @@ @implementation MVMCoreUILoggingHandler -- (void)defaultLogPageStateForController:(nonnull MFViewController *)controller { +- (void)defaultLogPageStateForController:(nonnull id )controller { } -- (void)defaultLogActionForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { +- (void)defaultLogActionForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { } -- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { +- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { return nil; } diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index 12c300f9..99e87809 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -22,6 +22,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public var header: MoleculeModelProtocol? public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]? diff --git a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift index 6dae1700..303ceba1 100644 --- a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift @@ -10,11 +10,13 @@ import UIKit open class ModalMoleculeListTemplate: MoleculeListTemplate { - override open func newDataBuildScreen() { - super.newDataBuildScreen() + override open func handleNewData() { MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in - self?.dismiss() + if let _ = self { + MVMCoreNavigationHandler.shared()?.removeCurrentViewController() + } }, verticalCentered: false) + super.handleNewData() } } diff --git a/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift index 9f1ea9b9..b50400a7 100644 --- a/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift @@ -10,10 +10,12 @@ import UIKit open class ModalMoleculeStackTemplate: MoleculeStackTemplate { - override open func newDataBuildScreen() { - super.newDataBuildScreen() + override open func handleNewData() { + super.handleNewData() MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in - self?.dismiss() + if let _ = self { + MVMCoreNavigationHandler.shared()?.removeCurrentViewController() + } }, verticalCentered: false) } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 1ea13b4c..722e90a7 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -12,12 +12,6 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //-------------------------------------------------- // MARK: - Stored Properties //-------------------------------------------------- - - public var formValidator: FormValidator? - public func validate() { - // Can override - } - public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (ListItemModelProtocol & MoleculeModelProtocol))]? var observer: NSKeyValueObservation? @@ -27,13 +21,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- - - open override func parsePageJSON(_ error: NSErrorPointer) { - do { - try parseTemplateJSON() - } catch let parseError { - error?.pointee = parseError as NSError - } + open override func parsePageJSON() throws { + try parseTemplateJSON() } open override var loadObject: MVMCoreLoadObject? { @@ -90,10 +79,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol return true } - open override func newDataBuildScreen() { - super.newDataBuildScreen() + open override func handleNewData() { setup() registerWithTable() + super.handleNewData() } //-------------------------------------------------- @@ -109,7 +98,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - open override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { + open func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { guard let moleculeInfo = moleculesInfo?[indexPath.row], let estimatedHeight = (moleculeInfo.class as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(with: moleculeInfo.molecule, delegateObject() as? MVMCoreUIDelegateObject) else { return 0 } @@ -127,47 +116,33 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol let cell = tableView.dequeueReusableCell(withIdentifier: moleculeInfo.identifier) else { return UITableViewCell() } - let delegate = delegateObject() as? MVMCoreUIDelegateObject let moleculeCell = cell as? MVMCoreUIMoleculeViewProtocol moleculeCell?.reset?() if let protocolCell = cell as? MoleculeListCellProtocol { - protocolCell.setLines(with: templateModel?.line, delegateObject: delegate, additionalData: nil, indexPath: indexPath) + protocolCell.setLines(with: templateModel?.line, delegateObject: selfDelegateObject, additionalData: nil, indexPath: indexPath) } - (moleculeCell as? ModelMoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegate, nil) + (moleculeCell as? ModelMoleculeViewProtocol)?.set(with: moleculeInfo.molecule, selfDelegateObject, nil) moleculeCell?.updateView(tableView.bounds.width) return cell } - open override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if let protocolCell = cell as? MoleculeListCellProtocol { protocolCell.willDisplay() } } - open override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil) } } - //-------------------------------------------------- - // MARK: - Cache Handling - //-------------------------------------------------- - - open override func pageTypesToListenFor() -> [Any]? { - guard let pageType = self.pageType else { return super.pageTypesToListenFor() } - return [pageType] - } - - open override func modulesToListenFor() -> [Any]? { - return loadObject?.requestParameters?.modules - } - //-------------------------------------------------- // MARK: - MoleculeDelegateProtocol //-------------------------------------------------- @@ -183,7 +158,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() @@ -212,7 +187,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() @@ -240,7 +215,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol view.layoutIfNeeded() } - public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open override func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], 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 { @@ -262,7 +237,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 6a895120..f68cfa1a 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -9,20 +9,11 @@ import UIKit open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { - public func validate() { - - } - - public var formValidator: FormValidator? - var observer: NSKeyValueObservation? public var templateModel: StackPageTemplateModel? - open override func parsePageJSON(_ error: NSErrorPointer) { - do { - try parseTemplateJSON() - } catch let parseError { - error?.pointee = parseError as NSError - } + + open override func parsePageJSON() throws { + try parseTemplateJSON() } open override var loadObject: MVMCoreLoadObject? { @@ -73,17 +64,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { } // MARK: - cache handling - open override func pageTypesToListenFor() -> [Any]? { - guard let pageType = self.pageType else { - return super.pageTypesToListenFor() - } - return [pageType] - } - - open override func modulesToListenFor() -> [Any]? { - return loadObject?.requestParameters?.modules - } - + /// Adds modules from requiredModules() to the MVMCoreViewControllerMapping.requiredModules map. open func updateRequiredModules() { if let requiredModules = requiredModules(), let pageType = pageType { diff --git a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift index 66cd0365..f3bde0e7 100644 --- a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift @@ -17,6 +17,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public init(pageType: String) { self.pageType = pageType diff --git a/MVMCoreUI/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Templates/StackPageTemplateModel.swift index ed94e4ef..28600453 100644 --- a/MVMCoreUI/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackPageTemplateModel.swift @@ -18,6 +18,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public var header: MoleculeModelProtocol? public var moleculeStack: MoleculeStackModel diff --git a/MVMCoreUI/Templates/TemplateProtocol.swift b/MVMCoreUI/Templates/TemplateProtocol.swift index fcb6bde2..f4717774 100644 --- a/MVMCoreUI/Templates/TemplateProtocol.swift +++ b/MVMCoreUI/Templates/TemplateProtocol.swift @@ -14,7 +14,7 @@ public protocol TemplateProtocol: FormHolderProtocol { var templateModel: TemplateModel? { get set } } -public extension TemplateProtocol where Self: MFViewController { +public extension TemplateProtocol where Self: ViewController { func parseTemplateJSON() throws { guard let pageJSON = self.loadObject?.pageJSON else { return } let data = try JSONSerialization.data(withJSONObject: pageJSON) diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index 5ad39c4b..fff9bdb8 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -18,6 +18,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public var header: MoleculeModelProtocol? public var middle: MoleculeModelProtocol? diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 148d102d..0f400027 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -12,17 +12,10 @@ import UIKit public func validate() { } - - public var formValidator: FormValidator? - public var templateModel: ThreeLayerPageTemplateModel? - open override func parsePageJSON(_ error: NSErrorPointer) { - do { - try parseTemplateJSON() - } catch let parseError { - error?.pointee = parseError as NSError - } + open override func parsePageJSON() throws { + try parseTemplateJSON() } override open func viewDidLoad() { @@ -31,8 +24,8 @@ import UIKit // Do any additional setup after loading the view. } - open override func newDataBuildScreen() { - super.newDataBuildScreen() + open override func handleNewData() { + super.handleNewData() heightConstraint?.isActive = true } From 2d3eb3351ba0aad42f389f913f7b3a32cb5a8834 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 13 Mar 2020 11:59:34 -0400 Subject: [PATCH 005/244] legacy navigation logic --- .../BaseControllers/ViewController.swift | 127 ++++++++++++++++-- 1 file changed, 115 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 96b56ce4..c2b6f55a 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -32,6 +32,26 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC private var previousScreenSize = CGSize.zero public var selectedField: UIView? + + public var masterShouldBeAccessible: Bool = false { + didSet { + if let manager = manager as? MFViewController { + manager.masterShouldBeAccessible = masterShouldBeAccessible + } else if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self { + MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(masterShouldBeAccessible, for: self) + } + } + } + + public var supportShouldBeAccessible: Bool = false { + didSet { + if let manager = manager as? MFViewController { + manager.supportShouldBeAccessible = supportShouldBeAccessible + } else if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self { + MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(supportShouldBeAccessible, for: self) + } + } + } /// Checks if the screen width has changed open func screenSizeChanged() -> Bool { @@ -105,7 +125,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC pageType = loadObject.pageType self.loadObject = loadObject - // Verifies all modules needed are loaded. + // Verifies all modules needed are loaded. TODO: change to ViewController guard MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) else { return false } // Parse the model for the page. @@ -146,11 +166,6 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC return true } - open func set(navigationItem: UINavigationItem) { - navigationItem.title = pageModel?.screenHeading - navigationItem.accessibilityLabel = pageModel?.screenHeading - } - /// Calls processNewData and then sets the ui to update with updateView open func handleNewDataAndUpdateUI() { handleNewData() @@ -161,9 +176,100 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, open func handleNewData() { // TODO atomize the navigation item - set(navigationItem: navigationItem) + set(navigationController: navigationController) formValidator?.validate() } + + // MARK: - Navigation Item (Move to model base) + open func set(navigationController: UINavigationController?) { + navigationItem.title = pageModel?.screenHeading + navigationItem.accessibilityLabel = pageModel?.screenHeading + guard let navigationController = navigationController else { + MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() + return + } + navigationController.setNavigationBarHidden(isNavigationBarHidden(), animated: true) + UIColor.setBackgroundColor(forNavigationBar: navigationBarColor(), navigationBar: navigationController.navigationBar, transparent: navigationBarTransparent()) + + let tint = navigationBarTintColor() ?? .black + navigationController.navigationBar.tintColor = tint + + // Have the navigation title match the tint color + navigationController.navigationBar.titleTextAttributes?.updateValue(navigationBarTintColor, forKey: .foregroundColor) + + if navigationController == MVMCoreUISplitViewController.main()?.navigationController { + // Update icons if main navigation controller. + MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels() + let master = masterShouldBeAccessible + masterShouldBeAccessible = master + let support = supportShouldBeAccessible + supportShouldBeAccessible = support + + showBottomProgressBar() + MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(tint) + + // Update separator. + MVMCoreUISession.sharedGlobal()?.navigationController?.separatorView?.isHidden = /*self is MVMCoreUITabBarPageControlViewController ||*/ manager != nil || loadObject?.requestParameters?.tabWasPressed ?? false == true + } + } + + open func navigationBarColor() -> UIColor { + return .white + } + + open func isNavigationBarHidden() -> Bool { + return false + } + + open func navigationBarTransparent() -> Bool { + return false + } + + open func navigationBarTintColor() -> UIColor? { + return nil + } + + open func isMasterInitiallyAccessible() -> Bool { + if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false { + return false + } + return MVMCoreUISession.sharedGlobal()?.launchAppLoadedSuccessfully ?? false + } + + open func isSupportInitiallyAccessible() -> Bool { + if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false { + return false + } + return (MVMCoreUISession.sharedGlobal()?.launchAppLoadedSuccessfully ?? false) || showRightPanelForScreenBeforeLaunchApp() + } + + open func showRightPanelForScreenBeforeLaunchApp() -> Bool { + return loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false + } + + open func isOverridingRightButton() -> Bool { + guard let rightPanelLink = loadObject?.pageJSON?.optionalDictionaryForKey("rightPanelButtonLink") else { + return false + } + MVMCoreActionHandler.shared()?.handleAction(with: rightPanelLink, additionalData: nil, delegateObject: delegateObject()) + return true + } + + open func isOverridingLeftButton() -> Bool { + guard let leftPanelLink = loadObject?.pageJSON?.optionalDictionaryForKey("leftPanelButtonLink") else { + return false + } + MVMCoreActionHandler.shared()?.handleAction(with: leftPanelLink, additionalData: nil, delegateObject: delegateObject()) + return true + } + + open func showBottomProgressBar() { + if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self, + let progressString = loadObject?.pageJSON?.optionalStringForKey(KeyProgressPercent), + let progress = Float(progressString) { + MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(progress / Float(100)) + } + } // MARK: - View lifecycle open func initialLoad() { @@ -215,7 +321,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC // Update the navigation bar ui when view is appearing unless in a manager. The manager is expected to handle. if manager == nil { - set(navigationItem: navigationItem) + set(navigationController: navigationController) } } @@ -250,7 +356,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC // MARK: - MVMCoreViewManagerViewControllerProtocol open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) { if initialLoadFinished { - set(navigationItem: manager.navigationItem) + set(navigationController: manager.navigationController) } MVMCoreUISession.sharedGlobal()?.currentPageType = pageType MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) @@ -285,13 +391,10 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC // Test to see if needed. open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { - } open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { - } open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { - } // MARK: - UITextFieldDelegate (Check if this is still needed) From 7793bcfcb6be81d3c53a5a749f2392da0f847ac8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 13 Mar 2020 13:31:33 -0400 Subject: [PATCH 006/244] update index functions --- .../BaseControllers/ViewController.swift | 10 +-- .../AccordionMoleculeTableViewCell.swift | 14 ++-- .../Items/DropDownFilterTableViewCell.swift | 8 +- .../Molecules/Items/TabsTableViewCell.swift | 18 ++--- .../ModelMoleculeDelegateProtocol.swift | 37 ++------- .../Templates/MoleculeListTemplate.swift | 78 +++---------------- 6 files changed, 37 insertions(+), 128 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 919703b3..7aca8f01 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -391,13 +391,11 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC return nil } - // Test to see if needed. + // Needed otherwise when subclassed, the extension gets called. open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {} - open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {} - open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {} - open func addMolecules(_ molecules: [[AnyHashable: Any]], indexPath: IndexPath, animation: UITableView.RowAnimation) {} - open func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {} - open func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {} + open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil } + open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) {} + open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) {} // MARK: - UITextFieldDelegate (Check if this is still needed) // To Remove TextFields Bug: Keyboard is not dismissing after reaching textfield max length limit diff --git a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift index 714c7dd9..a7970861 100644 --- a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -32,18 +32,14 @@ import UIKit override public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { accordionButton.isSelected = !accordionButton.isSelected accordionButton.setTitle(accordionButton.isSelected ? "-" : "+", for: .normal) - guard let model = accordionListItemModel else { - return - } - - guard let json = model.toJSON(), - let molecules = json.optionalArrayForKey("molecules") as? [[AnyHashable: Any]] - else { return } + guard let model = accordionListItemModel else { return } if accordionButton.isSelected { - delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: .automatic) + if let indexPath = delegateObject?.moleculeDelegate?.getIndexPath(for: model) { + delegateObject?.moleculeDelegate?.addMolecules(model.molecules, indexPath: indexPath, animation: .automatic) + } } else { - delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: .automatic) + delegateObject?.moleculeDelegate?.removeMolecules(model.molecules, animation: .automatic) } if (accordionListItemModel?.hideLineWhenExpanded ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 0661e3ed..aa581ba1 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,14 +29,16 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let molecules2D = (self.listItemModel as? DropDownListItemModel)?.molecules + let model = self.listItemModel as? DropDownListItemModel else { return } if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(molecules2D[self.previousIndex], sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(model.molecules[self.previousIndex], animation: .fade) } - self.delegateObject?.moleculeDelegate?.addMolecules(molecules2D[index], sender: self, animation: .fade) + if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) { + self.delegateObject?.moleculeDelegate?.addMolecules(model.molecules[index], indexPath: indexPath, animation: .fade) + } self.previousIndex = index } } diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift index da700a28..cb6ee755 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift @@ -54,23 +54,19 @@ import UIKit extension TabsTableViewCell: TopTabbarDelegate { public func shouldSelectItem(at index: Int, topTabbar: TopTabbar) -> Bool { - if let model = tabsListItemModel, - let json = model.toJSON(), - let json2d = json.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]] { - let molecules = json2d[topTabbar.selectedIndex] - delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) + if let model = tabsListItemModel { + let molecules = model.molecules[topTabbar.selectedIndex] + delegateObject?.moleculeDelegate?.removeMolecules(molecules, animation: index < tabs.selectedIndex ? .right : .left) } previousTabIndex = tabs.selectedIndex return true } public func topTabbar(_ topTabbar: TopTabbar, didSelectItemAt index: Int) { - if let model = tabsListItemModel, - let json = model.toJSON(), - let json2d = json.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]] { - let molecules = json2d[index] - delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) - } + guard let model = tabsListItemModel, + let indexPath = delegateObject?.moleculeDelegate?.getIndexPath(for: model) else { return } + let molecules = model.molecules[index] + delegateObject?.moleculeDelegate?.addMolecules(molecules, indexPath: indexPath, animation: index < previousTabIndex ? .left : .right) } } diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index eb175c3a..435e5a24 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -18,39 +18,16 @@ public protocol MoleculeDelegateProtocol { 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 addMolecules(_ molecules: [[AnyHashable : Any]], indexPath: IndexPath, animation: UITableView.RowAnimation) - - func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) - - //optional - func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) - func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) + func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? + func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], 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 nothing - } + public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {} - public func addMolecules(_ molecules: [[AnyHashable : Any]], indexPath: IndexPath, animation: UITableView.RowAnimation) { - // Do nothing - } - - public func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - // Do nothing - } - - public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { - // Do nothing - } - - public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { - // Do nothing - } + public func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil } + public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) {} + public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) {} } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 8871db4d..ca56b4af 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -158,77 +158,18 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - open override func addMolecules(_ molecules: [[AnyHashable: Any]], indexPath: IndexPath, animation: UITableView.RowAnimation) { - - var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() - - molecules.forEach { molecule in - if let data = try? JSONSerialization.data(withJSONObject: molecule), let listItemModel = try? JSONDecoder().decode(MoleculeListItemModel.self, from: data) { - tmpMolecules.append(listItemModel) - } - } - - DispatchQueue.main.async { - var indexPaths: [IndexPath] = [] - - 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) - indexPaths.append(IndexPath(row: index, section: 0)) - } - } - - self.tableView?.insertRows(at: indexPaths, with: animation) - self.updateViewConstraints() - self.view.layoutIfNeeded() - } + open override func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { + guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in + //TODO: cehck for molecule protocola eqality + let json = moleculeInfo.molecule.toJSON() + return json == molecule.toJSON() + }) else { return nil } + return IndexPath(row: index, section: 0) } - open override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - - DispatchQueue.main.async { [weak self] in - guard let indexPath = self?.tableView?.indexPath(for: sender) else { return } - DispatchQueue.global().async { - self?.addMolecules(molecules, indexPath: indexPath, animation: animation) - } - } - } - - open override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - - var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() - - molecules.forEach { molecule in - if let data = try? JSONSerialization.data(withJSONObject: molecule), - let listItemModel = try? JSONDecoder().decode(MoleculeListItemModel.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: { molecule.toJSON() == $0.molecule.toJSON() }) { - - moleculesInfo?.remove(at: removeIndex) - indexPaths.append(IndexPath(row: removeIndex + indexPaths.count, section: 0)) - } - } - - tableView?.deleteRows(at: indexPaths, with: animation) - updateViewConstraints() - view.layoutIfNeeded() - } - - open override func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { - + open override func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, 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 { @@ -246,8 +187,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { - + open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality From 7fd0eb65f74003bd1a95cb956918dd5eef681a7e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 13 Mar 2020 13:39:08 -0400 Subject: [PATCH 007/244] change func signature for better readability --- MVMCoreUI/Categories/UIColor+Extension.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 94bf780d..9abedf97 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -289,7 +289,7 @@ extension UIColor { return .white } - public class func setBackgroundColor(forNavigationBar color: UIColor, navigationBar: UINavigationBar, transparent: Bool) { + public class func setBackgroundColor(_ color: UIColor, for navigationBar: UINavigationBar, isTransparent: Bool) { DispatchQueue.main.async { @@ -305,7 +305,7 @@ extension UIColor { let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() - if transparent { + if isTransparent { navigationBar.setBackgroundImage(UIImage(), for: .default) navigationBar.isTranslucent = false } else { From 87fb08fb723f92620abfa4b017bd4e4d5bb22ff2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 16 Mar 2020 09:15:49 -0400 Subject: [PATCH 008/244] Navigation model --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + .../BaseControllers/ViewController.swift | 86 ++++++-------- .../FormUIHelpers/New/FormProtocol.swift | 3 +- .../TemplateModelProtocol.swift | 2 +- .../NavigationItemModelProtocol.swift | 108 +++++++++++++++++- .../Templates/MoleculeListTemplate.swift | 3 +- .../Templates/MoleculeStackTemplate.swift | 3 +- .../Templates/StackPageTemplateModel.swift | 32 ++---- MVMCoreUI/Templates/TemplateModel.swift | 50 ++++++++ MVMCoreUI/Templates/TemplateProtocol.swift | 8 +- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 3 +- 11 files changed, 212 insertions(+), 90 deletions(-) create mode 100644 MVMCoreUI/Templates/TemplateModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2f9e8526..5b09bfb8 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -196,6 +196,7 @@ 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 */; }; + D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; D256E9932412880000360572 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = D256E9922412880000360572 /* Header.swift */; }; D260105323CEA61600764D80 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105223CEA61600764D80 /* ToggleModel.swift */; }; @@ -563,6 +564,7 @@ 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 = ""; }; + D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; D256E9922412880000360572 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = ""; }; D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = ""; }; @@ -1237,6 +1239,7 @@ isa = PBXGroup; children = ( 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, + D22D8392241C27B100D3DF69 /* TemplateModel.swift */, 014AA72823C5059B006F3E93 /* StackPageTemplateModel.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, 942C378D2412F5B60066E45E /* ModalMoleculeStackTemplate.swift */, @@ -2033,6 +2036,7 @@ D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, + D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */, diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 7aca8f01..080c48c2 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -32,26 +32,6 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC private var previousScreenSize = CGSize.zero public var selectedField: UIView? - - public var masterShouldBeAccessible: Bool = false { - didSet { - if let manager = manager as? MFViewController { - manager.masterShouldBeAccessible = masterShouldBeAccessible - } else if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self { - MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(masterShouldBeAccessible, for: self) - } - } - } - - public var supportShouldBeAccessible: Bool = false { - didSet { - if let manager = manager as? MFViewController { - manager.supportShouldBeAccessible = supportShouldBeAccessible - } else if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self { - MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(supportShouldBeAccessible, for: self) - } - } - } /// Checks if the screen width has changed open func screenSizeChanged() -> Bool { @@ -143,6 +123,24 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC } open func parsePageJSON() throws { + if pageModel?.navigationItem == nil { + let navigationModel = NavigationItemModel() + if navigationModel.title == nil { + navigationModel.title = pageModel?.screenHeading + } + if navigationModel.showLeftPanelButton == nil { + navigationModel.showLeftPanelButton = isMasterInitiallyAccessible() + } + if navigationModel.showRightPanelButton == nil { + navigationModel.showRightPanelButton = isSupportInitiallyAccessible() + } + pageModel?.navigationItem = navigationModel + } + if self.formValidator == nil, + let model = pageModel as? FormHolderModelProtocol { + let rules = model.formRules + self.formValidator = FormValidator(rules) + } } open class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool { @@ -175,37 +173,35 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, open func handleNewData() { - // TODO atomize the navigation item - set(navigationController: navigationController) formValidator?.validate() } // MARK: - Navigation Item (Move to model base) open func set(navigationController: UINavigationController?) { - navigationItem.title = pageModel?.screenHeading - navigationItem.accessibilityLabel = pageModel?.screenHeading - guard let navigationController = navigationController else { + guard let navigationItemModel = pageModel?.navigationItem, + let navigationController = navigationController else { MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() return } - navigationController.setNavigationBarHidden(isNavigationBarHidden(), animated: true) - UIColor.setBackgroundColor(forNavigationBar: navigationBarColor(), navigationBar: navigationController.navigationBar, transparent: navigationBarTransparent()) + navigationItem.title = navigationItemModel.title + navigationItem.accessibilityLabel = navigationItemModel.title - let tint = navigationBarTintColor() ?? .black + navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) + UIColor.setBackgroundColor(forNavigationBar: navigationItemModel.backgroundColor?.uiColor ?? .white, navigationBar: navigationController.navigationBar, transparent: navigationItemModel.transparent) + + let tint = navigationItemModel.tintColor.uiColor navigationController.navigationBar.tintColor = tint // Have the navigation title match the tint color - navigationController.navigationBar.titleTextAttributes?.updateValue(navigationBarTintColor, forKey: .foregroundColor) + navigationController.navigationBar.titleTextAttributes?.updateValue(tint, forKey: .foregroundColor) - if navigationController == MVMCoreUISplitViewController.main()?.navigationController { - // Update icons if main navigation controller. + // Update icons if main navigation controller. + if navigationController == MVMCoreUISplitViewController.main()?.navigationController, + MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self { MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels() - let master = masterShouldBeAccessible - masterShouldBeAccessible = master - let support = supportShouldBeAccessible - supportShouldBeAccessible = support - - showBottomProgressBar() + MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(navigationItemModel.showLeftPanelButton ?? false, for: self) + MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(navigationItemModel.showRightPanelButton ?? false, for: self) + showBottomProgressBar() MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(tint) // Update separator. @@ -213,22 +209,6 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC } } - open func navigationBarColor() -> UIColor { - return .white - } - - open func isNavigationBarHidden() -> Bool { - return false - } - - open func navigationBarTransparent() -> Bool { - return false - } - - open func navigationBarTintColor() -> UIColor? { - return nil - } - open func isMasterInitiallyAccessible() -> Bool { if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false { return false diff --git a/MVMCoreUI/FormUIHelpers/New/FormProtocol.swift b/MVMCoreUI/FormUIHelpers/New/FormProtocol.swift index bef7f547..1e096372 100644 --- a/MVMCoreUI/FormUIHelpers/New/FormProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/New/FormProtocol.swift @@ -9,7 +9,6 @@ import Foundation //Protocol for Validation -public protocol FormProtocol: class { +public protocol FormHolderModelProtocol: class { var formRules: [FormGroupRule]? { get set } - var formValidator: FormValidator? { get set } } diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift index a981ec64..646123e1 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation -public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, FormProtocol { +public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, FormHolderModelProtocol { var template: String { get } } diff --git a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift index acddb931..24b375fe 100644 --- a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift @@ -8,10 +8,112 @@ import Foundation -public protocol NavigationItemModelProtocol: ModelProtocol { - +public protocol NavigationItemModelProtocol: MoleculeModelProtocol { + var title: String? { get set } + var titleView: MoleculeModelProtocol? { get set } + var hidden: Bool { get set } + var backgroundColor: Color? { get set } + var transparent: Bool { get set } + var tintColor: Color { get set } + var systemBackButton: Bool? { get set } + var showLeftPanelButton: Bool? { get set } + var showRightPanelButton: Bool? { get set } + var additionalLeftItems: [NavigationItemButtonModel]? { get set } + var additionalRightItems: [NavigationItemButtonModel]? { get set } } -public protocol NavigationItemButtonModelProtocol { +public class NavigationItemButtonModel: Codable { + var imageName: String + var action: ActionModelProtocol + public init(with imageName: String, action: ActionModelProtocol) { + self.imageName = imageName + self.action = action + } + + private enum CodingKeys: String, CodingKey { + case imageName + case action + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + imageName = try typeContainer.decode(String.self, forKey: .imageName) + action = try typeContainer.decodeModel(codingKey: .action) + } + + open func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(imageName, forKey: .imageName) + try container.encodeModel(action, forKey: .action) + } +} + +public class NavigationItemModel: NavigationItemModelProtocol { + public class var identifier: String { + return "navigationItem" + } + + public var title: String? + public var titleView: MoleculeModelProtocol? + public var hidden: Bool + public var backgroundColor: Color? + public var transparent: Bool + public var tintColor: Color + public var systemBackButton: Bool? + public var showLeftPanelButton: Bool? + public var showRightPanelButton: Bool? + public var additionalLeftItems: [NavigationItemButtonModel]? + public var additionalRightItems: [NavigationItemButtonModel]? + + init() { + hidden = false + transparent = false + backgroundColor = Color(uiColor: .white) + tintColor = Color(uiColor: .black) + } + + private enum CodingKeys: String, CodingKey { + case title + case titleView + case hidden + case backgroundColor + case transparent + case tintColor + case systemBackButton + case showLeftPanelButton + case showRightPanelButton + case additionalLeftItems + case additionalRightItems + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) + hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) ?? false + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white) + transparent = try typeContainer.decodeIfPresent(Bool.self, forKey: .transparent) ?? false + tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black) + systemBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .systemBackButton) ?? false + showLeftPanelButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .showLeftPanelButton) + showRightPanelButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .showRightPanelButton) + additionalLeftItems = try typeContainer.decodeIfPresent([NavigationItemButtonModel].self, forKey: .additionalLeftItems) + additionalRightItems = try typeContainer.decodeIfPresent([NavigationItemButtonModel].self, forKey: .additionalRightItems) + } + + open func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(title, forKey: .title) + try container.encodeModelIfPresent(titleView, forKey: .titleView) + try container.encode(hidden, forKey: .hidden) + try container.encode(backgroundColor, forKey: .backgroundColor) + try container.encode(transparent, forKey: .transparent) + try container.encode(tintColor, forKey: .tintColor) + try container.encodeIfPresent(systemBackButton, forKey: .systemBackButton) + try container.encode(showLeftPanelButton, forKey: .showLeftPanelButton) + try container.encode(showRightPanelButton, forKey: .showRightPanelButton) + try container.encodeIfPresent(additionalLeftItems, forKey: .additionalLeftItems) + try container.encodeIfPresent(additionalRightItems, forKey: .additionalRightItems) + } } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index ca56b4af..8cff8cd8 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -22,7 +22,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol // MARK: - Computed Properties //-------------------------------------------------- open override func parsePageJSON() throws { - try parseTemplateJSON() + try parseTemplate(json: loadObject?.pageJSON) + try super.parsePageJSON() } open override var loadObject: MVMCoreLoadObject? { diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index f68cfa1a..c8d807cc 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -13,7 +13,8 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { public var templateModel: StackPageTemplateModel? open override func parsePageJSON() throws { - try parseTemplateJSON() + try parseTemplate(json: loadObject?.pageJSON) + try super.parsePageJSON() } open override var loadObject: MVMCoreLoadObject? { diff --git a/MVMCoreUI/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Templates/StackPageTemplateModel.swift index 28600453..2b683d98 100644 --- a/MVMCoreUI/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackPageTemplateModel.swift @@ -9,55 +9,39 @@ import Foundation -@objcMembers public class StackPageTemplateModel: TemplateModelProtocol { - public var formRules: [FormGroupRule]? - public var formValidator: FormValidator? - - public static var identifier: String = "stack" - - public var pageType: String - public var screenHeading: String? - public var isAtomicTabs: Bool? - public var navigationItem: NavigationItemModelProtocol? +@objcMembers public class StackPageTemplateModel: TemplateModel { + public override class var identifier: String { + return "stack" + } public var header: MoleculeModelProtocol? public var moleculeStack: MoleculeStackModel public var footer: MoleculeModelProtocol? public init(pageType: String, moleculeStack: MoleculeStackModel) { - self.pageType = pageType self.moleculeStack = moleculeStack + super.init(pageType: pageType) } private enum CodingKeys: String, CodingKey { - case pageType - case screenHeading case header case footer case stack - case isAtomicTabs - case formRules } 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: .stack) - screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) - isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) header = try typeContainer.decodeModelIfPresent(codingKey: .header) footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) - formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(pageType, forKey: .pageType) try container.encode(moleculeStack, forKey: .stack) - try container.encodeIfPresent(screenHeading, forKey: .screenHeading) - try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) try container.encodeModelIfPresent(header, forKey: .header) try container.encodeModelIfPresent(footer, forKey: .footer) - try container.encodeIfPresent(formRules, forKey: .formRules) } } diff --git a/MVMCoreUI/Templates/TemplateModel.swift b/MVMCoreUI/Templates/TemplateModel.swift new file mode 100644 index 00000000..850ba80b --- /dev/null +++ b/MVMCoreUI/Templates/TemplateModel.swift @@ -0,0 +1,50 @@ +// +// TemplateModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class TemplateModel: TemplateModelProtocol { + public class var identifier: String { + return "" + } + public var pageType: String + public var screenHeading: String? + public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? + public var formRules: [FormGroupRule]? + + public init(pageType: String) { + self.pageType = pageType + } + + private enum CodingKeys: String, CodingKey { + case pageType + case screenHeading + case isAtomicTabs + case formRules + case navigationItem + } + + 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) + formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) + navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem) + } + + 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.encodeIfPresent(formRules, forKey: .formRules) + try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem) + } +} diff --git a/MVMCoreUI/Templates/TemplateProtocol.swift b/MVMCoreUI/Templates/TemplateProtocol.swift index f4717774..78b304b0 100644 --- a/MVMCoreUI/Templates/TemplateProtocol.swift +++ b/MVMCoreUI/Templates/TemplateProtocol.swift @@ -15,16 +15,16 @@ public protocol TemplateProtocol: FormHolderProtocol { } public extension TemplateProtocol where Self: ViewController { - func parseTemplateJSON() throws { - guard let pageJSON = self.loadObject?.pageJSON else { return } + func parseTemplate(json: [AnyHashable: Any]?) throws { + guard let pageJSON = json else { return } let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() let templateModel = try decoder.decode(TemplateModel.self, from: data) - + self.templateModel = templateModel + if self.formValidator == nil { let rules = templateModel.formRules self.formValidator = FormValidator(rules) } - self.templateModel = templateModel } } diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 0f400027..19859667 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -15,7 +15,8 @@ import UIKit public var templateModel: ThreeLayerPageTemplateModel? open override func parsePageJSON() throws { - try parseTemplateJSON() + try parseTemplate(json: loadObject?.pageJSON) + try super.parsePageJSON() } override open func viewDidLoad() { From 2c6f9667a50accebbdfa2416921e062cc1f51b90 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 16 Mar 2020 16:47:39 -0400 Subject: [PATCH 009/244] small changes --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ++++++++---- .../MVMControllerModelProtocol.swift | 13 +++++++++++++ MVMCoreUI/BaseControllers/ViewController.swift | 8 ++++---- ...Protocol.swift => FormHolderModelProtocol.swift} | 6 +++--- .../FormUIHelpers/New/FormHolderProtocol.swift | 3 +-- .../ModelProtocols/TemplateModelProtocol.swift | 2 +- MVMCoreUI/Templates/TemplateModel.swift | 2 +- MVMCoreUI/Templates/TemplateProtocol.swift | 10 +++------- MVMCoreUI/Templates/ThreeLayerTemplate.swift | 3 --- 9 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 MVMCoreUI/BaseControllers/MVMControllerModelProtocol.swift rename MVMCoreUI/FormUIHelpers/New/{FormProtocol.swift => FormHolderModelProtocol.swift} (50%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5b09bfb8..da20838e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */; }; 011D958524042432000E3791 /* RulesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D958424042432000E3791 /* RulesProtocol.swift */; }; 011D958724042492000E3791 /* FormFieldProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D958624042492000E3791 /* FormFieldProtocol.swift */; }; - 011D95892404249B000E3791 /* FormProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95882404249B000E3791 /* FormProtocol.swift */; }; + 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95882404249B000E3791 /* FormHolderModelProtocol.swift */; }; 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959A240451E3000E3791 /* RuleRequiredModel.swift */; }; 011D959D2404536F000E3791 /* RuleAnyValueChangedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959C2404536F000E3791 /* RuleAnyValueChangedModel.swift */; }; 011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959E240453A1000E3791 /* RuleAllValueChangedModel.swift */; }; @@ -197,6 +197,7 @@ 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 */; }; D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; + D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; D256E9932412880000360572 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = D256E9922412880000360572 /* Header.swift */; }; D260105323CEA61600764D80 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105223CEA61600764D80 /* ToggleModel.swift */; }; @@ -393,7 +394,7 @@ 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownListItemModel.swift; sourceTree = ""; }; 011D958424042432000E3791 /* RulesProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RulesProtocol.swift; sourceTree = ""; }; 011D958624042492000E3791 /* FormFieldProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormFieldProtocol.swift; sourceTree = ""; }; - 011D95882404249B000E3791 /* FormProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormProtocol.swift; sourceTree = ""; }; + 011D95882404249B000E3791 /* FormHolderModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormHolderModelProtocol.swift; sourceTree = ""; }; 011D959A240451E3000E3791 /* RuleRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleRequiredModel.swift; sourceTree = ""; }; 011D959C2404536F000E3791 /* RuleAnyValueChangedModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyValueChangedModel.swift; sourceTree = ""; }; 011D959E240453A1000E3791 /* RuleAllValueChangedModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAllValueChangedModel.swift; sourceTree = ""; }; @@ -565,6 +566,7 @@ 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 = ""; }; D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; + D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; D256E9922412880000360572 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = ""; }; D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = ""; }; @@ -797,7 +799,7 @@ isa = PBXGroup; children = ( 011D958A24042794000E3791 /* Rules */, - 011D95882404249B000E3791 /* FormProtocol.swift */, + 011D95882404249B000E3791 /* FormHolderModelProtocol.swift */, 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */, 011D95AA2405C553000E3791 /* FormItemProtocol.swift */, 011D958624042492000E3791 /* FormFieldProtocol.swift */, @@ -1306,6 +1308,7 @@ D29DF10F21E67A7D003B2FB9 /* BaseControllers */ = { isa = PBXGroup; children = ( + D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */, D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */, D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */, @@ -1815,6 +1818,7 @@ 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */, 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, + D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, @@ -2025,7 +2029,7 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, - 011D95892404249B000E3791 /* FormProtocol.swift in Sources */, + 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, diff --git a/MVMCoreUI/BaseControllers/MVMControllerModelProtocol.swift b/MVMCoreUI/BaseControllers/MVMControllerModelProtocol.swift new file mode 100644 index 00000000..579a612e --- /dev/null +++ b/MVMCoreUI/BaseControllers/MVMControllerModelProtocol.swift @@ -0,0 +1,13 @@ +// +// MVMControllerModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol MVMControllerModelProtocol: TemplateModelProtocol, FormHolderModelProtocol { + +} diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 080c48c2..e44ab353 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -11,7 +11,7 @@ import UIKit open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate { public var pageType: String? public var loadObject: MVMCoreLoadObject? - public var pageModel: PageModelProtocol? + public var pageModel: MVMControllerModelProtocol? /// Set if this page is containted in a manager. public var manager: (UIViewController & MVMCoreViewManagerProtocol)? @@ -123,6 +123,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC } open func parsePageJSON() throws { + // Convert legacy to navigation model. if pageModel?.navigationItem == nil { let navigationModel = NavigationItemModel() if navigationModel.title == nil { @@ -136,9 +137,8 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC } pageModel?.navigationItem = navigationModel } - if self.formValidator == nil, - let model = pageModel as? FormHolderModelProtocol { - let rules = model.formRules + if self.formValidator == nil { + let rules = pageModel?.formRules self.formValidator = FormValidator(rules) } } diff --git a/MVMCoreUI/FormUIHelpers/New/FormProtocol.swift b/MVMCoreUI/FormUIHelpers/New/FormHolderModelProtocol.swift similarity index 50% rename from MVMCoreUI/FormUIHelpers/New/FormProtocol.swift rename to MVMCoreUI/FormUIHelpers/New/FormHolderModelProtocol.swift index 1e096372..a9428a2b 100644 --- a/MVMCoreUI/FormUIHelpers/New/FormProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/New/FormHolderModelProtocol.swift @@ -1,14 +1,14 @@ // -// Validatable.swift +// FormHolderModelProtocol.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 2/5/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +// A protocol for the model of the delegate object that holds the form validator. The rules are stored in the model. import Foundation -//Protocol for Validation -public protocol FormHolderModelProtocol: class { +public protocol FormHolderModelProtocol { var formRules: [FormGroupRule]? { get set } } diff --git a/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift b/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift index 1e2f5522..26bceac4 100644 --- a/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift @@ -5,11 +5,10 @@ // Created by Suresh, Kamlesh on 2/26/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +// A delegate object that holds the form validator. import Foundation - -//Protocol for Validation public protocol FormHolderProtocol: NSObjectProtocol { var formValidator: FormValidator? { get set } } diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift index 646123e1..3ed37d6b 100644 --- a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation -public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, FormHolderModelProtocol { +public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol { var template: String { get } } diff --git a/MVMCoreUI/Templates/TemplateModel.swift b/MVMCoreUI/Templates/TemplateModel.swift index 850ba80b..053d45fc 100644 --- a/MVMCoreUI/Templates/TemplateModel.swift +++ b/MVMCoreUI/Templates/TemplateModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class TemplateModel: TemplateModelProtocol { +@objcMembers public class TemplateModel: MVMControllerModelProtocol { public class var identifier: String { return "" } diff --git a/MVMCoreUI/Templates/TemplateProtocol.swift b/MVMCoreUI/Templates/TemplateProtocol.swift index 78b304b0..4d494fe4 100644 --- a/MVMCoreUI/Templates/TemplateProtocol.swift +++ b/MVMCoreUI/Templates/TemplateProtocol.swift @@ -9,22 +9,18 @@ import Foundation -public protocol TemplateProtocol: FormHolderProtocol { +public protocol TemplateProtocol: class { associatedtype TemplateModel: TemplateModelProtocol var templateModel: TemplateModel? { get set } } -public extension TemplateProtocol where Self: ViewController { +public extension TemplateProtocol where Self: ViewController { func parseTemplate(json: [AnyHashable: Any]?) throws { guard let pageJSON = json else { return } let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() let templateModel = try decoder.decode(TemplateModel.self, from: data) self.templateModel = templateModel - - if self.formValidator == nil { - let rules = templateModel.formRules - self.formValidator = FormValidator(rules) - } + self.pageModel = templateModel as? MVMControllerModelProtocol } } diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 19859667..ba35c971 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -9,9 +9,6 @@ import UIKit @objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { - public func validate() { - - } public var templateModel: ThreeLayerPageTemplateModel? open override func parsePageJSON() throws { From f4f5d8dc84c87e43cf552eafe539e08e6c21b4c7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 16 Mar 2020 19:41:50 -0400 Subject: [PATCH 010/244] fixes --- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 2 +- .../ThreeLayerTableViewController.swift | 2 +- .../BaseControllers/ViewController.swift | 42 +++++++++---------- .../Templates/ListPageTemplateModel.swift | 2 +- .../Templates/MoleculeListTemplate.swift | 2 +- .../StackCenteredPageTemplateModel.swift | 2 +- .../ThreeLayerPageTemplateModel.swift | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index e61a5af3..d8415d2d 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -181,7 +181,7 @@ import UIKit let widthWillChange = !MVMCoreGetterUtility.cgfequal(widthConstraint?.constant ?? 0, width ?? 0) let heightWillChange = !MVMCoreGetterUtility.cgfequal(heightConstraint?.constant ?? 0, height ?? 0) let sizeWillChange = (width == nil || height == nil) && !(size?.equalTo(imageView.image?.size ?? CGSize.zero) ?? false) - let heightChangeFromSpinner = ((height ?? size?.height) ?? 0) < loadingSpinnerHeightConstraint?.constant ?? CGFloat.leastNormalMagnitude + let heightChangeFromSpinner = (heightConstraint?.isActive ?? false) ? false : ((height ?? size?.height) ?? 0) < loadingSpinnerHeightConstraint?.constant ?? CGFloat.leastNormalMagnitude return widthWillChange || heightWillChange || sizeWillChange || heightChangeFromSpinner } diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index 2fba0e07..0a7f4e55 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -37,10 +37,10 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { } open override func handleNewData() { + super.handleNewData() createViewForTableHeader() createViewForTableFooter() tableView?.reloadData() - super.handleNewData() } override open func viewDidLoad() { diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index e44ab353..12169a7c 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -123,24 +123,6 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC } open func parsePageJSON() throws { - // Convert legacy to navigation model. - if pageModel?.navigationItem == nil { - let navigationModel = NavigationItemModel() - if navigationModel.title == nil { - navigationModel.title = pageModel?.screenHeading - } - if navigationModel.showLeftPanelButton == nil { - navigationModel.showLeftPanelButton = isMasterInitiallyAccessible() - } - if navigationModel.showRightPanelButton == nil { - navigationModel.showRightPanelButton = isSupportInitiallyAccessible() - } - pageModel?.navigationItem = navigationModel - } - if self.formValidator == nil { - let rules = pageModel?.formRules - self.formValidator = FormValidator(rules) - } } open class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool { @@ -173,7 +155,24 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, open func handleNewData() { - formValidator?.validate() + // Convert legacy to navigation model. + if pageModel?.navigationItem == nil { + let navigationModel = NavigationItemModel() + if navigationModel.title == nil { + navigationModel.title = pageModel?.screenHeading + } + if navigationModel.showLeftPanelButton == nil { + navigationModel.showLeftPanelButton = isMasterInitiallyAccessible() + } + if navigationModel.showRightPanelButton == nil { + navigationModel.showRightPanelButton = isSupportInitiallyAccessible() + } + pageModel?.navigationItem = navigationModel + } + if self.formValidator == nil { + let rules = pageModel?.formRules + self.formValidator = FormValidator(rules) + } } // MARK: - Navigation Item (Move to model base) @@ -257,6 +256,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC } open func updateViews() { + formValidator?.validate() } override open func viewDidLoad() { @@ -312,7 +312,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC if manager == nil { MVMCoreUISession.sharedGlobal()?.currentPageType = pageType - MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + //MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) } } @@ -341,7 +341,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC set(navigationController: manager.navigationController) } MVMCoreUISession.sharedGlobal()?.currentPageType = pageType - MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + //MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) } // MARK: - MVMCoreActionDelegateProtocol diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index 99e87809..db25742b 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ListPageTemplateModel: TemplateModelProtocol { +@objcMembers public class ListPageTemplateModel: MVMControllerModelProtocol { public var formRules: [FormGroupRule]? public var formValidator: FormValidator? diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 8cff8cd8..84b88fd4 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -81,9 +81,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } open override func handleNewData() { + super.handleNewData() setup() registerWithTable() - super.handleNewData() } //-------------------------------------------------- diff --git a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift index f3bde0e7..49fb67c5 100644 --- a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class StackCenteredPageTemplateModel: TemplateModelProtocol { +@objcMembers public class StackCenteredPageTemplateModel: MVMControllerModelProtocol { public var formRules: [FormGroupRule]? public var formValidator: FormValidator? diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index fff9bdb8..b745cb0f 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ThreeLayerPageTemplateModel: TemplateModelProtocol { +@objcMembers public class ThreeLayerPageTemplateModel: MVMControllerModelProtocol { public var formRules: [FormGroupRule]? public var formValidator: FormValidator? From c65d7d233e8b7530a798f4082964c8526462d5a5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 16 Mar 2020 23:06:31 -0400 Subject: [PATCH 011/244] validate_on_appear --- MVMCoreUI/BaseControllers/MFViewController.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index fef3b860..7266c54f 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -484,7 +484,6 @@ - (void)newDataBuildAndUpdate { [MVMCoreDispatchUtility performBlockOnMainThread:^{ [self newDataBuildScreen]; - [self startValidation]; self.needToUpdateUI = YES; [self.view setNeedsLayout]; }]; @@ -536,6 +535,8 @@ if (!self.disableAnimations) { [self.introAnimationManager performAnimations]; } + + [self startValidation]; } - (void)viewWillDisappear:(BOOL)animated { From 720a5569b527d324799c9eeaa319780ea83a6341 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 17 Mar 2020 10:18:06 +0530 Subject: [PATCH 012/244] 19156(List - Two Column - Divider - Subsection) initial commit. Added model and molecule class. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ .../ListTwoColumnSubsectionDivider.swift | 62 +++++++++++++++++++ .../ListTwoColumnSubsectionDividerModel.swift | 48 ++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 9 +-- 4 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 796d5b7d..131f1e93 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -171,6 +171,8 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; + AAE131E1242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE131E0242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift */; }; + AAE131E3242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE131E2242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift */; }; 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 */; }; @@ -542,6 +544,8 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; + AAE131E0242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ListTwoColumnSubsectionDivider.swift; path = MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift; sourceTree = SOURCE_ROOT; }; + AAE131E2242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ListTwoColumnSubsectionDividerModel.swift; path = MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift; sourceTree = SOURCE_ROOT; }; 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 = ""; }; @@ -909,6 +913,8 @@ 526A265A240D1FCE00B0D828 /* TwoColumn */ = { isa = PBXGroup; children = ( + AAE131E0242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift */, + AAE131E2242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift */, ); path = TwoColumn; sourceTree = ""; @@ -1971,6 +1977,7 @@ 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, + AAE131E1242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift in Sources */, 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, @@ -1995,6 +2002,7 @@ D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, + AAE131E3242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift new file mode 100644 index 00000000..b051fcab --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift @@ -0,0 +1,62 @@ +// +// ListTwoColumnSubsectionDivider.swift +// MVMCoreUI +// +// Created by Lekshmi S on 17/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListTwoColumnSubsectionDivider: TableViewCell { + + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + let leftLabel = Label.createLabelBoldBodySmall(true) + let rightLabel = Label.createLabelBoldBodySmall(true) + var stack: Stack + + //------------------------------------------------------- + // MARK: - Initializers + //------------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 75, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent: 25, horizontalAlignment: .leading))], + axis: .horizontal, spacing: 8) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListTwoColumnSubsectionDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + open override func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift new file mode 100644 index 00000000..51d17cde --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift @@ -0,0 +1,48 @@ +// +// ListTwoColumnSubsectionDividerModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 17/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListTwoColumnSubsectionDividerModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list2CSbscDiv" + public var leftLabel: LabelModel + public var rightLabel: LabelModel + + public init(leftLabel: LabelModel, rightLabel: LabelModel) { + self.leftLabel = leftLabel + self.rightLabel = rightLabel + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index cc3950cd..681bc2cb 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -107,14 +107,15 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) // Designed Section Dividers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) - - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnSubsectionDivider.self, viewModelClass: ListTwoColumnSubsectionDividerModel.self) + // TODO: Need model MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DigitEntryField.self, forKey: "digitTextField" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DateDropdownEntryField.self, forKey: "dateDropdownEntryField" as NSString) From fc741e38df432ce44dcf1c3365c2e541972a6175 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Tue, 17 Mar 2020 14:54:26 +0530 Subject: [PATCH 013/244] initial commit --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++++++ .../ListRightVariableButtonAllTextAndLinks.swift | 9 +++++++++ .../ListRightVariableButtonAllTextAndLinksModel.swift | 9 +++++++++ 3 files changed, 26 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 796d5b7d..b274b715 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -171,6 +171,8 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; + BB6C6A7F2420CE5D005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6A7E2420CE5D005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */; }; + BB6C6A812420CE6E005F7224 /* ListRightVariableButtonAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6A802420CE6E005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */; }; 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 */; }; @@ -542,6 +544,8 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; + BB6C6A7E2420CE5D005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinksModel.swift; sourceTree = ""; }; + BB6C6A802420CE6E005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinks.swift; 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 = ""; }; @@ -939,6 +943,8 @@ AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( + BB6C6A7E2420CE5D005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */, + BB6C6A802420CE6E005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */, AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, C7F8012223E846C300396FBD /* ListRVWheelModel.swift */, @@ -2027,6 +2033,7 @@ D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, + BB6C6A7F2420CE5D005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, 0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */, @@ -2041,6 +2048,7 @@ 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */, D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, + BB6C6A812420CE6E005F7224 /* ListRightVariableButtonAllTextAndLinks.swift in Sources */, 94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */, 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift new file mode 100644 index 00000000..8edcdb20 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -0,0 +1,9 @@ +// +// ListRightVariableButtonAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 17/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift new file mode 100644 index 00000000..ce10407e --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -0,0 +1,9 @@ +// +// ListRightVariableButtonAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 17/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation From f4f6557c90407a8a369ed8657aab9ac83bc85b6b Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Tue, 17 Mar 2020 16:02:39 +0530 Subject: [PATCH 014/244] ListRightVariableButtonAllTextAndLinks molecule implemented --- ...stRightVariableButtonAllTextAndLinks.swift | 43 +++++++++++++++++++ ...htVariableButtonAllTextAndLinksModel.swift | 37 ++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 3 files changed, 81 insertions(+) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index 8edcdb20..3f95682a 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -7,3 +7,46 @@ // import Foundation +@objcMembers open class ListRightVariableButtonAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + var stack: Stack + let button = Button(frame: .zero) + let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 5,horizontalAlignment: .leading)), + (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .top))],axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableTextButtonAllTextAndLinksModel else { return } + button.set(with: model.button, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index ce10407e..91e9ead2 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -7,3 +7,40 @@ // import Foundation +public class ListRightVariableTextButtonAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ + public static var identifier: String = "listRVBtn" + public var button: ButtonModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + public init(button: ButtonModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.button = button + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + self.button.size = .tiny + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case button + case eyebrowHeadlineBodyLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + button = try typeContainer.decode(ButtonModel.self, forKey: .button) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(button, forKey: .button) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index cc3950cd..69eb4994 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -103,6 +103,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableTextButtonAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) From ddfeb9cd359a11823a921cbb9e9dcad74bd7dc2c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 17 Mar 2020 09:35:14 -0400 Subject: [PATCH 015/244] merge --- .../FormUIHelpers/FormHolderModelProtocol.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift diff --git a/MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift b/MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift new file mode 100644 index 00000000..a9428a2b --- /dev/null +++ b/MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift @@ -0,0 +1,14 @@ +// +// FormHolderModelProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 2/5/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// +// A protocol for the model of the delegate object that holds the form validator. The rules are stored in the model. + +import Foundation + +public protocol FormHolderModelProtocol { + var formRules: [FormGroupRule]? { get set } +} From 8243820f854c6d5a44c036d0924ae0a05ccf37bd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 17 Mar 2020 13:48:34 -0400 Subject: [PATCH 016/244] track action fixes --- .../BaseControllers/ViewController.swift | 23 ++++++++++++++----- .../Items/DropDownFilterTableViewCell.swift | 4 +--- .../Templates/MoleculeListTemplate.swift | 2 ++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 12169a7c..80662cad 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -8,9 +8,9 @@ import UIKit -open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate { - public var pageType: String? - public var loadObject: MVMCoreLoadObject? +@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate { + @objc public var pageType: String? + @objc public var loadObject: MVMCoreLoadObject? public var pageModel: MVMControllerModelProtocol? /// Set if this page is containted in a manager. @@ -208,6 +208,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC } } + // Eventually will be moved to server open func isMasterInitiallyAccessible() -> Bool { if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false { return false @@ -215,6 +216,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC return MVMCoreUISession.sharedGlobal()?.launchAppLoadedSuccessfully ?? false } + // Eventually will be moved to server open func isSupportInitiallyAccessible() -> Bool { if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false { return false @@ -226,6 +228,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC return loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false } + // Eventually will be moved to separate button in navigation item model open func isOverridingRightButton() -> Bool { guard let rightPanelLink = loadObject?.pageJSON?.optionalDictionaryForKey("rightPanelButtonLink") else { return false @@ -234,6 +237,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC return true } + // Eventually will be moved to separate button in navigation item model open func isOverridingLeftButton() -> Bool { guard let leftPanelLink = loadObject?.pageJSON?.optionalDictionaryForKey("leftPanelButtonLink") else { return false @@ -242,6 +246,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC return true } + // Eventually will be moved to Model open func showBottomProgressBar() { if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self, let progressString = loadObject?.pageJSON?.optionalStringForKey(KeyProgressPercent), @@ -265,6 +270,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC // Do any additional setup after loading the view. MVMCoreLoggingHandler.logDebugMessage(withDelegate: "View Controller Loaded : \(self)") + // We use our own margins. viewRespectsSystemMinimumLayoutMargins = false // Presents from the bottom. @@ -278,7 +284,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC // Handle data on load handleNewData() - + view.setNeedsLayout() } @@ -312,7 +318,7 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC if manager == nil { MVMCoreUISession.sharedGlobal()?.currentPageType = pageType - //MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) } } @@ -340,8 +346,9 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC if initialLoadFinished { set(navigationController: manager.navigationController) } + // Janky way to track current page. MVMCoreUISession.sharedGlobal()?.currentPageType = pageType - //MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) } // MARK: - MVMCoreActionDelegateProtocol @@ -351,6 +358,10 @@ open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMC MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: selfDelegateObject) } + open func logAction(withActionInformation actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { + MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController: self, actionInformation: actionInformation, additionalData: additionalData) + } + // MARK: - MoleculeDelegateProtocol open func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? { guard let name = name else { return nil } diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 41801046..aa581ba1 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,9 +29,7 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), - let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], - !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) + let model = self.listItemModel as? DropDownListItemModel else { return } if self.previousIndex != NSNotFound { diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index a539240e..bca29172 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -183,6 +183,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } + guard indexPaths.count > 0 else { return } self.tableView?.insertRows(at: indexPaths, with: animation) self.updateViewConstraints() self.view.layoutIfNeeded() @@ -200,6 +201,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } + guard indexPaths.count > 0 else { return } tableView?.deleteRows(at: indexPaths, with: animation) updateViewConstraints() view.layoutIfNeeded() From 0f6ded4591679c9f0c1d660649def673985edc65 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 17 Mar 2020 15:08:27 -0400 Subject: [PATCH 017/244] move action models --- MVMCoreUI.xcodeproj/project.pbxproj | 16 +++++++++++++ .../ActionCollapseNotificationModel.swift | 21 ++++++++++++++++ MVMCoreUI/Actions/ActionTopAlertModel.swift | 24 +++++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 4 ++++ 4 files changed, 65 insertions(+) create mode 100644 MVMCoreUI/Actions/ActionCollapseNotificationModel.swift create mode 100644 MVMCoreUI/Actions/ActionTopAlertModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b16286eb..d1d76cb3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -154,6 +154,8 @@ 94AF4A3F23E9D13900676048 /* MFCaretButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94AF4A3D23E9D13900676048 /* MFCaretButton.m */; }; 94AF4A4223E9D19E00676048 /* MFCaretView.h in Headers */ = {isa = PBXBuildFile; fileRef = 94AF4A4023E9D19E00676048 /* MFCaretView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */ = {isa = PBXBuildFile; fileRef = 94AF4A4123E9D19E00676048 /* MFCaretView.m */; }; + 94C0150A24215643005811A9 /* ActionTopAlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C0150924215643005811A9 /* ActionTopAlertModel.swift */; }; + 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C0150B2421564A005811A9 /* ActionCollapseNotificationModel.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 */; }; @@ -533,6 +535,8 @@ 94AF4A3D23E9D13900676048 /* MFCaretButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFCaretButton.m; sourceTree = ""; }; 94AF4A4023E9D19E00676048 /* MFCaretView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFCaretView.h; sourceTree = ""; }; 94AF4A4123E9D19E00676048 /* MFCaretView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFCaretView.m; sourceTree = ""; }; + 94C0150924215643005811A9 /* ActionTopAlertModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionTopAlertModel.swift; sourceTree = ""; }; + 94C0150B2421564A005811A9 /* ActionCollapseNotificationModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionCollapseNotificationModel.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 = ""; }; @@ -943,6 +947,15 @@ path = TwoColumn; sourceTree = ""; }; + 94C01508242155FE005811A9 /* Actions */ = { + isa = PBXGroup; + children = ( + 94C0150924215643005811A9 /* ActionTopAlertModel.swift */, + 94C0150B2421564A005811A9 /* ActionCollapseNotificationModel.swift */, + ); + path = Actions; + sourceTree = ""; + }; 94C2D9822386F3E30006CF46 /* Label */ = { isa = PBXGroup; children = ( @@ -1271,6 +1284,7 @@ D29DF11E21E6851E003B2FB9 /* TopAlert */, D29DF10D21E67A70003B2FB9 /* Atoms */, D29DF10E21E67A77003B2FB9 /* Molecules */, + 94C01508242155FE005811A9 /* Actions */, D22479902316A9CB003FCCF9 /* Organisms */, D29DF0DF21E418B2003B2FB9 /* Templates */, D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */, @@ -1924,6 +1938,7 @@ 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, + 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, @@ -2049,6 +2064,7 @@ C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */, + 94C0150A24215643005811A9 /* ActionTopAlertModel.swift in Sources */, 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, diff --git a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift new file mode 100644 index 00000000..17799ec2 --- /dev/null +++ b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift @@ -0,0 +1,21 @@ +// +// ActionCollapseNotificationModel.swift +// MVMCore +// +// Created by Ryan on 3/17/20. +// Copyright © 2020 myverizon. All rights reserved. +// + +import UIKit + +@objcMembers public class ActionCollapseNotificationModel: ActionModelProtocol { + public static var identifier: String = "collapseNotification" + + public var actionType: String? + + public var extraParameters: JSONValueDictionary? + + public var analyticsData: JSONValueDictionary? + + public var title: String? +} diff --git a/MVMCoreUI/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Actions/ActionTopAlertModel.swift new file mode 100644 index 00000000..54746f31 --- /dev/null +++ b/MVMCoreUI/Actions/ActionTopAlertModel.swift @@ -0,0 +1,24 @@ +// +// ActionTopAlertModel.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 12/16/19. +// Copyright © 2019 myverizon. All rights reserved. +// + +import Foundation + +@objcMembers public class ActionTopAlertModel: ActionModelProtocol { + + public static var identifier: String = "topAlert" + public var actionType: String? = ActionTopAlertModel.identifier + public var pageType: String + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + // Temporary fix till server changes + public var title: String? + + public init(pageType: String) { + self.pageType = pageType + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index a0d18912..b62eebfd 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -132,5 +132,9 @@ import Foundation try? ModelRegistry.register(RuleAllValueChangedModel.self) try? ModelRegistry.register(RuleEqualsModel.self) try? ModelRegistry.register(RuleRegexModel.self) + + // Actions + try? ModelRegistry.register(ActionTopAlertModel.self) + try? ModelRegistry.register(ActionCollapseNotificationModel.self) } } From a2c73d9d7dee782f9a24f6c375949dca89261a18 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 17 Mar 2020 16:17:58 -0400 Subject: [PATCH 018/244] add codable method to avoid set actionType value --- .../ActionCollapseNotificationModel.swift | 22 ++++++++++++++ MVMCoreUI/Actions/ActionTopAlertModel.swift | 29 ++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift index 17799ec2..9561b2ad 100644 --- a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift +++ b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift @@ -18,4 +18,26 @@ import UIKit public var analyticsData: JSONValueDictionary? public var title: String? + + public enum CodingKeys: String, CodingKey { + case actionType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCoreUI/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Actions/ActionTopAlertModel.swift index 54746f31..6e3f4dbd 100644 --- a/MVMCoreUI/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Actions/ActionTopAlertModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class ActionTopAlertModel: ActionModelProtocol { public static var identifier: String = "topAlert" - public var actionType: String? = ActionTopAlertModel.identifier + public var actionType: String? public var pageType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -21,4 +21,31 @@ import Foundation public init(pageType: String) { self.pageType = pageType } + + public enum CodingKeys: String, CodingKey { + case actionType + case pageType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decode(String.self, forKey: .pageType) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(pageType, forKey: .pageType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } + + } From 5b97fbfac08ea85d745b2cec478c6653667adeee Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 17 Mar 2020 16:59:30 -0400 Subject: [PATCH 019/244] remove encode, decode method since actionType already handled by default encode behavior --- .../ActionCollapseNotificationModel.swift | 22 --------------- MVMCoreUI/Actions/ActionTopAlertModel.swift | 27 ------------------- 2 files changed, 49 deletions(-) diff --git a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift index 9561b2ad..17799ec2 100644 --- a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift +++ b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift @@ -18,26 +18,4 @@ import UIKit public var analyticsData: JSONValueDictionary? public var title: String? - - public enum CodingKeys: String, CodingKey { - case actionType - case title - case extraParameters - case analyticsData - } - - public required init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - title = try typeContainer.decodeIfPresent(String.self, forKey: .title) - extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) - analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) - } - - public func encode(to encoder: Encoder) throws { - var encoderContainer = encoder.container(keyedBy: CodingKeys.self) - try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) - try encoderContainer.encodeIfPresent(title, forKey: .title) - try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) - try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) - } } diff --git a/MVMCoreUI/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Actions/ActionTopAlertModel.swift index 6e3f4dbd..ac0d5684 100644 --- a/MVMCoreUI/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Actions/ActionTopAlertModel.swift @@ -21,31 +21,4 @@ import Foundation public init(pageType: String) { self.pageType = pageType } - - public enum CodingKeys: String, CodingKey { - case actionType - case pageType - case title - case extraParameters - case analyticsData - } - - public required init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - pageType = try typeContainer.decode(String.self, forKey: .pageType) - title = try typeContainer.decodeIfPresent(String.self, forKey: .title) - extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) - analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) - } - - public func encode(to encoder: Encoder) throws { - var encoderContainer = encoder.container(keyedBy: CodingKeys.self) - try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) - try encoderContainer.encode(pageType, forKey: .pageType) - try encoderContainer.encodeIfPresent(title, forKey: .title) - try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) - try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) - } - - } From 6f46b51ac7e9731355fcd67c828903658c800b28 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 17 Mar 2020 22:53:40 -0400 Subject: [PATCH 020/244] delay --- MVMCoreUI/BaseControllers/MFViewController+Form.swift | 5 ++++- MVMCoreUI/BaseControllers/MFViewController.m | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Form.swift b/MVMCoreUI/BaseControllers/MFViewController+Form.swift index 2c3b14bf..73f12754 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Form.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Form.swift @@ -13,7 +13,10 @@ extension MFViewController: ObservingTextFieldDelegate { public extension MFViewController { @objc func startValidation() { - (self as? FormHolderProtocol)?.formValidator?.validate() + // Temporary fix with delay. + DispatchQueue.main.asyncAfter(deadline: .now() + 0.000001) { [weak self] in + (self as? FormHolderProtocol)?.formValidator?.validate() + } } @objc func addFormParams(requestParameters: MVMCoreRequestParameters) { diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 7266c54f..a097e0f0 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -487,6 +487,7 @@ self.needToUpdateUI = YES; [self.view setNeedsLayout]; }]; + [self startValidation]; } - (void)didReceiveMemoryWarning { @@ -535,8 +536,6 @@ if (!self.disableAnimations) { [self.introAnimationManager performAnimations]; } - - [self startValidation]; } - (void)viewWillDisappear:(BOOL)animated { From 768b36a73939442e3eba629bf5cb794d152f26eb Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 17 Mar 2020 22:55:38 -0400 Subject: [PATCH 021/244] moving tp block --- MVMCoreUI/BaseControllers/MFViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index a097e0f0..fef3b860 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -484,10 +484,10 @@ - (void)newDataBuildAndUpdate { [MVMCoreDispatchUtility performBlockOnMainThread:^{ [self newDataBuildScreen]; + [self startValidation]; self.needToUpdateUI = YES; [self.view setNeedsLayout]; }]; - [self startValidation]; } - (void)didReceiveMemoryWarning { From a336ec0f89a45d5f24970558bab0c65d9b896fc0 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 18 Mar 2020 12:53:26 +0530 Subject: [PATCH 022/244] button styles implemented --- .../ListRightVariableButtonAllTextAndLinks.swift | 12 +++++------- ...ListRightVariableButtonAllTextAndLinksModel.swift | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index 3f95682a..0712b9b1 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -13,12 +13,14 @@ import Foundation // MARK: - Outlets //----------------------------------------------------- var stack: Stack - let button = Button(frame: .zero) + let button = PrimaryButton.button() let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 5,horizontalAlignment: .leading)), - (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .top))],axis: .horizontal) + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 5, horizontalAlignment: .leading)), + (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .center))], + axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -45,8 +47,4 @@ import Foundation open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 90 } - - open override func reset() { - super.reset() - } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index 91e9ead2..d98d784b 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -17,10 +17,12 @@ public class ListRightVariableTextButtonAllTextAndLinksModel: ListItemModel,Mole self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink super.init() } + /// Defaults to set override public func setDefaults() { super.setDefaults() self.button.size = .tiny + self.button.style = ButtonStyle.secondary } private enum CodingKeys: String, CodingKey { From 45805ebd2347db7121ba0e94c3485f1b7cd99d1e Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 18 Mar 2020 16:19:08 +0530 Subject: [PATCH 023/244] files moved to subsections folder --- MVMCoreUI.xcodeproj/project.pbxproj | 20 +++++++++++-------- ...eColumnTextWithWhitespaceDividerTall.swift | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2d816c5c..1226efed 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -173,10 +173,12 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; - BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; - BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; + BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; + BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; + BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */; }; + BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; 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 */; }; @@ -550,10 +552,12 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; - BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; - BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; + BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; + BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; + BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTallModel.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift; sourceTree = SOURCE_ROOT; }; + BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTall.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = SOURCE_ROOT; }; 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 = ""; }; @@ -901,8 +905,6 @@ 52267A0523FFE0A900906CBA /* OneColumn */ = { isa = PBXGroup; children = ( - BB47A58124161003002BB23C /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */, - BB47A5832416101D002BB23C /* ListOneColumnTextWithWhitespaceDividerTall.swift */, 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */, 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */, @@ -932,6 +934,8 @@ 525665CB24211FD5007BF25F /* OneColumn */ = { isa = PBXGroup; children = ( + BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */, + BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */, BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */, BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */, ); @@ -1890,11 +1894,11 @@ 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, - BB47A58224161003002BB23C /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, 011D95A3240453F8000E3791 /* RuleRegexModel.swift in Sources */, D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, + BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, 011D9602240DA20A000E3791 /* ValidProtocol.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, @@ -1960,7 +1964,6 @@ 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, 526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, - BB47A5842416101D002BB23C /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, @@ -2036,6 +2039,7 @@ C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, + BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index fdc660fb..f8685b29 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -12,9 +12,9 @@ import Foundation //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - var stack: Stack - let headline = Label.commonLabelH3(true) - let body = Label.commonLabelB2(true) + public var stack: Stack + public let headline = Label.commonLabelH3(true) + public let body = Label.commonLabelB2(true) // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { From 43accdfa7908451d2417fbaace2120406f9a9080 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 18 Mar 2020 16:34:22 +0530 Subject: [PATCH 024/244] Added code in mapping class --- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index a0d18912..4efcde72 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -115,6 +115,8 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) + // Designed Headers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) From 4b6891851cbf4f2b39f2993978cc9b748dafc32a Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 18 Mar 2020 18:32:09 +0530 Subject: [PATCH 025/244] ListOneColumnTextWithWhitespaceDividerShort Molecule implemented --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++-- ...ColumnTextWithWhitespaceDividerShort.swift | 56 +++++++++++++++++++ ...nTextWithWhitespaceDividerShortModel.swift | 48 ++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b16286eb..1515117d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -173,10 +173,12 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; - BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; - BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; + BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; + BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; + BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; + BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; 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 */; }; @@ -550,10 +552,12 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; - BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; - BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; + BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; + BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; + BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; + BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; 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 = ""; }; @@ -930,6 +934,8 @@ 525665CB24211FD5007BF25F /* OneColumn */ = { isa = PBXGroup; children = ( + BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */, + BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */, BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */, BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */, ); @@ -2104,6 +2110,7 @@ DBC4391B224421A0001AB423 /* CaretLink.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */, + BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */, 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */, C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, @@ -2117,6 +2124,7 @@ D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, 011D959D2404536F000E3791 /* RuleAnyValueChangedModel.swift in Sources */, D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, + BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */, C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, D29E28DD23D7404C00ACEA85 /* ContainerHelper.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift new file mode 100644 index 00000000..c5ec73c0 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift @@ -0,0 +1,56 @@ +// +// ListOneColumnTextWithWhitespaceDividerShort.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 04/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListOneColumnTextWithWhitespaceDividerShort: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + var stack: Stack + let headline = Label.commonLabelH3(true) + let body = Label.commonLabelB2(true) + + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), + (view: body, model: StackItemModel(spacing: 5,horizontalAlignment: .leading))], + axis: .vertical) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListOneColumnTextWithWhitespaceDividerShortModel else { return } + headline.set(with: model.headline, delegateObject, additionalData) + body.set(with: model.body, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + headline.styleH3(true) + body.styleB2(true) + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift new file mode 100644 index 00000000..feabb9e9 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift @@ -0,0 +1,48 @@ +// +// ListOneColumnTextWithWhitespaceDividerShortModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 04/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListOneColumnTextWithWhitespaceDividerShortModel: ListItemModel,MoleculeModelProtocol{ + public static var identifier: String = "list1CTxtDiv1" + public var headline: LabelModel + public var body: LabelModel + + public init(headline: LabelModel, body: LabelModel) { + self.headline = headline + self.body = body + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "shortDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case headline + case body + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + body = try typeContainer.decode(LabelModel.self, forKey: .body) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(headline, forKey: .headline) + try container.encode(body, forKey: .body) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index a0d18912..5193becb 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -112,6 +112,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) // Designed Section Dividers + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) From 7db9308f8beb6461cef8ac1d24f6a5f49e859488 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Mar 2020 09:56:43 -0400 Subject: [PATCH 026/244] bugfix --- .../ListLeftVariableRadioButtonAndPaymentMethod.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift index b4bb2fc3..12ae94fe 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift @@ -64,4 +64,8 @@ import UIKit open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 90 } + + public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + radioButton.tapAction() + } } From 503a77efa117a0979f1424f69f7ae48aabdf803b Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Wed, 18 Mar 2020 19:39:26 +0530 Subject: [PATCH 027/244] spacing change. --- .../OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index f8685b29..105ee614 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -19,7 +19,7 @@ import Foundation // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), - (view: body, model: StackItemModel(spacing: 5,horizontalAlignment: .leading))], + (view: body, model: StackItemModel(spacing: 0,horizontalAlignment: .leading))], axis: .vertical) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -52,6 +52,5 @@ import Foundation super.reset() headline.styleH3(true) body.styleB2(true) - } } From 42b824549c77fc2b36ac48140f3b5cc50eb11772 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 18 Mar 2020 10:22:49 -0400 Subject: [PATCH 028/244] adding color --- MVMCoreUI/Categories/UIColor+Extension.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 9abedf97..81fe6743 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -42,7 +42,7 @@ extension UIColor { "orangeShade2": (.mvmOrangeShade2, "#984700"), "orangeAA": (.mvmOrangeAA, "#CC4D0F"), "blue": (.mvmBlue, "#0077B4"), - "blue33": (.mvmBlue33, "#57B1DF"), + "blue33": (.mvmBlue33, "#B1D8EF"), "blue66": (.mvmBlue66, "#57B1DF"), "blueShade1": (.mvmBlueShade1, "#136598"), "blueShade2": (.mvmBlueShade2, "#0B4467"), @@ -162,7 +162,7 @@ extension UIColor { /// HEX: #0077B4 public static let mvmBlue = UIColor.color8Bits(red: 0, green: 119, blue: 180) - /// HEX: #57B1DF + /// HEX: #B1D8EF public static let mvmBlue33 = UIColor.color8Bits(red: 87, green: 177, blue: 223) /// HEX: #57B1DF From 969d9601abc3fb2238d427da67438d5d3e1f3223 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 18 Mar 2020 10:26:52 -0400 Subject: [PATCH 029/244] main async --- MVMCoreUI/BaseControllers/MFViewController+Form.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Form.swift b/MVMCoreUI/BaseControllers/MFViewController+Form.swift index 73f12754..ef461a66 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Form.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Form.swift @@ -13,8 +13,7 @@ extension MFViewController: ObservingTextFieldDelegate { public extension MFViewController { @objc func startValidation() { - // Temporary fix with delay. - DispatchQueue.main.asyncAfter(deadline: .now() + 0.000001) { [weak self] in + DispatchQueue.main.async { [weak self] in (self as? FormHolderProtocol)?.formValidator?.validate() } } From 524cd4d6b071df41805dccaff9827fa1b523db43 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Wed, 18 Mar 2020 20:54:50 +0530 Subject: [PATCH 030/244] minor code changes. --- .../ListOneColumnTextWithWhitespaceDividerShort.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift index c5ec73c0..96432274 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift @@ -12,14 +12,14 @@ import Foundation //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - var stack: Stack - let headline = Label.commonLabelH3(true) - let body = Label.commonLabelB2(true) + public var stack: Stack + public let headline = Label.commonLabelH3(true) + public let body = Label.commonLabelB2(true) // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), - (view: body, model: StackItemModel(spacing: 5,horizontalAlignment: .leading))], + (view: body, model: StackItemModel(spacing: 0,horizontalAlignment: .leading))], axis: .vertical) super.init(style: style, reuseIdentifier: reuseIdentifier) } From 44bd74c6836f8f086cebd173770485e89ee01f2e Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Wed, 18 Mar 2020 11:27:37 -0400 Subject: [PATCH 031/244] Makes drawBottomCurvedShadowsOnRect more flexible by allowing the rect to be passed in with a non (0,0) origin --- MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index 4a21b1a5..5c796417 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -260,15 +260,15 @@ static const CGFloat VertialShadowOffset = 6; UIBezierPath *shadowPath = [UIBezierPath bezierPath]; //get the variables for frame - CGFloat x = 0; - CGFloat y = 0; + CGFloat x = rect.origin.x; + CGFloat y = rect.origin.y; CGFloat width = CGRectGetWidth(rect); CGFloat height = CGRectGetHeight(rect); [shadowPath moveToPoint:CGPointMake(x + HorizontalShadowInset, y)]; - [shadowPath addLineToPoint:CGPointMake(width - HorizontalShadowInset, y)]; - [shadowPath addLineToPoint:CGPointMake(width - HorizontalShadowInset, height-VertialShadowOffset/2)]; - [shadowPath addQuadCurveToPoint:CGPointMake(x + HorizontalShadowInset, height - VertialShadowOffset/2) controlPoint:CGPointMake(width/2.f, height - VertialShadowOffset * 1.5)]; + [shadowPath addLineToPoint:CGPointMake(x + width - HorizontalShadowInset, y)]; + [shadowPath addLineToPoint:CGPointMake(x + width - HorizontalShadowInset, height-VertialShadowOffset/2)]; + [shadowPath addQuadCurveToPoint:CGPointMake(x + HorizontalShadowInset, height - VertialShadowOffset/2) controlPoint:CGPointMake((x + width)/2.f, height - VertialShadowOffset * 1.5)]; [shadowPath addLineToPoint:CGPointMake(x + HorizontalShadowInset, y)]; [shadowPath closePath]; From a1942f84687105958ad018923d70d7410d23c7c5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 18 Mar 2020 11:31:52 -0400 Subject: [PATCH 032/244] main thread --- MVMCoreUI/BaseControllers/MFViewController+Form.swift | 4 +--- MVMCoreUI/BaseControllers/MFViewController.m | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Form.swift b/MVMCoreUI/BaseControllers/MFViewController+Form.swift index ef461a66..2c3b14bf 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Form.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Form.swift @@ -13,9 +13,7 @@ extension MFViewController: ObservingTextFieldDelegate { public extension MFViewController { @objc func startValidation() { - DispatchQueue.main.async { [weak self] in - (self as? FormHolderProtocol)?.formValidator?.validate() - } + (self as? FormHolderProtocol)?.formValidator?.validate() } @objc func addFormParams(requestParameters: MVMCoreRequestParameters) { diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index fef3b860..52cf01cf 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -484,7 +484,9 @@ - (void)newDataBuildAndUpdate { [MVMCoreDispatchUtility performBlockOnMainThread:^{ [self newDataBuildScreen]; - [self startValidation]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self startValidation]; + }); self.needToUpdateUI = YES; [self.view setNeedsLayout]; }]; From 3210d8cc8818aa8d7cac53fb673cd862d30dd7df Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Mar 2020 13:25:44 -0400 Subject: [PATCH 033/244] cleanup --- MVMCoreUI.xcodeproj/project.pbxproj | 6 +++- .../ActionCollapseNotificationModel.swift | 4 --- MVMCoreUI/Actions/ActionOpenPanelModel.swift | 31 +++++++++++++++++++ MVMCoreUI/Actions/ActionTopAlertModel.swift | 1 - .../OtherHandlers/MoleculeObjectMapping.swift | 1 + .../Templates/ListPageTemplateModel.swift | 2 ++ .../StackCenteredPageTemplateModel.swift | 24 +++++++------- .../Templates/StackPageTemplateModel.swift | 2 ++ .../ThreeLayerPageTemplateModel.swift | 2 ++ 9 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 MVMCoreUI/Actions/ActionOpenPanelModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d1d76cb3..40550124 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -368,6 +368,7 @@ 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 */; }; D2C521A923EDE79E00CA2634 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2C521A823EDE79E00CA2634 /* ViewController.swift */; }; + D2C78CD224228BBD00B69FDE /* ActionOpenPanelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2C78CD124228BBD00B69FDE /* ActionOpenPanelModel.swift */; }; D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */; }; D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */; }; D2D90B42240463E100DD6EC9 /* MoleculeHeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D90B41240463E100DD6EC9 /* MoleculeHeaderModel.swift */; }; @@ -761,6 +762,7 @@ 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 = ""; }; D2C521A823EDE79E00CA2634 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + D2C78CD124228BBD00B69FDE /* ActionOpenPanelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionOpenPanelModel.swift; 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 = ""; }; D2D90B41240463E100DD6EC9 /* MoleculeHeaderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeHeaderModel.swift; sourceTree = ""; }; @@ -952,6 +954,7 @@ children = ( 94C0150924215643005811A9 /* ActionTopAlertModel.swift */, 94C0150B2421564A005811A9 /* ActionCollapseNotificationModel.swift */, + D2C78CD124228BBD00B69FDE /* ActionOpenPanelModel.swift */, ); path = Actions; sourceTree = ""; @@ -1282,9 +1285,9 @@ D22D1F582204D2590077CEC0 /* Legacy */, D29DF10F21E67A7D003B2FB9 /* BaseControllers */, D29DF11E21E6851E003B2FB9 /* TopAlert */, + 94C01508242155FE005811A9 /* Actions */, D29DF10D21E67A70003B2FB9 /* Atoms */, D29DF10E21E67A77003B2FB9 /* Molecules */, - 94C01508242155FE005811A9 /* Actions */, D22479902316A9CB003FCCF9 /* Organisms */, D29DF0DF21E418B2003B2FB9 /* Templates */, D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */, @@ -2069,6 +2072,7 @@ D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, + D2C78CD224228BBD00B69FDE /* ActionOpenPanelModel.swift in Sources */, 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift index 17799ec2..4dad156b 100644 --- a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift +++ b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift @@ -10,12 +10,8 @@ import UIKit @objcMembers public class ActionCollapseNotificationModel: ActionModelProtocol { public static var identifier: String = "collapseNotification" - public var actionType: String? - public var extraParameters: JSONValueDictionary? - public var analyticsData: JSONValueDictionary? - public var title: String? } diff --git a/MVMCoreUI/Actions/ActionOpenPanelModel.swift b/MVMCoreUI/Actions/ActionOpenPanelModel.swift new file mode 100644 index 00000000..ce3977d8 --- /dev/null +++ b/MVMCoreUI/Actions/ActionOpenPanelModel.swift @@ -0,0 +1,31 @@ +// +// ActionOpenPanelModel.swift +// MVMCore +// +// Created by Khan, Arshad on 12/02/20. +// Copyright © 2020 myverizon. All rights reserved. +// + +import Foundation + +public class ActionOpenPanelModel: ActionModelProtocol { + + public enum Panel: String, Codable { + case left + case right + case support // Legacy, means left + case menu // Legacy, means right. + } + + public static var identifier: String = "openPanel" + public var actionType: String? + public var panel: Panel + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + // Temporary fix till server changes + public var title: String? + + public init(panel: Panel) { + self.panel = panel + } +} diff --git a/MVMCoreUI/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Actions/ActionTopAlertModel.swift index ac0d5684..6da64912 100644 --- a/MVMCoreUI/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Actions/ActionTopAlertModel.swift @@ -9,7 +9,6 @@ import Foundation @objcMembers public class ActionTopAlertModel: ActionModelProtocol { - public static var identifier: String = "topAlert" public var actionType: String? public var pageType: String diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index b62eebfd..8617ba0b 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -136,5 +136,6 @@ import Foundation // Actions try? ModelRegistry.register(ActionTopAlertModel.self) try? ModelRegistry.register(ActionCollapseNotificationModel.self) + try? ModelRegistry.register(ActionOpenPanelModel.self) } } diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index 12c300f9..f48e53e4 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -44,6 +44,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case moleculeName + case template case pageType case screenHeading case molecules @@ -73,6 +74,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(pageType, forKey: .pageType) + try container.encode(template, forKey: .template) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeModelsIfPresent(molecules, forKey: .molecules) try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) diff --git a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift index 66cd0365..bc39fbf9 100644 --- a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift @@ -23,22 +23,24 @@ import Foundation } private enum CodingKeys: String, CodingKey { - case pageType - case screenHeading - case isAtomicTabs + case pageType + case template + case screenHeading + 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) + 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) } 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) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(pageType, forKey: .pageType) + try container.encode(template, forKey: .template) + try container.encodeIfPresent(screenHeading, forKey: .screenHeading) + try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) } } diff --git a/MVMCoreUI/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Templates/StackPageTemplateModel.swift index ed94e4ef..74cb72b8 100644 --- a/MVMCoreUI/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackPageTemplateModel.swift @@ -30,6 +30,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case pageType + case template case screenHeading case header case footer @@ -52,6 +53,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(pageType, forKey: .pageType) + try container.encode(template, forKey: .template) try container.encode(moleculeStack, forKey: .stack) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index 5ad39c4b..f42a3bbd 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -32,6 +32,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case pageType + case template case screenHeading case header case footer @@ -52,6 +53,7 @@ import Foundation public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(pageType, forKey: .pageType) + try container.encode(template, forKey: .template) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) try container.encodeModelIfPresent(header, forKey: .header) From 9b941285956c7f8dbb56f59cd292af7f66596c31 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Mar 2020 13:32:17 -0400 Subject: [PATCH 034/244] remove key --- MVMCoreUI/Templates/ListPageTemplateModel.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index f48e53e4..e7eac47f 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -43,7 +43,6 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { - case moleculeName case template case pageType case screenHeading From d556d4b14a8c0e7411add8159f59a3d9a8d1f4f1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Mar 2020 13:39:48 -0400 Subject: [PATCH 035/244] form rules --- MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift | 3 +++ MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift | 3 +++ 2 files changed, 6 insertions(+) diff --git a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift index bc39fbf9..117d624c 100644 --- a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift @@ -27,6 +27,7 @@ import Foundation case template case screenHeading case isAtomicTabs + case formRules } required public init(from decoder: Decoder) throws { @@ -34,6 +35,7 @@ import Foundation pageType = try typeContainer.decode(String.self, forKey: .pageType) screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) + formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) } public func encode(to encoder: Encoder) throws { @@ -42,5 +44,6 @@ import Foundation try container.encode(template, forKey: .template) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) + try container.encodeIfPresent(formRules, forKey: .formRules) } } diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index f42a3bbd..dcd4aa9f 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -38,6 +38,7 @@ import Foundation case footer case middle case isAtomicTabs + case formRules } required public init(from decoder: Decoder) throws { @@ -48,6 +49,7 @@ import Foundation header = try typeContainer.decodeModelIfPresent(codingKey: .header) middle = try typeContainer.decodeModelIfPresent(codingKey: .middle) footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) + formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) } public func encode(to encoder: Encoder) throws { @@ -59,5 +61,6 @@ import Foundation try container.encodeModelIfPresent(header, forKey: .header) try container.encodeModelIfPresent(header, forKey: .middle) try container.encodeModelIfPresent(footer, forKey: .footer) + try container.encodeIfPresent(formRules, forKey: .formRules) } } From 9baf3948ad9de6dc8bcc46685f4b95a01026ac07 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 18 Mar 2020 14:05:01 -0400 Subject: [PATCH 036/244] touchup --- MVMCoreUI/Atoms/Views/RadioButton.swift | 62 ++++++++++++++------ MVMCoreUI/Atoms/Views/RadioButtonModel.swift | 31 ++++++++-- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/RadioButton.swift b/MVMCoreUI/Atoms/Views/RadioButton.swift index ce95c639..7dd5976a 100644 --- a/MVMCoreUI/Atoms/Views/RadioButton.swift +++ b/MVMCoreUI/Atoms/Views/RadioButton.swift @@ -8,31 +8,30 @@ import UIKit -@objcMembers public class RadioButton: Control { +@objcMembers open class RadioButton: Control { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- - var diameter: CGFloat = 30 { + public var diameter: CGFloat = 30 { didSet { widthConstraint?.constant = diameter } } - var enabledColor = UIColor.black - var disabledColor = UIColor.mfSilver() - var delegateObject: MVMCoreUIDelegateObject? - - var widthConstraint: NSLayoutConstraint? - var heightConstraint: NSLayoutConstraint? - - var radioModel: RadioButtonModel? { + public var enabledColor: UIColor = .black + public var disabledColor: UIColor = .mfSilver() + public var delegateObject: MVMCoreUIDelegateObject? + + public var radioModel: RadioButtonModel? { return model as? RadioButtonModel } - lazy var radioGroupName: String? = { + lazy public var radioGroupName: String? = { [unowned self] in return radioModel?.fieldKey }() - lazy var radioButtonSelectionHelper: RadioButtonSelectionHelper? = { - [unowned self] in + lazy public var radioButtonSelectionHelper: RadioButtonSelectionHelper? = { if let radioGroupName = radioGroupName, let radioButtonModel = delegateObject?.formHolderDelegate?.formValidator?.radioButtonsModelByGroup[radioGroupName] { return radioButtonModel @@ -41,20 +40,40 @@ import UIKit } }() + //-------------------------------------------------- + // MARK: - Constraints + //-------------------------------------------------- + + public var widthConstraint: NSLayoutConstraint? + public var heightConstraint: NSLayoutConstraint? + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + open override func draw(_ rect: CGRect) { guard let context = UIGraphicsGetCurrentContext() else { return } + let color = isEnabled ? enabledColor.cgColor : disabledColor.cgColor layer.cornerRadius = bounds.width * 0.5 layer.borderColor = color layer.borderWidth = bounds.width * 0.0333 + if isSelected { // Space around inner circle is 1/5 the size - context.addEllipse(in: CGRect(x: bounds.width*0.2, y: bounds.height*0.2, width: bounds.width*0.6, height: bounds.height*0.6)) + context.addEllipse(in: CGRect(x: bounds.width * 0.2, + y: bounds.height * 0.2, + width: bounds.width * 0.6, + height: bounds.height * 0.6)) context.setFillColor(color) context.fillPath() } } + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + /// The action performed when tapped. func tapAction() { if let radioButtonModel = radioButtonSelectionHelper { @@ -82,9 +101,13 @@ import UIKit return radioModel?.fieldValue } -// MARK: - MVMViewProtocol + //-------------------------------------------------- + // MARK: - MVMViewProtocol + //-------------------------------------------------- + open override func setupView() { super.setupView() + backgroundColor = .white clipsToBounds = true widthConstraint = widthAnchor.constraint(equalToConstant: 30) @@ -98,12 +121,13 @@ import UIKit accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") } - public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - guard let model = model as? RadioButtonModel else { - return - } + + guard let model = model as? RadioButtonModel else { return } + self.delegateObject = delegateObject + isSelected = model.state let radioButtonModel = RadioButtonSelectionHelper.setupForRadioButtonGroup(model, formValidator: delegateObject?.formHolderDelegate?.formValidator) FormValidator.setupValidation(molecule: radioButtonModel, delegate: delegateObject?.formHolderDelegate) diff --git a/MVMCoreUI/Atoms/Views/RadioButtonModel.swift b/MVMCoreUI/Atoms/Views/RadioButtonModel.swift index 0aa56cc0..581e03f8 100644 --- a/MVMCoreUI/Atoms/Views/RadioButtonModel.swift +++ b/MVMCoreUI/Atoms/Views/RadioButtonModel.swift @@ -9,18 +9,26 @@ import Foundation import MVMCore -public class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { +open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "radioButton" public var backgroundColor: Color? public var state: Bool = false public var enabled: Bool = true - + public var baseValue: AnyHashable? public var groupName: String? public var fieldKey: String? public var fieldValue: String? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor @@ -31,22 +39,37 @@ public class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { case groupName } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(_ state: Bool) { self.state = state } - + + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + public func formFieldValue() -> AnyHashable? { return state } - + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { self.state = state } + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { self.enabled = enabled } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) From 572568ca6f09d1f5a5f877b706be8211ed294e7d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Mar 2020 14:23:37 -0400 Subject: [PATCH 037/244] missed spacing --- .../ListOneColumnTextWithWhitespaceDividerTall.swift | 4 ++-- .../ListOneColumnTextWithWhitespaceDividerTallModel.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index 105ee614..1f2bcd6f 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -19,7 +19,7 @@ import Foundation // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), - (view: body, model: StackItemModel(spacing: 0,horizontalAlignment: .leading))], + (view: body, model: StackItemModel(spacing: 0, horizontalAlignment: .leading))], axis: .vertical) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -37,7 +37,7 @@ import Foundation stack.restack() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return } headline.set(with: model.headline, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift index f93f601b..7c95b7e8 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -8,7 +8,7 @@ import Foundation -public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel,MoleculeModelProtocol{ +public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "list1CTxtDiv2" public var headline: LabelModel public var body: LabelModel From 8a6cd8984559add1bf8c84e9c744eeb9197e6f98 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Mar 2020 14:31:56 -0400 Subject: [PATCH 038/244] spacing --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++---- .../ListOneColumnTextWithWhitespaceDividerShort.swift | 4 ++-- ...ListOneColumnTextWithWhitespaceDividerShortModel.swift | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b9ce9b73..f17d7906 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -181,7 +181,7 @@ BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */; }; BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; - BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; + BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; @@ -567,7 +567,7 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTall.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = SOURCE_ROOT; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; - C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; 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 = ""; }; @@ -944,10 +944,10 @@ 525665CB24211FD5007BF25F /* OneColumn */ = { isa = PBXGroup; children = ( - BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */, - BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */, BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */, BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */, + BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */, + BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */, BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */, BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */, ); diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift index 96432274..ec65967d 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift @@ -19,7 +19,7 @@ import Foundation // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), - (view: body, model: StackItemModel(spacing: 0,horizontalAlignment: .leading))], + (view: body, model: StackItemModel(spacing: 0, horizontalAlignment: .leading))], axis: .vertical) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -37,7 +37,7 @@ import Foundation stack.restack() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListOneColumnTextWithWhitespaceDividerShortModel else { return } headline.set(with: model.headline, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift index feabb9e9..340ccddc 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift @@ -8,7 +8,7 @@ import Foundation -public class ListOneColumnTextWithWhitespaceDividerShortModel: ListItemModel,MoleculeModelProtocol{ +public class ListOneColumnTextWithWhitespaceDividerShortModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "list1CTxtDiv1" public var headline: LabelModel public var body: LabelModel From 422e041c45374f5a7aa0d0a87a15aa9bcc9e0e90 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Mar 2020 14:49:46 -0400 Subject: [PATCH 039/244] change to make git happy --- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 5d7afdcc..f2bf9e78 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -112,12 +112,11 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) // Designed Section Dividers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) // Designed Headers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) From e8eba296d581103105c9e296207d50a3fdc91fa7 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Thu, 19 Mar 2020 10:18:57 +0530 Subject: [PATCH 040/244] ListRightVariableTextLinkAllTextAndLinks Molecule implemented --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ ...RightVariableTextLinkAllTextAndLinks.swift | 49 +++++++++++++++++++ ...VariableTextLinkAllTextAndLinksModel.swift | 41 ++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f17d7906..9c6f92dc 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -183,6 +183,8 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; + BB6C6ADC24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ADB24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift */; }; + BB6C6ADE24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ADD24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift */; }; 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 */; }; @@ -567,6 +569,8 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTall.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = SOURCE_ROOT; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; + BB6C6ADB24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinksModel.swift; sourceTree = ""; }; + BB6C6ADD24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinks.swift; 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 = ""; }; @@ -997,6 +1001,8 @@ AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( + BB6C6ADB24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift */, + BB6C6ADD24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift */, AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, 8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */, @@ -1991,6 +1997,7 @@ 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, + BB6C6ADE24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift in Sources */, 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, @@ -2060,6 +2067,7 @@ D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, + BB6C6ADC24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */, C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift new file mode 100644 index 00000000..d9d04205 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift @@ -0,0 +1,49 @@ +// +// ListRightVariableTextLinkAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 19/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListRightVariableTextLinkAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + public var stack: Stack + public let link = Link(frame: .zero) + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + // MARK: - Initializers + + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 5,horizontalAlignment: .leading)), + (view: link, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .top))],axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableTextLinkAllTextAndLinksModel else { return } + link.set(with: model.link, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift new file mode 100644 index 00000000..7541d38d --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift @@ -0,0 +1,41 @@ +// +// ListRightVariableTextLinkAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 19/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListRightVariableTextLinkAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ + public static var identifier: String = "listRVLink" + public var link: LinkModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + public init(link: LinkModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.link = link + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case link + case eyebrowHeadlineBodyLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + link = try typeContainer.decode(LinkModel.self, forKey: .link) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(link, forKey: .link) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + } +} From bc5f8f541e1f228a74d342edc440feb5913e7a0b Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Thu, 19 Mar 2020 10:41:08 +0530 Subject: [PATCH 041/244] Molecule added to mapping class --- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index f2bf9e78..3abc86e7 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -106,6 +106,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTextLinkAllTextAndLinks.self, viewModelClass: ListRightVariableTextLinkAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) From 18dcf3072f20c5fb7af4d97cb695c4ea95fece21 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 19 Mar 2020 16:28:35 -0400 Subject: [PATCH 042/244] required identifiers --- .../Actions/ActionCollapseNotificationModel.swift | 2 +- MVMCoreUI/Actions/ActionOpenPanelModel.swift | 2 +- MVMCoreUI/Actions/ActionTopAlertModel.swift | 2 +- MVMCoreUI/Atoms/TextFields/TextFieldModel.swift | 2 +- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 2 +- MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift | 2 +- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- .../ModelProtocols/MoleculeModelProtocol.swift | 4 ++-- .../Molecules/Doughnut/DoughnutChartModel.swift | 4 ++-- .../ImageHeadlineBodyModel.swift | 2 +- .../Molecules/Items/MoleculeCollectionViewCell.swift | 5 ++--- MVMCoreUI/Molecules/Items/StackItemModel.swift | 2 +- .../LeftRightViews/ActionDetailWithImageModel.swift | 2 +- .../HeadlineBodyLinkToggleModel.swift | 2 +- .../ToggleMolecules/HeadlineBodyToggleModel.swift | 2 +- .../ToggleMolecules/LabelToggleModel.swift | 2 +- MVMCoreUI/Molecules/ScrollerModel.swift | 2 +- .../EyebrowHeadlineBodyLinkModel.swift | 2 +- .../HeadlineBodyButtonModel.swift | 2 +- .../HeadlineBodyLinkModel.swift | 2 +- .../VerticalCombinationViews/HeadlineBodyModel.swift | 2 +- .../StringAndMoleculeStack.swift | 3 +-- MVMCoreUI/Organisms/Carousel.swift | 5 ++--- MVMCoreUI/Organisms/Stack.swift | 12 +++++------- ...MCoreUIMoleculeMappingObject+ModelExtension.swift | 8 ++------ MVMCoreUI/Templates/ModalMoleculeListTemplate.swift | 4 ++-- MVMCoreUI/Templates/MoleculeListTemplate.swift | 6 ++---- 27 files changed, 38 insertions(+), 49 deletions(-) diff --git a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift index 4dad156b..9a6e6793 100644 --- a/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift +++ b/MVMCoreUI/Actions/ActionCollapseNotificationModel.swift @@ -10,7 +10,7 @@ import UIKit @objcMembers public class ActionCollapseNotificationModel: ActionModelProtocol { public static var identifier: String = "collapseNotification" - public var actionType: String? + public var actionType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? public var title: String? diff --git a/MVMCoreUI/Actions/ActionOpenPanelModel.swift b/MVMCoreUI/Actions/ActionOpenPanelModel.swift index ce3977d8..55fd272a 100644 --- a/MVMCoreUI/Actions/ActionOpenPanelModel.swift +++ b/MVMCoreUI/Actions/ActionOpenPanelModel.swift @@ -18,7 +18,7 @@ public class ActionOpenPanelModel: ActionModelProtocol { } public static var identifier: String = "openPanel" - public var actionType: String? + public var actionType: String = ActionOpenPanelModel.identifier public var panel: Panel public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? diff --git a/MVMCoreUI/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Actions/ActionTopAlertModel.swift index 6da64912..628633c2 100644 --- a/MVMCoreUI/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Actions/ActionTopAlertModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class ActionTopAlertModel: ActionModelProtocol { public static var identifier: String = "topAlert" - public var actionType: String? + public var actionType: String = ActionTopAlertModel.identifier public var pageType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? diff --git a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift index d901d13a..4d6f1fd0 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? = TextFieldModel.identifier + public var moleculeName: String = TextFieldModel.identifier public var editable: Bool? public var disabled: Bool? public var errorMsg: String? diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 0f585119..d5ba0a14 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeModelProtocol { public static var identifier: String = "image" public var backgroundColor: Color? - public var moleculeName: String? = ImageViewModel.identifier + public var moleculeName: String = ImageViewModel.identifier public var image: String public var accessibilityText: String? public var fallbackImage: String? diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index 44564c93..07c534f8 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -14,7 +14,7 @@ import UIKit //-------------------------------------------------- public static var identifier: String = "leftRightLabelView" - public var moleculeName: String? = LeftRightLabelModel.identifier + public var moleculeName: String = LeftRightLabelModel.identifier public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel? diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 80662cad..333df798 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -186,7 +186,7 @@ import UIKit navigationItem.accessibilityLabel = navigationItemModel.title navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) - UIColor.setBackgroundColor(forNavigationBar: navigationItemModel.backgroundColor?.uiColor ?? .white, navigationBar: navigationController.navigationBar, transparent: navigationItemModel.transparent) + UIColor.setBackgroundColor(navigationItemModel.backgroundColor?.uiColor ?? .white, for: navigationController.navigationBar, isTransparent: navigationItemModel.transparent) let tint = navigationItemModel.tintColor.uiColor navigationController.navigationBar.tintColor = tint diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index 2928cf2a..913c3bd0 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -2,13 +2,13 @@ import Foundation public protocol MoleculeModelProtocol: ModelProtocol { - var moleculeName: String? { get } + var moleculeName: String { get } var backgroundColor: Color? { get set } } public extension MoleculeModelProtocol { - var moleculeName: String? { + var moleculeName: String { get { return Self.identifier } } diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift index 1e5c7dce..ff9b1bf6 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class DoughnutChartModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChart" - public var moleculeName: String? = DoughnutChartModel.identifier + public var moleculeName: String = DoughnutChartModel.identifier public var title: LabelModel? public var subtitle: LabelModel? public var sections: [DoughnutChartItemModel] @@ -25,7 +25,7 @@ import Foundation @objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "doughnutChartItem" - public var moleculeName: String? = DoughnutChartItemModel.identifier + public var moleculeName: String = DoughnutChartItemModel.identifier public var label: LabelModel @Percent public var percent: CGFloat public var color: Color diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift index f34e7b94..4ac675c5 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift @@ -10,7 +10,7 @@ import Foundation public struct ImageHeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "imageHeadlineBody" - public var moleculeName: String? = ImageHeadlineBodyModel.identifier + public var moleculeName: String = ImageHeadlineBodyModel.identifier public var backgroundColor: Color? public var image: ImageViewModel public var headlineBody: HeadlineBodyModel diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift index 9c63ba64..cf1779be 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift @@ -116,11 +116,10 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi 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(with: molecule, delegateObject) ?? molecule.moleculeName else { + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type else { return nil } - return name + return moleculeClass.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName } public func updateView(_ size: CGFloat) { diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Molecules/Items/StackItemModel.swift index 795b2983..12254fb5 100644 --- a/MVMCoreUI/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/StackItemModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { public static var identifier: String = "simpleStackItem" - public var moleculeName: String? = StackItemModel.identifier + public var moleculeName: String = StackItemModel.identifier public var backgroundColor: Color? public var spacing: CGFloat? public var percent: Int? diff --git a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift index 9dbf53c0..d617f053 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift @@ -10,7 +10,7 @@ import Foundation public struct ActionDetailWithImageModel: MoleculeModelProtocol { public static var identifier: String = "actionDetailWithImage" - public var moleculeName: String? = ActionDetailWithImageModel.identifier + public var moleculeName: String = ActionDetailWithImageModel.identifier public var backgroundColor: Color? public var headlineBodyButton: HeadlineBodyButtonModel public var image: ImageViewModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift index aad8ec06..917bf5dc 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift @@ -9,7 +9,7 @@ import Foundation public struct HeadlineBodyLinkToggleModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLinkToggle" - public var moleculeName: String? = HeadlineBodyLinkToggleModel.identifier + public var moleculeName: String = HeadlineBodyLinkToggleModel.identifier public var backgroundColor: Color? public var headlineBodyLink: HeadlineBodyLinkModel public var toggle: ToggleModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift index bb3391a6..800c976b 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift @@ -11,7 +11,7 @@ import Foundation open class HeadlineBodyToggleModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyToggle" - public var moleculeName: String? = HeadlineBodyToggleModel.identifier + public var moleculeName: String = HeadlineBodyToggleModel.identifier open var backgroundColor: Color? open var headlineBody: HeadlineBodyModel open var toggle: ToggleModel diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index 526ac6b9..16f292ed 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -10,7 +10,7 @@ import Foundation public class LabelToggleModel: MoleculeModelProtocol { public static var identifier: String = "labelToggle" - public var moleculeName: String? = LabelToggleModel.identifier + public var moleculeName: String = LabelToggleModel.identifier public var backgroundColor: Color? public var label: LabelModel public var toggle: ToggleModel diff --git a/MVMCoreUI/Molecules/ScrollerModel.swift b/MVMCoreUI/Molecules/ScrollerModel.swift index 91dc2e1c..74256e99 100644 --- a/MVMCoreUI/Molecules/ScrollerModel.swift +++ b/MVMCoreUI/Molecules/ScrollerModel.swift @@ -10,6 +10,6 @@ import UIKit public class ScrollerModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "scroller" - public var moleculeName: String? = ScrollerModel.identifier + public var moleculeName: String = ScrollerModel.identifier public var backgroundColor: Color? } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index e277f5de..0f158c2c 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -14,7 +14,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol { //-------------------------------------------------- public static var identifier: String = "eyebrowHeadlineBodyLink" - public var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier + public var moleculeName: String = EyebrowHeadlineBodyLinkModel.identifier public var backgroundColor: Color? public var eyebrow: LabelModel? public var headline: LabelModel? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift index ec97fda0..439e3aec 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -10,7 +10,7 @@ import Foundation public struct HeadlineBodyButtonModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyButton" - public var moleculeName: String? = HeadlineBodyButtonModel.identifier + public var moleculeName: String = HeadlineBodyButtonModel.identifier public var backgroundColor: Color? public var headlineBody: HeadlineBodyModel diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift index 27f0d670..4ef4018b 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift @@ -10,7 +10,7 @@ import Foundation public struct HeadlineBodyLinkModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLink" - public var moleculeName: String? = HeadlineBodyLinkModel.identifier + public var moleculeName: String = HeadlineBodyLinkModel.identifier public var headlineBody: HeadlineBodyModel public var link: LinkModel public var backgroundColor: Color? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 0ec98c65..e715b61e 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers open class HeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "headlineBody" - public var moleculeName: String? = HeadlineBodyModel.identifier + public var moleculeName: String = HeadlineBodyModel.identifier public var headline: LabelModel? public var body: LabelModel? public var style: String? diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift index 48f39fa0..56cc0447 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift @@ -14,8 +14,7 @@ open class StringAndMoleculeStack: MoleculeStackView { 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 { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: stringAndMoleculeModel.molecule.moleculeName) as? (UIView & ModelMoleculeViewProtocol) else { // Throw error return } diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index ba675adf..b4fa5c24 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -158,11 +158,10 @@ open class Carousel: View { // MARK: - Convenience /// Returns the (identifier, class) of the molecule for the given map. 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(with: molecule, delegateObject) ?? molecule.moleculeName else { + guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) else { return nil } - return (moleculeName, className, molecule) + return ((className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) } /// Sets the alignment from the string. diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 8fa220ec..8e6df863 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -162,13 +162,11 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto } var name = "stack<" for case let item in model.molecules { - if let moleculeName = item.moleculeName { - if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type, - let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) { - name.append(nameForReuse + ",") - } else { - name.append(moleculeName + ",") - } + if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[item.moleculeName] as? ModelMoleculeViewProtocol.Type, + let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) { + name.append(nameForReuse + ",") + } else { + name.append(item.moleculeName + ",") } } name.append(">") diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 8eb0c34d..a7054d4e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -16,10 +16,7 @@ public extension MVMCoreUIMoleculeMappingObject { } func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? { - if let moleculeName = model.moleculeName { - return moleculeMapping.object(forKey: moleculeName) as? AnyClass - } - return nil + return moleculeMapping.object(forKey: model.moleculeName) as? AnyClass } func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { @@ -27,8 +24,7 @@ public extension MVMCoreUIMoleculeMappingObject { } func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { - guard let moleculeName = model.moleculeName, - let molecule = createMolecule(forName: moleculeName) else { + guard let molecule = createMolecule(forName: model.moleculeName) else { return nil } diff --git a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift index 65ec0931..7c62faab 100644 --- a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift @@ -13,9 +13,9 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate { public var closeButton: MFCustomButton? override open func handleNewData() { - super.newDataBuildScreen() + super.handleNewData() closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in - self?.dismiss() + MVMCoreNavigationHandler.shared()?.removeCurrentViewController() }, verticalCentered: false) } } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index bca29172..9503a4c6 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -215,10 +215,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? { guard let listItem = listItem, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), - let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName - else { return nil } - + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) else { return nil } + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName return (moleculeName, moleculeClass, listItem) } From dc3796ccb3aa3dd9b3d2ff26b1155d961129a422 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Fri, 20 Mar 2020 11:11:27 +0530 Subject: [PATCH 043/244] Class name changed --- .../ListRightVariableButtonAllTextAndLinks.swift | 8 ++++---- .../ListRightVariableButtonAllTextAndLinksModel.swift | 2 +- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index 0712b9b1..ba162be3 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -12,9 +12,9 @@ import Foundation //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - var stack: Stack - let button = PrimaryButton.button() - let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + public var stack: Stack + public let button = PrimaryButton.button() + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { @@ -39,7 +39,7 @@ import Foundation open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListRightVariableTextButtonAllTextAndLinksModel else { return } + guard let model = model as? ListRightVariableButtonAllTextAndLinksModel else { return } button.set(with: model.button, delegateObject, additionalData) eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index d98d784b..a306a86c 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -7,7 +7,7 @@ // import Foundation -public class ListRightVariableTextButtonAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ +public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ public static var identifier: String = "listRVBtn" public var button: ButtonModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 69eb4994..dda1e61f 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -103,7 +103,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableTextButtonAllTextAndLinksModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableButtonAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) From d1a984191255cbc8b2a6e51a98a0597d4b4e9132 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Fri, 20 Mar 2020 11:32:33 +0530 Subject: [PATCH 044/244] files added after merging --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ++++++++---- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index fee58e68..37ca99a7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -183,6 +183,8 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; + BB6C6AE1242492F2005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ADF242492C0005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */; }; + BB6C6AE2242492F2005F7224 /* ListRightVariableButtonAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AE0242492F1005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */; }; 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 */; }; @@ -567,6 +569,8 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTall.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = SOURCE_ROOT; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; + BB6C6ADF242492C0005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinksModel.swift; sourceTree = ""; }; + BB6C6AE0242492F1005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinks.swift; 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 = ""; }; @@ -997,8 +1001,8 @@ AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( - BB6C6A7E2420CE5D005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */, - BB6C6A802420CE6E005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */, + BB6C6ADF242492C0005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */, + BB6C6AE0242492F1005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */, AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, 8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */, @@ -1961,6 +1965,7 @@ 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, + BB6C6AE1242492F2005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, @@ -2103,7 +2108,6 @@ D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, - BB6C6A7F2420CE5D005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, 0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */, @@ -2118,12 +2122,12 @@ 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */, D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, - BB6C6A812420CE6E005F7224 /* ListRightVariableButtonAllTextAndLinks.swift in Sources */, 94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */, 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 011D95892404249B000E3791 /* FormProtocol.swift in Sources */, + BB6C6AE2242492F2005F7224 /* ListRightVariableButtonAllTextAndLinks.swift in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, 525239C22407BD1000454969 /* ListTwoColumnPriceDetails.swift in Sources */, diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index f2bf9e78..d4f79cc8 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -104,6 +104,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableButtonAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) From 283e7315f15b3e7a4a32691ecc95711240074e93 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Fri, 20 Mar 2020 15:09:06 +0530 Subject: [PATCH 045/244] ListThreeColumnBillChangesDivider Molecule created --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ .../ListThreeColumnBillChangesDivider.swift | 49 ++++++++++++++++ ...stThreeColumnBillChangesDividerModel.swift | 57 +++++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 2 + 4 files changed, 116 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f17d7906..5d708eb6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -183,6 +183,8 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; + BB6C6AE42424A7A0005F7224 /* ListThreeColumnBillChangesDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AE32424A7A0005F7224 /* ListThreeColumnBillChangesDividerModel.swift */; }; + BB6C6AE62424A7B1005F7224 /* ListThreeColumnBillChangesDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AE52424A7B1005F7224 /* ListThreeColumnBillChangesDivider.swift */; }; 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 */; }; @@ -567,6 +569,8 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTall.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = SOURCE_ROOT; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; + BB6C6AE32424A7A0005F7224 /* ListThreeColumnBillChangesDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillChangesDividerModel.swift; sourceTree = ""; }; + BB6C6AE52424A7B1005F7224 /* ListThreeColumnBillChangesDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillChangesDivider.swift; 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 = ""; }; @@ -1227,6 +1231,8 @@ children = ( 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, + BB6C6AE32424A7A0005F7224 /* ListThreeColumnBillChangesDividerModel.swift */, + BB6C6AE52424A7B1005F7224 /* ListThreeColumnBillChangesDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -2073,6 +2079,7 @@ 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */, + BB6C6AE42424A7A0005F7224 /* ListThreeColumnBillChangesDividerModel.swift in Sources */, 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */, DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, 0A21DB89235E06EF00C160A2 /* MFMdnTextField.m in Sources */, @@ -2154,6 +2161,7 @@ D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */, C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, + BB6C6AE62424A7B1005F7224 /* ListThreeColumnBillChangesDivider.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, D29E28DD23D7404C00ACEA85 /* ContainerHelper.swift in Sources */, 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift new file mode 100644 index 00000000..e4949e21 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift @@ -0,0 +1,49 @@ +// +// ListThreeColumnBillChangesDivider.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListThreeColumnBillChangesDivider: TableViewCell { + + public let leftLabel = Label(frame: .zero) + public let centerLabel = Label(frame: .zero) + public let rightLabel = Label(frame: .zero) + var stack: Stack + + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 34, horizontalAlignment: .center)), + (view: rightLabel, model: StackItemModel(percent: 33, horizontalAlignment: .trailing))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - MFViewProtocol + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + // MARK: - ModelMoleculeViewProtocol + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnBillChangesDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 120 + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift new file mode 100644 index 00000000..9e69d200 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift @@ -0,0 +1,57 @@ +// +// ListThreeColumnBillChangesDividerModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListThreeColumnBillChangesDividerModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list3CBillChgDiv" + public var leftLabel: LabelModel + public var centerLabel: LabelModel + public var rightLabel: LabelModel + + public init(leftLabel: LabelModel, centerLabel:LabelModel, rightLabel: LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + leftLabel.fontStyle = "BoldBodySmall" + rightLabel.fontStyle = "BoldBodySmall" + centerLabel.fontStyle = "BoldBodySmall" + + + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index f2bf9e78..88e9d538 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -114,6 +114,8 @@ import Foundation // Designed Section Dividers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnBillChangesDivider.self, viewModelClass: ListThreeColumnBillChangesDividerModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) From e633ea564c6e10beb272cd074eb0530b4fed6d43 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Fri, 20 Mar 2020 15:50:17 +0530 Subject: [PATCH 046/244] spacing change --- .../RightVariable/ListRightVariableButtonAllTextAndLinks.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index ba162be3..0fd7fdad 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -18,7 +18,7 @@ import Foundation // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 5, horizontalAlignment: .leading)), + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 0, horizontalAlignment: .leading)), (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .center))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) From 2905b3799a4121dcd162095dac3dcb09e899e109 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Fri, 20 Mar 2020 17:12:02 +0530 Subject: [PATCH 047/244] alignment changes --- .../ThreeColumn/ListThreeColumnBillChangesDividerModel.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift index 9e69d200..c40e2c5c 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift @@ -27,8 +27,6 @@ public class ListThreeColumnBillChangesDividerModel: ListItemModel, MoleculeMode leftLabel.fontStyle = "BoldBodySmall" rightLabel.fontStyle = "BoldBodySmall" centerLabel.fontStyle = "BoldBodySmall" - - } private enum CodingKeys: String, CodingKey { From 8e4d42e67be35c65008c7e8574fae1cdbe1eec7f Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 20 Mar 2020 17:41:08 +0530 Subject: [PATCH 048/244] 19180(List - Three Column - Speed Test - Divider) story initial commit Added model class and molecule class. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ .../ListThreeColumnSpeedTestDivider.swift | 63 +++++++++++++++++++ ...ListThreeColumnSpeedTestDividerModel.swift | 53 ++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 125 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f17d7906..b9510660 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -175,6 +175,8 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; + AA72AF172424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA72AF162424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift */; }; + AA72AF192424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA72AF182424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; @@ -559,6 +561,8 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; + AA72AF162424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestDivider.swift; sourceTree = ""; }; + AA72AF182424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestDividerModel.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; @@ -1227,6 +1231,8 @@ children = ( 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, + AA72AF162424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift */, + AA72AF182424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -2082,6 +2088,7 @@ 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */, 94C0150A24215643005811A9 /* ActionTopAlertModel.swift in Sources */, + AA72AF172424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift in Sources */, 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, @@ -2116,6 +2123,7 @@ D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, 94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */, + AA72AF192424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift in Sources */, 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift new file mode 100644 index 00000000..b278185d --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift @@ -0,0 +1,63 @@ +// +// ListThreeColumnSpeedTestDivider.swift +// MVMCoreUI +// +// Created by Lekshmi S on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnSpeedTestDivider: TableViewCell { + + //------------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + let leftLabel = Label.createLabelBoldBodySmall(true) + let centerLabel = Label.createLabelBoldBodySmall(true) + let rightLabel = Label.createLabelBoldBodySmall(true) + var stack: Stack + + //------------------------------------------------------- + // MARK: - Initializers + //------------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal, spacing: 8) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + //------------------------------------------------------ + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnSpeedTestDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + open override func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + centerLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift new file mode 100644 index 00000000..44f697ad --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift @@ -0,0 +1,53 @@ +// +// ListThreeColumnSpeedTestDividerModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnSpeedTestDividerModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list3CSpdTstDiv" + public var leftLabel: LabelModel + public var centerLabel: LabelModel + public var rightLabel: LabelModel + + public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index f2bf9e78..a364e216 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -117,6 +117,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnSpeedTestDivider.self, viewModelClass: ListThreeColumnSpeedTestDividerModel.self) // Designed Headers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) From 39fc20ef7933f957e61fe1e9bf889a8de31b7ff7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 20 Mar 2020 15:54:55 -0400 Subject: [PATCH 049/244] cleanup --- MVMCoreUI.xcodeproj/project.pbxproj | 100 ++++------ .../Atoms/Buttons/ButtonModel.swift | 0 .../Atoms/Buttons/CaretLink.swift | 31 ++- .../Atoms/Buttons/CaretLinkModel.swift | 0 .../Atoms/Buttons/Link/ExternalLink.swift | 2 +- .../Buttons/Link/ExternalLinkModel.swift | 0 .../Atoms/Buttons/Link/Link.swift | 2 +- .../Atoms/Buttons/Link/LinkModel.swift | 0 .../Atoms/Buttons/PillButton.swift | 2 +- .../Atoms/Buttons}/RadioButton.swift | 0 .../Atoms/Buttons}/RadioButtonModel.swift | 0 .../Buttons}/RadioButtonSelectionHelper.swift | 0 .../TextFields/BaseDropdownEntryField.swift | 16 +- .../BaseDropdownEntryFieldModel.swift | 0 .../TextFields/DateDropdownEntryField.swift | 18 +- .../DateDropdownEntryFieldModel.swift | 0 .../Atoms/TextFields/DigitBox.swift | 0 .../Atoms/TextFields/DigitEntryField.swift | 34 +--- .../TextFields/DigitEntryFieldModel.swift | 0 .../Atoms/TextFields/EntryField.swift | 47 +---- .../Atoms/TextFields/EntryFieldModel.swift | 0 .../TextFields/ItemDropdownEntryField.swift | 19 +- .../ItemDropdownEntryFieldModel.swift | 0 .../Atoms/TextFields/MdnEntryField.swift | 4 + .../Atoms/TextFields/MdnEntryFieldModel.swift | 0 .../Atoms/TextFields/TextEntryField.swift | 62 +----- .../TextFields/TextEntryFieldModel.swift | 0 .../{ => Atomic}/Atoms/Views/Arrow.swift | 0 .../{ => Atomic}/Atoms/Views/ArrowModel.swift | 0 .../{ => Atomic}/Atoms/Views/CaretView.swift | 8 +- .../Atoms/Views/CaretViewModel.swift | 0 .../{ => Atomic}/Atoms/Views/Checkbox.swift | 6 +- .../Atoms/Views/CheckboxLabel.swift | 38 ++-- .../Atoms/Views/CheckboxLabelModel.swift | 0 .../Atoms/Views/CheckboxModel.swift | 0 .../Atoms/Views/CircleProgressModel.swift | 0 .../{ => Atomic}/Atoms/Views/DashLine.swift | 6 - .../Atoms/Views/DashLineModel.swift | 0 .../{ => Atomic}/Atoms/Views/GraphView.swift | 5 - .../Views/GraphViewAnimationHandler.swift | 0 .../Atoms/Views/ImageViewModel.swift | 0 .../Atoms/Views/Label/Label.swift | 18 +- .../Label/LabelAttributeActionModel.swift | 0 .../Label/LabelAttributeColorModel.swift | 0 .../Views/Label/LabelAttributeFontModel.swift | 0 .../Label/LabelAttributeImageModel.swift | 0 .../Views/Label/LabelAttributeModel.swift | 0 .../LabelAttributeStrikeThroughModel.swift | 0 .../Label/LabelAttributeUnderlineModel.swift | 0 .../Atoms/Views/Label/LabelModel.swift | 0 .../Atoms/Views/LeftRightLabelModel.swift | 0 .../Atoms/Views/LeftRightLabelView.swift | 22 --- MVMCoreUI/{ => Atomic}/Atoms/Views/Line.swift | 30 +-- .../{ => Atomic}/Atoms/Views/LineModel.swift | 0 .../Atoms/Views/MFLoadImageView.swift | 50 +---- .../Atoms/Views/MFTransparentGIFView.swift | 0 .../Atoms/Views/MultiProgress.swift | 7 +- .../Atoms/Views/MultiProgressModel.swift | 0 .../Atoms/Views/ProgressBar.swift | 14 +- .../Atoms/Views/ProgressBarModel.swift | 0 .../{ => Atomic}/Atoms/Views/Toggle.swift | 52 ++--- .../Atoms/Views/ToggleModel.swift | 28 ++- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 184 ++++++++++++++++++ .../Headers/HeadersH2NoButtonsBodyText.swift | 0 .../HeadersH2NoButtonsBodyTextModel.swift | 0 ...tLeftVariableCheckboxAllTextAndLinks.swift | 2 +- ...VariableCheckboxAllTextAndLinksModel.swift | 0 .../ListLeftVariableIconWithRightCaret.swift | 0 ...tLeftVariableIconWithRightCaretModel.swift | 0 ...tVariableRadioButtonAndPaymentMethod.swift | 0 ...ableRadioButtonAndPaymentMethodModel.swift | 0 ...neColumnFullWidthTextAllTextAndLinks.swift | 0 ...umnFullWidthTextAllTextAndLinksModel.swift | 0 .../ListOneColumnFullWidthTextBodyText.swift | 0 ...tOneColumnFullWidthTextBodyTextModel.swift | 0 .../List/RightVariable/ListRVWheel.swift | 4 +- .../List/RightVariable/ListRVWheelModel.swift | 0 .../ListRightVariablePayments.swift | 0 .../ListRightVariablePaymentsModel.swift | 0 .../ListRightVariableTotalData.swift | 0 .../ListRightVariableTotalDataModel.swift | 0 .../ListTwoColumnCompareChanges.swift | 0 .../ListTwoColumnCompareChangesModel.swift | 0 .../ListTwoColumnPriceDescription.swift | 0 .../ListTwoColumnPriceDescriptionModel.swift | 0 .../TwoColumn/ListTwoColumnPriceDetails.swift | 2 +- .../ListTwoColumnPriceDetailsModel.swift | 0 .../LockUps/ListProgressBarData.swift | 4 +- .../LockUps/ListProgressBarDataModel.swift | 0 .../ListFourColumnDataUsageDivider.swift | 4 +- .../ListFourColumnDataUsageDividerModel.swift | 0 ...ColumnFullWidthTextDividerSubsection.swift | 0 ...nFullWidthTextDividerSubsectionModel.swift | 0 ...ColumnTextWithWhitespaceDividerShort.swift | 0 ...nTextWithWhitespaceDividerShortModel.swift | 0 ...eColumnTextWithWhitespaceDividerTall.swift | 0 ...mnTextWithWhitespaceDividerTallModel.swift | 0 .../ListThreeColumnPlanDataDivider.swift | 2 +- .../ListThreeColumnPlanDataDividerModel.swift | 0 .../Molecules/Doughnut/DoughnutChart.swift | 5 - .../Doughnut/DoughnutChartModel.swift | 0 .../Doughnut/DoughnutChartView.swift | 9 - .../{ => Atomic}/Molecules/FooterModel.swift | 0 MVMCoreUI/Atomic/Molecules/FooterView.swift | 12 ++ MVMCoreUI/{ => Atomic}/Molecules/Header.swift | 12 +- .../{ => Atomic}/Molecules/HeaderModel.swift | 0 .../ImageHeadlineBody.swift | 4 +- .../ImageHeadlineBodyModel.swift | 0 .../RadioButtonLabel.swift | 0 .../RadioButtonLabelModel.swift | 0 .../TabsModel.swift | 0 .../TwoButtonView.swift | 4 +- .../TwoButtonViewModel.swift | 0 .../Items/AccordionListItemModel.swift | 0 .../AccordionMoleculeTableViewCell.swift | 0 .../Molecules/Items/CarouselItemModel.swift | 0 .../Items/DropDownFilterTableViewCell.swift | 0 .../Items/DropDownListItemModel.swift | 0 .../Molecules/Items/ListItemModel.swift | 0 .../Items/MoleculeCollectionViewCell.swift | 25 +-- .../Items/MoleculeListItemModel.swift | 0 .../Molecules/Items/MoleculeStackItem.swift | 0 .../Items/MoleculeStackItemModel.swift | 0 .../Items/MoleculeTableViewCell.swift | 20 +- .../Molecules/Items/StackItem.swift | 0 .../Molecules/Items/StackItemModel.swift | 0 .../Items/StackItemModelProtocol.swift | 0 .../Molecules/Items/TabsListItemModel.swift | 0 .../Molecules/Items/TabsTableViewCell.swift | 3 +- .../ActionDetailWithImage.swift | 7 +- .../ActionDetailWithImageModel.swift | 0 .../LeftRightViews/CornerLabels.swift | 13 +- .../LeftRightViews/CornerLabelsModel.swift | 0 .../HeadlineBodyLinkToggle.swift | 2 +- .../HeadlineBodyLinkToggleModel.swift | 0 .../ToggleMolecules/HeadlineBodyToggle.swift | 11 +- .../HeadlineBodyToggleModel.swift | 0 .../ToggleMolecules/LabelToggle.swift | 4 +- .../ToggleMolecules/LabelToggleModel.swift | 0 .../Molecules/ModuleMolecule.swift | 10 +- .../Molecules/ModuleMoleculeModel.swift | 0 .../Molecules/MoleculeHeaderModel.swift | 0 .../Molecules/MoleculeHeaderView.swift | 11 +- .../NavigationItemModelProtocol.swift | 0 .../{ => Atomic}/Molecules/Scroller.swift | 4 +- .../Molecules/ScrollerModel.swift | 0 .../EyebrowHeadlineBodyLink.swift | 4 +- .../EyebrowHeadlineBodyLinkModel.swift | 0 .../HeadLineBodyCaretLinkImage.swift | 4 +- .../HeadlineBody.swift | 22 +-- .../HeadlineBodyButton.swift | 12 +- .../HeadlineBodyButtonModel.swift | 63 ++++++ .../HeadlineBodyCaretLinkImageModel.swift | 0 .../HeadlineBodyLink.swift | 4 +- .../HeadlineBodyLinkModel.swift | 0 .../HeadlineBodyModel.swift | 0 .../Lists/NumberedList.swift | 0 .../Lists/NumberedListModel.swift | 0 .../StringAndMoleculeModel.swift | 0 .../StringAndMoleculeStack.swift | 3 +- .../StringAndMoleculeView.swift | 6 +- .../Lists/UnOrderedList.swift | 0 .../Lists/UnOrderedListModel.swift | 0 .../{ => Atomic}/Organisms/Carousel.swift | 19 +- .../Organisms/CarouselModel.swift | 0 .../Organisms/MoleculeStackModel.swift | 0 .../Organisms/MoleculeStackView.swift | 2 +- MVMCoreUI/{ => Atomic}/Organisms/Stack.swift | 12 +- .../{ => Atomic}/Organisms/StackModel.swift | 0 .../Organisms/StackModelProtocol.swift | 0 .../Protocols/MoleculeDelegateProtocol.swift} | 4 +- .../Protocols/MoleculeViewProtocol.swift} | 42 +++- .../Protocols}/TemplateProtocol.swift | 0 .../Templates/ListPageTemplateModel.swift | 31 +-- .../Templates/ModalMoleculeListTemplate.swift | 0 .../ModalMoleculeListTemplate.swift.orig | 30 +++ .../ModalMoleculeStackTemplate.swift | 0 .../Templates/MoleculeListCellProtocol.swift | 0 .../Templates/MoleculeListTemplate.swift | 47 ++--- .../MoleculeStackCenteredTemplate.swift | 0 .../Templates/MoleculeStackTemplate.swift | 16 +- .../StackCenteredPageTemplateModel.swift | 0 .../Templates/StackPageTemplateModel.swift | 0 .../StackPageTemplateModel.swift.orig | 58 ++++++ .../Templates/TemplateModel.swift | 14 +- .../ThreeLayerPageTemplateModel.swift | 0 .../Templates/ThreeLayerTemplate.swift | 6 +- .../Buttons/MFCustomButton+ActionModel.swift | 25 --- ...maryButton+MoleculeProtocolExtension.swift | 38 ---- .../Atoms/TextFields/TextFieldModel.swift | 27 --- .../Atoms/Views/MFView+ModelExtension.swift | 24 --- .../Atoms/Views/MVMCoreUISwitch+Model.swift | 28 --- MVMCoreUI/BaseClasses/Button.swift | 16 +- .../BaseClasses/ButtonModelProtocol.swift | 1 - MVMCoreUI/BaseClasses/Control.swift | 23 +-- MVMCoreUI/BaseClasses/TableViewCell.swift | 10 +- MVMCoreUI/BaseClasses/TextField.swift | 24 +-- MVMCoreUI/BaseClasses/View.swift | 28 +-- .../BaseControllers/ViewController.swift | 15 +- .../Categories/UIStackView+Extension.swift | 4 +- .../Views/Container/Container.swift | 25 +-- .../Views/EntryFieldContainer.swift | 12 +- .../Containers/Views/MoleculeContainer.swift | 29 +-- .../Controllers/MFViewController+Model.swift | 2 +- MVMCoreUI/Legacy/Views/ButtonView.swift | 26 +-- MVMCoreUI/Legacy/Views/LabelView.m | 6 +- .../Views/LabelWithInternalButton.swift | 57 +----- MVMCoreUI/Legacy/Views/MFCustomButton.h | 1 - MVMCoreUI/Legacy/Views/MFDigitTextField.m | 17 +- MVMCoreUI/Legacy/Views/MFTextButton.h | 2 +- MVMCoreUI/Legacy/Views/MFTextButton.m | 23 --- MVMCoreUI/Legacy/Views/MFTextField.h | 2 +- MVMCoreUI/Legacy/Views/MFTextField.m | 15 -- MVMCoreUI/Legacy/Views/MFView.h | 6 +- MVMCoreUI/Legacy/Views/MFView.m | 20 -- MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h | 2 +- MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m | 35 +--- .../Views/MVMCoreUIMoleculeViewProtocol.h | 39 ---- MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.h | 3 +- MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m | 19 -- MVMCoreUI/Legacy/Views/MVMCoreUISwitch.h | 3 +- MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m | 47 +---- MVMCoreUI/Legacy/Views/PrimaryButton.h | 3 +- MVMCoreUI/Legacy/Views/PrimaryButton.m | 95 ++------- MVMCoreUI/Legacy/Views/PrimaryButtonView.m | 18 -- MVMCoreUI/Legacy/Views/SeparatorView.m | 51 +---- MVMCoreUI/Legacy/Views/ViewConstrainingView.h | 12 -- MVMCoreUI/Legacy/Views/ViewConstrainingView.m | 121 +----------- MVMCoreUI/MVMCoreUI.h | 2 - .../ModelProtocols/PageModelProtocol.swift | 2 - MVMCoreUI/Molecules/FooterView.swift | 18 -- .../Molecules/MoleculeViewProtocol.swift | 37 ---- .../HeadlineBodyButtonModel.swift | 19 -- MVMCoreUI/OtherHandlers/CoreUIObject.swift | 4 +- ...MoleculeMappingObject+ModelExtension.swift | 49 ----- .../MVMCoreUIMoleculeMappingObject.h | 42 ---- .../MVMCoreUIMoleculeMappingObject.m | 101 ---------- .../OtherHandlers/MoleculeObjectMapping.swift | 143 -------------- 238 files changed, 811 insertions(+), 1938 deletions(-) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/ButtonModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/CaretLink.swift (91%) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/CaretLinkModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/Link/ExternalLink.swift (98%) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/Link/ExternalLinkModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/Link/Link.swift (98%) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/Link/LinkModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Buttons/PillButton.swift (99%) rename MVMCoreUI/{Atoms/Views => Atomic/Atoms/Buttons}/RadioButton.swift (100%) rename MVMCoreUI/{Atoms/Views => Atomic/Atoms/Buttons}/RadioButtonModel.swift (100%) rename MVMCoreUI/{Molecules => Atomic/Atoms/Buttons}/RadioButtonSelectionHelper.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/BaseDropdownEntryField.swift (84%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/BaseDropdownEntryFieldModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/DateDropdownEntryField.swift (87%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/DateDropdownEntryFieldModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/DigitBox.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/DigitEntryField.swift (94%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/DigitEntryFieldModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/EntryField.swift (87%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/EntryFieldModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/ItemDropdownEntryField.swift (90%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/ItemDropdownEntryFieldModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/MdnEntryField.swift (97%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/MdnEntryFieldModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/TextEntryField.swift (86%) rename MVMCoreUI/{ => Atomic}/Atoms/TextFields/TextEntryFieldModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Arrow.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/ArrowModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/CaretView.swift (94%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/CaretViewModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Checkbox.swift (99%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/CheckboxLabel.swift (84%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/CheckboxLabelModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/CheckboxModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/CircleProgressModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/DashLine.swift (89%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/DashLineModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/GraphView.swift (95%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/GraphViewAnimationHandler.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/ImageViewModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/Label.swift (98%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelAttributeActionModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelAttributeColorModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelAttributeFontModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelAttributeImageModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelAttributeModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelAttributeUnderlineModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Label/LabelModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/LeftRightLabelModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/LeftRightLabelView.swift (85%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Line.swift (73%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/LineModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/MFLoadImageView.swift (90%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/MFTransparentGIFView.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/MultiProgress.swift (88%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/MultiProgressModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/ProgressBar.swift (76%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/ProgressBarModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/Toggle.swift (89%) rename MVMCoreUI/{ => Atomic}/Atoms/Views/ToggleModel.swift (63%) create mode 100644 MVMCoreUI/Atomic/MoleculeObjectMapping.swift rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyText.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyTextModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift (96%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/LockUps/ListProgressBarData.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/LockUps/ListProgressBarDataModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDivider.swift (96%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsection.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift (100%) rename MVMCoreUI/{Molecules/DesignedComponents/List => Atomic/Molecules/DesignedComponents/SectionDividers}/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift (100%) rename MVMCoreUI/{Molecules/DesignedComponents/List => Atomic/Molecules/DesignedComponents/SectionDividers}/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift (98%) rename MVMCoreUI/{ => Atomic}/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Doughnut/DoughnutChart.swift (98%) rename MVMCoreUI/{ => Atomic}/Molecules/Doughnut/DoughnutChartModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Doughnut/DoughnutChartView.swift (93%) rename MVMCoreUI/{ => Atomic}/Molecules/FooterModel.swift (100%) create mode 100644 MVMCoreUI/Atomic/Molecules/FooterView.swift rename MVMCoreUI/{ => Atomic}/Molecules/Header.swift (86%) rename MVMCoreUI/{ => Atomic}/Molecules/HeaderModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift (96%) rename MVMCoreUI/{ => Atomic}/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift (100%) rename MVMCoreUI/{Molecules => Atomic/Molecules/HorizontalCombinationViews}/RadioButtonLabel.swift (100%) rename MVMCoreUI/{Molecules => Atomic/Molecules/HorizontalCombinationViews}/RadioButtonLabelModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/HorizontalCombinationViews/TabsModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/HorizontalCombinationViews/TwoButtonView.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/AccordionListItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/AccordionMoleculeTableViewCell.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/CarouselItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/DropDownFilterTableViewCell.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/DropDownListItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/ListItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/MoleculeCollectionViewCell.swift (85%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/MoleculeListItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/MoleculeStackItem.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/MoleculeStackItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/MoleculeTableViewCell.swift (58%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/StackItem.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/StackItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/StackItemModelProtocol.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/TabsListItemModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Items/TabsTableViewCell.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ActionDetailWithImage.swift (94%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ActionDetailWithImageModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/CornerLabels.swift (95%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/CornerLabelsModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggle.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggle.swift (86%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ToggleMolecules/LabelToggle.swift (95%) rename MVMCoreUI/{ => Atomic}/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/ModuleMolecule.swift (84%) rename MVMCoreUI/{ => Atomic}/Molecules/ModuleMoleculeModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/MoleculeHeaderModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/MoleculeHeaderView.swift (71%) rename MVMCoreUI/{ => Atomic}/Molecules/NavigationItemModelProtocol.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/Scroller.swift (85%) rename MVMCoreUI/{ => Atomic}/Molecules/ScrollerModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift (96%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/HeadlineBody.swift (82%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift (90%) create mode 100644 MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/HeadlineBodyLink.swift (97%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/Lists/NumberedList.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift (84%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift (94%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift (100%) rename MVMCoreUI/{ => Atomic}/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Organisms/Carousel.swift (95%) rename MVMCoreUI/{ => Atomic}/Organisms/CarouselModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Organisms/MoleculeStackModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Organisms/MoleculeStackView.swift (89%) rename MVMCoreUI/{ => Atomic}/Organisms/Stack.swift (95%) rename MVMCoreUI/{ => Atomic}/Organisms/StackModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Organisms/StackModelProtocol.swift (100%) rename MVMCoreUI/{OtherHandlers/ModelMoleculeDelegateProtocol.swift => Atomic/Protocols/MoleculeDelegateProtocol.swift} (88%) rename MVMCoreUI/{Molecules/ModelMoleculeViewProtocol.swift => Atomic/Protocols/MoleculeViewProtocol.swift} (55%) rename MVMCoreUI/{Templates => Atomic/Protocols}/TemplateProtocol.swift (100%) rename MVMCoreUI/{ => Atomic}/Templates/ListPageTemplateModel.swift (65%) rename MVMCoreUI/{ => Atomic}/Templates/ModalMoleculeListTemplate.swift (100%) create mode 100644 MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig rename MVMCoreUI/{ => Atomic}/Templates/ModalMoleculeStackTemplate.swift (100%) rename MVMCoreUI/{ => Atomic}/Templates/MoleculeListCellProtocol.swift (100%) rename MVMCoreUI/{ => Atomic}/Templates/MoleculeListTemplate.swift (81%) rename MVMCoreUI/{ => Atomic}/Templates/MoleculeStackCenteredTemplate.swift (100%) rename MVMCoreUI/{ => Atomic}/Templates/MoleculeStackTemplate.swift (70%) rename MVMCoreUI/{ => Atomic}/Templates/StackCenteredPageTemplateModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Templates/StackPageTemplateModel.swift (100%) create mode 100644 MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig rename MVMCoreUI/{ => Atomic}/Templates/TemplateModel.swift (77%) rename MVMCoreUI/{ => Atomic}/Templates/ThreeLayerPageTemplateModel.swift (100%) rename MVMCoreUI/{ => Atomic}/Templates/ThreeLayerTemplate.swift (76%) delete mode 100644 MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift delete mode 100644 MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift delete mode 100644 MVMCoreUI/Atoms/TextFields/TextFieldModel.swift delete mode 100644 MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift delete mode 100644 MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift rename MVMCoreUI/{Atoms => Legacy}/Views/LabelWithInternalButton.swift (92%) delete mode 100644 MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h delete mode 100644 MVMCoreUI/Molecules/FooterView.swift delete mode 100644 MVMCoreUI/Molecules/MoleculeViewProtocol.swift delete mode 100644 MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift delete mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift delete mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h delete mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m delete mode 100644 MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index af3081dc..3b3c7871 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -35,11 +35,10 @@ 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.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 */; }; + 012A88C8238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88C7238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift */; }; 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 */; }; - 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */; }; 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */; }; 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72223C501E2006F3E93 /* ContainerModel.swift */; }; @@ -54,10 +53,7 @@ 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D942327ED1900EF99AA /* HeadlineBodyLinkToggle.swift */; }; 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB372360C6AC0024EF95 /* RadioButtonLabel.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 */; }; - 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 */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -213,15 +209,14 @@ 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 */; }; + D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */; }; D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */; }; D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */; }; - D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; D256E9932412880000360572 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = D256E9922412880000360572 /* Header.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 */; }; @@ -242,7 +237,6 @@ 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 */; }; D28A837923C7D5BC00DFE4FC /* PageModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */; }; D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837A23C928DA00DFE4FC /* MoleculeListCellProtocol.swift */; }; D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837C23CCA86A00DFE4FC /* TabsListItemModel.swift */; }; @@ -252,7 +246,6 @@ D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; }; D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; }; D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */; }; - 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 */; }; @@ -356,9 +349,6 @@ D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */; }; D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */; }; D29E28DD23D7404C00ACEA85 /* ContainerHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28DC23D7404C00ACEA85 /* ContainerHelper.swift */; }; - 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 */; }; @@ -436,10 +426,9 @@ 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemModel.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 = ""; }; + 012A88C7238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeDelegateProtocol.swift; sourceTree = ""; }; 012A88EB238F084D00FE3DA1 /* FooterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModel.swift; sourceTree = ""; }; 012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; - 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIContentMode+Extension.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 = ""; }; @@ -454,10 +443,7 @@ 01509D942327ED1900EF99AA /* HeadlineBodyLinkToggle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyLinkToggle.swift; sourceTree = ""; }; 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonLabel.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 = ""; }; - 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 = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; @@ -569,8 +555,8 @@ AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; - BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTallModel.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift; sourceTree = SOURCE_ROOT; }; - BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListOneColumnTextWithWhitespaceDividerTall.swift; path = MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = SOURCE_ROOT; }; + BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTallModel.swift; sourceTree = ""; }; + BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; @@ -603,15 +589,14 @@ 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 = ""; }; + D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+Extension.swift"; sourceTree = ""; }; D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescription.swift; sourceTree = ""; }; D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescriptionModel.swift; sourceTree = ""; }; - D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; D256E9922412880000360572 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.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 = ""; }; @@ -631,7 +616,6 @@ 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 = ""; }; D28A837823C7D5BC00DFE4FC /* PageModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageModelProtocol.swift; 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 = ""; }; @@ -641,7 +625,6 @@ D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = ""; }; D28A838823CCCFCB00DFE4FC /* LinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkModel.swift; sourceTree = ""; }; D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonModel.swift; sourceTree = ""; }; - 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 = ""; }; @@ -760,9 +743,6 @@ D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeView.swift; sourceTree = ""; }; D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeModel.swift; sourceTree = ""; }; D29E28DC23D7404C00ACEA85 /* ContainerHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerHelper.swift; sourceTree = ""; }; - 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 = ""; }; @@ -872,7 +852,7 @@ 01C74D87224298E2009C25A3 /* FormUIHelpers */ = { isa = PBXGroup; children = ( - 011D95882404249B000E3791 /* FormProtocol.swift */, + 011D95882404249B000E3791 /* FormHolderModelProtocol.swift */, 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */, 011D95AA2405C553000E3791 /* FormItemProtocol.swift */, 011D958624042492000E3791 /* FormFieldProtocol.swift */, @@ -1047,6 +1027,7 @@ D213347523842FF5008E41B3 /* Views */ = { isa = PBXGroup; children = ( + DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, 94FB966023D797DA003D482B /* MFTextButton.h */, 94FB966123D797DA003D482B /* MFTextButton.m */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, @@ -1094,7 +1075,6 @@ D29DF24321E6A176003B2FB9 /* MFDigitTextField.h */, D29DF24821E6A177003B2FB9 /* MFDigitTextField.m */, D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */, - D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */, D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */, 94F217B423E0BF6100A47C06 /* PrimaryButtonView.h */, @@ -1147,6 +1127,8 @@ D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */, D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */, D28A837E23CCA96400DFE4FC /* TabsModel.swift */, + 011D9625240EBB16000E3791 /* RadioButtonLabelModel.swift */, + 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */, ); path = HorizontalCombinationViews; sourceTree = ""; @@ -1308,6 +1290,7 @@ D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */ = { isa = PBXGroup; children = ( + D2C78CD324252F4E00B69FDE /* Atomic */, 01509D96232803B200EF99AA /* Models */, 012A88EF23985E0100FE3DA1 /* CustomPrimitives */, D2B18B7D236090D500A9AEDC /* BaseClasses */, @@ -1322,10 +1305,6 @@ D29DF10F21E67A7D003B2FB9 /* BaseControllers */, D29DF11E21E6851E003B2FB9 /* TopAlert */, 94C01508242155FE005811A9 /* Actions */, - D29DF10D21E67A70003B2FB9 /* Atoms */, - D29DF10E21E67A77003B2FB9 /* Molecules */, - D22479902316A9CB003FCCF9 /* Organisms */, - D29DF0DF21E418B2003B2FB9 /* Templates */, D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */, D29DF0D021E404D4003B2FB9 /* Info.plist */, ); @@ -1335,7 +1314,6 @@ D29DF0DF21E418B2003B2FB9 /* Templates */ = { isa = PBXGroup; children = ( - 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, D22D8392241C27B100D3DF69 /* TemplateModel.swift */, 014AA72823C5059B006F3E93 /* StackPageTemplateModel.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, @@ -1385,15 +1363,10 @@ D2A514662213885800345BFB /* MoleculeHeaderView.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, D274CA322236A78900B01B62 /* FooterView.swift */, - 0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */, 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */, D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */, D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */, - 011D9625240EBB16000E3791 /* RadioButtonLabelModel.swift */, - 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */, - 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, - 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, D260105723CF9CC500764D80 /* Doughnut */, D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */, ); @@ -1508,8 +1481,9 @@ DBC4391A224421A0001AB423 /* CaretLink.swift */, D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */, D2E2A99E23E07F8A000B42E6 /* PillButton.swift */, - D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */, - D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */, + 0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */, + 011D95AE2407266E000E3791 /* RadioButtonModel.swift */, + 01004F2F22721C3800991ECC /* RadioButton.swift */, ); path = Buttons; sourceTree = ""; @@ -1532,21 +1506,16 @@ D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */, D213347623843825008E41B3 /* Line.swift */, - DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, 94C2D9822386F3E30006CF46 /* Label */, 31BE15CA23D8924C00452370 /* CheckboxModel.swift */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */, - 011D95AE2407266E000E3791 /* RadioButtonModel.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 */, 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */, 0AE98BB423FF18D2004C5109 /* Arrow.swift */, ); @@ -1571,7 +1540,6 @@ 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */, 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */, 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */, - 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, ); path = TextFields; sourceTree = ""; @@ -1607,11 +1575,6 @@ D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */, D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */, D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, - 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */, - D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, - D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, - 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, - 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, ); path = OtherHandlers; sourceTree = ""; @@ -1723,6 +1686,29 @@ path = BaseClasses; sourceTree = ""; }; + D2C78CD324252F4E00B69FDE /* Atomic */ = { + isa = PBXGroup; + children = ( + 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, + D2C78CD424252F5D00B69FDE /* Protocols */, + D29DF10D21E67A70003B2FB9 /* Atoms */, + D29DF10E21E67A77003B2FB9 /* Molecules */, + D22479902316A9CB003FCCF9 /* Organisms */, + D29DF0DF21E418B2003B2FB9 /* Templates */, + ); + path = Atomic; + sourceTree = ""; + }; + D2C78CD424252F5D00B69FDE /* Protocols */ = { + isa = PBXGroup; + children = ( + 012A88C7238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift */, + 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, + 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, + ); + path = Protocols; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -1743,7 +1729,6 @@ D29DF29B21E7ADB9003B2FB9 /* StackableViewController.h in Headers */, D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */, D29DF15421E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h in Headers */, - D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */, 9458C3172406C8FD00930963 /* UIFont+FontWrapping.h in Headers */, D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */, D29DF29A21E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h in Headers */, @@ -1777,7 +1762,6 @@ 0A21DB88235E06EF00C160A2 /* MFMdnTextField.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 */, @@ -1926,11 +1910,10 @@ D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */, BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */, - 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */, + 012A88C8238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift in Sources */, 0A7EF86123D8AC2500B2AAD1 /* DigitEntryFieldModel.swift in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */, - 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */, 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, @@ -1958,7 +1941,6 @@ 0A21DB91235E0EDB00C160A2 /* DigitBox.swift in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */, - D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, @@ -1976,7 +1958,6 @@ 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, - 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, @@ -1986,13 +1967,11 @@ 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, - 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */, 011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */, AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, D213347723843825008E41B3 /* Line.swift in Sources */, - D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */, D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */, 525019DE2406430800EED91C /* ListProgressBarData.swift in Sources */, D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */, @@ -2010,7 +1989,6 @@ D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, - D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, @@ -2110,7 +2088,6 @@ 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, D2C78CD224228BBD00B69FDE /* ActionOpenPanelModel.swift in Sources */, - 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, @@ -2182,7 +2159,6 @@ D29E28DD23D7404C00ACEA85 /* ContainerHelper.swift in Sources */, 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, - D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, 94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */, 011D95AB2405C553000E3791 /* FormItemProtocol.swift in Sources */, D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Buttons/ButtonModel.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift diff --git a/MVMCoreUI/Atoms/Buttons/CaretLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift similarity index 91% rename from MVMCoreUI/Atoms/Buttons/CaretLink.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift index 50eb7f83..697f4282 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift @@ -35,6 +35,27 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { private var caretSpacingConstraint: NSLayoutConstraint? + //------------------------------------------------------ + // MARK: - Inits + //------------------------------------------------------ + + // Default values for view. + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + backgroundColor = .clear + translatesAutoresizingMaskIntoConstraints = false + setTitleColor(enabledColor, for: .normal) + setTitleColor(disabledColor, for: .disabled) + } + + public override init(frame: CGRect) { + super.init(frame: frame) + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + } + //------------------------------------------------------ // MARK: - Lifecycle //------------------------------------------------------ @@ -115,16 +136,6 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { //------------------------------------------------------ // MARK: - Atomization //------------------------------------------------------ - - // Default values for view. - @objc open func setAsMolecule() { - - backgroundColor = .clear - translatesAutoresizingMaskIntoConstraints = false - setTitleColor(enabledColor, for: .normal) - setTitleColor(disabledColor, for: .disabled) - } - public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let caretLinkModel = model as? CaretLinkModel else { return } if let color = caretLinkModel.backgroundColor { diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift diff --git a/MVMCoreUI/Atoms/Buttons/Link/ExternalLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift similarity index 98% rename from MVMCoreUI/Atoms/Buttons/Link/ExternalLink.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift index 3cd601b6..9fe48936 100644 --- a/MVMCoreUI/Atoms/Buttons/Link/ExternalLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift @@ -17,7 +17,7 @@ open class ExternalLink: Link { public var exportImageView: UIImageView? //-------------------------------------------------- - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atoms/Buttons/Link/ExternalLinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLinkModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Buttons/Link/ExternalLinkModel.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLinkModel.swift diff --git a/MVMCoreUI/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift similarity index 98% rename from MVMCoreUI/Atoms/Buttons/Link/Link.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index c64bd13b..d65ce3ce 100644 --- a/MVMCoreUI/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -44,7 +44,7 @@ import UIKit } //-------------------------------------------------- - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Buttons/Link/LinkModel.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift diff --git a/MVMCoreUI/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift similarity index 99% rename from MVMCoreUI/Atoms/Buttons/PillButton.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index da8cf0c7..3d5bd46b 100644 --- a/MVMCoreUI/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -118,7 +118,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) } - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { // The button will get styled in the enable check in super. super.set(with: model, delegateObject, additionalData) diff --git a/MVMCoreUI/Atoms/Views/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/RadioButton.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift diff --git a/MVMCoreUI/Atoms/Views/RadioButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/RadioButtonModel.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift diff --git a/MVMCoreUI/Molecules/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift similarity index 100% rename from MVMCoreUI/Molecules/RadioButtonSelectionHelper.swift rename to MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/BaseDropdownEntryField.swift similarity index 84% rename from MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/BaseDropdownEntryField.swift index b7c59fd5..f7083df5 100644 --- a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/BaseDropdownEntryField.swift @@ -52,6 +52,10 @@ import UIKit fatalError("DropdownEntryField does not support xib.") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(model: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Setup //-------------------------------------------------- @@ -77,15 +81,3 @@ import UIKit dropDownCaretView.setOptional(with: model.caretView, delegateObject, additionalData) } } - -// MARK: - MVMCoreUIMoleculeViewProtocol -extension BaseDropdownEntryField { - - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let dictionary = json, !dictionary.isEmpty else { return } - - dropDownCaretView.setWithJSON(dictionary, delegateObject: delegateObject, additionalData: additionalData) - } -} diff --git a/MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/BaseDropdownEntryFieldModel.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/BaseDropdownEntryFieldModel.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/BaseDropdownEntryFieldModel.swift diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/DateDropdownEntryField.swift similarity index 87% rename from MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/DateDropdownEntryField.swift index 95174096..a7a483fc 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/DateDropdownEntryField.swift @@ -58,6 +58,10 @@ import UIKit fatalError("DateDropdownEntryField init(coder:) has not been implemented") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(model: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- @@ -119,17 +123,3 @@ import UIKit dateFormat = model.dateFormat } } - -// MARK: - MVMCoreUIMoleculeViewProtocol -extension DateDropdownEntryField { - - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let dictionary = json, !dictionary.isEmpty else { return } - - if let dateFormat = dictionary["dateFormat"] as? String { - self.dateFormat = dateFormat - } - } -} diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/DateDropdownEntryFieldModel.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/DateDropdownEntryFieldModel.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/DateDropdownEntryFieldModel.swift diff --git a/MVMCoreUI/Atoms/TextFields/DigitBox.swift b/MVMCoreUI/Atomic/Atoms/TextFields/DigitBox.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/DigitBox.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/DigitBox.swift diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryField.swift similarity index 94% rename from MVMCoreUI/Atoms/TextFields/DigitEntryField.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryField.swift index 53181bff..e6ab727e 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryField.swift @@ -193,6 +193,10 @@ import UIKit fatalError("DigitEntryField xib has not been implemented") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(model: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Setup //-------------------------------------------------- @@ -343,6 +347,10 @@ import UIKit super.set(with: model, delegateObject, additionalData) } + + public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 115 + } } // MARK: - TextField Delegate @@ -440,29 +448,3 @@ extension DigitEntryField { return proprietorTextDelegate?.textFieldShouldEndEditing?(textField) ?? true } } - -// MARK: - MVMCoreUIMoleculeViewProtocol -extension DigitEntryField { - - @objc 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 } - - numberOfDigits = dictionary["digits"] as? Int ?? 4 - - if let _ = dictionary["secureEntry"] as? Bool { - setAsSecureTextEntry(true) - } - - if !dictionary.isEmpty{ - for digitBox in digitBoxes { - MVMCoreUICommonViewsUtility.addDismissToolbar(digitBox.digitField, delegate: delegateObject as? UITextFieldDelegate) - } - } - } - - @objc open override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 115 - } -} diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryFieldModel.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/DigitEntryFieldModel.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryFieldModel.swift diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift similarity index 87% rename from MVMCoreUI/Atoms/TextFields/EntryField.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift index 43a15a3b..a0f0e7dc 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift @@ -161,6 +161,11 @@ import UIKit fatalError("EntryField does not support xib.") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + set(with: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -226,6 +231,9 @@ import UIKit entryFieldContainer.updateView(size) } + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- @objc open override func reset() { super.reset() @@ -258,45 +266,8 @@ import UIKit self.isSelected = isSelected } } -} -// MARK: - MVMCoreUIMoleculeViewProtocol -extension EntryField { - - @objc 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 } - - entryFieldContainer.setWithJSON(dictionary, delegateObject: delegateObject, additionalData: additionalData) - - if let titleText = dictionary[KeyTitle] as? String { - title = titleText - } - - if let disable = dictionary[KeyDisable] as? String, disable.isEqual(StringY) || dictionary.boolForKey(KeyDisable) { - isEnabled = false - } - - if let feedback = dictionary["feedback"] as? String { - self.standardMessage = feedback - } - - if let errMessage = dictionary[KeyErrorMessage] as? String { - errorMessage = errMessage - } - - if let isLocked = dictionary["isLocked"] as? Bool { - self.isLocked = isLocked - } - - if let isSelected = dictionary["isSelected"] as? Bool { - self.isSelected = isSelected - } - } - - @objc open class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 115 } } diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/ItemDropdownEntryField.swift similarity index 90% rename from MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/ItemDropdownEntryField.swift index 0ecfc4ad..bd6d793c 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/ItemDropdownEntryField.swift @@ -51,6 +51,10 @@ open class ItemDropdownEntryField: BaseDropdownEntryField { fatalError("ItemDropdownEntryField init(coder:) has not been implemented") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(model: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- @@ -135,21 +139,6 @@ extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource { } } -// MARK: - MVMCoreUIMoleculeViewProtocol -extension ItemDropdownEntryField { - - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let dictionary = json, !dictionary.isEmpty else { return } - - if let options = dictionary["options"] as? [String] { - pickerData = options - setPickerDelegates(delegate: self) - } - } -} - // MARK: - Accessibility extension ItemDropdownEntryField { diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/ItemDropdownEntryFieldModel.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/ItemDropdownEntryFieldModel.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/ItemDropdownEntryFieldModel.swift diff --git a/MVMCoreUI/Atoms/TextFields/MdnEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/MdnEntryField.swift similarity index 97% rename from MVMCoreUI/Atoms/TextFields/MdnEntryField.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/MdnEntryField.swift index 92a1e073..77b5a4a4 100644 --- a/MVMCoreUI/Atoms/TextFields/MdnEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/MdnEntryField.swift @@ -65,6 +65,10 @@ import MVMCore fatalError("MdnEntryField xib not supported.") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(model: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Setup //-------------------------------------------------- diff --git a/MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/MdnEntryFieldModel.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/MdnEntryFieldModel.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/MdnEntryFieldModel.swift diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift similarity index 86% rename from MVMCoreUI/Atoms/TextFields/TextEntryField.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift index 4c56036e..12fe6de0 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift @@ -154,6 +154,10 @@ import UIKit fatalError("TextEntryField does not support xib.") } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(model: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -315,64 +319,6 @@ import UIKit } } -// MARK: - MVMCoreUIMoleculeViewProtocol -extension TextEntryField { - - @objc open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - - guard let delegateObject = delegateObject, - let dictionary = json - else { return } - - if let enabledTextColorHex = dictionary["enabledTextColor"] as? String { - textColor.enabled = UIColor.mfGet(forHex: enabledTextColorHex) - } - - if let disabledTextColorHex = dictionary["disabledTextColor"] as? String { - textColor.disabled = UIColor.mfGet(forHex: disabledTextColorHex) - } - - if let text = dictionary[KeyText] as? String { - self.text = text - } - - if let placeholder = dictionary[placeholder] as? String { - self.placeholder = placeholder - } - - switch dictionary.stringForkey(KeyType) { - case "password": - textField.isSecureTextEntry = true - - case "number": - textField.keyboardType = .numberPad - - case "email": - textField.keyboardType = .emailAddress - - default: - break - } - - let regex = dictionary.stringForkey("regex") - - if !regex.isEmpty { - validationBlock = { enteredValue in - guard let value = enteredValue else { return false } - return MVMCoreUIUtility.validate(value, withRegularExpression: regex) - } - } else { - defaultValidationBlock() - } - - - uiTextFieldDelegate = delegateObject.uiTextFieldDelegate - observingTextFieldDelegate = delegateObject.observingTextFieldDelegate - MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) - } -} - // MARK: - Accessibility extension TextEntryField { diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift similarity index 100% rename from MVMCoreUI/Atoms/TextFields/TextEntryFieldModel.swift rename to MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift diff --git a/MVMCoreUI/Atoms/Views/Arrow.swift b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Arrow.swift rename to MVMCoreUI/Atomic/Atoms/Views/Arrow.swift diff --git a/MVMCoreUI/Atoms/Views/ArrowModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/ArrowModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atomic/Atoms/Views/CaretView.swift similarity index 94% rename from MVMCoreUI/Atoms/Views/CaretView.swift rename to MVMCoreUI/Atomic/Atoms/Views/CaretView.swift index fff56f82..93874287 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CaretView.swift @@ -178,16 +178,12 @@ open class CaretView: View { //------------------------------------------------------ // Default values for view. - @objc open override func setAsMolecule() { + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.init(frame: .zero) defaultState() - } - - 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 } set(with: model, delegateObject, additionalData) } - //MARK: - MVMCoreMoleculeViewProtocol override public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let caretModel = model as? CaretViewModel else { diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/CaretViewModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift similarity index 99% rename from MVMCoreUI/Atoms/Views/Checkbox.swift rename to MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift index f288c4cd..c76383cb 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift @@ -382,11 +382,7 @@ import MVMCore checkWidth = 2.0 checkAndBypassAnimations(selected: false) } - - open func setAsMolecule() { - setupView() - } - + public override func updateView(_ size: CGFloat) { super.updateView(size) diff --git a/MVMCoreUI/Atoms/Views/CheckboxLabel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift similarity index 84% rename from MVMCoreUI/Atoms/Views/CheckboxLabel.swift rename to MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift index 72429aa2..5d4f68be 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxLabel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift @@ -65,6 +65,14 @@ alignCheckbox(.center) } + @objc override open func updateView(_ size: CGFloat) { + super.updateView(size) + + label.updateView(size) + checkbox.updateView(size) + layoutIfNeeded() + } + //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -115,6 +123,9 @@ } } + //-------------------------------------------------- + // MARK: - Atomic + //-------------------------------------------------- open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let checkBoxWithLabelModel = model as? CheckboxLabelModel else { return } @@ -125,23 +136,11 @@ checkbox.set(with: checkBoxWithLabelModel.checkbox, delegateObject, additionalData) label.set(with: checkBoxWithLabelModel.label, delegateObject, additionalData) } -} - -// MARK: - Molecular -extension CheckboxLabel { - open class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 200 } - @objc override open func updateView(_ size: CGFloat) { - super.updateView(size) - - label.updateView(size) - checkbox.updateView(size) - layoutIfNeeded() - } - open override func reset() { super.reset() @@ -149,17 +148,4 @@ extension CheckboxLabel { checkbox.reset() alignCheckbox(.center) } - - override open 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 checkboxAlignment = dictionary["checkboxAlignment"] as? String, let position = CheckboxPosition(rawValue: checkboxAlignment) { - alignCheckbox(position) - } - - checkbox.setWithJSON(dictionary.dictionaryForKey("checkbox"), delegateObject: delegateObject, additionalData: additionalData) - label.setWithJSON(dictionary.dictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData) - } } diff --git a/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/CheckboxModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift diff --git a/MVMCoreUI/Atoms/Views/CircleProgressModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CircleProgressModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/CircleProgressModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/CircleProgressModel.swift diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift similarity index 89% rename from MVMCoreUI/Atoms/Views/DashLine.swift rename to MVMCoreUI/Atomic/Atoms/Views/DashLine.swift index 63b28dbd..86d2fd61 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/DashLine.swift @@ -87,12 +87,6 @@ open class DashLine: View { isHidden = false } - 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 } - set(with: model, delegateObject, additionalData) - } - - //MARK: - MVMCoreMoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let dashLineModel = dashModel else { diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/DashLineModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/DashLineModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/DashLineModel.swift diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atomic/Atoms/Views/GraphView.swift similarity index 95% rename from MVMCoreUI/Atoms/Views/GraphView.swift rename to MVMCoreUI/Atomic/Atoms/Views/GraphView.swift index 997c58d0..3cf22d79 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/GraphView.swift @@ -32,11 +32,6 @@ import UIKit createGraphCircle(model) rotationAnimation(model) } - - override open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: CircleProgressModel.self) else { return } - set(with: model, delegateObject, additionalData) - } class func getAngle(_ piValue: Double) -> Double { return piValue / (2.0 * Double.pi) * 360.0 diff --git a/MVMCoreUI/Atoms/Views/GraphViewAnimationHandler.swift b/MVMCoreUI/Atomic/Atoms/Views/GraphViewAnimationHandler.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/GraphViewAnimationHandler.swift rename to MVMCoreUI/Atomic/Atoms/Views/GraphViewAnimationHandler.swift diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/ImageViewModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift similarity index 98% rename from MVMCoreUI/Atoms/Views/Label/Label.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index c7e72204..3cea5dd8 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -12,7 +12,7 @@ import MVMCore public typealias ActionBlock = () -> () -@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol, ModelMoleculeViewProtocol { +@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol { //------------------------------------------------------ // MARK: - Properties @@ -128,6 +128,12 @@ public typealias ActionBlock = () -> () } } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + styleB2(true) + set(with: model, delegateObject, additionalData) + } + //------------------------------------------------------ // MARK: - Factory Functions //------------------------------------------------------ @@ -870,16 +876,6 @@ extension Label { accessibilityTraits = .staticText } - @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - clauses = [] - Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) - hero = json?["hero"] as? Int - } - - public func setAsMolecule() { - styleB2(true) - } - public func needsToBeConstrained() -> Bool { return true } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeActionModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeActionModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelAttributeColorModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelAttributeFontModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelAttributeImageModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeUnderlineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelAttributeUnderlineModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/Label/LabelModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelModel.swift diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift similarity index 85% rename from MVMCoreUI/Atoms/Views/LeftRightLabelView.swift rename to MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift index d8cebb51..a7c59cd3 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelView.swift @@ -40,11 +40,6 @@ import Foundation super.init(coder: aDecoder) } - public convenience init(json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { - self.init() - setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - override open func setupView() { super.setupView() @@ -162,23 +157,6 @@ import Foundation // MARK: - Atomization //------------------------------------------------------ - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject as? MVMCoreUIDelegateObject, additionalData: additionalData) - - guard let dictionary = json else { return } - - leftTextLabel.setWithJSON(dictionary.optionalDictionaryForKey("leftText"), delegateObject: delegateObject as? MVMCoreUIDelegateObject, additionalData: additionalData) - rightTextLabel.setWithJSON(dictionary.optionalDictionaryForKey("rightText"), delegateObject: delegateObject as? MVMCoreUIDelegateObject, additionalData: additionalData) - - if !leftTextLabel.hasText { - constrainRightLabel() - } else if !rightTextLabel.hasText { - constrainLeftLabel() - } - } - - //MARK: - MVMCoreMoleculeViewProtocol - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let leftRightLabelModel = model as? LeftRightLabelModel else { diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift similarity index 73% rename from MVMCoreUI/Atoms/Views/Line.swift rename to MVMCoreUI/Atomic/Atoms/Views/Line.swift index 37bf5688..0429c1c6 100644 --- a/MVMCoreUI/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -54,22 +54,10 @@ import UIKit 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 = LineModel.Style.init(rawValue: typeString) { - setStyle(type) - } else { - setStyle(.standard) - } - - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - + // MARK: - MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let lineModel = model as? LineModel { - setStyle(lineModel.type ?? .standard) + setStyle(lineModel.type) } super.set(with: model, delegateObject, additionalData) } @@ -78,13 +66,9 @@ import UIKit setStyle(.standard) } - open func copyBackgroundColor() -> Bool { - return false - } - - public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let type = json?.optionalStringForKey(KeyType), let style = LineModel.Style(rawValue: type) else { return 1 } - switch style { + public override static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + guard let type = (model as? LineModel)?.type else { return 1 } + switch type { case .none: return 0 case .medium: @@ -101,4 +85,8 @@ extension Line: MVMCoreUIViewConstrainingProtocol { open func needsToBeConstrained() -> Bool { return true } + + open func copyBackgroundColor() -> Bool { + return false + } } diff --git a/MVMCoreUI/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/LineModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/LineModel.swift diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift similarity index 90% rename from MVMCoreUI/Atoms/Views/MFLoadImageView.swift rename to MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift index d8415d2d..b8b5321d 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift @@ -8,7 +8,8 @@ import UIKit -@objcMembers open class MFLoadImageView: ViewConstrainingView, ModelMoleculeViewProtocol { +// TODO: Change to container instead of ViewConstraining without breaking legacy stack. +@objcMembers open class MFLoadImageView: ViewConstrainingView, MoleculeViewProtocol { public let loadingSpinner = MFLoadingSpinner(frame: .zero) public let imageView = MFTransparentGIFView(frame: .zero) public var addSizeConstraintsForAspectRatio = false @@ -46,6 +47,13 @@ import UIKit super.init(coder: aDecoder) } + required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.init(frame: .zero) + addSizeConstraintsForAspectRatio = true + pinEdges(.all) + set(with: model, delegateObject, additionalData) + } + public func pinEdges(_ edge: UIRectEdge) { edges = edge if edge == UIRectEdge.all { @@ -211,11 +219,7 @@ import UIKit public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.delegateObject = delegateObject - // TODO: Temporary, should be moved to init once we have type erasure ready. - setAsMolecule() - guard let imageModel = model as? ImageViewModel else { - return - } + guard let imageModel = model as? ImageViewModel else { return } if let accessibilityString = imageModel.accessibilityText { imageView.accessibilityLabel = accessibilityString imageView.accessibilityTraits = .staticText @@ -241,40 +245,6 @@ import UIKit } } - // MARK: - MVMCoreUIMoleculeViewProtocol functions - open override func setAsMolecule() { - addSizeConstraintsForAspectRatio = true - pinEdges(.all) - } - - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return json?.optionalCGFloatForKey("height") ?? 0 - } - - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - self.delegateObject = delegateObject - if let accessibilityString = json?.optionalStringForKey("accessibilityText") { - imageView.accessibilityLabel = accessibilityString - imageView.accessibilityTraits = .staticText - imageView.isAccessibilityElement = true - } - let width = json?.optionalCGFloatForKey("width") ?? imageWidth - let height = json?.optionalCGFloatForKey("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 let imageName = json?.optionalStringForKey("image"), shouldLoadImage(withName: imageName, width: width, height: height) { - imageView.image = nil - imageView.animatedImage = nil - loadImage(withName: imageName, format: json?.optionalStringForKey("imageFormat"), width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: json?.optionalStringForKey("fallbackImage")) - } - } - // MARK: - load functions public func loadImage(withName imageName: String?, format: String? = nil, width: NSNumber? = nil, height: NSNumber? = nil, customFallbackImage: String? = nil, allowServerParameters: Bool = false, localBundle: Bundle? = nil, completionHandler: MVMCoreGetImageBlock? = nil) { diff --git a/MVMCoreUI/Atoms/Views/MFTransparentGIFView.swift b/MVMCoreUI/Atomic/Atoms/Views/MFTransparentGIFView.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/MFTransparentGIFView.swift rename to MVMCoreUI/Atomic/Atoms/Views/MFTransparentGIFView.swift diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift similarity index 88% rename from MVMCoreUI/Atoms/Views/MultiProgress.swift rename to MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift index 02be560c..72f84f5e 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MultiProgress.swift @@ -63,7 +63,7 @@ import UIKit } } - //MARK: - MVMCoreMoleculeViewProtocol + //MARK: - MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let multiProgressModel = multiProgressModel else { @@ -81,8 +81,7 @@ import UIKit progressList = nil } - 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 } - set(with: model, delegateObject, additionalData) + public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return (model as? MultiProgressBarModel)?.thickness ?? 8 } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/MultiProgressModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift similarity index 76% rename from MVMCoreUI/Atoms/Views/ProgressBar.swift rename to MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift index 3f302135..1b9f1e74 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers open class ProgressBar: UIProgressView, MVMCoreViewProtocol, ModelMoleculeViewProtocol, MVMCoreUIMoleculeViewProtocol { +@objcMembers open class ProgressBar: UIProgressView, MVMCoreViewProtocol, MoleculeViewProtocol { var progressBarModel: ProgressBarModel? var thickness: CGFloat = 8.0 { @@ -32,7 +32,7 @@ import Foundation setupView() } - init() { + public init() { super.init(frame: .zero) setupView() } @@ -50,7 +50,7 @@ import Foundation public func updateView(_ size: CGFloat) { } - //MARK: - MVMCoreMoleculeViewProtocol + //MARK: - MoleculeViewProtocol public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let progressBarModel = model as? ProgressBarModel else { return @@ -63,12 +63,6 @@ import Foundation } } - // MARK: - MVMCoreUIMoleculeViewProtocol - 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 } - set(with: model, delegateObject, additionalData) - } - public func reset() { thickness = 8 progress = 0 @@ -76,7 +70,7 @@ import Foundation trackTintColor = UIColor.mfLightSilver() } - public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 8 } } diff --git a/MVMCoreUI/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift similarity index 100% rename from MVMCoreUI/Atoms/Views/ProgressBarModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift similarity index 89% rename from MVMCoreUI/Atoms/Views/Toggle.swift rename to MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 7e45c567..3d9a2f21 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -334,7 +334,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) } } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let toggleModel = model as? ToggleModel else { return @@ -342,49 +342,32 @@ public typealias ActionBlockConfirmation = () -> (Bool) self.model = model self.delegateObject = delegateObject - let toggleModelJSON = toggleModel.toJSON() FormValidator.setupValidation(molecule: toggleModel, delegate: delegateObject?.formHolderDelegate) - setWithJSON(toggleModelJSON, delegateObject: delegateObject, additionalData: additionalData) - } - - //TODO: change to setWith Model - public 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 color = dictionary["onTintColor"] as? String { - containerTintColor?.on = UIColor.mfGet(forHex: color) + guard let model = model as? ToggleModel else { return } + if let color = model.onTintColor?.uiColor { + containerTintColor?.on = color } - if let color = dictionary["offTintColor"] as? String { - containerTintColor?.off = UIColor.mfGet(forHex: color) + if let color = model.offTintColor?.uiColor { + containerTintColor?.off = color } - if let color = dictionary["onKnobTintColor"] as? String { - knobTintColor?.on = UIColor.mfGet(forHex: color) + if let color = model.onKnobTintColor?.uiColor { + knobTintColor?.on = color } - if let color = dictionary["offKnobTintColor"] as? String { - knobTintColor?.off = UIColor.mfGet(forHex: color) + if let color = model.offKnobTintColor?.uiColor { + knobTintColor?.off = color } - if let state = dictionary["state"] as? Bool { - changeStateNoAnimation(state) - } + changeStateNoAnimation(model.state) + isAnimated = model.animated + isEnabled = model.enabled - if let actionMap = dictionary.optionalDictionaryForKey("action") { + if let actionMap = model.action?.toJSON() { didToggleAction = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } - - if let isAnimated = dictionary["isAnimated"] as? Bool { - self.isAnimated = isAnimated - } - - if let isEnabled = dictionary["isEnabled"] as? Bool{ - self.isEnabled = isEnabled - } } public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -392,13 +375,8 @@ public typealias ActionBlockConfirmation = () -> (Bool) } } -// MARK: - MVMCoreUIMoleculeViewProtocol +// MARK: - MVMCoreUIViewConstrainingProtocol extension Toggle { - - - public class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return Self.getContainerHeight() - } public func needsToBeConstrained() -> Bool { return true diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift similarity index 63% rename from MVMCoreUI/Atoms/Views/ToggleModel.swift rename to MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift index 5e67be8a..334ba00f 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift @@ -8,25 +8,37 @@ import UIKit -public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { +public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol { public static var identifier: String = "toggle" public var backgroundColor: Color? public var state: Bool = true + public var animated: Bool = true + public var enabled: Bool = true public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? public var fieldKey: String? public var groupName: String? = FormValidator.defaultGroupName public var baseValue: AnyHashable? + public var onTintColor: Color? + public var offTintColor: Color? + public var onKnobTintColor: Color? + public var offKnobTintColor: Color? private enum CodingKeys: String, CodingKey { case moleculeName case state + case animated + case enabled case action case backgroundColor case fieldKey case alternateAction case groupName + case onTintColor + case offTintColor + case onKnobTintColor + case offKnobTintColor } public func formFieldValue() -> AnyHashable? { @@ -42,6 +54,12 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { self.state = state } + if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + self.enabled = enabled + } + if let animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) { + self.animated = animated + } action = try typeContainer.decodeModelIfPresent(codingKey: .action) alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) @@ -49,6 +67,10 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } + onTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onTintColor) + offTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offTintColor) + onKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onKnobTintColor) + offKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offKnobTintColor) } public func encode(to encoder: Encoder) throws { @@ -60,5 +82,9 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { try container.encode(state, forKey: .state) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(onTintColor, forKey: .onTintColor) + try container.encodeIfPresent(onKnobTintColor, forKey: .onKnobTintColor) + try container.encodeIfPresent(onKnobTintColor, forKey: .onKnobTintColor) + try container.encodeIfPresent(offKnobTintColor, forKey: .offKnobTintColor) } } diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift new file mode 100644 index 00000000..e6806e0c --- /dev/null +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -0,0 +1,184 @@ +// +// MoleculeObjectMapping.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 10/28/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class MoleculeObjectMapping: NSObject { + + public var moleculeMapping: [String: MoleculeViewProtocol.Type] = [:] + + /// Returns the mapping object stored in the singleton + public static func shared() -> Self? { + return MVMCoreActionUtility.initializerClassCheck(CoreUIObject.sharedInstance()?.moleculeMap, classToVerify: self) as? Self + } + + /// Registers the model with the model registry and the view with the mapper. + func register(viewClass: V.Type, viewModelClass: M.Type) { + try? ModelRegistry.register(viewModelClass) + moleculeMapping.updateValue(viewClass, forKey: viewModelClass.identifier) + } + + /// Returns the type of molecule view for the given model + func getMoleculeClass(_ model: MoleculeModelProtocol) -> MoleculeViewProtocol.Type? { + return moleculeMapping[model.moleculeName] + } + + /// Creates a molecule with the given model. + func createMolecule(_ model: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> MoleculeViewProtocol? { + guard let type = moleculeMapping[model.moleculeName] else { return nil } + return type.init(model: model, delegateObject, additionalData) + } + + /// Call to register all of the CoreUI molecules. + public static func registerObjects() { + // Stacks + MoleculeObjectMapping.shared()?.register(viewClass: MoleculeStackView.self, viewModelClass: MoleculeStackModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Stack.self, viewModelClass: StackModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) + + // Label + MoleculeObjectMapping.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) + // need to move labelattributemodel to different method + try? ModelRegistry.register(LabelAttributeFontModel.self) + try? ModelRegistry.register(LabelAttributeColorModel.self) + try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... + try? ModelRegistry.register(LabelAttributeUnderlineModel.self) + try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) + try? ModelRegistry.register(LabelAttributeActionModel.self) + + // Buttons + MoleculeObjectMapping.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) + + // Entry Field + MoleculeObjectMapping.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextEntryFieldModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: MdnEntryField.self, viewModelClass: MdnEntryFieldModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: DigitEntryField.self, viewModelClass: DigitEntryFieldModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ItemDropdownEntryField.self, viewModelClass: ItemDropdownEntryFieldModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) + + // Other Atoms + MoleculeObjectMapping.shared()?.register(viewClass: ProgressBar.self, viewModelClass: ProgressBarModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: MultiProgress.self, viewModelClass: MultiProgressBarModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: CaretView.self, viewModelClass: CaretViewModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: DashLine.self, viewModelClass: DashLineModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: MFLoadImageView.self, viewModelClass: ImageViewModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Line.self, viewModelClass: LineModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: GraphView.self, viewModelClass: CircleProgressModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) + + // Horizontal Combination Molecules + MoleculeObjectMapping.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ImageHeadlineBody.self, viewModelClass: ImageHeadlineBodyModel.self) + + // Vertical Combination Molecules + MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: HeadLineBodyCaretLinkImage.self, viewModelClass: HeadlineBodyCaretLinkImageModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: EyebrowHeadlineBodyLink.self, viewModelClass: EyebrowHeadlineBodyLinkModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLink.self, viewModelClass: HeadlineBodyLinkModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyButton.self, viewModelClass: HeadlineBodyButtonModel.self) + + // Left Right Molecules + MoleculeObjectMapping.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: LeftRightLabelView.self, viewModelClass: LeftRightLabelModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: LabelToggle.self, viewModelClass: LabelToggleModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) + + // List items + MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: DropDownFilterTableViewCell.self, viewModelClass: DropDownListItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: AccordionMoleculeTableViewCell.self, viewModelClass: AccordionListItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: TabsTableViewCell.self, viewModelClass: TabsListItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.self) + + // Other Items + MoleculeObjectMapping.shared()?.register(viewClass: MoleculeStackItem.self, viewModelClass: MoleculeStackItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: MoleculeCollectionViewCell.self, viewModelClass: CarouselItemModel.self) + + // Other Container Molecules + MoleculeObjectMapping.shared()?.register(viewClass: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: FooterView.self, viewModelClass: FooterModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Scroller.self, viewModelClass: ScrollerModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ModuleMolecule.self, viewModelClass: ModuleMoleculeModel.self) + + // Other Molecules + MoleculeObjectMapping.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self) + + // Other Organisms + MoleculeObjectMapping.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self) + + // Designed List Items + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) + + // Designed Section Dividers + MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + + // Designed Headers + MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) + + // TODO: Need View + try? ModelRegistry.register(TabsModel.self) + + // Helper models + try? ModelRegistry.register(RuleRequiredModel.self) + try? ModelRegistry.register(RuleAnyRequiredModel.self) + try? ModelRegistry.register(RuleAnyValueChangedModel.self) + try? ModelRegistry.register(RuleAllValueChangedModel.self) + try? ModelRegistry.register(RuleEqualsModel.self) + try? ModelRegistry.register(RuleRegexModel.self) + + // Actions + try? ModelRegistry.register(ActionTopAlertModel.self) + try? ModelRegistry.register(ActionCollapseNotificationModel.self) + try? ModelRegistry.register(ActionOpenPanelModel.self) + } + + /// Convenience function to get required modules for a give model + public static func getRequiredModules(for model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + guard let model = model else { return nil } + return MoleculeObjectMapping.shared()?.getMoleculeClass(model)?.requiredModules(with: model, delegateObject, error: error) + } + + /// Convenience function to add require modules for the given model to the passed in array. + public static func addRequiredModules(for model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, moduleList: inout [String]?, errorList: inout [MVMCoreErrorObject]?) { + guard let model = model else { return } + let error: AutoreleasingUnsafeMutablePointer? = nil + if let modules = getRequiredModules(for: model, delegateObject, error: error) { + moduleList?.append(contentsOf: modules) + } + if let error = error?.pointee { + errorList?.append(error) + } + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyText.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyText.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyText.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyTextModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyTextModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/HeadersH2NoButtonsBodyTextModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift similarity index 97% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index 8d7fb539..85558caa 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -32,7 +32,7 @@ import Foundation stack.restack() } - // MARK:- MVMCoreUIMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinksModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaret.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethodModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinks.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextAllTextAndLinksModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift similarity index 96% rename from MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift index 5ad5d182..8ca28609 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift @@ -39,7 +39,7 @@ import Foundation } //------------------------------------------------- - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //------------------------------------------------- open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) @@ -50,7 +50,7 @@ import Foundation } //------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //------------------------------------------------- open override func reset() { super.reset() diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift similarity index 97% rename from MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift index 610821b3..43836cf0 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift @@ -32,7 +32,7 @@ import UIKit rightLabel.updateView(size) } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListTwoColumnPriceDetailsModel else { return } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/LockUps/ListProgressBarData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/ListProgressBarData.swift similarity index 97% rename from MVMCoreUI/Molecules/DesignedComponents/LockUps/ListProgressBarData.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/ListProgressBarData.swift index 48f734ad..16b1e93e 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/LockUps/ListProgressBarData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/ListProgressBarData.swift @@ -44,7 +44,7 @@ import UIKit } //----------------------------------------------------- - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //----------------------------------------------------- open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) @@ -59,7 +59,7 @@ import UIKit } //----------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //----------------------------------------------------- override open func reset() { super.reset() diff --git a/MVMCoreUI/Molecules/DesignedComponents/LockUps/ListProgressBarDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/ListProgressBarDataModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/LockUps/ListProgressBarDataModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/ListProgressBarDataModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDivider.swift similarity index 96% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDivider.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDivider.swift index 8e37c16a..f857b167 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDivider.swift @@ -38,7 +38,7 @@ import Foundation stack.restack() } - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListFourColumnDataUsageDividerModel else { return } @@ -52,7 +52,7 @@ import Foundation return 121 } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() label1.styleBoldBodySmall(true) diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsection.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsection.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsection.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsection.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift similarity index 98% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift index cc904a77..a641f60f 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDivider.swift @@ -35,7 +35,7 @@ import Foundation stack.restack() } - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListThreeColumnPlanDataDividerModel else { return } diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift similarity index 100% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift similarity index 98% rename from MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift rename to MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index acaa0923..d84c7dc0 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -49,11 +49,6 @@ open class DoughnutChart: View { clearLayers() } - public override func setAsMolecule() { - titleLabel.setAsMolecule() - subTitleLabel.setAsMolecule() - } - open override func setupView() { super.setupView() guard labelContainer.superview == nil else { diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Doughnut/DoughnutChartModel.swift rename to MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift diff --git a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift similarity index 93% rename from MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift rename to MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift index 7d279759..280385cb 100644 --- a/MVMCoreUI/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift @@ -80,11 +80,6 @@ import Foundation stack.verticalAlignment = .fill colorLablesStack.set(with: stack, delegateObject, additionalData) } - - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: DoughnutChartModel.self) else { return } - set(with: model, delegateObject, additionalData) - } } extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { @@ -145,10 +140,6 @@ class ColorViewWithLabel: View { label.reset() } - override func setAsMolecule() { - label.setAsMolecule() - } - override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let chartItemModel = model as? DoughnutChartItemModel else { diff --git a/MVMCoreUI/Molecules/FooterModel.swift b/MVMCoreUI/Atomic/Molecules/FooterModel.swift similarity index 100% rename from MVMCoreUI/Molecules/FooterModel.swift rename to MVMCoreUI/Atomic/Molecules/FooterModel.swift diff --git a/MVMCoreUI/Atomic/Molecules/FooterView.swift b/MVMCoreUI/Atomic/Molecules/FooterView.swift new file mode 100644 index 00000000..f54a84e5 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/FooterView.swift @@ -0,0 +1,12 @@ +// +// FooterView.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/11/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class FooterView: MoleculeContainer { +} diff --git a/MVMCoreUI/Molecules/Header.swift b/MVMCoreUI/Atomic/Molecules/Header.swift similarity index 86% rename from MVMCoreUI/Molecules/Header.swift rename to MVMCoreUI/Atomic/Molecules/Header.swift index c878c5ff..63a13fbc 100644 --- a/MVMCoreUI/Molecules/Header.swift +++ b/MVMCoreUI/Atomic/Molecules/Header.swift @@ -12,14 +12,14 @@ open class HeaderView: Container { public let line = Line() /// Convenience for doing some default setting - open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? + open var molecule: MoleculeViewProtocol? var headerModel: HeaderModel? { get { return model as? HeaderModel } } /// Convenience function to add a molecule to the view. - open func addMolecule(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + open func addMolecule(_ molecule: MoleculeViewProtocol) { addSubview(molecule) containerHelper.constrainView(molecule) self.molecule = molecule @@ -29,7 +29,7 @@ open class HeaderView: Container { open override func updateView(_ size: CGFloat) { super.updateView(size) line.updateView(size) - molecule?.updateView(size) + (molecule as? MVMCoreViewProtocol)?.updateView(size) } public override func setupView() { @@ -41,14 +41,14 @@ open class HeaderView: Container { NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() line.setStyle(.heavy) - molecule?.reset?() + molecule?.reset() } - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let headerModel = headerModel else { return } diff --git a/MVMCoreUI/Molecules/HeaderModel.swift b/MVMCoreUI/Atomic/Molecules/HeaderModel.swift similarity index 100% rename from MVMCoreUI/Molecules/HeaderModel.swift rename to MVMCoreUI/Atomic/Molecules/HeaderModel.swift diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift similarity index 96% rename from MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift rename to MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift index 469b1929..c73557e0 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift @@ -41,7 +41,7 @@ import UIKit imageView.updateView(size) } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() headlineBody.reset() @@ -50,7 +50,7 @@ import UIKit imageView.reset() } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 95 } diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift similarity index 100% rename from MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift rename to MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift diff --git a/MVMCoreUI/Molecules/RadioButtonLabel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift similarity index 100% rename from MVMCoreUI/Molecules/RadioButtonLabel.swift rename to MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabel.swift diff --git a/MVMCoreUI/Molecules/RadioButtonLabelModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift similarity index 100% rename from MVMCoreUI/Molecules/RadioButtonLabelModel.swift rename to MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift similarity index 100% rename from MVMCoreUI/Molecules/HorizontalCombinationViews/TabsModel.swift rename to MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift similarity index 97% rename from MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift rename to MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 98160441..285c429c 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -89,7 +89,7 @@ import UIKit equalWidthConstraint?.isActive = false } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() setDefault() @@ -100,7 +100,7 @@ import UIKit return .center } - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let model = model as? TwoButtonViewModel, let buttonModel = model.primaryButton ?? model.secondaryButton else { return 0 } diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift similarity index 100% rename from MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift rename to MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift diff --git a/MVMCoreUI/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionListItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/AccordionListItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/AccordionListItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift rename to MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift diff --git a/MVMCoreUI/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/CarouselItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift rename to MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownListItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/DropDownListItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/DropDownListItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/ListItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift similarity index 85% rename from MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift rename to MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift index cf1779be..219617ec 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift @@ -8,10 +8,9 @@ import UIKit -open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeViewProtocol, ModelMoleculeViewProtocol { +open class MoleculeCollectionViewCell: UICollectionViewCell, MoleculeViewProtocol { - open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? - open var json: [AnyHashable: Any]? + open var molecule: MoleculeViewProtocol? public let containerHelper = ContainerHelper() // In updateView, will set padding to default. @@ -69,10 +68,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let collectionModel = model as? CarouselItemModel else { - return - } - + guard let collectionModel = model as? CarouselItemModel else { return } if let useHorizontalMargins = collectionModel.useHorizontalMargins { updateViewHorizontalDefaults = useHorizontalMargins } @@ -92,23 +88,22 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi } if molecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(collectionModel.molecule, delegateObject, false) { + if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(collectionModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { contentView.insertSubview(moleculeView, at: 0) containerHelper.constrainView(moleculeView) molecule = moleculeView } } else { - (molecule as? ModelMoleculeViewProtocol)?.set(with: collectionModel.molecule, delegateObject, additionalData) + molecule?.set(with: collectionModel.molecule, delegateObject, additionalData) } - guard let molecule = molecule else { return } - containerHelper.set(with: json, for: molecule) - + guard let molecule = molecule as? (UIView & MVMCoreUIViewConstrainingProtocol) else { return } + containerHelper.set(with: collectionModel, for: molecule) accessibilityElements = molecule.subviews } public func reset() { - molecule?.reset?() + molecule?.reset() updateViewVerticalDefaults = true updateViewHorizontalDefaults = true backgroundColor = .white @@ -116,14 +111,14 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi 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 else { + let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { return nil } return moleculeClass.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName } public func updateView(_ size: CGFloat) { - molecule?.updateView(size) + (molecule as? MVMCoreViewProtocol)?.updateView(size) MFStyler.setDefaultMarginsFor(contentView, size: size, horizontal: updateViewHorizontalDefaults, vertical: updateViewVerticalDefaults) } diff --git a/MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeListItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/MoleculeListItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/MoleculeListItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItem.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeStackItem.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/MoleculeStackItem.swift rename to MVMCoreUI/Atomic/Molecules/Items/MoleculeStackItem.swift diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeStackItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/MoleculeStackItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift similarity index 58% rename from MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift rename to MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift index 33229092..4534a506 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift @@ -11,7 +11,7 @@ import UIKit @objcMembers open class MoleculeTableViewCell: TableViewCell { - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -21,8 +21,8 @@ import UIKit } if molecule != nil { - (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) - } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { + molecule?.set(with: castModel.molecule, delegateObject, additionalData) + } else if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(castModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { addMolecule(moleculeView) } super.set(with: model, delegateObject, additionalData) @@ -31,23 +31,23 @@ import UIKit public override class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moleculeModel = (model as? MoleculeListItemModel)?.molecule else { return "\(self)<>" } - let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type - let moleculeName = className?.nameForReuse(with: moleculeModel, delegateObject) ?? moleculeModel.moleculeName ?? "" + let className = MoleculeObjectMapping.shared()?.getMoleculeClass(moleculeModel) + let moleculeName = className?.nameForReuse(with: 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) + public static func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + guard let moleculeModel = (model as? MoleculeListItemModel)?.molecule, + let theClass = MoleculeObjectMapping.shared()?.getMoleculeClass(moleculeModel) else { return nil } - return theClass.requiredModules?(moleculeJSON, delegateObject: delegateObject, error: error) + return theClass.requiredModules(with: moleculeModel, delegateObject, error: error) } public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { guard let moleculeModel = (model as? MoleculeContainerModel)?.molecule, - let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type, + let classType = MoleculeObjectMapping.shared()?.getMoleculeClass(moleculeModel), let height = classType.estimatedHeight(with: moleculeModel, delegateObject) else { return 80 } diff --git a/MVMCoreUI/Molecules/Items/StackItem.swift b/MVMCoreUI/Atomic/Molecules/Items/StackItem.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/StackItem.swift rename to MVMCoreUI/Atomic/Molecules/Items/StackItem.swift diff --git a/MVMCoreUI/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/StackItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/Items/StackItemModelProtocol.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift rename to MVMCoreUI/Atomic/Molecules/Items/StackItemModelProtocol.swift diff --git a/MVMCoreUI/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift similarity index 100% rename from MVMCoreUI/Molecules/Items/TabsListItemModel.swift rename to MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift similarity index 97% rename from MVMCoreUI/Molecules/Items/TabsTableViewCell.swift rename to MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index cb6ee755..16794eb1 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -44,7 +44,8 @@ import UIKit public override func reset() { super.reset() - tabs.reset() + // TODO: Uncomment when finished with Ryan Tab pr. + //tabs.reset() } public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImage.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift similarity index 94% rename from MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImage.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift index b550ad0d..d693f2b5 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImage.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImage.swift @@ -45,11 +45,6 @@ import UIKit super.init(coder: aDecoder) } - public convenience init(json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.init() - setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - //------------------------------------------------------ // MARK: - View Lifecycle //------------------------------------------------------ @@ -113,7 +108,7 @@ import UIKit setDefaultState() } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 197 } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift similarity index 100% rename from MVMCoreUI/Molecules/LeftRightViews/ActionDetailWithImageModel.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabels.swift similarity index 95% rename from MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabels.swift index bbdda6af..c0018e9b 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabels.swift @@ -140,19 +140,14 @@ import UIKit width.isActive = true } - // MARK: - MVMCoreUIMoleculeViewProtocol - public override func setAsMolecule() { - super.setAsMolecule() - styleDefault() - } - + // MARK: - MoleculeViewProtocol public override func reset() { super.reset() styleDefault() spaceAboveMolecule = 6.0 spaceBelowMolecule = 6.0 - (middleView as? MVMCoreUIMoleculeViewProtocol)?.reset?() + (middleView as? MoleculeViewProtocol)?.reset() } func styleDefault() { @@ -170,8 +165,8 @@ import UIKit super.set(with: model, delegateObject, additionalData) guard let model = model as? CornerLabelsModel else { return } if middleView != nil { - (middleView as? ModelMoleculeViewProtocol)?.set(with: model, delegateObject, additionalData) - } else if let moleculeModel = model.molecule, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject) { + (middleView as? MoleculeViewProtocol)?.set(with: model, delegateObject, additionalData) + } else if let moleculeModel = model.molecule, let molecule = MoleculeObjectMapping.shared()?.createMolecule(moleculeModel, delegateObject: delegateObject, additionalData: additionalData) { addMiddleView(molecule) } diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift similarity index 100% rename from MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggle.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggle.swift similarity index 97% rename from MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggle.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggle.swift index bfed52e4..0d1f0089 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggle.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggle.swift @@ -37,7 +37,7 @@ import UIKit toggle.reset() } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? HeadlineBodyLinkToggleModel else { return } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift similarity index 100% rename from MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggle.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggle.swift similarity index 86% rename from MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggle.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggle.swift index bbfe0ffc..138d58ed 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggle.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggle.swift @@ -34,13 +34,12 @@ import UIKit NSLayoutConstraint.pinViews(leftView: headlineBody, rightView: toggle, alignTop: false) } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - guard let headlineBodyToggleModel = model as? HeadlineBodyToggleModel else { - return - } - setWithJSON(headlineBodyToggleModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) + guard let headlineBodyToggleModel = model as? HeadlineBodyToggleModel else { return } + headlineBody.set(with: headlineBodyToggleModel.headlineBody, delegateObject, additionalData) + toggle.set(with: headlineBodyToggleModel.toggle, delegateObject, additionalData) } open class override func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -50,7 +49,7 @@ import UIKit return max(toggleHeight, headlineBody) } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() headlineBody.reset() diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift similarity index 100% rename from MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggle.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggle.swift similarity index 95% rename from MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggle.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggle.swift index ccbdf9c3..9ce24d3b 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggle.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggle.swift @@ -31,7 +31,7 @@ import UIKit NSLayoutConstraint.pinViews(leftView: label, rightView: toggle, alignTop: false) } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let model = model as? LabelToggleModel, let toggleHeight = Toggle.estimatedHeight(with: model.toggle, delegateObject), @@ -47,7 +47,7 @@ import UIKit toggle.set(with: labelToggleModel.toggle, delegateObject, additionalData) } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() label.reset() diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift similarity index 100% rename from MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift rename to MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Atomic/Molecules/ModuleMolecule.swift similarity index 84% rename from MVMCoreUI/Molecules/ModuleMolecule.swift rename to MVMCoreUI/Atomic/Molecules/ModuleMolecule.swift index e92f41da..7374b067 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Atomic/Molecules/ModuleMolecule.swift @@ -10,7 +10,7 @@ import UIKit open class ModuleMolecule: Container { - open var moduleMolecule: (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol)? + open var moduleMolecule: MoleculeViewProtocol? var moduleMoleculeModel: ModuleMoleculeModel? { get { return model as? ModuleMoleculeModel } } @@ -29,10 +29,10 @@ open class ModuleMolecule: Container { } if moduleMolecule == nil { - if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moduleModel, delegateObject, false) { + if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(moduleModel, delegateObject: delegateObject, additionalData: additionalData) { addSubview(moleculeView) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values)) - moduleMolecule = moleculeView as? (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol) + moduleMolecule = moleculeView isAccessibilityElement = false if moleculeView.accessibilityElements != nil { @@ -50,7 +50,7 @@ open class ModuleMolecule: Container { guard let moduleMolecule = model as? ModuleMoleculeModel, let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName), - let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, + let classType = MoleculeObjectMapping.shared()?.getMoleculeClass(moduleModel), let height = classType.estimatedHeight(with: moduleModel, delegateObject) else { // Critical error return 0 @@ -61,7 +61,7 @@ open class ModuleMolecule: Container { public override class func nameForReuse(with 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, + let classType = MoleculeObjectMapping.shared()?.getMoleculeClass(moduleModel), let name = classType.nameForReuse(with: moduleModel, delegateObject) else { // Critical error return "moduleMolecule<>" diff --git a/MVMCoreUI/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/ModuleMoleculeModel.swift similarity index 100% rename from MVMCoreUI/Molecules/ModuleMoleculeModel.swift rename to MVMCoreUI/Atomic/Molecules/ModuleMoleculeModel.swift diff --git a/MVMCoreUI/Molecules/MoleculeHeaderModel.swift b/MVMCoreUI/Atomic/Molecules/MoleculeHeaderModel.swift similarity index 100% rename from MVMCoreUI/Molecules/MoleculeHeaderModel.swift rename to MVMCoreUI/Atomic/Molecules/MoleculeHeaderModel.swift diff --git a/MVMCoreUI/Molecules/MoleculeHeaderView.swift b/MVMCoreUI/Atomic/Molecules/MoleculeHeaderView.swift similarity index 71% rename from MVMCoreUI/Molecules/MoleculeHeaderView.swift rename to MVMCoreUI/Atomic/Molecules/MoleculeHeaderView.swift index 3404afc3..bff5a14f 100644 --- a/MVMCoreUI/Molecules/MoleculeHeaderView.swift +++ b/MVMCoreUI/Atomic/Molecules/MoleculeHeaderView.swift @@ -30,13 +30,13 @@ public class MoleculeHeaderView: MoleculeContainer { NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() line.setStyle(.heavy) } - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let headerModel = headerModel else { return } @@ -44,11 +44,4 @@ public class MoleculeHeaderView: MoleculeContainer { line.set(with: lineModel, delegateObject, additionalData) } } - - 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 - } } diff --git a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/NavigationItemModelProtocol.swift similarity index 100% rename from MVMCoreUI/Molecules/NavigationItemModelProtocol.swift rename to MVMCoreUI/Atomic/Molecules/NavigationItemModelProtocol.swift diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Atomic/Molecules/Scroller.swift similarity index 85% rename from MVMCoreUI/Molecules/Scroller.swift rename to MVMCoreUI/Atomic/Molecules/Scroller.swift index 6184f3d0..56c33df7 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Atomic/Molecules/Scroller.swift @@ -32,9 +32,9 @@ import UIKit public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let casteModel = model as? ScrollerModel { if view != nil { - (view as? ModelMoleculeViewProtocol)?.set(with: casteModel.molecule, delegateObject, additionalData) + (view as? MoleculeViewProtocol)?.set(with: casteModel.molecule, delegateObject, additionalData) } else { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(casteModel.molecule, delegateObject) { + if let molecule = MoleculeObjectMapping.shared()?.createMolecule(casteModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { contentView.addSubview(molecule) molecule.translatesAutoresizingMaskIntoConstraints = false containerHelper.constrainView(molecule) diff --git a/MVMCoreUI/Molecules/ScrollerModel.swift b/MVMCoreUI/Atomic/Molecules/ScrollerModel.swift similarity index 100% rename from MVMCoreUI/Molecules/ScrollerModel.swift rename to MVMCoreUI/Atomic/Molecules/ScrollerModel.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift similarity index 96% rename from MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 49b08b44..ebe54017 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -41,7 +41,7 @@ import UIKit } //-------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- open override func reset() { @@ -53,7 +53,7 @@ import UIKit } //-------------------------------------------------- - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift similarity index 97% rename from MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index 00ccaeeb..8f36c0a3 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -65,14 +65,14 @@ import Foundation sendSubviewToBack(backgroundImageView) } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() headlineBody.reset() backgroundImageView.reset() } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 320 } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift similarity index 82% rename from MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift index a120807d..904a3c65 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -121,7 +121,7 @@ open class HeadlineBody: View { } //-------------------------------------------------- - // MARK: - ModelMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -139,28 +139,8 @@ open class HeadlineBody: View { messageLabel.setOptional(with: 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() stylePageHeader() } - - public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 58 - } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift similarity index 90% rename from MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift index 90183e6e..35522146 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift @@ -15,7 +15,7 @@ import UIKit //------------------------------------------------------ let headlineBody = HeadlineBody(frame: .zero) - let button = PrimaryButton.primaryTinyButton(false)! + let button = PillButton(frame: .zero) //------------------------------------------------------ // MARK: - Properties @@ -45,11 +45,6 @@ import UIKit super.init(coder: aDecoder) } - public convenience init(json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.init() - setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - //------------------------------------------------------ // MARK: - View Lifecycle //------------------------------------------------------ @@ -89,8 +84,7 @@ import UIKit headlineBody.headlineLabel.font = MFStyler.fontH3() headlineBody.messageLabel.font = MFStyler.fontB3() - button.setAsTiny(true) - button.setAsSecondaryCustom() + button.styleSecondary() button.isHidden = false buttonHeadlinePadding = PaddingTwo } @@ -107,7 +101,7 @@ import UIKit defaultState() } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 320 } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift new file mode 100644 index 00000000..51d011e8 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -0,0 +1,63 @@ +// +// HeadlineBodyButtonModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/22/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class HeadlineBodyButtonModel: MoleculeModelProtocol { + public static var identifier: String = "headlineBodyButton" + public var moleculeName: String = HeadlineBodyButtonModel.identifier + public var backgroundColor: Color? + + public var headlineBody: HeadlineBodyModel + public var button: ButtonModel + public var buttonHeadlinePadding: CGFloat + + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + + /// Defaults to set + public func setDefaults() { + button.size = .tiny + button.style = .secondary + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case headlineBody + case button + case buttonHeadlinePadding + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + 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) + button = try typeContainer.decode(ButtonModel.self, forKey: .button) + buttonHeadlinePadding = try typeContainer.decode(CGFloat.self, forKey: .buttonHeadlinePadding) + setDefaults() + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(headlineBody, forKey: .headlineBody) + try container.encode(button, forKey: .button) + try container.encode(buttonHeadlinePadding, forKey: .buttonHeadlinePadding) + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLink.swift similarity index 97% rename from MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLink.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLink.swift index e9bfabaa..da5014a9 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLink.swift @@ -58,7 +58,7 @@ import UIKit } } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol open override func reset() { super.reset() headlineBody.reset() @@ -66,7 +66,7 @@ import UIKit link.reset() } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? HeadlineBodyLinkModel else { return } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedList.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedList.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedList.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedList.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift similarity index 84% rename from MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift index 56cc0447..4ff045ce 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeStack.swift @@ -14,7 +14,8 @@ open class StringAndMoleculeStack: MoleculeStackView { guard let model = stackModel else { return } for stackItemModel in model.molecules { guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel, - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: stringAndMoleculeModel.molecule.moleculeName) as? (UIView & ModelMoleculeViewProtocol) else { + let molecule = MoleculeObjectMapping.shared()?.createMolecule(stringAndMoleculeModel.molecule, delegateObject: delegateObject + , additionalData: additionalData) else { // Throw error return } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift similarity index 94% rename from MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index 09ed8a7b..6db91703 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -11,7 +11,7 @@ import Foundation open class StringAndMoleculeView: View { var label = Label.commonLabelB2(true) var string: String - var molecule: UIView & ModelMoleculeViewProtocol + var molecule: MoleculeViewProtocol var leftWidthConstraint: NSLayoutConstraint? @Percent var percentage: CGFloat = 5 @@ -27,7 +27,7 @@ open class StringAndMoleculeView: View { } // MARK: - Inits - public init(string: String, molecule: UIView & ModelMoleculeViewProtocol) { + public init(string: String, molecule: MoleculeViewProtocol) { self.string = string self.molecule = molecule super.init(frame: .zero) @@ -73,7 +73,7 @@ open class StringAndMoleculeView: View { override open func reset() { super.reset() label.reset() - (molecule as? MVMCoreUIMoleculeViewProtocol)?.reset?() + molecule.reset() } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedList.swift diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift similarity index 100% rename from MVMCoreUI/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift rename to MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift similarity index 95% rename from MVMCoreUI/Organisms/Carousel.swift rename to MVMCoreUI/Atomic/Organisms/Carousel.swift index b4fa5c24..d1d3af1b 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -50,6 +50,8 @@ open class Carousel: View { // For adding pager public var bottomPin: NSLayoutConstraint? + public var delegateObject: MVMCoreUIDelegateObject? + // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() @@ -82,8 +84,9 @@ open class Carousel: View { } } - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + self.delegateObject = delegateObject super.set(with: model, delegateObject, additionalData) guard let carouselModel = model as? CarouselModel else { return } collectionView.backgroundColor = backgroundColor @@ -141,7 +144,7 @@ open class Carousel: View { 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) + pagingView = MoleculeObjectMapping.shared()?.createMolecule(molecule, delegateObject: delegateObject) as? (UIView & MVMCoreUIPagingProtocol) } addPaging(view: pagingView, position: (CGFloat(molecule?.position ?? 20))) } @@ -158,10 +161,10 @@ open class Carousel: View { // MARK: - Convenience /// Returns the (identifier, class) of the molecule for the given map. func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? { - guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) else { + guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { return nil } - return ((className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) + return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) } /// Sets the alignment from the string. @@ -272,11 +275,11 @@ extension Carousel: UICollectionViewDataSource { return UICollectionViewCell() } let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath) - if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol { - protocolCell.reset?() - protocolCell.set(with: moleculeInfo.molecule, nil, nil) - protocolCell.updateView(collectionView.bounds.width) + if let protocolCell = cell as? MoleculeViewProtocol { + protocolCell.reset() + protocolCell.set(with: moleculeInfo.molecule, delegateObject, nil) } + (cell as? MVMCoreViewProtocol)?.updateView(collectionView.bounds.width) setAccessiblity(cell, index: indexPath.row) return cell } diff --git a/MVMCoreUI/Organisms/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/CarouselModel.swift similarity index 100% rename from MVMCoreUI/Organisms/CarouselModel.swift rename to MVMCoreUI/Atomic/Organisms/CarouselModel.swift diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Atomic/Organisms/MoleculeStackModel.swift similarity index 100% rename from MVMCoreUI/Organisms/MoleculeStackModel.swift rename to MVMCoreUI/Atomic/Organisms/MoleculeStackModel.swift diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift similarity index 89% rename from MVMCoreUI/Organisms/MoleculeStackView.swift rename to MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift index 12d79dcd..0f13cde5 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Atomic/Organisms/MoleculeStackView.swift @@ -36,7 +36,7 @@ open class MoleculeStackView: Stack { override open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { - if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegateObject) as? MoleculeStackItem { + if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) as? MoleculeStackItem { stackItems.append(stackItem) } } diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift similarity index 95% rename from MVMCoreUI/Organisms/Stack.swift rename to MVMCoreUI/Atomic/Organisms/Stack.swift index 8e6df863..23797927 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -128,14 +128,14 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto } //-------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- open override func reset() { super.reset() backgroundColor = .clear for item in stackItems { - (item as? MVMCoreUIMoleculeViewProtocol)?.reset?() + (item as? MoleculeViewProtocol)?.reset() } } @@ -162,7 +162,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto } var name = "stack<" for case let item in model.molecules { - if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[item.moleculeName] as? ModelMoleculeViewProtocol.Type, + if let moleculeClass = MoleculeObjectMapping.shared()?.moleculeMapping[item.moleculeName], let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) { name.append(nameForReuse + ",") } else { @@ -181,7 +181,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto for case let item in model.molecules { if item.gone { continue } - let height = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(with: item, delegateObject) ?? 0 + let height = (MoleculeObjectMapping.shared()?.getMoleculeClass(item))?.estimatedHeight(with: item, delegateObject) ?? 0 if !horizontal { // Vertical stack aggregates the items let spacing = item.spacing ?? model.spacing @@ -198,7 +198,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto guard let model = model 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(with: item, delegateObject, error: error) { + if let modulesForMolecule = (MoleculeObjectMapping.shared()?.getMoleculeClass(item))?.requiredModules(with: item, delegateObject, error: error) { modules += modulesForMolecule } } @@ -216,7 +216,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto open 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)?.set(with: element, delegateObject, additionalData) + (stackItems[index] as? MoleculeViewProtocol)?.set(with: element, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Organisms/StackModel.swift b/MVMCoreUI/Atomic/Organisms/StackModel.swift similarity index 100% rename from MVMCoreUI/Organisms/StackModel.swift rename to MVMCoreUI/Atomic/Organisms/StackModel.swift diff --git a/MVMCoreUI/Organisms/StackModelProtocol.swift b/MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift similarity index 100% rename from MVMCoreUI/Organisms/StackModelProtocol.swift rename to MVMCoreUI/Atomic/Organisms/StackModelProtocol.swift diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift similarity index 88% rename from MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift rename to MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift index 435e5a24..e845f4f0 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift @@ -15,7 +15,7 @@ public protocol MoleculeDelegateProtocol { 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 + func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) //optional /// Asks the delegate to add or remove molecules. func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? @@ -25,7 +25,7 @@ public protocol MoleculeDelegateProtocol { extension MoleculeDelegateProtocol { - public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {} + public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {} public func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil } public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) {} diff --git a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift similarity index 55% rename from MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift rename to MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift index fbeadd96..1ee85184 100644 --- a/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift @@ -1,5 +1,5 @@ // -// ModelMoleculeViewProtocol.swift +// MoleculeViewProtocol.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 10/24/19. @@ -8,30 +8,54 @@ import Foundation -public protocol ModelMoleculeViewProtocol { +import UIKit +import MVMCore.MVMCoreViewProtocol + +public protocol MoleculeViewProtocol: UIView { + + /// Initializes the view with the model + init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) + + /// Sets the view with the model. func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) + + /// Resets to default state before set with json is called again. + func reset() + + /// Allows the molecule to set its name for reuse. Default could be moleculeName. static func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? + + /// For the molecule list to load more efficiently. static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? + + /// Can return the required modules static func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? } -extension ModelMoleculeViewProtocol { +extension MoleculeViewProtocol { + /// Calls set with model + public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + self.init(frame: .zero) + set(with: model, delegateObject, additionalData) + } + + /// Uses moleculeName public static func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model.moleculeName } + + // Do nothing, optionals. + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {} + public func reset() {} + public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } public static func requiredModules(with model: MoleculeModelProtocol, _ 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) - } + /// Temporary convenience function for helping bridge the gap for legacy code. public func setOptional(with model: T?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let model = model { set(with: model, delegateObject, additionalData) diff --git a/MVMCoreUI/Templates/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift similarity index 100% rename from MVMCoreUI/Templates/TemplateProtocol.swift rename to MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift similarity index 65% rename from MVMCoreUI/Templates/ListPageTemplateModel.swift rename to MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift index 57d99f26..a2cb3473 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift @@ -8,22 +8,14 @@ import Foundation -@objcMembers public class ListPageTemplateModel: MVMControllerModelProtocol { - - public var formRules: [FormGroupRule]? - public var formValidator: FormValidator? - +@objcMembers public class ListPageTemplateModel: TemplateModel { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public static var identifier: String = "list" - - public var pageType: String - public var screenHeading: String? - public var isAtomicTabs: Bool? - public var navigationItem: NavigationItemModelProtocol? - + public override class var identifier: String { + return "list" + } public var header: MoleculeModelProtocol? public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]? public var footer: MoleculeModelProtocol? @@ -34,7 +26,7 @@ import Foundation //-------------------------------------------------- public init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol & MoleculeModelProtocol]) { - self.pageType = pageType + super.init(pageType: pageType) self.screenHeading = screenHeading self.molecules = molecules } @@ -61,27 +53,20 @@ import Foundation 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) molecules = try typeContainer.decodeModelsIfPresent(codingKey: .molecules) - isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) header = try typeContainer.decodeModelIfPresent(codingKey: .header) footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(pageType, forKey: .pageType) - try container.encode(template, forKey: .template) - try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeModelsIfPresent(molecules, forKey: .molecules) - try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) try container.encodeModelIfPresent(header, forKey: .header) try container.encodeModelIfPresent(footer, forKey: .footer) try container.encode(line, forKey: .line) - try container.encodeIfPresent(formRules, forKey: .formRules) } } diff --git a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift similarity index 100% rename from MVMCoreUI/Templates/ModalMoleculeListTemplate.swift rename to MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig new file mode 100644 index 00000000..af43d0af --- /dev/null +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig @@ -0,0 +1,30 @@ +// +// ModalMoleculeListTemplate.swift +// MVMCoreUI +// +// Created by Ryan on 3/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class ModalMoleculeListTemplate: MoleculeListTemplate { + +<<<<<<< HEAD + override open func handleNewData() { + MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in + if let _ = self { + MVMCoreNavigationHandler.shared()?.removeCurrentViewController() + } +======= + public var closeButton: MFCustomButton? + + override open func newDataBuildScreen() { + super.newDataBuildScreen() + closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in + self?.dismiss() +>>>>>>> develop + }, verticalCentered: false) + super.handleNewData() + } +} diff --git a/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift similarity index 100% rename from MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift rename to MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift diff --git a/MVMCoreUI/Templates/MoleculeListCellProtocol.swift b/MVMCoreUI/Atomic/Templates/MoleculeListCellProtocol.swift similarity index 100% rename from MVMCoreUI/Templates/MoleculeListCellProtocol.swift rename to MVMCoreUI/Atomic/Templates/MoleculeListCellProtocol.swift diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift similarity index 81% rename from MVMCoreUI/Templates/MoleculeListTemplate.swift rename to MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 9503a4c6..f79211ea 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -46,7 +46,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, false) + let molecule = MoleculeObjectMapping.shared()?.createMolecule(headerModel, delegateObject: delegateObjectIVar) else { return super.viewForTop() } // Temporary, Default the horizontal padding @@ -59,7 +59,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) + let molecule = MoleculeObjectMapping.shared()?.createMolecule(footerModel, delegateObject: delegateObjectIVar) else { return super.viewForBottom() } return molecule @@ -101,7 +101,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { guard let moleculeInfo = moleculesInfo?[indexPath.row], - let estimatedHeight = (moleculeInfo.class as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(with: moleculeInfo.molecule, delegateObject() as? MVMCoreUIDelegateObject) + let estimatedHeight = (moleculeInfo.class as? MoleculeViewProtocol.Type)?.estimatedHeight(with: moleculeInfo.molecule, delegateObject() as? MVMCoreUIDelegateObject) else { return 0 } return estimatedHeight @@ -117,29 +117,20 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol let cell = tableView.dequeueReusableCell(withIdentifier: moleculeInfo.identifier) else { return UITableViewCell() } - let moleculeCell = cell as? MVMCoreUIMoleculeViewProtocol - moleculeCell?.reset?() - - if let protocolCell = cell as? MoleculeListCellProtocol { - protocolCell.setLines(with: templateModel?.line, delegateObject: selfDelegateObject, additionalData: nil, indexPath: indexPath) - } - - (moleculeCell as? ModelMoleculeViewProtocol)?.set(with: moleculeInfo.molecule, selfDelegateObject, nil) - moleculeCell?.updateView(tableView.bounds.width) + (cell as? MoleculeViewProtocol)?.reset() + (cell as? MoleculeListCellProtocol)?.setLines(with: templateModel?.line, delegateObject: delegateObjectIVar, additionalData: nil, indexPath: indexPath) + (cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil) + (cell as? MVMCoreViewProtocol)?.updateView(tableView.bounds.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells cell.layoutIfNeeded() return cell } open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { - - if let protocolCell = cell as? MoleculeListCellProtocol { - protocolCell.willDisplay() - } + (cell as? MoleculeListCellProtocol)?.willDisplay() } open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil) } @@ -149,7 +140,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol // MARK: - MoleculeDelegateProtocol //-------------------------------------------------- - open override func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { if let tableView = tableView { let point = molecule.convert(molecule.bounds.origin, to: tableView) @@ -215,8 +206,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? { guard let listItem = listItem, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) else { return nil } - let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName + let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(listItem) else { return nil } + let moleculeName = moleculeClass.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName return (moleculeName, moleculeClass, listItem) } @@ -250,19 +241,17 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol /// Gets modules required by the loadObject.pageJSON. open func requiredModules() -> [Any]? { + var modules: [String]? = [] + var errors: [MVMCoreErrorObject]? = nil + MoleculeObjectMapping.addRequiredModules(for: templateModel?.header, delegateObjectIVar, moduleList: &modules, errorList: &errors) + MoleculeObjectMapping.addRequiredModules(for: templateModel?.footer, delegateObjectIVar, moduleList: &modules, errorList: &errors) - let modules: NSMutableArray = [] - 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) - - if let molecules = loadObject?.pageJSON?.optionalArrayForKey(KeyMolecules) as? [[AnyHashable: Any]] { + if let molecules = templateModel?.molecules { for molecule in molecules { - MVMCoreUIMoleculeMappingObject.addRequiredModules(forJSON: molecule, delegateObject: delegate, moduleList: modules, errorList: nil) + MoleculeObjectMapping.addRequiredModules(for: molecule, delegateObjectIVar, moduleList: &modules, errorList: &errors) } } - return modules as? [Any] + return modules } } diff --git a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeStackCenteredTemplate.swift similarity index 100% rename from MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift rename to MVMCoreUI/Atomic/Templates/MoleculeStackCenteredTemplate.swift diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift similarity index 70% rename from MVMCoreUI/Templates/MoleculeStackTemplate.swift rename to MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift index c8d807cc..b26bbc8a 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift @@ -37,7 +37,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, false) else { + let molecule = MoleculeObjectMapping.shared()?.createMolecule(headerModel, delegateObject: delegateObjectIVar) else { return nil } return molecule @@ -58,7 +58,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, false) else { + let molecule = MoleculeObjectMapping.shared()?.createMolecule(footerModel, delegateObject: delegateObjectIVar) else { return nil } return molecule @@ -75,11 +75,11 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { /// Gets modules required by the loadObject.pageJSON. open func requiredModules() -> [Any]? { - let modules: NSMutableArray = [] - 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("stack"), delegateObject: delegate, moduleList: modules, errorList: nil) - return modules as? [Any] + var modules: [String]? = [] + var errors: [MVMCoreErrorObject]? = nil + MoleculeObjectMapping.addRequiredModules(for: templateModel?.header, delegateObjectIVar, moduleList: &modules, errorList: &errors) + MoleculeObjectMapping.addRequiredModules(for: templateModel?.footer, delegateObjectIVar, moduleList: &modules, errorList: &errors) + MoleculeObjectMapping.addRequiredModules(for: templateModel?.moleculeStack, delegateObjectIVar, moduleList: &modules, errorList: &errors) + return modules } } diff --git a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackCenteredPageTemplateModel.swift similarity index 100% rename from MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift rename to MVMCoreUI/Atomic/Templates/StackCenteredPageTemplateModel.swift diff --git a/MVMCoreUI/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift similarity index 100% rename from MVMCoreUI/Templates/StackPageTemplateModel.swift rename to MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift diff --git a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig new file mode 100644 index 00000000..504378cd --- /dev/null +++ b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig @@ -0,0 +1,58 @@ +// +// StackPageTemplate.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 11/22/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class StackPageTemplateModel: TemplateModel { + public override class var identifier: String { + return "stack" + } + + public var header: MoleculeModelProtocol? + public var moleculeStack: MoleculeStackModel + public var footer: MoleculeModelProtocol? + + public init(pageType: String, moleculeStack: MoleculeStackModel) { + self.moleculeStack = moleculeStack + super.init(pageType: pageType) + } + + private enum CodingKeys: String, CodingKey { +<<<<<<< HEAD +======= + case pageType + case template + case screenHeading +>>>>>>> develop + case header + case footer + case stack + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + moleculeStack = try typeContainer.decode(MoleculeStackModel.self, forKey: .stack) + header = try typeContainer.decodeModelIfPresent(codingKey: .header) + footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) + 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) +<<<<<<< HEAD +======= + try container.encode(pageType, forKey: .pageType) + try container.encode(template, forKey: .template) +>>>>>>> develop + try container.encode(moleculeStack, forKey: .stack) + try container.encodeModelIfPresent(header, forKey: .header) + try container.encodeModelIfPresent(footer, forKey: .footer) + } +} diff --git a/MVMCoreUI/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift similarity index 77% rename from MVMCoreUI/Templates/TemplateModel.swift rename to MVMCoreUI/Atomic/Templates/TemplateModel.swift index 053d45fc..224b902f 100644 --- a/MVMCoreUI/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -13,8 +13,11 @@ import Foundation return "" } public var pageType: String + public var template: String { + // Although this is done in the extension, it is needed for the encoding. + return Self.identifier + } public var screenHeading: String? - public var isAtomicTabs: Bool? public var navigationItem: NavigationItemModelProtocol? public var formRules: [FormGroupRule]? @@ -24,8 +27,8 @@ import Foundation private enum CodingKeys: String, CodingKey { case pageType + case template case screenHeading - case isAtomicTabs case formRules case navigationItem } @@ -34,17 +37,16 @@ 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) - isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs) formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) - navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem) + // navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(pageType, forKey: .pageType) + try container.encode(template, forKey: .template) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) - try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) try container.encodeIfPresent(formRules, forKey: .formRules) - try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem) + //try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem) } } diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift similarity index 100% rename from MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift rename to MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift similarity index 76% rename from MVMCoreUI/Templates/ThreeLayerTemplate.swift rename to MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift index ba35c971..8f963f5d 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Atomic/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, false) else { + let molecule = MoleculeObjectMapping.shared()?.createMolecule(headerModel, delegateObject: delegateObjectIVar) 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, false) else { + let molecule = MoleculeObjectMapping.shared()?.createMolecule(middleModel, delegateObject: delegateObjectIVar) 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, false) else { + let molecule = MoleculeObjectMapping.shared()?.createMolecule(footerModel, delegateObject: delegateObjectIVar) else { return nil } return molecule diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift deleted file mode 100644 index 84f4be33..00000000 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// 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: ActionModelProtocol, 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/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift b/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift deleted file mode 100644 index 6cf0df21..00000000 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton+MoleculeProtocolExtension.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// 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 set(with model: MoleculeModelProtocol, _ 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() - } - } - - 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/Atoms/TextFields/TextFieldModel.swift b/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift deleted file mode 100644 index 4d6f1fd0..00000000 --- a/MVMCoreUI/Atoms/TextFields/TextFieldModel.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// TextFieldModel.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/24/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -@objcMembers public class TextFieldModel: MoleculeModelProtocol { - - public static var identifier: String = "textField" - public var backgroundColor: Color? - public var moleculeName: String = TextFieldModel.identifier - public var editable: Bool? - public var disabled: Bool? - public var errorMsg: String? - public var label: String? - public var type: String? - public var value: String? - public var regex: String? - - public var required: Bool? - public var fieldKey: String? - public var groupName: String? -} diff --git a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift deleted file mode 100644 index 840a5d18..00000000 --- a/MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// 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: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - self.model = model - if let backgroundColor = model.backgroundColor { - self.backgroundColor = backgroundColor.uiColor - } - } -} - -extension ModelMoleculeViewProtocol where Self: MFView { - public func set(with 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 deleted file mode 100644 index 1b7ad307..00000000 --- a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch+Model.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// 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 set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let model = model as? ToggleModel else { return } - - FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) - setState(model.state, 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/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 8722b800..f4ab51c6 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -8,7 +8,7 @@ public typealias ButtonAction = (Button) -> () -@objcMembers open class Button: UIButton, MFButtonProtocol, ModelMoleculeViewProtocol { +@objcMembers open class Button: UIButton, MFButtonProtocol, MoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -86,7 +86,7 @@ public typealias ButtonAction = (Button) -> () } } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model @@ -111,6 +111,10 @@ public typealias ButtonAction = (Button) -> () open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } + + open func reset() { + backgroundColor = .clear + } } // MARK: - MVMCoreViewProtocol @@ -127,14 +131,6 @@ extension Button: MVMCoreViewProtocol { } } -// MARK: - MVMCoreUIMoleculeViewProtocol -extension Button: MVMCoreUIMoleculeViewProtocol { - - open func reset() { - backgroundColor = .clear - } -} - // MARK: AppleGuidelinesProtocol extension Button: AppleGuidelinesProtocol { diff --git a/MVMCoreUI/BaseClasses/ButtonModelProtocol.swift b/MVMCoreUI/BaseClasses/ButtonModelProtocol.swift index d16c2464..1288f4e3 100644 --- a/MVMCoreUI/BaseClasses/ButtonModelProtocol.swift +++ b/MVMCoreUI/BaseClasses/ButtonModelProtocol.swift @@ -9,6 +9,5 @@ import Foundation public protocol ButtonModelProtocol: EnableableModelProtocol { - var enabled: Bool { get set } var action: ActionModelProtocol { get set } } diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 265e56b3..29c7bad4 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class Control: UIControl, ModelMoleculeViewProtocol { +@objcMembers open class Control: UIControl, MoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -47,7 +47,7 @@ import UIKit } } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model.backgroundColor { @@ -66,6 +66,10 @@ import UIKit open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } + + open func reset() { + backgroundColor = .clear + } } // MARK: - AppleGuidelinesProtocol @@ -86,18 +90,3 @@ extension Control: MVMCoreViewProtocol { insetsLayoutMarginsFromSafeArea = false } } - -// 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) - } - } - - open func reset() { - backgroundColor = .clear - } -} diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index ebf25a3c..36aade11 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -8,9 +8,9 @@ import UIKit -@objcMembers open class TableViewCell: UITableViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol, ModelMoleculeViewProtocol { +@objcMembers open class TableViewCell: UITableViewCell, MoleculeViewProtocol, MoleculeListCellProtocol { - open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? + open var molecule: MoleculeViewProtocol? open var listItemModel: ListItemModelProtocol? public let containerHelper = ContainerHelper() @@ -86,7 +86,7 @@ import UIKit } /// Adds the molecule to the view. - open func addMolecule(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + open func addMolecule(_ molecule: MoleculeViewProtocol) { contentView.addSubview(molecule) containerHelper.constrainView(molecule) self.molecule = molecule @@ -139,7 +139,7 @@ import UIKit topSeparatorView?.updateView(size) bottomSeparatorView?.updateView(size) - molecule?.updateView(size) + (molecule as? MVMCoreViewProtocol)?.updateView(size) } open func setupView() { @@ -182,7 +182,7 @@ import UIKit } open func reset() { - molecule?.reset?() + molecule?.reset() backgroundColor = .white } diff --git a/MVMCoreUI/BaseClasses/TextField.swift b/MVMCoreUI/BaseClasses/TextField.swift index b1a13854..c571d52d 100644 --- a/MVMCoreUI/BaseClasses/TextField.swift +++ b/MVMCoreUI/BaseClasses/TextField.swift @@ -17,9 +17,6 @@ public protocol TextFieldDidDeleteProtocol: class { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - open var json: [AnyHashable: Any]? - private var initialSetupPerformed = false /// Set to true to hide the blinking textField cursor. @@ -87,23 +84,14 @@ extension TextField: MVMCoreViewProtocol { } } -/// MARK:- MVMCoreUIMoleculeViewProtocol -extension TextField: MVMCoreUIMoleculeViewProtocol { - - open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.json = json - - guard let dictionary = json else { return } - - if let backgroundColorString = dictionary.optionalStringForKey(KeyBackgroundColor) { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) - } - - if let text = dictionary[KeyText] as? String { - self.text = text +/// MARK:- MoleculeViewProtocol +extension TextField: MoleculeViewProtocol { + open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + if let color = model.backgroundColor?.uiColor { + backgroundColor = color } } - + open func reset() { backgroundColor = .clear } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index 860ce442..f68e942b 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class View: UIView, ModelMoleculeViewProtocol { +@objcMembers open class View: UIView, MoleculeViewProtocol { open var json: [AnyHashable: Any]? open var model: MoleculeModelProtocol? @@ -39,7 +39,7 @@ import UIKit } } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model if let backgroundColor = model.backgroundColor { @@ -58,6 +58,10 @@ import UIKit open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { return nil } + + open func reset() { + backgroundColor = .clear + } } // MARK:- MVMCoreViewProtocol @@ -72,23 +76,3 @@ extension View: MVMCoreViewProtocol { MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0) } } - -// MARK:- MVMCoreUIMoleculeViewProtocol -extension View: 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) - } - } - - open func reset() { - backgroundColor = .clear - } - - open func setAsMolecule() { - - } -} diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 333df798..3735f62d 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -16,12 +16,10 @@ import UIKit /// Set if this page is containted in a manager. public var manager: (UIViewController & MVMCoreViewManagerProtocol)? - public var selfDelegateObject: MVMCoreUIDelegateObject? + /// A temporary iVar backer for delegateObject() until we change the protocol + public var delegateObjectIVar: MVMCoreUIDelegateObject? public func delegateObject() -> DelegateObject? { - if selfDelegateObject == nil { - selfDelegateObject = MVMCoreUIDelegateObject.create(withDelegateForAll: self) - } - return selfDelegateObject + return delegateObjectIVar } public var formValidator: FormValidator? @@ -276,6 +274,9 @@ import UIKit // Presents from the bottom. modalPresentationStyle = MVMCoreGetterUtility.isOnIPad() ? UIModalPresentationStyle.formSheet : UIModalPresentationStyle.overCurrentContext + // Create the default delegate object. + delegateObjectIVar = MVMCoreUIDelegateObject.create(withDelegateForAll: self) + // Do some initial loading. if !initialLoadFinished { initialLoadFinished = true @@ -355,7 +356,7 @@ import UIKit open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { formValidator?.addFormParams(requestParameters: requestParameters) requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") - MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: selfDelegateObject) + MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: delegateObject()) } open func logAction(withActionInformation actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { @@ -383,7 +384,7 @@ import UIKit } // Needed otherwise when subclassed, the extension gets called. - open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {} + open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {} open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil } open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) {} open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) {} diff --git a/MVMCoreUI/Categories/UIStackView+Extension.swift b/MVMCoreUI/Categories/UIStackView+Extension.swift index e968fd7c..a793635a 100644 --- a/MVMCoreUI/Categories/UIStackView+Extension.swift +++ b/MVMCoreUI/Categories/UIStackView+Extension.swift @@ -8,7 +8,7 @@ import Foundation -extension UIStackView: MVMCoreUIMoleculeViewProtocol { +extension UIStackView: MoleculeViewProtocol { public func updateView(_ size: CGFloat) { for view in arrangedSubviews { (view as? MVMCoreViewProtocol)?.updateView(size) @@ -17,7 +17,7 @@ extension UIStackView: MVMCoreUIMoleculeViewProtocol { public func reset() { for view in arrangedSubviews { - (view as? MVMCoreUIMoleculeViewProtocol)?.reset?() + (view as? MoleculeViewProtocol)?.reset() } } } diff --git a/MVMCoreUI/Containers/Views/Container/Container.swift b/MVMCoreUI/Containers/Views/Container/Container.swift index a08cd651..eb05cd21 100644 --- a/MVMCoreUI/Containers/Views/Container/Container.swift +++ b/MVMCoreUI/Containers/Views/Container/Container.swift @@ -15,13 +15,18 @@ open class Container: View, ContainerProtocol { get { return model as? ContainerModelProtocol } } - // MARK:- ModelMoleculeViewProtocol + // MARK:- MoleculeViewProtocol override open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let containerModel = model as? ContainerModelProtocol else { return } containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol) } + override open func reset() { + super.reset() + (view as? MoleculeViewProtocol)?.reset() + } + // MARK:- ContainerProtocol open func alignHorizontal(_ alignment: UIStackView.Alignment) { containerHelper.alignHorizontal(alignment) @@ -62,21 +67,3 @@ public extension Container { 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/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index 773721f7..eae81741 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -273,7 +273,7 @@ import UIKit } //-------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -281,13 +281,3 @@ import UIKit 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/Containers/Views/MoleculeContainer.swift b/MVMCoreUI/Containers/Views/MoleculeContainer.swift index f98451dd..98ecfa28 100644 --- a/MVMCoreUI/Containers/Views/MoleculeContainer.swift +++ b/MVMCoreUI/Containers/Views/MoleculeContainer.swift @@ -14,28 +14,13 @@ open class MoleculeContainer: Container { 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 { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - return - } - if view == nil { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: false) { - addAndContain(molecule) - } - } else { - (view as? MVMCoreUIMoleculeViewProtocol)?.setWithJSON?(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) - } - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let casteModel = model as? MoleculeContainerModelProtocol { if view != nil { - (view as? ModelMoleculeViewProtocol)?.set(with: casteModel.molecule, delegateObject, additionalData) + (view as? MoleculeViewProtocol)?.set(with: casteModel.molecule, delegateObject, additionalData) } else { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(casteModel.molecule, delegateObject) { + if let molecule = MoleculeObjectMapping.shared()?.createMolecule(casteModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { addMolecule(molecule) } } @@ -45,16 +30,16 @@ open class MoleculeContainer: Container { public override static func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let containerModel = model as? MoleculeContainerModelProtocol, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, + let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(containerModel.molecule), let moleculeName = moleculeClass.nameForReuse(with: containerModel.molecule, delegateObject) else { - return "\(model.moleculeName ?? "moleculeContainer")<>" + return "\(model.moleculeName)<>" } - return "\(model.moleculeName ?? "moleculeContainer")<\(moleculeName)>" + return "\(model.moleculeName)<\(moleculeName)>" } public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let containerModel = model as? MoleculeContainerModelProtocol else { return 0 } - guard let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type, + guard let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(containerModel.molecule), let moleculeHeight = moleculeClass.estimatedHeight(with: containerModel.molecule, delegateObject) else { return (containerModel.topMarginPadding ?? 0) + (containerModel.bottomMarginPadding ?? 0) } @@ -63,7 +48,7 @@ open class MoleculeContainer: Container { public override class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let containerModel = model as? MoleculeContainerModelProtocol, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type else { return nil } + let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(containerModel.molecule) else { return nil } return moleculeClass.requiredModules(with: containerModel.molecule, delegateObject, error: error) } } diff --git a/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift b/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift index 05e506eb..30abf59d 100644 --- a/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift +++ b/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift @@ -32,7 +32,7 @@ extension MFViewController: MoleculeDelegateProtocol { } // These are required because swift will call the extension function otherwise. - @objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {} + public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {} @objc public func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {} @objc public func addMolecules(_ molecules: [[AnyHashable : Any]], indexPath: IndexPath, animation: UITableView.RowAnimation) {} diff --git a/MVMCoreUI/Legacy/Views/ButtonView.swift b/MVMCoreUI/Legacy/Views/ButtonView.swift index 088c4a00..4c489ae5 100644 --- a/MVMCoreUI/Legacy/Views/ButtonView.swift +++ b/MVMCoreUI/Legacy/Views/ButtonView.swift @@ -30,16 +30,7 @@ import UIKit primaryButton?.isEnabled = enabled } - public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) { - super.init(frame: .zero) - setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - // MARK: - MVMCoreViewProtocol - open override func reset() { - primaryButton?.reset() - } - open override func updateView(_ size: CGFloat) { super.updateView(size) MVMCoreDispatchUtility.performBlock(onMainThread: { @@ -53,26 +44,11 @@ import UIKit alignCenterHorizontal() } - // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setAsMolecule() { - super.setAsMolecule() - primaryButton?.setAsMolecule() - } - - open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - primaryButton?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - } - - public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 42 - } - + // MARK: - Constraining open override func copyBackgroundColor() -> Bool { return true } - // MARK: - Constraining func setupButton() { if let primaryButton = primaryButton, !subviews.contains(primaryButton) { addSubview(primaryButton) diff --git a/MVMCoreUI/Legacy/Views/LabelView.m b/MVMCoreUI/Legacy/Views/LabelView.m index d13ff39a..0bb98bd6 100644 --- a/MVMCoreUI/Legacy/Views/LabelView.m +++ b/MVMCoreUI/Legacy/Views/LabelView.m @@ -9,6 +9,7 @@ #import #import "MFStyler.h" #import + @interface LabelView () // Sets up the view. @@ -36,11 +37,6 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - [self.label setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; -} - - (void)alignLeft { [super alignLeft]; self.label.textAlignment = NSTextAlignmentLeft; diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Legacy/Views/LabelWithInternalButton.swift similarity index 92% rename from MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift rename to MVMCoreUI/Legacy/Views/LabelWithInternalButton.swift index 251f5b45..13a16a33 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Legacy/Views/LabelWithInternalButton.swift @@ -15,7 +15,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt @available(*, deprecated, message: "Use Label instead.") -@objcMembers open class LabelWithInternalButton: UIControl, MVMCoreViewProtocol, MFButtonProtocol, MVMCoreUIMoleculeViewProtocol { +@objcMembers open class LabelWithInternalButton: UIControl, MVMCoreViewProtocol, MFButtonProtocol, MoleculeViewProtocol { //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -585,59 +585,4 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt } setLabelAttributes() } - - //------------------------------------------------------ - // MARK: - Atomization - //------------------------------------------------------ - - // Default values for view. - @objc open func setAsMolecule() { - - } - - @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - // Configure class properties with JSON values - guard let dictionary = json else { return } - - if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String { - self.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) - } - - if let normalTextFont = dictionary["normalTextFont"] as? String, let normalSize = dictionary["normalSize"] as? CGFloat { - self.normalTextFont = UIFont(name: normalTextFont, size: normalSize) - } - - if let actionTextFont = dictionary["actionTextFont"] as? String, let actionSize = dictionary["actionSize"] as? CGFloat { - self.actionTextFont = UIFont(name: actionTextFont, size: actionSize) - } - - if let normalTextColorHex = dictionary["normalTextColor"] as? String { - self.normalTextColor = UIColor.mfGet(forHex: normalTextColorHex) - } - - if let actionTextColorHex = dictionary["actionTextColor"] as? String { - self.actionTextColor = UIColor.mfGet(forHex: actionTextColorHex) - } - - if let makeWholeViewClickable = dictionary["makeWholeViewClickable"] as? Bool { - self.makeWholeViewClickable = makeWholeViewClickable - } - - if let frontText = dictionary["frontText"] as? String { - self.frontText = frontText - } - - if let backText = dictionary["backText"] as? String { - self.backText = backText - } - - if let actionText = dictionary["actionText"] as? String { - self.actionText = actionText - } - - // Want this to be last because it has a willSet feature. - if let text = dictionary["text"] as? String { - self.text = text - } - } } diff --git a/MVMCoreUI/Legacy/Views/MFCustomButton.h b/MVMCoreUI/Legacy/Views/MFCustomButton.h index 9d08883d..c43f87bc 100644 --- a/MVMCoreUI/Legacy/Views/MFCustomButton.h +++ b/MVMCoreUI/Legacy/Views/MFCustomButton.h @@ -10,7 +10,6 @@ @import MVMCore.MVMCoreActionDelegateProtocol; #import #import -#import @class DelegateObject; typedef void (^ButtonTapBlock)(id _Nonnull sender); diff --git a/MVMCoreUI/Legacy/Views/MFDigitTextField.m b/MVMCoreUI/Legacy/Views/MFDigitTextField.m index 5f76e88b..931707f3 100644 --- a/MVMCoreUI/Legacy/Views/MFDigitTextField.m +++ b/MVMCoreUI/Legacy/Views/MFDigitTextField.m @@ -19,6 +19,7 @@ #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" #import + @import MVMCore.MVMCoreDispatchUtility; @interface MFDigitTextField () @@ -145,22 +146,6 @@ [self alignCenterHorizontal]; } -#pragma mark - Molecule - -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - NSNumber *digitsNumber = [json optionalNumberForKey:@"digits"]; - NSUInteger digits = digitsNumber ? digitsNumber.integerValue : 4; - if (digits != self.numberOfDigits) { - self.numberOfDigits = digits; - [self buildTextFieldsViewForSize:[MVMCoreUIUtility getWidth]]; - } - [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; -} - -+ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { - return 44; -} - #pragma mark - Getters - (NSString *)placeholder { diff --git a/MVMCoreUI/Legacy/Views/MFTextButton.h b/MVMCoreUI/Legacy/Views/MFTextButton.h index 1e81e1f0..6240adb4 100644 --- a/MVMCoreUI/Legacy/Views/MFTextButton.h +++ b/MVMCoreUI/Legacy/Views/MFTextButton.h @@ -10,7 +10,7 @@ #import @class MFSizeObject; -@interface MFTextButton : MFCustomButton +@interface MFTextButton : MFCustomButton @property (nonnull, strong, nonatomic) MFSizeObject *sizeObject; diff --git a/MVMCoreUI/Legacy/Views/MFTextButton.m b/MVMCoreUI/Legacy/Views/MFTextButton.m index a0ee6ca7..31b3a4ee 100644 --- a/MVMCoreUI/Legacy/Views/MFTextButton.m +++ b/MVMCoreUI/Legacy/Views/MFTextButton.m @@ -127,29 +127,6 @@ return theButton; } -#pragma mark - MVMCoreUIMoleculeViewProtocol - -- (void)reset { - [self setTitleColor:[UIColor mfTextButtonColor] forState:UIControlStateNormal]; -} - -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - NSString *color = [json string:KeyTextColor]; - if (color) { - [self setTitleColor:[UIColor mfGetColorForHex:color] forState:UIControlStateNormal]; - } - [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; - if ([self titleForState:UIControlStateNormal].length == 0) { - self.heightConstraint.constant = 0; - } else { - self.heightConstraint.constant = self.sizeObject.standardSize; - } -} - -+ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { - return 31; -} - #pragma mark - MVMCoreUIViewConstrainingProtocol - (BOOL)needsToBeConstrained { diff --git a/MVMCoreUI/Legacy/Views/MFTextField.h b/MVMCoreUI/Legacy/Views/MFTextField.h index aa3ab573..323c59fd 100644 --- a/MVMCoreUI/Legacy/Views/MFTextField.h +++ b/MVMCoreUI/Legacy/Views/MFTextField.h @@ -28,7 +28,7 @@ @end -@interface MFTextField : ViewConstrainingView +@interface MFTextField : ViewConstrainingView @property (nullable, weak, nonatomic) UIView *view; diff --git a/MVMCoreUI/Legacy/Views/MFTextField.m b/MVMCoreUI/Legacy/Views/MFTextField.m index 081f9fe8..da6dcaa3 100644 --- a/MVMCoreUI/Legacy/Views/MFTextField.m +++ b/MVMCoreUI/Legacy/Views/MFTextField.m @@ -555,19 +555,4 @@ } } -#pragma mark - MVMCoreUIMoleculeViewProtocol - -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { - [self setWithMap:json]; - self.uiTextFieldDelegate = delegateObject.uiTextFieldDelegate; - [MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:self.uiTextFieldDelegate]; - } -} - - -+ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { - return 76; -} @end diff --git a/MVMCoreUI/Legacy/Views/MFView.h b/MVMCoreUI/Legacy/Views/MFView.h index dd8e01a8..ab179d57 100644 --- a/MVMCoreUI/Legacy/Views/MFView.h +++ b/MVMCoreUI/Legacy/Views/MFView.h @@ -7,14 +7,10 @@ // #import -#import #import @import MVMCore.MVMCoreViewProtocol; -@interface MFView : UIView - -@property (nullable, nonatomic, strong) NSDictionary *json; -@property (nullable, nonatomic, strong) id model; +@interface MFView : UIView // Called in the initialization functions. Can setup ui here. - (void)setupView; diff --git a/MVMCoreUI/Legacy/Views/MFView.m b/MVMCoreUI/Legacy/Views/MFView.m index 6d939fc8..a01d1ca7 100644 --- a/MVMCoreUI/Legacy/Views/MFView.m +++ b/MVMCoreUI/Legacy/Views/MFView.m @@ -44,24 +44,4 @@ - (void)updateView:(CGFloat)size { } -#pragma mark - MVMCoreUIMoleculeViewProtocol - -- (void)setAsMolecule { - self.translatesAutoresizingMaskIntoConstraints = NO; - self.insetsLayoutMarginsFromSafeArea = NO; -} - -- (void)reset { - self.backgroundColor = [UIColor clearColor]; -} - -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - self.json = json; - - NSString *colorString = [json string:KeyBackgroundColor]; - if (colorString) { - self.backgroundColor = [UIColor mfGetColorForHex:colorString]; - } -} - @end diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h index f1638f6a..ba7bf4cc 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h +++ b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h @@ -12,7 +12,7 @@ @class Label; @class MFSizeObject; -@interface MVMCoreUICheckBox : UIControl +@interface MVMCoreUICheckBox : UIControl @property (nullable, weak, nonatomic) MVMCoreUICheckMarkView *checkMark; @property (readonly, nonatomic) BOOL isSelected; diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m index 4c6bf8a5..8e0afcd0 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m +++ b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m @@ -21,7 +21,7 @@ static const CGFloat FaultTolerance = 20.f; static const CGFloat CheckBoxHeightWidth = 18.0; -@interface MVMCoreUICheckBox () +@interface MVMCoreUICheckBox () @property (nonatomic, readwrite) BOOL isSelected; @property (weak, nonatomic) UIView *checkedSquare; @@ -42,13 +42,12 @@ static const CGFloat CheckBoxHeightWidth = 18.0; @property (nonatomic) BOOL isRequired; @property (nullable, strong, nonatomic) NSString *fieldKey; -@property (nullable, strong, nonatomic) MVMCoreUIDelegateObject *delegateObject; @end @implementation MVMCoreUICheckBox -#pragma mark - MVMCoreUIMoleculeViewProtocol +#pragma mark - Constraining protocol - (BOOL)needsToBeConstrained { return YES; @@ -58,29 +57,6 @@ static const CGFloat CheckBoxHeightWidth = 18.0; return UIStackViewAlignmentLeading; } -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - - self.delegateObject = delegateObject; - self.fieldKey = [json stringForKey:KeyFieldKey]; - self.isRequired = [json boolForKey:KeyRequired]; - - NSString *checkedColorHex = [json string:@"checkedColor"]; - NSString *unCheckedColorHex = [json string:@"unCheckedColor"]; - - UIColor *checkedColor = checkedColorHex ? [UIColor mfGetColorForHex:checkedColorHex]: [UIColor clearColor]; - UIColor *unCheckedColor = unCheckedColorHex ? [UIColor mfGetColorForHex:unCheckedColorHex]: [UIColor clearColor]; - - [self setupWithCheckedColor:checkedColor - unCheckColor:unCheckedColor - label:[json dict:KeyLabel] - delegateObject:delegateObject - additionalData: additionalData]; -} - -+ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { - return CheckBoxHeightWidth; -} - #pragma mark - convenient class methods + (instancetype)mfCheckBox { @@ -269,11 +245,6 @@ static const CGFloat CheckBoxHeightWidth = 18.0; [self setDescriptionText:text]; } -- (void)setupWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor label:(NSDictionary *)labelJson delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - [self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor]; - [self.descriptionLabel setWithJSON:labelJson delegateObject:delegateObject additionalData:additionalData]; -} - - (void)updateView:(CGFloat)size { [MVMCoreDispatchUtility performBlockOnMainThread:^{ [self.descriptionLabel updateView:size]; @@ -330,8 +301,6 @@ static const CGFloat CheckBoxHeightWidth = 18.0; } completion:nil]; [self.checkMark updateCheckSelected:NO animated:animated]; } - -// [FormValidator enableByValidationWithDelegate:self.delegateObject.formValidationProtocol]; } - (void)setColor:(nullable UIColor *)color forState:(UIControlState)state { diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h deleted file mode 100644 index f11a5002..00000000 --- a/MVMCoreUI/Legacy/Views/MVMCoreUIMoleculeViewProtocol.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// MVMCoreUIMoleculeViewProtocol.h -// MVMCoreUI -// -// Created by Scott Pfeil on 2/11/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import -@import MVMCore.MVMCoreViewProtocol; -@class MVMCoreUIDelegateObject; -@class MVMCoreErrorObject; -@class MoleculeModelProtocol; - -@protocol MVMCoreUIMoleculeViewProtocol - -@optional - -/// 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; - -/// Resets to default state before set with json is called again. -- (void)reset; - -/// For the molecule list to load more efficiently. -+ (CGFloat)estimatedHeightForRow:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject; - -/// Allows the molecule to set its name for reuse. Default could be moleculeName. -+ (nullable NSString *)nameForReuse:(nullable NSDictionary *)molecule delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject; - -/// Can return the required modules -+ (nullable NSArray *)requiredModules:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error; - -@end - - diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.h b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.h index e86d3f9e..ba71bd70 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.h +++ b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.h @@ -8,10 +8,9 @@ #import #import -#import #import -@interface MVMCoreUIPageControl : UIControl +@interface MVMCoreUIPageControl : UIControl // These properties effectively do what their corresponding namesakes do in UIPageControl @property (nonatomic) NSInteger currentPage; diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m index f2b9976e..feef75ab 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m +++ b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m @@ -311,25 +311,6 @@ static CGFloat const IndicatorRectangleHeight = 4; self.currentPage = page; } -#pragma mark - MVMCoreUIMoleculeViewProtocol - -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - NSString *colorString = [json string:KeyBackgroundColor]; - if (colorString) { - self.backgroundColor = [UIColor mfGetColorForHex:colorString]; - } - colorString = [json string:@"barsColor"]; - if (colorString) { - UIColor *color = [UIColor mfGetColorForHex:colorString]; - self.pageIndicatorTintColor = color; - self.currentPageIndicatorTintColor = color; - } - colorString = [json string:@"currentBarColor"]; - if (colorString) { - self.currentPageIndicatorTintColor = [UIColor mfGetColorForHex:colorString]; - } -} - #pragma mark - Accessibility - (UIAccessibilityTraits)accessibilityTraits { return UIAccessibilityTraitAdjustable; diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.h b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.h index 256aabfa..91444466 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.h +++ b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.h @@ -8,12 +8,11 @@ #import -#import #import @import MVMCore.MVMCoreViewProtocol; typedef void(^ValueChangeBlock)(void); -@interface MVMCoreUISwitch : UIControl +@interface MVMCoreUISwitch : UIControl @property (assign, nonatomic, getter=isOn) BOOL on; @property (nullable, strong, nonatomic) UIColor *onTintColor; diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m index 8cbb434d..4a7125fe 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m +++ b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m @@ -38,9 +38,6 @@ const CGFloat SwitchShakeIntensity = 2; @property (nonatomic) BOOL canChangeValue; -@property (strong, nonatomic, nullable) NSDictionary *json; -@property (nullable, strong, nonatomic) DelegateObject *delegate; - @end @implementation MVMCoreUISwitch @@ -141,51 +138,13 @@ const CGFloat SwitchShakeIntensity = 2; } } -#pragma mark - MVMCoreUIMoleculeViewProtocol - -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - self.json = json; - self.delegate = delegateObject; - - NSString *color = [json string:@"onTintColor"]; - if (color) { - self.onTintColor = [UIColor mfGetColorForHex:color]; - } - - color = [json string:@"offTintColor"]; - if (color) { - self.offTintColor = [UIColor mfGetColorForHex:color]; - } - - color = [json string:@"onKnobTintColor"]; - if (color) { - self.onKnobTintColor = [UIColor mfGetColorForHex:color]; - } - - color = [json string:@"offKnobTintColor"]; - if (color) { - self.offKnobTintColor = [UIColor mfGetColorForHex:color]; - } - - [self setState:[json boolForKey:@"state"] animated:false]; - - NSDictionary *actionMap = [json dict:@"action"]; - if (actionMap) { - [self addTarget:self action:@selector(addCustomAction) forControlEvents:UIControlEventTouchUpInside]; - } -} - - (void)addCustomAction { if (self.actionBlock) { self.actionBlock(); } } -+ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { - return [self getSwitchHeight]; -} - -#pragma mark - MVMCoreUIMoleculeViewProtocol +#pragma mark - Constraining Protocol - (BOOL)needsToBeConstrained { return YES; @@ -338,10 +297,6 @@ const CGFloat SwitchShakeIntensity = 2; if (self.valueChangedBlock) { self.valueChangedBlock(); } -// if (self.delegate && [self.delegate respondsToSelector:@selector(formValidationProtocol)] && [[self.delegate performSelector:@selector(formValidationProtocol)] respondsToSelector:@selector(formValidatorModel)]) { -// FormValidator *formValidator = [[self.delegate performSelector:@selector(formValidationProtocol)] performSelector:@selector(formValidatorModel)]; -// [formValidator enableByValidation]; -// } } - (void)setState:(BOOL)state withoutBlockAnimated:(BOOL)animated { diff --git a/MVMCoreUI/Legacy/Views/PrimaryButton.h b/MVMCoreUI/Legacy/Views/PrimaryButton.h index e83484a0..511519be 100644 --- a/MVMCoreUI/Legacy/Views/PrimaryButton.h +++ b/MVMCoreUI/Legacy/Views/PrimaryButton.h @@ -10,7 +10,6 @@ #import #import #import -#import typedef enum : NSUInteger { PrimaryButtonTypeRed, @@ -26,7 +25,7 @@ typedef enum : NSUInteger { static CGFloat const PrimaryButtonHeight = 42.0; static CGFloat const PrimaryButtonSmallHeight = 30.0; -@interface PrimaryButton : MFCustomButton +@interface PrimaryButton : MFCustomButton @property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set diff --git a/MVMCoreUI/Legacy/Views/PrimaryButton.m b/MVMCoreUI/Legacy/Views/PrimaryButton.m index 0e16ce8e..7a235fce 100644 --- a/MVMCoreUI/Legacy/Views/PrimaryButton.m +++ b/MVMCoreUI/Legacy/Views/PrimaryButton.m @@ -499,6 +499,25 @@ [self setTitleColor:[self titleColorForState:UIControlStateNormal] forState:UIControlStateHighlighted]; } +- (void)setAsStandardCustom { + // Default to standard look. + self.primaryButtonType = PrimaryButtonTypeCustom; + self.fillColor = [UIColor blackColor]; + self.textColor = [UIColor whiteColor]; + self.disabledTextColor = self.textColor; + self.borderColor = nil; + _bordered = false; +} + +- (void)setAsSecondaryCustom { + // Default to standard look. + self.primaryButtonType = PrimaryButtonTypeCustom; + self.fillColor = nil; + self.textColor = nil; + self.borderColor = [UIColor blackColor]; + _bordered = true; +} + - (void)setBordered:(BOOL)bordered { if (bordered != _bordered) { if (self.primaryButtonType == PrimaryButtonTypeCustom) { @@ -636,81 +655,7 @@ return button; } -#pragma mark - Molecule protocol - -- (void)reset { - [self setAsStandardCustom]; -} - -- (void)setAsStandardCustom { - // Default to standard look. - self.primaryButtonType = PrimaryButtonTypeCustom; - self.fillColor = [UIColor blackColor]; - self.textColor = [UIColor whiteColor]; - self.disabledTextColor = self.textColor; - self.borderColor = nil; - _bordered = false; -} - -- (void)setAsSecondaryCustom { - // Default to standard look. - self.primaryButtonType = PrimaryButtonTypeCustom; - self.fillColor = nil; - self.textColor = nil; - self.borderColor = [UIColor blackColor]; - _bordered = true; -} - -- (void)setAsMolecule { - self.translatesAutoresizingMaskIntoConstraints = false; - [self pinHeight]; - [self setAsStandardCustom]; -} - -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - - self.validationRequired = [json boolForKey:@"required"]; - self.requiredGroupsList = [json array:@"requiredGroups"]; - - self.primaryButtonType = PrimaryButtonTypeCustom; - NSString *style = [json string:@"style"]; - if ([style isEqualToString:@"primary"]) { - [self setAsStandardCustom]; - } else if ([style isEqualToString:@"secondary"]) { - [self setAsSecondaryCustom]; - } - - NSString *color = [json string:@"fillColor"]; - if (color) { - self.fillColor = [UIColor mfGetColorForHex:color]; - } - if ((color = [json string:KeyTextColor])) { - self.textColor = [UIColor mfGetColorForHex:color]; - } - if ((color = [json string:@"borderColor"])) { - self.borderColor = [UIColor mfGetColorForHex:color]; - } - _bordered = self.borderColor != nil; - if ((color = [json string:@"disabledFillColor"])) { - self.disabledFillColor = [UIColor mfGetColorForHex:color]; - } - if ((color = [json string:@"disabledTextColor"])) { - self.disabledTextColor = [UIColor mfGetColorForHex:color]; - } - if ((color = [json string:@"disabledBorderColor"])) { - self.disabledBorderColor = [UIColor mfGetColorForHex:color]; - } - - NSString *size = [json string:@"size"]; - if ([size isEqualToString:@"small"]) { - [self setAsSmallButton:YES]; - } else if ([size isEqualToString:@"tiny"]) { - [self setAsTiny:YES]; - } else { - [self setAsSmallButton:NO]; - } - [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; -} +#pragma mark - Constraining Protocol - (UIStackViewAlignment)horizontalAlignment { return UIStackViewAlignmentCenter; diff --git a/MVMCoreUI/Legacy/Views/PrimaryButtonView.m b/MVMCoreUI/Legacy/Views/PrimaryButtonView.m index 8c76353c..2855359a 100644 --- a/MVMCoreUI/Legacy/Views/PrimaryButtonView.m +++ b/MVMCoreUI/Legacy/Views/PrimaryButtonView.m @@ -19,9 +19,6 @@ @interface PrimaryButtonView () @property (weak, nonatomic) UIView *twoButtonView; -@property (weak, nonatomic) NSLayoutConstraint *alignCenterPin; -@property (weak, nonatomic) NSLayoutConstraint *alignCenterLeftPin; -@property (weak, nonatomic) NSLayoutConstraint *alignCenterRightPin; @property (weak, nonatomic) NSLayoutConstraint *height; @property (nonatomic, strong) NSArray *horizontalConstraints; @@ -38,21 +35,6 @@ }]; } -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - NSString *backgroundColorString = [json string:@"backgroundColor"]; - if (backgroundColorString) { - self.backgroundColor = [UIColor mfGetColorForHex:backgroundColorString]; - } - NSDictionary *primaryButtonMap = [json dict:@"primaryButton"]; - NSDictionary *secondaryButtonMap = [json dict:@"secondaryButton"]; - [self setupUIWithPrimaryButtonMap:primaryButtonMap secondaryButtonMap:secondaryButtonMap]; - [self.primaryButton setAsStandardCustom]; - [self.secondaryButton setAsSecondaryCustom]; - [self.primaryButton setWithJSON:primaryButtonMap delegateObject:delegateObject additionalData:additionalData]; - [self.secondaryButton setWithJSON:secondaryButtonMap delegateObject:delegateObject additionalData:additionalData]; -} - #pragma mark - Inits - (instancetype)init { diff --git a/MVMCoreUI/Legacy/Views/SeparatorView.m b/MVMCoreUI/Legacy/Views/SeparatorView.m index 9f85c311..0a86559d 100644 --- a/MVMCoreUI/Legacy/Views/SeparatorView.m +++ b/MVMCoreUI/Legacy/Views/SeparatorView.m @@ -95,32 +95,6 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - if (json) { - NSString *type = [json string:KeyType]; - if ([type isEqualToString:@"none"]) { - self.hidden = YES; - } else { - self.hidden = NO; - if ([type isEqualToString:@"medium"]) { - [self setAsMedium]; - } else if ([type isEqualToString:@"heavy"]) { - [self setAsHeavy]; - } else if ([type isEqualToString:@"standard"]) { - [self setAsLight]; - } - } - } else { - self.hidden = YES; - } - - NSString *colorString = [json string:KeyBackgroundColor]; - if (colorString) { - self.backgroundColor = [UIColor mfGetColorForHex:colorString]; - } -} - #pragma mark - helper - (void)hide { @@ -162,17 +136,9 @@ [self setNeedsLayout]; [self layoutIfNeeded]; } - -- (BOOL)shouldBeVisible { - return ![[self.json string:KeyType] isEqualToString:@"none"]; -} -#pragma mark - Molecule +#pragma mark - Constraining Protocol -- (void)reset { - [self setAsLight]; -} - - (BOOL)needsToBeConstrained { return YES; } @@ -181,19 +147,4 @@ return NO; } -+ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { - NSString *type = [json string:KeyType]; - if ([type isEqualToString:@"none"]) { - return 0; - } else { - if ([type isEqualToString:@"medium"]) { - return 2; - } else if ([type isEqualToString:@"heavy"]) { - return 4; - } else { - return 1; - } - } -} - @end diff --git a/MVMCoreUI/Legacy/Views/ViewConstrainingView.h b/MVMCoreUI/Legacy/Views/ViewConstrainingView.h index 30f5a552..7ba4fd21 100644 --- a/MVMCoreUI/Legacy/Views/ViewConstrainingView.h +++ b/MVMCoreUI/Legacy/Views/ViewConstrainingView.h @@ -39,9 +39,6 @@ @property (nonatomic) CGFloat topMarginPadding; @property (nonatomic) CGFloat bottomMarginPadding; -/// A molecule if we constrain one. -@property (weak, nullable, nonatomic) UIView *molecule; - /// A flag for if we should add a molecule from json. @property (nonatomic) BOOL shouldSetupMoleculeFromJSON; @@ -51,9 +48,6 @@ // Returns a view with the provided view as a subview, pinned. + (nonnull ViewConstrainingView *)viewConstrainingView:(nonnull UIView *)view; -// Can be initialized with a molecule to constrain -- (nonnull instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment; - #pragma mark - Constraining // Use these to sets the constants, because subclasses may align differently. @@ -78,9 +72,6 @@ // Add a view to be constrained in this view. - (void)addConstrainedView:(nonnull UIView *)view; -/// Can override to change how the molecule is added when shouldSetupMoleculeFromJSON = true. Inserts the molecule at 0 and calls pinToSuperView. -- (void)addMolecule:(nonnull UIView *)molecule; - // Change the alignment of the label - (void)alignLeft; - (void)alignCenterHorizontal; @@ -97,7 +88,4 @@ /// Convenience function for getting the alignment from a map. + (UIStackViewAlignment)getAlignmentForString:(nullable NSString *)alignmentString defaultAlignment:(UIStackViewAlignment)defaultAlignment; -/// Makes the view isAccessibilityElement false and adds molecule elements to accessbilityElements. -- (void)setMoleculeAccessibility; - @end diff --git a/MVMCoreUI/Legacy/Views/ViewConstrainingView.m b/MVMCoreUI/Legacy/Views/ViewConstrainingView.m index b98e72a5..8d36f351 100644 --- a/MVMCoreUI/Legacy/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Legacy/Views/ViewConstrainingView.m @@ -13,7 +13,6 @@ #import "NSLayoutConstraint+MFConvenience.h" #import "MFStyler.h" #import "MVMCoreUIConstants.h" -#import "MVMCoreUIMoleculeMappingObject.h" #import "MVMCoreUIUtility.h" #import "MVMCoreUIViewConstrainingProtocol.h" @@ -22,18 +21,6 @@ @implementation ViewConstrainingView -- (nonnull instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment { - if (self = [super init]) { - if (!molecule.superview) { - [self addConstrainedView:molecule alignment:alignment]; - [self setAsMolecule]; - } - self.molecule = molecule; - [self setMoleculeAccessibility]; - } - return self; -} - + (nonnull ViewConstrainingView *)emptyView { ViewConstrainingView *view = [[ViewConstrainingView alloc] initWithFrame:CGRectZero]; view.translatesAutoresizingMaskIntoConstraints = NO; @@ -240,11 +227,6 @@ } } -- (void)addMolecule:(nonnull UIView *)molecule { - [self insertSubview:molecule atIndex:0]; - [self pinViewToSuperView:molecule]; -} - #pragma mark - MVMCoreUIViewConstrainingProtocol - (void)alignHorizontal:(UIStackViewAlignment)alignment { @@ -285,114 +267,27 @@ } } -- (void)shouldSetHorizontalMargins:(BOOL)shouldSet { - if (![self.json optionalNumberForKey:@"useHorizontalMargins"]) { - self.updateViewHorizontalDefaults = shouldSet; - } -} - -- (void)shouldSetVerticalMargins:(BOOL)shouldSet { - if (![self.json optionalNumberForKey:@"useVerticalMargins"]) { - self.updateViewVerticalDefaults = shouldSet; - } -} - #pragma mark - MVMCoreViewProtocol - (void)setupView { [super setupView]; self.translatesAutoresizingMaskIntoConstraints = NO; self.backgroundColor = [UIColor clearColor]; - self.topMarginPadding = PaddingDefaultVerticalSpacing3; - self.bottomMarginPadding = PaddingDefaultVerticalSpacing3; - [MVMCoreUIUtility setMarginsForView:self leading:0 top:0 trailing:0 bottom:0]; } - (void)updateView:(CGFloat)size { [super updateView:size]; - [self.molecule updateView:size]; - [MFStyler setMarginsForView:self size:size defaultHorizontal:self.updateViewHorizontalDefaults top:(self.updateViewVerticalDefaults ? self.topMarginPadding : 0) bottom:(self.updateViewVerticalDefaults ? self.bottomMarginPadding : 0)]; - UIEdgeInsets margins = [MVMCoreUIUtility getMarginsForView:self]; + if ([self.constrainedView respondsToSelector:@selector(updateView:)]) { + [((id)self.constrainedView) updateView:size]; + } if (self.updateViewHorizontalDefaults) { - [self setLeftPinConstant:margins.left]; - [self setRightPinConstant:margins.right]; + CGFloat padding = [MFStyler defaultHorizontalPaddingForSize:size]; + [self setLeftPinConstant:padding]; + [self setRightPinConstant:padding]; } if (self.updateViewVerticalDefaults) { - [self setTopPinConstant:margins.top]; - [self setBottomPinConstant:margins.bottom]; - } -} - -#pragma mark - MVMCoreUIMoleculeViewProtocol - -- (void)setMoleculeAccessibility { - if (self.molecule) { - self.isAccessibilityElement = NO; - if (self.molecule.accessibilityElements) { - self.accessibilityElements = self.molecule.accessibilityElements; - } else { - self.accessibilityElements = @[self.molecule]; - } - } -} - -- (void)reset { - [super reset]; - self.updateViewHorizontalDefaults = NO; - self.updateViewVerticalDefaults = NO; - self.topMarginPadding = PaddingDefaultVerticalSpacing3; - self.bottomMarginPadding = PaddingDefaultVerticalSpacing3; - if ([self.molecule respondsToSelector:@selector(horizontalAlignment)]) { - [self alignHorizontal:[(UIView *)self.molecule horizontalAlignment]]; - } - [self alignVertical:UIStackViewAlignmentFill]; - if ([self.molecule respondsToSelector:@selector(reset)]) { - [self.molecule performSelector:@selector(reset)]; - } -} - -- (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; + [self setTopPinConstant:self.topMarginPadding]; + [self setBottomPinConstant:self.bottomMarginPadding]; } } diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 22707550..4075a110 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -20,7 +20,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import -#import #pragma mark - TopAlert #import @@ -106,7 +105,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #pragma mark - Molecules #import -#import #import #import diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift index 7f50873e..c201104a 100644 --- a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift @@ -8,10 +8,8 @@ import Foundation - public protocol PageModelProtocol { var pageType: String { get set } var screenHeading: String? { get set } - var isAtomicTabs: Bool? { get set } var navigationItem: NavigationItemModelProtocol? { get set } } diff --git a/MVMCoreUI/Molecules/FooterView.swift b/MVMCoreUI/Molecules/FooterView.swift deleted file mode 100644 index b9113d1d..00000000 --- a/MVMCoreUI/Molecules/FooterView.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// FooterView.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 3/11/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -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 - } - return 42 - } -} diff --git a/MVMCoreUI/Molecules/MoleculeViewProtocol.swift b/MVMCoreUI/Molecules/MoleculeViewProtocol.swift deleted file mode 100644 index 63fff68c..00000000 --- a/MVMCoreUI/Molecules/MoleculeViewProtocol.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// 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 - -@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/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift deleted file mode 100644 index 439e3aec..00000000 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// 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 moleculeName: String = HeadlineBodyButtonModel.identifier - public var backgroundColor: Color? - - public var headlineBody: HeadlineBodyModel - public var button: ButtonModel - public var buttonHeadlinePadding: CGFloat -} diff --git a/MVMCoreUI/OtherHandlers/CoreUIObject.swift b/MVMCoreUI/OtherHandlers/CoreUIObject.swift index d60cdd6a..3553b54b 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIObject.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIObject.swift @@ -9,7 +9,7 @@ import UIKit @objcMembers open class CoreUIObject: MVMCoreObject { - public var moleculeMap: MVMCoreUIMoleculeMappingObject? + public var moleculeMap: MoleculeObjectMapping? open override func defaultInitialSetup() { cache = MVMCoreCache() @@ -18,7 +18,7 @@ import UIKit session = MVMCoreUISession() viewControllerMapping = MVMCoreUIViewControllerMappingObject() loggingDelegate = MVMCoreUILoggingHandler() - moleculeMap = MVMCoreUIMoleculeMappingObject() + moleculeMap = MoleculeObjectMapping() MoleculeObjectMapping.registerObjects() } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift deleted file mode 100644 index a7054d4e..00000000 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ /dev/null @@ -1,49 +0,0 @@ -// -// 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 register(viewClass: V.Type, viewModelClass: M.Type) { - try? ModelRegistry.register(viewModelClass) - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(viewClass, forKey: viewModelClass.identifier as NSString) - } - - func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? { - return moleculeMapping.object(forKey: model.moleculeName) as? AnyClass - } - - func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { - return createMolecule(model, delegateObject, false) - } - - func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { - guard let molecule = createMolecule(forName: model.moleculeName) else { - return nil - } - - let setData = {() in - if let molecule = molecule as? ModelMoleculeViewProtocol { - molecule.set(with: model, delegateObject, nil) - } else { - molecule.setWithJSON?(model.toJSON(), delegateObject: delegateObject, additionalData: nil) - } - } - - if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, - castMolecule.needsToBeConstrained?() ?? false { - let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.horizontalAlignment?() ?? .fill) - setData() - return view - } else { - setData() - return molecule - } - } -} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h deleted file mode 100644 index 776566c8..00000000 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject.h -// MVMCoreUI -// -// Created by Scott Pfeil on 2/11/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import -#import -@class MVMCoreUIDelegateObject; -@class MVMCoreLoadObject; -@class MVMCoreErrorObject; - -@interface MVMCoreUIMoleculeMappingObject : NSObject - -/// Maps molecule name to class. -@property (nonnull, strong, nonatomic) NSMutableDictionary *moleculeMapping; - -/// Returns the shared instance -+ (nullable instancetype)sharedMappingObject; - -/// Returns the molecule class. -- (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json; - -#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; - -/// 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 - -+ (nullable NSArray *)getRequiredModulesForJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error; -+ (void)addRequiredModulesForJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject moduleList:(nullable NSMutableArray *)moduleList errorList:(nullable NSMutableArray *)errorList; - -@end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m deleted file mode 100644 index ccaa9115..00000000 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ /dev/null @@ -1,101 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject.m -// MVMCoreUI -// -// Created by Scott Pfeil on 2/11/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreUIMoleculeMappingObject.h" -@import MVMCore.MVMCoreActionUtility; -@import MVMCore.NSDictionary_MFConvenience; -@import MVMCore.MVMCoreLoadObject; -@import MVMCore.MVMCoreErrorObject; -#import -#import "MFTextField.h" -#import "MVMCoreUIPageControl.h" -#import "MVMCoreUIViewConstrainingProtocol.h" - - -@implementation MVMCoreUIMoleculeMappingObject - -- (NSMutableDictionary *)moleculeMapping { - - // Keeps a mapping of the given page type - static dispatch_once_t onceToken; - static NSMutableDictionary *mapping; - dispatch_once(&onceToken, ^{ - mapping = [@{} mutableCopy]; - }); - return mapping; -} - -+ (nullable instancetype)sharedMappingObject { - return [MVMCoreActionUtility initializerClassCheck:[CoreUIObject sharedInstance].moleculeMap classToVerify:self]; -} - -- (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json { - NSString *moleculeName = [json string:KeyMoleculeName]; - if (moleculeName) { - return [self.moleculeMapping objectForKey:moleculeName]; - } - return nil; -} - -#pragma mark - Molecule Creation - -- (nullable UIView *)createMoleculeForName:(nonnull NSString *)name { - Class class = [self.moleculeMapping objectForKey:name]; - if (!class) { - return nil; - } - UIView *molecule = [[class alloc] init]; - if ([molecule respondsToSelector:@selector(setAsMolecule)]) { - [molecule setAsMolecule]; - } - return molecule; -} - -- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject { - return [self createMoleculeForJSON:json delegateObject:delegateObject constrainIfNeeded:NO]; -} - -- (nullable UIView *)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded { - NSString *moleculeName = [json string:KeyMoleculeName]; - if (!moleculeName) { - return nil; - } - UIView *molecule = [self createMoleculeForName:moleculeName]; - - // 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(horizontalAlignment)] ? [castMolecule horizontalAlignment] : UIStackViewAlignmentFill]; - } - [molecule setWithJSON:json delegateObject:delegateObject additionalData:nil]; - return molecule; -} - -#pragma mark - Convenience - -+ (nullable NSArray *)getRequiredModulesForJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error { - Class theClass = [[MVMCoreUIMoleculeMappingObject sharedMappingObject] getMoleculeClassWithJSON:json]; - if ([theClass respondsToSelector:@selector(requiredModules:delegateObject:error:)]) { - return [theClass requiredModules:json delegateObject:delegateObject error:error]; - } else { - return nil; - } -} - -+ (void)addRequiredModulesForJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject moduleList:(nullable NSMutableArray *)moduleList errorList:(nullable NSMutableArray *)errorList { - MVMCoreErrorObject *error = nil; - NSArray *modules = [self getRequiredModulesForJSON:json delegateObject:delegateObject error:&error]; - if (modules) { - [moduleList addObjectsFromArray:modules]; - } - if (error) { - [errorList addObject:error]; - } -} - -@end diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift deleted file mode 100644 index f2bf9e78..00000000 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ /dev/null @@ -1,143 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject+ModelMapping.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -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: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) - - // Label - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - // need to move labelattributemodel to different method - try? ModelRegistry.register(LabelAttributeFontModel.self) - try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... - try? ModelRegistry.register(LabelAttributeUnderlineModel.self) - try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - try? ModelRegistry.register(LabelAttributeActionModel.self) - - // Buttons - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) - - // Entry Field - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - - // Other Atoms - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) - - // 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: HeadlineBodyLink.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: LabelToggle.self, viewModelClass: LabelToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - - // List items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.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: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.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) - - // Designed List Items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - - // Designed Section Dividers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - - // Designed Headers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) - - // TODO: Need model - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - - // TODO: Need View - try? ModelRegistry.register(TabsModel.self) - - // Helper models - try? ModelRegistry.register(RuleRequiredModel.self) - try? ModelRegistry.register(RuleAnyRequiredModel.self) - try? ModelRegistry.register(RuleAnyValueChangedModel.self) - try? ModelRegistry.register(RuleAllValueChangedModel.self) - try? ModelRegistry.register(RuleEqualsModel.self) - try? ModelRegistry.register(RuleRegexModel.self) - - // Actions - try? ModelRegistry.register(ActionTopAlertModel.self) - try? ModelRegistry.register(ActionCollapseNotificationModel.self) - try? ModelRegistry.register(ActionOpenPanelModel.self) - } -} From cb6f2059948c96409d2dac881264fafec05ba4fe Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 20 Mar 2020 19:33:53 -0400 Subject: [PATCH 050/244] radio selection fix --- MVMCoreUI/Atoms/Views/RadioButton.swift | 4 +--- .../Molecules/RadioButtonSelectionHelper.swift | 16 ++++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/RadioButton.swift b/MVMCoreUI/Atoms/Views/RadioButton.swift index 7dd5976a..4158cb3f 100644 --- a/MVMCoreUI/Atoms/Views/RadioButton.swift +++ b/MVMCoreUI/Atoms/Views/RadioButton.swift @@ -128,9 +128,7 @@ import UIKit self.delegateObject = delegateObject isSelected = model.state - let radioButtonModel = RadioButtonSelectionHelper.setupForRadioButtonGroup(model, - formValidator: delegateObject?.formHolderDelegate?.formValidator) - FormValidator.setupValidation(molecule: radioButtonModel, delegate: delegateObject?.formHolderDelegate) + RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject) } public override func reset() { diff --git a/MVMCoreUI/Molecules/RadioButtonSelectionHelper.swift b/MVMCoreUI/Molecules/RadioButtonSelectionHelper.swift index 263a85a4..601588db 100644 --- a/MVMCoreUI/Molecules/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Molecules/RadioButtonSelectionHelper.swift @@ -14,7 +14,7 @@ import UIKit public var fieldKey: String? public var groupName: String? = FormValidator.defaultGroupName - private var selectedRadioButton: RadioButton? + var selectedRadioButton: RadioButton? private var fieldGroupName: String? public var baseValue: AnyHashable? @@ -22,16 +22,20 @@ import UIKit self.fieldKey = fieldKey } - public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, formValidator: FormValidator?) -> RadioButtonSelectionHelper { + public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) { guard let groupName = radioButtonModel.fieldKey, - let formValidator = formValidator else { - return RadioButtonSelectionHelper(radioButtonModel.fieldKey) + let formValidator = delegateObject?.formHolderDelegate?.formValidator else { + return } - let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey) + let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey) radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper - return radioButtonSelectionHelper + + if radioButtonModel.state { + radioButtonSelectionHelper.selectedRadioButton = radioButton + } + FormValidator.setupValidation(molecule: radioButtonSelectionHelper, delegate: delegateObject?.formHolderDelegate) } public func selected(_ radioButton: RadioButton) { From af3280fc067df66d1dac475adee4f1ab0163adb3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Sat, 21 Mar 2020 09:39:47 -0400 Subject: [PATCH 051/244] move files --- ...eColumnTextWithWhitespaceDividerTall.swift | 56 +++++++++++++++++++ ...mnTextWithWhitespaceDividerTallModel.swift | 48 ++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift new file mode 100644 index 00000000..1f2bcd6f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -0,0 +1,56 @@ +// +// ListOneColumnTextWithWhitespaceDividerTall.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 09/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListOneColumnTextWithWhitespaceDividerTall: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + public var stack: Stack + public let headline = Label.commonLabelH3(true) + public let body = Label.commonLabelB2(true) + + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), + (view: body, model: StackItemModel(spacing: 0, horizontalAlignment: .leading))], + axis: .vertical) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return } + headline.set(with: model.headline, delegateObject, additionalData) + body.set(with: model.body, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + headline.styleH3(true) + body.styleB2(true) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift new file mode 100644 index 00000000..7c95b7e8 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -0,0 +1,48 @@ +// +// ListOneColumnTextWithWhitespaceDividerTallModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 09/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list1CTxtDiv2" + public var headline: LabelModel + public var body: LabelModel + + public init(headline: LabelModel, body: LabelModel) { + self.headline = headline + self.body = body + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case headline + case body + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + body = try typeContainer.decode(LabelModel.self, forKey: .body) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(headline, forKey: .headline) + try container.encode(body, forKey: .body) + } +} From e3cf14f898baacf8e103b68cc4622d5784066e05 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Sat, 21 Mar 2020 09:40:48 -0400 Subject: [PATCH 052/244] file move --- ...eColumnTextWithWhitespaceDividerTall.swift | 56 ------------------- ...mnTextWithWhitespaceDividerTallModel.swift | 48 ---------------- 2 files changed, 104 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift deleted file mode 100644 index 1f2bcd6f..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ /dev/null @@ -1,56 +0,0 @@ -// -// ListOneColumnTextWithWhitespaceDividerTall.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 09/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -@objcMembers open class ListOneColumnTextWithWhitespaceDividerTall: TableViewCell { - - //----------------------------------------------------- - // MARK: - Outlets - //----------------------------------------------------- - public var stack: Stack - public let headline = Label.commonLabelH3(true) - public let body = Label.commonLabelB2(true) - - // MARK: - Initializers - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), - (view: body, model: StackItemModel(spacing: 0, horizontalAlignment: .leading))], - axis: .vertical) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - //----------------------------------------------------- - // MARK: - View Lifecycle - //----------------------------------------------------- - override open func setupView() { - super.setupView() - addMolecule(stack) - stack.restack() - } - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return } - headline.set(with: model.headline, delegateObject, additionalData) - body.set(with: model.body, delegateObject, additionalData) - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 90 - } - - open override func reset() { - super.reset() - headline.styleH3(true) - body.styleB2(true) - } -} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift deleted file mode 100644 index 7c95b7e8..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// ListOneColumnTextWithWhitespaceDividerTallModel.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 09/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "list1CTxtDiv2" - public var headline: LabelModel - public var body: LabelModel - - public init(headline: LabelModel, body: LabelModel) { - self.headline = headline - self.body = body - super.init() - } - - /// Defaults to set - override public func setDefaults() { - super.setDefaults() - style = "tallDivider" - } - - private enum CodingKeys: String, CodingKey { - case moleculeName - case headline - case body - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - headline = try typeContainer.decode(LabelModel.self, forKey: .headline) - body = try typeContainer.decode(LabelModel.self, forKey: .body) - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(headline, forKey: .headline) - try container.encode(body, forKey: .body) - } -} From 77dc590a72085f25fc9edbab74e9efab2f7457b1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Sat, 21 Mar 2020 09:50:11 -0400 Subject: [PATCH 053/244] Temporary additions --- .../ListLeftVariableRadioButtonAndPaymentMethod.swift | 1 + .../List/RightVariable/ListRightVariablePayments.swift | 1 + .../HorizontalCombinationViews/ImageHeadlineBody.swift | 6 ++---- .../HeadLineBodyCaretLinkImage.swift | 5 ++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift index 12ae94fe..be918aca 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift @@ -38,6 +38,7 @@ import UIKit //----------------------------------------------------- override open func setupView() { super.setupView() + leftImage.addSizeConstraintsForAspectRatio = true addMolecule(stack) stack.restack() eyebrowHeadlineBodyLink.body.textColor = .mvmOrangeAA diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift index 9cfccd04..2eac0789 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift @@ -36,6 +36,7 @@ import Foundation //------------------------------------------------------- override open func setupView() { super.setupView() + rightImage.addSizeConstraintsForAspectRatio = true addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift index c73557e0..1afe7489 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/ImageHeadlineBody.swift @@ -18,12 +18,10 @@ import UIKit open override func setupView() { super.setupView() - guard subviews.count == 0 else { - return - } headlineBody.headlineLabel.styleB1(true) headlineBody.spaceBetweenLabelsConstant = 0 - + imageView.addSizeConstraintsForAspectRatio = true + addSubview(headlineBody) addSubview(imageView) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift index 8f36c0a3..8d4dba6d 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadLineBodyCaretLinkImage.swift @@ -27,12 +27,11 @@ import Foundation open override func setupView() { super.setupView() - guard subviews.count == 0 else { - return - } heightConstraint = heightAnchor.constraint(equalToConstant: Self.heightConstant) heightConstraint?.isActive = true + backgroundImageView.addSizeConstraintsForAspectRatio = true + let container = MVMCoreUICommonViewsUtility.commonView() addAndContain(container) From f750fd129ca607e034577862b10b6af59ec812c8 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Mon, 23 Mar 2020 11:19:40 +0530 Subject: [PATCH 054/244] MF-19186 : List -Three Column - Data Usage - Divider - Initial Commit --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ .../ListThreeColumnDataUsageDivider.swift | 61 +++++++++++++++++++ ...ListThreeColumnDataUsageDividerModel.swift | 51 ++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 121 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f17d7906..1887955b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -131,6 +131,8 @@ 8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */; }; 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */; }; 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */; }; + 8D21E4B924247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D21E4B824247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift */; }; + 8D21E4BB2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D21E4BA2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift */; }; 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; @@ -516,6 +518,8 @@ 8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTotalData.swift; sourceTree = ""; }; 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyTextModel.swift; sourceTree = ""; }; 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyText.swift; sourceTree = ""; }; + 8D21E4B824247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnDataUsageDividerModel.swift; sourceTree = ""; }; + 8D21E4BA2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnDataUsageDivider.swift; sourceTree = ""; }; 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; @@ -1227,6 +1231,8 @@ children = ( 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, + 8D21E4B824247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift */, + 8D21E4BA2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -1890,6 +1896,7 @@ D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonSelectionHelper.swift in Sources */, 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, + 8D21E4B924247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift in Sources */, D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, @@ -1983,6 +1990,7 @@ D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, + 8D21E4BB2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift new file mode 100644 index 00000000..c4944e3e --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift @@ -0,0 +1,61 @@ +// +// ListThreeColumnDataUsageDivider.swift +// MVMCoreUI +// +// Created by Kruthika KP on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnDataUsageDivider: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + public let leftLabel = Label.createLabelBoldBodySmall(true) + public let centerLabel = Label.createLabelBoldBodySmall(true) + public let rightLabel = Label.createLabelBoldBodySmall(true) + var stack: Stack + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center)), + (view: rightLabel, model: StackItemModel(percent: 34, horizontalAlignment: .center))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + // MARK: - ModelMoleculeViewProtocol + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnDataUsageDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + open override func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + centerLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift new file mode 100644 index 00000000..f57bdf01 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift @@ -0,0 +1,51 @@ +// +// ListThreeColumnDataUsageDividerModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnDataUsageDividerModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list3CDataUsgDiv" + public let leftLabel: LabelModel + public let centerLabel: LabelModel + public let rightLabel: LabelModel + + public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from:decoder) + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index f2bf9e78..a33e298e 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -117,6 +117,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnDataUsageDivider.self, viewModelClass: ListThreeColumnDataUsageDividerModel.self) // Designed Headers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) From c39e344f25c46aa4673ef1f1b57fab96c17779f7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 11:03:41 -0400 Subject: [PATCH 055/244] crash fix --- MVMCoreUI.xcodeproj/project.pbxproj | 10 +++++++--- .../Atoms/TextFields/TextEntryField.swift | 4 ++-- .../BaseControllers/ViewController.swift | 2 +- ...VMCoreUICommonViewsUtility+Extension.swift | 20 +++++++++++++++++++ 4 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index af3081dc..5308ee86 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -213,10 +213,10 @@ 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 */; }; + D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */; }; D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */; }; D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */; }; - D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; D256E9932412880000360572 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = D256E9922412880000360572 /* Header.swift */; }; @@ -266,6 +266,7 @@ 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 */; }; + D29C94D5242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29C94D4242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.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, ); }; }; @@ -603,10 +604,10 @@ 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 = ""; }; + D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+Extension.swift"; sourceTree = ""; }; D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescription.swift; sourceTree = ""; }; D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescriptionModel.swift; sourceTree = ""; }; - D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; D256E9922412880000360572 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = ""; }; @@ -655,6 +656,7 @@ 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 = ""; }; + D29C94D4242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUICommonViewsUtility+Extension.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 = ""; }; @@ -872,7 +874,7 @@ 01C74D87224298E2009C25A3 /* FormUIHelpers */ = { isa = PBXGroup; children = ( - 011D95882404249B000E3791 /* FormProtocol.swift */, + 011D95882404249B000E3791 /* FormHolderModelProtocol.swift */, 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */, 011D95AA2405C553000E3791 /* FormItemProtocol.swift */, 011D958624042492000E3791 /* FormFieldProtocol.swift */, @@ -1474,6 +1476,7 @@ D29DF13B21E6870B003B2FB9 /* Sizing */, D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */, D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */, + D29C94D4242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift */, D29DF14D21E693AD003B2FB9 /* MFFonts.h */, D29DF14C21E693AD003B2FB9 /* MFFonts.m */, 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */, @@ -2026,6 +2029,7 @@ 525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */, 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */, 94FB966323D797DA003D482B /* MFTextButton.m in Sources */, + D29C94D5242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift in Sources */, D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, 0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index 4c56036e..33f75604 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -19,7 +19,7 @@ import UIKit } -@objcMembers open class TextEntryField: EntryField, UITextFieldDelegate { +@objcMembers open class TextEntryField: EntryField, UITextFieldDelegate, ObservingTextFieldDelegate { //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- @@ -311,7 +311,7 @@ import UIKit uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate - //MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) + textField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: observingTextFieldDelegate ?? self) } } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 333df798..7e1141ba 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -8,7 +8,7 @@ import UIKit -@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate { +@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate { @objc public var pageType: String? @objc public var loadObject: MVMCoreLoadObject? public var pageModel: MVMControllerModelProtocol? diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift new file mode 100644 index 00000000..70c84d40 --- /dev/null +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift @@ -0,0 +1,20 @@ +// +// MVMCoreUICommonViewsUtility+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/23/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public extension MVMCoreUICommonViewsUtility { + static func getToolbarWithDoneButton(delegate: ObservingTextFieldDelegate) -> UIToolbar { + let toolbar = self.makeEmptyToolbar() + let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) + let button = UIBarButtonItem(barButtonSystemItem: .done, target: delegate, action: #selector(ObservingTextFieldDelegate.dismissFieldInput(sender:))) + button.tintColor = .black + toolbar.setItems([space, button], animated: false) + return toolbar + } +} From d05c96a9ad39516bd8957ff0f5fe1e6e791372ca Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 11:09:08 -0400 Subject: [PATCH 056/244] digit box miss fix --- MVMCoreUI/Atoms/TextFields/DigitEntryField.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index 53181bff..b249d89f 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -338,7 +338,7 @@ import UIKit setAsSecureTextEntry(model.secureEntry) for digitBox in digitBoxes { - MVMCoreUICommonViewsUtility.addDismissToolbar(digitBox.digitField, delegate: delegateObject as? UITextFieldDelegate) + digitBox.digitField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: delegateObject?.observingTextFieldDelegate ?? self) } super.set(with: model, delegateObject, additionalData) From 13fc3adf09cc39241f22062d5b6e75c26aba28fc Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 11:11:56 -0400 Subject: [PATCH 057/244] add comment --- MVMCoreUI/BaseControllers/ViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 7e1141ba..fac7a60e 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -16,6 +16,7 @@ import UIKit /// Set if this page is containted in a manager. public var manager: (UIViewController & MVMCoreViewManagerProtocol)? + // TODO: Change this logic once we convert the MVMCoreViewControllerProtocol to swift public var selfDelegateObject: MVMCoreUIDelegateObject? public func delegateObject() -> DelegateObject? { if selfDelegateObject == nil { From b49b45660c0f83b934779aff283fa8646674e65d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 12:32:23 -0400 Subject: [PATCH 058/244] Navigation item improvements --- .../BaseControllers/ViewController.swift | 53 +++++++------------ .../Containers/NavigationController.swift | 30 +++++++++++ .../NavigationItemModelProtocol.swift | 12 +++-- MVMCoreUI/Utility/MVMCoreUIUtility.h | 3 ++ MVMCoreUI/Utility/MVMCoreUIUtility.m | 21 ++++++++ 5 files changed, 82 insertions(+), 37 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index fac7a60e..39226786 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -94,6 +94,14 @@ import UIKit try parsePageJSON() MVMCoreDispatchUtility.performBlock(onMainThread: { self.handleNewDataAndUpdateUI() + // If the screen is showing, can update the navigation controller. + if let navigationController = self.manager?.navigationController, + self.manager!.getCurrentViewController() == self { + self.set(navigationController: navigationController) + } else if let navigationController = self.navigationController, + self == MVMCoreUIUtility.getCurrentVisibleController() { + self.set(navigationController: navigationController) + } }) } catch { if let coreError = MVMCoreErrorObject.createErrorObject(for: error, location: "updateJSON for pageType: \(String(describing: pageType))") { @@ -156,20 +164,15 @@ import UIKit /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, open func handleNewData() { - // Convert legacy to navigation model. - if pageModel?.navigationItem == nil { - let navigationModel = NavigationItemModel() - if navigationModel.title == nil { - navigationModel.title = pageModel?.screenHeading - } - if navigationModel.showLeftPanelButton == nil { - navigationModel.showLeftPanelButton = isMasterInitiallyAccessible() - } - if navigationModel.showRightPanelButton == nil { - navigationModel.showRightPanelButton = isSupportInitiallyAccessible() - } - pageModel?.navigationItem = navigationModel + // TODO: remove legacy. Temporary, convert legacy to navigation model. + var navigationModel = pageModel?.navigationItem ?? NavigationItemModel() + navigationModel.title = pageModel?.screenHeading + navigationModel.showLeftPanelButton = isMasterInitiallyAccessible() + navigationModel.showRightPanelButton = isSupportInitiallyAccessible() + if /*(self as? MVMCoreUITabBarPageControlViewController) != nil ||*/ manager != nil || loadObject?.requestParameters?.tabWasPressed ?? false == true { + navigationModel.line = LineModel(type: .none) } + pageModel?.navigationItem = navigationModel if self.formValidator == nil { let rules = pageModel?.formRules self.formValidator = FormValidator(rules) @@ -183,30 +186,12 @@ import UIKit MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() return } - navigationItem.title = navigationItemModel.title - navigationItem.accessibilityLabel = navigationItemModel.title - - navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) - UIColor.setBackgroundColor(navigationItemModel.backgroundColor?.uiColor ?? .white, for: navigationController.navigationBar, isTransparent: navigationItemModel.transparent) - - let tint = navigationItemModel.tintColor.uiColor - navigationController.navigationBar.tintColor = tint - - // Have the navigation title match the tint color - navigationController.navigationBar.titleTextAttributes?.updateValue(tint, forKey: .foregroundColor) - - // Update icons if main navigation controller. if navigationController == MVMCoreUISplitViewController.main()?.navigationController, - MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self { + navigationController.topViewController == self { MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels() - MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(navigationItemModel.showLeftPanelButton ?? false, for: self) - MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(navigationItemModel.showRightPanelButton ?? false, for: self) - showBottomProgressBar() - MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(tint) - - // Update separator. - MVMCoreUISession.sharedGlobal()?.navigationController?.separatorView?.isHidden = /*self is MVMCoreUITabBarPageControlViewController ||*/ manager != nil || loadObject?.requestParameters?.tabWasPressed ?? false == true + showBottomProgressBar() } + NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: self) } // Eventually will be moved to server diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 6e18e427..74aadca7 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -39,4 +39,34 @@ import UIKit MVMCoreUISession.sharedGlobal()?.setup(asStandardLoadViewDelegate: navigationController) return navigationController } + + public static func set(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: (UIViewController & MVMCoreViewControllerProtocol)) { + viewController.navigationItem.title = navigationItemModel.title + viewController.navigationItem.accessibilityLabel = navigationItemModel.title + viewController.navigationItem.hidesBackButton = !navigationItemModel.systemBackButton + + navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) + UIColor.setBackgroundColor(navigationItemModel.backgroundColor?.uiColor ?? .white, for: navigationController.navigationBar, isTransparent: navigationItemModel.transparent) + + let tint = navigationItemModel.tintColor.uiColor + navigationController.navigationBar.tintColor = tint + + // Have the navigation title match the tint color + navigationController.navigationBar.titleTextAttributes?.updateValue(tint, forKey: .foregroundColor) + + // Update icons if main navigation controller. + if navigationController == MVMCoreUISession.sharedGlobal()?.navigationController, + navigationController.topViewController == viewController { + // Update line. + MVMCoreUISession.sharedGlobal()?.navigationController?.separatorView?.set(with: navigationItemModel.line ?? LineModel(type: .standard), viewController.delegateObject?() as? MVMCoreUIDelegateObject, nil) + } + + if navigationController == MVMCoreUISplitViewController.main()?.navigationController, + navigationController.topViewController == viewController { + // Update Panels + MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(navigationItemModel.showLeftPanelButton ?? false, for: viewController) + MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(navigationItemModel.showRightPanelButton ?? false, for: viewController) + MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(tint) + } + } } diff --git a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift index 24b375fe..605b6e5e 100644 --- a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift @@ -15,7 +15,8 @@ public protocol NavigationItemModelProtocol: MoleculeModelProtocol { var backgroundColor: Color? { get set } var transparent: Bool { get set } var tintColor: Color { get set } - var systemBackButton: Bool? { get set } + var line: LineModel? { get set } + var systemBackButton: Bool { get set } var showLeftPanelButton: Bool? { get set } var showRightPanelButton: Bool? { get set } var additionalLeftItems: [NavigationItemButtonModel]? { get set } @@ -60,7 +61,8 @@ public class NavigationItemModel: NavigationItemModelProtocol { public var backgroundColor: Color? public var transparent: Bool public var tintColor: Color - public var systemBackButton: Bool? + public var line: LineModel? + public var systemBackButton = false public var showLeftPanelButton: Bool? public var showRightPanelButton: Bool? public var additionalLeftItems: [NavigationItemButtonModel]? @@ -71,6 +73,7 @@ public class NavigationItemModel: NavigationItemModelProtocol { transparent = false backgroundColor = Color(uiColor: .white) tintColor = Color(uiColor: .black) + line = LineModel(type: .standard) } private enum CodingKeys: String, CodingKey { @@ -80,6 +83,7 @@ public class NavigationItemModel: NavigationItemModelProtocol { case backgroundColor case transparent case tintColor + case line case systemBackButton case showLeftPanelButton case showRightPanelButton @@ -95,6 +99,7 @@ public class NavigationItemModel: NavigationItemModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white) transparent = try typeContainer.decodeIfPresent(Bool.self, forKey: .transparent) ?? false tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black) + line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) systemBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .systemBackButton) ?? false showLeftPanelButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .showLeftPanelButton) showRightPanelButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .showRightPanelButton) @@ -110,7 +115,8 @@ public class NavigationItemModel: NavigationItemModelProtocol { try container.encode(backgroundColor, forKey: .backgroundColor) try container.encode(transparent, forKey: .transparent) try container.encode(tintColor, forKey: .tintColor) - try container.encodeIfPresent(systemBackButton, forKey: .systemBackButton) + try container.encodeIfPresent(line, forKey: .line) + try container.encode(systemBackButton, forKey: .systemBackButton) try container.encode(showLeftPanelButton, forKey: .showLeftPanelButton) try container.encode(showRightPanelButton, forKey: .showRightPanelButton) try container.encodeIfPresent(additionalLeftItems, forKey: .additionalLeftItems) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 9300de90..21c92c38 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -31,6 +31,9 @@ NS_ASSUME_NONNULL_BEGIN // Returns the margins for a view. + (UIEdgeInsets)getMarginsForView:(nullable UIView *)view; +/// Gets the current visible view controller. Checks presented view controllers first, and then it checks on the NavigationController in the session object. ++ (UIViewController *)getCurrentVisibleController; + #pragma mark - Setters + (void)setMarginsForView:(nullable UIView *)view leading:(CGFloat)leading top:(CGFloat)top trailing:(CGFloat)trailing bottom:(CGFloat)bottom; diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index b760eb36..4b0278de 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -10,6 +10,7 @@ #import "MVMCoreUIConstants.h" #import "MVMCoreUISession.h" #import "MVMCoreUISplitViewController.h" +#import @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreGetterUtility; @@ -60,6 +61,26 @@ return UIEdgeInsetsMake(view.directionalLayoutMargins.top, view.directionalLayoutMargins.leading, view.directionalLayoutMargins.bottom, view.directionalLayoutMargins.trailing); } ++ (UIViewController *)getCurrentVisibleController { + UIViewController *baseViewController = [MVMCoreNavigationHandler sharedNavigationHandler].viewControllerToPresentOn ?: [UIApplication sharedApplication].keyWindow.rootViewController; + UIViewController *viewController = nil; + while (baseViewController.presentedViewController && !baseViewController.presentedViewController.isBeingDismissed) { + viewController = baseViewController.presentedViewController; + baseViewController = viewController; + } + if ([viewController isKindOfClass:[UINavigationController class]]) { + viewController = ((UINavigationController *)viewController).topViewController; + } + // if it is not presented viewcontroller, existing BAU logic will be working + if (!viewController) { + viewController = [MVMCoreUISession sharedGlobal].navigationController.topViewController; + if ([viewController conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { + viewController = [viewController performSelector:@selector(getCurrentViewController)]; + } + } + return viewController; +} + #pragma mark - Setters + (void)setMarginsForView:(nullable UIView *)view leading:(CGFloat)leading top:(CGFloat)top trailing:(CGFloat)trailing bottom:(CGFloat)bottom { From 776939777bdfe5367f0b3394a5977833c90b812e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 14:28:36 -0400 Subject: [PATCH 059/244] Retain cycle fixes --- MVMCoreUI/Atoms/Buttons/PillButton.swift | 2 +- MVMCoreUI/FormUIHelpers/FormValidator.swift | 2 +- MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift | 2 +- MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atoms/Buttons/PillButton.swift index da8cf0c7..c760c0b7 100644 --- a/MVMCoreUI/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atoms/Buttons/PillButton.swift @@ -130,7 +130,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { self?.enableField(model.enabled) } - FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index 8977fad5..0a14e027 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -14,7 +14,7 @@ import MVMCore static var defaultGroupName: String = "default" var extraValidationBlock: (() -> Bool)? var formRules: [FormGroupRule]? - var delegate: FormHolderProtocol? + weak var delegate: FormHolderProtocol? var fieldMolecules: [String: FormFieldProtocol] = [:] var formActionMolecules: [FormActionFieldProtocol] = [] var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:] diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index 54de3802..c9d5d34c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -13,7 +13,7 @@ open class MVMCoreUIDelegateObject: DelegateObject { public weak var buttonDelegate: ButtonDelegateProtocol? public weak var uiTextFieldDelegate: UITextFieldDelegate? public weak var observingTextFieldDelegate: ObservingTextFieldDelegate? - public var moleculeDelegate: MoleculeDelegateProtocol? + public weak var moleculeDelegate: MoleculeDelegateProtocol? open override func setAll(withDelegate delegate: Any) { super.setAll(withDelegate: delegate) diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index 435e5a24..07df3296 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol MoleculeDelegateProtocol { +public protocol MoleculeDelegateProtocol: AnyObject { /// returns a module for the corresponding module name. func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? From 71fdc43b86aafa9fa9a464313b014a673e8fb35a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 14:55:26 -0400 Subject: [PATCH 060/244] typo fix --- .../BaseControllers/ProgrammaticScrollViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift index 10583b14..b6ed6353 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift +++ b/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift @@ -31,7 +31,7 @@ open class ProgrammaticScrollViewController: ScrollingViewController { let scrollView = UIScrollView() scrollView.backgroundColor = .clear - scrollView.translatesAutoresizingMaskIntoConstraints = true + scrollView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(scrollView) // Sets the constraints for the scroll view From 7b36f466fa862960742ecebca6871f8f8bbbc671 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 15:01:31 -0400 Subject: [PATCH 061/244] navigation item update to fix crash --- MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift | 2 +- MVMCoreUI/Molecules/NavigationItemModelProtocol.swift | 4 ++-- MVMCoreUI/Templates/ListPageTemplateModel.swift | 2 +- MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift | 2 +- MVMCoreUI/Templates/TemplateModel.swift | 2 +- MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift index 7f50873e..5c53ea4e 100644 --- a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift @@ -13,5 +13,5 @@ public protocol PageModelProtocol { var pageType: String { get set } var screenHeading: String? { get set } var isAtomicTabs: Bool? { get set } - var navigationItem: NavigationItemModelProtocol? { get set } + var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } } diff --git a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift index 605b6e5e..d7df7cc9 100644 --- a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol NavigationItemModelProtocol: MoleculeModelProtocol { +public protocol NavigationItemModelProtocol { var title: String? { get set } var titleView: MoleculeModelProtocol? { get set } var hidden: Bool { get set } @@ -50,7 +50,7 @@ public class NavigationItemButtonModel: Codable { } } -public class NavigationItemModel: NavigationItemModelProtocol { +public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtocol { public class var identifier: String { return "navigationItem" } diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index 57d99f26..0188a434 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -22,7 +22,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? - public var navigationItem: NavigationItemModelProtocol? + public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? public var header: MoleculeModelProtocol? public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]? diff --git a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift index c3a4b64e..22934239 100644 --- a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift @@ -17,7 +17,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? - public var navigationItem: NavigationItemModelProtocol? + public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? public init(pageType: String) { self.pageType = pageType diff --git a/MVMCoreUI/Templates/TemplateModel.swift b/MVMCoreUI/Templates/TemplateModel.swift index 053d45fc..786068d0 100644 --- a/MVMCoreUI/Templates/TemplateModel.swift +++ b/MVMCoreUI/Templates/TemplateModel.swift @@ -15,7 +15,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? - public var navigationItem: NavigationItemModelProtocol? + public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? public var formRules: [FormGroupRule]? public init(pageType: String) { diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index c45e7fb7..9ee830e2 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -18,7 +18,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? - public var navigationItem: NavigationItemModelProtocol? + public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? public var header: MoleculeModelProtocol? public var middle: MoleculeModelProtocol? From 8860ced85e2499bb2b2177851d22dc1cff50d880 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 15:22:04 -0400 Subject: [PATCH 062/244] fix typo --- 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 9503a4c6..d68a1170 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -162,7 +162,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in - //TODO: cehck for molecule protocola eqality + //TODO: check for molecule protocola eqaulity let json = moleculeInfo.molecule.toJSON() return json == molecule.toJSON() }) else { return nil } @@ -192,7 +192,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] - //TODO: cehck for molecule protocola eqality + //TODO: check for molecule protocola equality for molecule in molecules { if let removeIndex = moleculesInfo?.firstIndex(where: { molecule.toJSON() == $0.molecule.toJSON() }) { From fec64291ee7a25996a5dd0fd01359ae4ef72f463 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 23 Mar 2020 16:58:45 -0400 Subject: [PATCH 063/244] cleanup --- MVMCoreUI/BaseControllers/ThreeLayerViewController.swift | 4 ++-- MVMCoreUI/Templates/ModalMoleculeListTemplate.swift | 2 +- MVMCoreUI/Templates/MoleculeListTemplate.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift index bf557814..9eacd25c 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift @@ -62,6 +62,8 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController { } open override func handleNewData() { + super.handleNewData() + // Removes the views topView?.removeFromSuperview() middleView?.removeFromSuperview() @@ -78,8 +80,6 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController { heightConstraint?.isActive = false setupLayers() - - super.handleNewData() } //MARK:-Functions to subclass diff --git a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift index 7c62faab..eda35d6b 100644 --- a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift @@ -14,7 +14,7 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate { override open func handleNewData() { super.handleNewData() - closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in + closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { _ in MVMCoreNavigationHandler.shared()?.removeCurrentViewController() }, verticalCentered: false) } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index d68a1170..073d234c 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -162,7 +162,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in - //TODO: check for molecule protocola eqaulity + //TODO: check for molecule protocol eqaulity let json = moleculeInfo.molecule.toJSON() return json == molecule.toJSON() }) else { return nil } @@ -192,7 +192,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] - //TODO: check for molecule protocola equality + //TODO: check for molecule protocol equality for molecule in molecules { if let removeIndex = moleculesInfo?.firstIndex(where: { molecule.toJSON() == $0.molecule.toJSON() }) { From 2226d9beed2b38bb41bcc581d51d436cd82950cd Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Tue, 24 Mar 2020 10:37:48 +0530 Subject: [PATCH 064/244] 190780 - List- Three Column - International Data Divider - Initial commit --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ ...tThreeColumnInternationalDataDivider.swift | 67 +++++++++++++++++++ ...eColumnInternationalDataDividerModel.swift | 52 ++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 128 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f17d7906..06f3740f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -134,6 +134,8 @@ 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; + 8DFBDE1D24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFBDE1C24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift */; }; + 8DFBDE1F24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFBDE1E24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift */; }; 942C372E241149170066E45E /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */; }; 942C372F241149170066E45E /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */; }; 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; }; @@ -519,6 +521,8 @@ 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; + 8DFBDE1C24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDividerModel.swift; sourceTree = ""; }; + 8DFBDE1E24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDivider.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-55Rg.otf"; sourceTree = ""; }; @@ -1227,6 +1231,8 @@ children = ( 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, + 8DFBDE1C24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift */, + 8DFBDE1E24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -1909,6 +1915,7 @@ BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */, 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */, 0A7EF86123D8AC2500B2AAD1 /* DigitEntryFieldModel.swift in Sources */, + 8DFBDE1D24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, @@ -2123,6 +2130,7 @@ 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, 525239C22407BD1000454969 /* ListTwoColumnPriceDetails.swift in Sources */, + 8DFBDE1F24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D2E2A9A323E096B1000B42E6 /* DisableableModelProtocol.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift new file mode 100644 index 00000000..60977ef1 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift @@ -0,0 +1,67 @@ +// +// ListThreeColumnInternationalDataDivider.swift +// MVMCoreUI +// +// Created by Kruthika KP on 23/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnInternationalDataDivider: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + let leftLabel = Label.createLabelBoldBodySmall(true) + let centerLabel = Label.createLabelBoldBodySmall(true) + let rightLabel = Label.createLabelBoldBodySmall(true) + var stack: Stack + + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 34, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - MFViewProtocol + //----------------------------------------------------- + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + //----------------------------------------------------- + // MARK: - ModelMoleculeViewProtocol + //----------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnInternationalDataDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + //----------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //----------------------------------------------------- + override open func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + centerLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } +} + diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift new file mode 100644 index 00000000..19d71073 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift @@ -0,0 +1,52 @@ +// +// ListThreeColumnInternationalDataDividerModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 23/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnInternationalDataDividerModel : ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list3CIntDataDiv" + public var leftLabel: LabelModel + public var centerLabel: LabelModel + public var rightLabel: LabelModel + + public init (leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index f2bf9e78..7bda1e5f 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -117,6 +117,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnInternationalDataDivider.self, viewModelClass: ListThreeColumnInternationalDataDividerModel.self) // Designed Headers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) From 95d705abb48ec48e7a8e02d6a2bc37e38a25ab01 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Tue, 24 Mar 2020 17:02:29 +0530 Subject: [PATCH 065/244] 19078 - List - Three Column - International Data - Updated to latest --- MVMCoreUI.xcodeproj/project.pbxproj | 25 +++++--- .../ListThreeColumnInternationalData.swift} | 59 ++++++++++--------- ...stThreeColumnInternationalDataModel.swift} | 25 +++++--- .../OtherHandlers/MoleculeObjectMapping.swift | 2 +- 4 files changed, 65 insertions(+), 46 deletions(-) rename MVMCoreUI/Molecules/DesignedComponents/{SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift => List/ThreeColumn/ListThreeColumnInternationalData.swift} (58%) rename MVMCoreUI/Molecules/DesignedComponents/{SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift => List/ThreeColumn/ListThreeColumnInternationalDataModel.swift} (62%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 06f3740f..a1bf3ac2 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -134,8 +134,8 @@ 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; - 8DFBDE1D24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFBDE1C24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift */; }; - 8DFBDE1F24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFBDE1E24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift */; }; + 8DFB6D8B242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFB6D8A242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift */; }; + 8DFB6D8D242A138000A3F715 /* ListThreeColumnInternationalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFB6D8C242A138000A3F715 /* ListThreeColumnInternationalData.swift */; }; 942C372E241149170066E45E /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */; }; 942C372F241149170066E45E /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */; }; 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; }; @@ -521,8 +521,8 @@ 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; - 8DFBDE1C24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDividerModel.swift; sourceTree = ""; }; - 8DFBDE1E24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDivider.swift; sourceTree = ""; }; + 8DFB6D8A242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataModel.swift; sourceTree = ""; }; + 8DFB6D8C242A138000A3F715 /* ListThreeColumnInternationalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalData.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-55Rg.otf"; sourceTree = ""; }; @@ -923,6 +923,7 @@ 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */, 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */, + 8DFB6D89242A134600A3F715 /* ThreeColumn */, ); path = OneColumn; sourceTree = ""; @@ -965,6 +966,16 @@ path = TwoColumn; sourceTree = ""; }; + 8DFB6D89242A134600A3F715 /* ThreeColumn */ = { + isa = PBXGroup; + children = ( + 8DFB6D8A242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift */, + 8DFB6D8C242A138000A3F715 /* ListThreeColumnInternationalData.swift */, + ); + name = ThreeColumn; + path = ../ThreeColumn; + sourceTree = ""; + }; 94C01508242155FE005811A9 /* Actions */ = { isa = PBXGroup; children = ( @@ -1231,8 +1242,6 @@ children = ( 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, - 8DFBDE1C24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift */, - 8DFBDE1E24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -1884,6 +1893,7 @@ D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, + 8DFB6D8D242A138000A3F715 /* ListThreeColumnInternationalData.swift in Sources */, 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, @@ -1915,7 +1925,6 @@ BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */, 012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */, 0A7EF86123D8AC2500B2AAD1 /* DigitEntryFieldModel.swift in Sources */, - 8DFBDE1D24288958007F3433 /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, @@ -2130,7 +2139,6 @@ 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, 525239C22407BD1000454969 /* ListTwoColumnPriceDetails.swift in Sources */, - 8DFBDE1F24288965007F3433 /* ListThreeColumnInternationalDataDivider.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D2E2A9A323E096B1000B42E6 /* DisableableModelProtocol.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, @@ -2157,6 +2165,7 @@ D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, + 8DFB6D8B242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, 011D959D2404536F000E3791 /* RuleAnyValueChangedModel.swift in Sources */, D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift b/MVMCoreUI/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift similarity index 58% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift index 60977ef1..948bdb9b 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift @@ -1,28 +1,34 @@ // -// ListThreeColumnInternationalDataDivider.swift +// ListThreeColumnInternationalData.swift // MVMCoreUI // -// Created by Kruthika KP on 23/03/20. +// Created by Kruthika KP on 24/03/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // import Foundation -@objcMembers open class ListThreeColumnInternationalDataDivider: TableViewCell { + +@objcMembers public class ListThreeColumnInternationalData: TableViewCell { //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - let leftLabel = Label.createLabelBoldBodySmall(true) - let centerLabel = Label.createLabelBoldBodySmall(true) - let rightLabel = Label.createLabelBoldBodySmall(true) var stack: Stack + let leftLabel = Label.createLabelRegularBodySmall(true) + let centerLabel = Label.createLabelRegularBodySmall(true) + let rightLabel = Label.createLabelRegularBodySmall(true) + let arrow = Arrow(frame: .zero) + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), - (view: centerLabel, model: StackItemModel(percent: 34, horizontalAlignment: .leading)), - (view: rightLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center))], - axis: .horizontal) + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading)), + (view: arrow, model: StackItemModel(percent: 4, horizontalAlignment: .trailing)), + (view: centerLabel, model: StackItemModel(percent: 46, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent:30,horizontalAlignment: .center))], + axis: .horizontal,spacing: 2) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -31,37 +37,34 @@ import Foundation } //----------------------------------------------------- - // MARK: - MFViewProtocol + // MARK: - View Lifecycle //----------------------------------------------------- - open override func setupView() { + override open func setupView() { super.setupView() addMolecule(stack) - stack.restack() + arrow.pinHeightAndWidth() } - //----------------------------------------------------- - // MARK: - ModelMoleculeViewProtocol - //----------------------------------------------------- - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListThreeColumnInternationalDataDividerModel else { return } + guard let model = model as? ListThreeColumnInternationalDataModel else { return } leftLabel.set(with: model.leftLabel, delegateObject, additionalData) centerLabel.set(with: model.centerLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + arrow.set(with: model.arrow, delegateObject, additionalData) + stack.restack() } - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 121 + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 } - //----------------------------------------------------- - // MARK: - MVMCoreUIMoleculeViewProtocol - //----------------------------------------------------- - override open func reset() { + open override func reset() { super.reset() - leftLabel.styleBoldBodySmall(true) - centerLabel.styleBoldBodySmall(true) - rightLabel.styleBoldBodySmall(true) + leftLabel.styleRegularBodySmall(true) + centerLabel.styleRegularBodySmall(true) + rightLabel.styleRegularBodySmall(true) + arrow.reset() } + } - diff --git a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift similarity index 62% rename from MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift rename to MVMCoreUI/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift index 19d71073..5a2ceff2 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift @@ -1,36 +1,41 @@ // -// ListThreeColumnInternationalDataDividerModel.swift +// ListThreeColumnInternationalDataModel.swift // MVMCoreUI // -// Created by Kruthika KP on 23/03/20. +// Created by Kruthika KP on 24/03/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // import Foundation -public class ListThreeColumnInternationalDataDividerModel : ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "list3CIntDataDiv" +public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModelProtocol { + + public static var identifier: String = "list3CIntData" public var leftLabel: LabelModel public var centerLabel: LabelModel public var rightLabel: LabelModel + public var arrow: ArrowModel - public init (leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel) { + public init(leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel,arrow:ArrowModel){ self.leftLabel = leftLabel self.centerLabel = centerLabel self.rightLabel = rightLabel + self.arrow = arrow super.init() } - override public func setDefaults() { + public override func setDefaults() { super.setDefaults() - style = "tallDivider" + arrow.degrees = 50 + arrow.color = Color.init(uiColor: .mvmGreen) } - private enum CodingKeys: String, CodingKey { + private enum CodingKeys: String, CodingKey{ case moleculeName case leftLabel case centerLabel case rightLabel + case arrow } required public init(from decoder: Decoder) throws { @@ -38,15 +43,17 @@ public class ListThreeColumnInternationalDataDividerModel : ListItemModel, Molec leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + arrow = try typeContainer.decode(ArrowModel.self, forKey: .arrow) try super.init(from: decoder) } - public override func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(leftLabel, forKey: .leftLabel) try container.encode(centerLabel, forKey: .centerLabel) try container.encode(rightLabel, forKey: .rightLabel) + try container.encode(arrow, forKey: .arrow) } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 7bda1e5f..666a5c61 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -110,6 +110,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) // Designed Section Dividers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) @@ -117,7 +118,6 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnInternationalDataDivider.self, viewModelClass: ListThreeColumnInternationalDataDividerModel.self) // Designed Headers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) From cc051713320bbf07d1396d669dfd09cde9f6525e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 09:25:47 -0400 Subject: [PATCH 066/244] for now --- MVMCoreUI/Atoms/TextFields/DigitEntryField.swift | 10 ++-------- MVMCoreUI/Atoms/TextFields/EntryField.swift | 2 +- MVMCoreUI/Atoms/TextFields/TextEntryField.swift | 10 +++++++--- .../MVMCoreUICommonViewsUtility+Extension.swift | 3 +++ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index b249d89f..3d0b69a5 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -207,7 +207,7 @@ import UIKit let digitBox = DigitBox() digitBox.isAccessibilityElement = true - MVMCoreUICommonViewsUtility.addDismissToolbar(digitBox.digitField, delegate: self) + digitBox.digitField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: self) digitBox.digitField.delegate = self digitBox.digitBoxDelegate = self return digitBox @@ -329,18 +329,12 @@ import UIKit } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - - + guard let model = model as? DigitEntryFieldModel else { return } numberOfDigits = model.digits - setAsSecureTextEntry(model.secureEntry) - for digitBox in digitBoxes { - digitBox.digitField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: delegateObject?.observingTextFieldDelegate ?? self) - } - super.set(with: model, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atoms/TextFields/EntryField.swift index 43a15a3b..cafa91be 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryField.swift @@ -117,7 +117,7 @@ import UIKit feedbackLabel.text = newFeedback feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true entryFieldContainer.refreshUI() - delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) +// delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) } } diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index 33f75604..c97412a8 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -49,6 +49,10 @@ import UIKit /// Validate when user resigns editing. Default: true public var validateWhenDoneEditing: Bool = true + + public var textEntryFieldModel: TextEntryFieldModel? { + return model as? TextEntryFieldModel + } //-------------------------------------------------- // MARK: - Computed Properties @@ -87,7 +91,7 @@ import UIKit get { return textField.text } set { textField.text = newValue - (model as? TextEntryFieldModel)?.text = newValue + textEntryFieldModel?.text = newValue } } @@ -167,7 +171,8 @@ import UIKit textField.heightAnchor.constraint(equalToConstant: 24), textField.topAnchor.constraint(equalTo: container.topAnchor, constant: 12), textField.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 16), - container.bottomAnchor.constraint(equalTo: textField.bottomAnchor, constant: 12)]) + container.bottomAnchor.constraint(equalTo: textField.bottomAnchor, constant: 12) + ]) textFieldTrailingConstraint = container.trailingAnchor.constraint(equalTo: textField.trailingAnchor, constant: 16) textFieldTrailingConstraint?.isActive = true @@ -366,7 +371,6 @@ extension TextEntryField { defaultValidationBlock() } - uiTextFieldDelegate = delegateObject.uiTextFieldDelegate observingTextFieldDelegate = delegateObject.observingTextFieldDelegate MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift index 70c84d40..3ee452b0 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility+Extension.swift @@ -9,12 +9,15 @@ import Foundation public extension MVMCoreUICommonViewsUtility { + static func getToolbarWithDoneButton(delegate: ObservingTextFieldDelegate) -> UIToolbar { + let toolbar = self.makeEmptyToolbar() let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) let button = UIBarButtonItem(barButtonSystemItem: .done, target: delegate, action: #selector(ObservingTextFieldDelegate.dismissFieldInput(sender:))) button.tintColor = .black toolbar.setItems([space, button], animated: false) + return toolbar } } From 7fdff34eeb1ba962bff869297fde964d6bda774a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 24 Mar 2020 09:54:18 -0400 Subject: [PATCH 067/244] Warning and analyze fixes --- .../MVMCoreUISplitViewController.m | 3 +-- .../MVMCoreUITabBarPageControlViewController.m | 2 +- MVMCoreUI/Legacy/Controllers/MFViewController.h | 3 --- MVMCoreUI/Legacy/Controllers/MFViewController.m | 17 ----------------- .../TopLabelsAndBottomButtonsViewController.m | 15 ++++++++------- MVMCoreUI/Legacy/Views/MFCaretButton.m | 6 +++--- MVMCoreUI/Legacy/Views/MFCaretView.m | 2 +- MVMCoreUI/Legacy/Views/MFRadioButton.h | 8 ++++---- MVMCoreUI/Legacy/Views/MFTextField.h | 4 ---- MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m | 6 +++--- MVMCoreUI/Legacy/Views/SeparatorView.h | 3 --- .../TopAlert/MVMCoreUITopAlertExpandableView.m | 8 ++++---- MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m | 14 +++++++------- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 2 +- MVMCoreUI/Utility/MVMCoreUIUtility.m | 2 +- MVMCoreUI/Utility/Sizing/MFSizeObject.m | 2 +- 16 files changed, 35 insertions(+), 62 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 44642f3a..476e7264 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -100,7 +100,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth { CGFloat width; - if (forWidth) { + if (forWidth != nil) { width = [forWidth floatValue]; } else { width = [MVMCoreUISplitViewController getApplicationViewWidth]; @@ -814,7 +814,6 @@ CGFloat const PanelAnimationDuration = 0.2; // The main view. NavigationController *navigationController = [NavigationController setupNavigationController]; self.navigationController = navigationController; - self.automaticallyAdjustsScrollViewInsets = NO; UIView *mainView = navigationController.view; mainView.translatesAutoresizingMaskIntoConstraints = NO; diff --git a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m index d700e57f..1df6bd67 100644 --- a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m +++ b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m @@ -181,7 +181,7 @@ __block NSInteger currentIndex = NSNotFound; if (!self.loadObject.pageDataFromCache) { NSNumber *currentIndexNumber = [self.loadObject.pageJSON optionalNumberForKey:@"currentTabIndex"]; - if (currentIndexNumber) { + if (currentIndexNumber != nil) { currentIndex = [currentIndexNumber integerValue]; } } diff --git a/MVMCoreUI/Legacy/Controllers/MFViewController.h b/MVMCoreUI/Legacy/Controllers/MFViewController.h index 38ced354..cd96a07f 100644 --- a/MVMCoreUI/Legacy/Controllers/MFViewController.h +++ b/MVMCoreUI/Legacy/Controllers/MFViewController.h @@ -96,9 +96,6 @@ // This view controller should subclass this function and check the load to make sure it has all the needed data. Fills the error object if there are any errors. Returns if we should finish the load or not. - (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error; -/// Called in newDataBuildScreen. Can override to parse the json into a model object. -- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error; - // Sets the screen to use the screen heading. // it is required in device flow, where we are showing greeting name as screen heading, // device details screen heading needs to be updated/refreshed again, if user has changed device nick name diff --git a/MVMCoreUI/Legacy/Controllers/MFViewController.m b/MVMCoreUI/Legacy/Controllers/MFViewController.m index 52cf01cf..febb14cf 100644 --- a/MVMCoreUI/Legacy/Controllers/MFViewController.m +++ b/MVMCoreUI/Legacy/Controllers/MFViewController.m @@ -88,25 +88,10 @@ self.pageType = loadObject.pageType; self.loadObject = loadObject; - NSError *parseError = nil; - [self parsePageJSON:&parseError]; - if (parseError) { - if (error) { - MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; - errorObject.messageToDisplay = [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess]; - *error = errorObject; - } - return false; - } - // Verifies all modules needed are loaded. return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error]; } -- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error { - -} - // Sets the screen to use the screen heading. // it is required in device flow, where we are showing greeting name as screen heading, // device details screen heading needs to be updated/refreshed again, if user has changed device nick name @@ -255,8 +240,6 @@ - (BOOL)newPageLoaded:(nonnull NSDictionary *)page { self.loadObject.pageJSON = page; - NSError *parseError = nil; - [self parsePageJSON:&parseError]; return YES; } diff --git a/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.m index 5998c5da..f99bce31 100644 --- a/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.m @@ -35,8 +35,8 @@ @property (strong, nonatomic) UIView *topAccessoryView; // Adds the button view to the screen. Out of the scroll or in. -- (void)addViewOutsideOfScrollView:(UIView *)bottomView; -- (void)addViewToContentView:(UIView *)bottomView; +- (void)addViewOutsideOfScrollView:(nonnull UIView *)bottomView; +- (void)addViewToContentView:(nonnull UIView *)bottomView; @end @@ -133,8 +133,7 @@ self.topConstraintForTopView.active = YES; // Checks if we are using a different object than the bottom buttons. UIView *bottomView = [self useCustomViewInsteadOfButtons]; - self.customBottemView = (bottomView != nil); - if (!self.customBottemView) { + if (bottomView == nil) { // Sets up the buttons/button. NSDictionary *primaryButtonDictionary = [self primaryButtonMap]; @@ -144,8 +143,10 @@ self.primaryButton = buttonView.primaryButton; bottomView = buttonView; self.bottomView = bottomView; + self.customBottemView = NO; } else { self.bottomView = bottomView; + self.customBottemView = YES; } [self updateTopLabelsBottomButtonsPadding]; @@ -220,7 +221,7 @@ // Needs the height constraint heightConstraint.active = YES; - if (!spaceAbove && !spaceBelow) { + if (spaceAbove == nil && spaceBelow == nil) { // No set space above or below, make the spacers the same height with a default minimum. UIView *topSpacer = [MVMCoreUICommonViewsUtility commonView]; @@ -237,7 +238,7 @@ minimumHeightSpacer.active = YES; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topBetweenEdgeView]-0-[topSpacer]-0-[viewBetween]-0-[bottomSpacer]-0-[bottomBetweenEdgeView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topBetweenEdgeView,topSpacer,viewBetween,bottomSpacer,bottomBetweenEdgeView)]]; - } else if (spaceAbove) { + } else if (spaceAbove != nil) { // Space above is set, space below is free. UIView *bottomSpacer = [MVMCoreUICommonViewsUtility commonView]; @@ -249,7 +250,7 @@ NSDictionary *verticalMetrics = @{@"top":spaceAbove}; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topBetweenEdgeView]-top-[viewBetween]-0-[bottomSpacer]-0-[bottomBetweenEdgeView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:verticalMetrics views:NSDictionaryOfVariableBindings(topBetweenEdgeView,viewBetween,bottomSpacer,bottomBetweenEdgeView)]]; - } else if (spaceBelow) { + } else if (spaceBelow != nil) { // Space below is set, space above is free. UIView *topSpacer = [MVMCoreUICommonViewsUtility commonView]; diff --git a/MVMCoreUI/Legacy/Views/MFCaretButton.m b/MVMCoreUI/Legacy/Views/MFCaretButton.m index bd8f058c..e5deff1c 100644 --- a/MVMCoreUI/Legacy/Views/MFCaretButton.m +++ b/MVMCoreUI/Legacy/Views/MFCaretButton.m @@ -49,7 +49,7 @@ CGFloat const CaretViewWidth = 6.6f; - (void)addCaretImageView { [self.rightView removeFromSuperview]; UIEdgeInsets edgeInsets = self.contentEdgeInsets; - CGFloat rightInset = self.rightViewWidth?self.rightViewWidth.floatValue:CaretViewWidth; + CGFloat rightInset = self.rightViewWidth != nil ? self.rightViewWidth.floatValue : CaretViewWidth; UIEdgeInsets newInsets = UIEdgeInsetsMake(edgeInsets.top, edgeInsets.left, edgeInsets.bottom, 4 + rightInset); self.contentEdgeInsets = newInsets; UIView *caretViewIs = self.rightView; @@ -60,11 +60,11 @@ CGFloat const CaretViewWidth = 6.6f; self.rightView.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:self.rightView]; - CGFloat width = self.rightViewWidth?self.rightViewWidth.floatValue:CaretViewWidth; + CGFloat width = self.rightViewWidth != nil ? self.rightViewWidth.floatValue : CaretViewWidth; NSLayoutConstraint *caretViewWidthConstraint = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width]; caretViewWidthConstraint.active = YES; - CGFloat height = self.rightViewHeight?self.rightViewHeight.floatValue:CaretViewHeight; + CGFloat height = self.rightViewHeight != nil ? self.rightViewHeight.floatValue : CaretViewHeight; NSLayoutConstraint *caretViewHeightConstraint = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:height]; caretViewHeightConstraint.active = YES; diff --git a/MVMCoreUI/Legacy/Views/MFCaretView.m b/MVMCoreUI/Legacy/Views/MFCaretView.m index 182f7a74..c8036f57 100644 --- a/MVMCoreUI/Legacy/Views/MFCaretView.m +++ b/MVMCoreUI/Legacy/Views/MFCaretView.m @@ -65,7 +65,7 @@ CGContextClearRect(context, rect); CGFloat lineWidth; - if (self.lineWidth) { + if (self.lineWidth != nil) { lineWidth = self.lineWidth.floatValue; } else { lineWidth = self.frame.size.width/2.6; diff --git a/MVMCoreUI/Legacy/Views/MFRadioButton.h b/MVMCoreUI/Legacy/Views/MFRadioButton.h index c5e053c0..740a6192 100644 --- a/MVMCoreUI/Legacy/Views/MFRadioButton.h +++ b/MVMCoreUI/Legacy/Views/MFRadioButton.h @@ -43,10 +43,10 @@ typedef void (^CircleSelectedClosure)(_Nonnull id sender); @property (nonatomic, strong, nullable) NSLayoutConstraint *widthConstraint; @property (nonatomic) BOOL respondsToTapGesture; @property (nonatomic, getter = isSelected) BOOL selected; -@property (strong, nonatomic) NSLayoutConstraint *innerHeightConstarint; -@property (strong, nonatomic) NSLayoutConstraint *innerWidthConstarint; -@property (strong, nonatomic) NSLayoutConstraint *outerHeightConstarint; -@property (strong, nonatomic) NSLayoutConstraint *outerWidthConstarint; +@property (strong, nonatomic, nullable) NSLayoutConstraint *innerHeightConstarint; +@property (strong, nonatomic, nullable) NSLayoutConstraint *innerWidthConstarint; +@property (strong, nonatomic, nullable) NSLayoutConstraint *outerHeightConstarint; +@property (strong, nonatomic, nullable) NSLayoutConstraint *outerWidthConstarint; // Set line width manually - (void)setCheckMarkLineWidth:(CGFloat)lineWidth; diff --git a/MVMCoreUI/Legacy/Views/MFTextField.h b/MVMCoreUI/Legacy/Views/MFTextField.h index 323c59fd..260bc936 100644 --- a/MVMCoreUI/Legacy/Views/MFTextField.h +++ b/MVMCoreUI/Legacy/Views/MFTextField.h @@ -131,8 +131,4 @@ - (void)setAccessibilityString:(nullable NSString *)accessibilityString; -// For Validator Protocol -- (nullable NSString *)formFieldName; -- (nullable id)formFieldValue; - @end diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m index 4a7125fe..0799c224 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m +++ b/MVMCoreUI/Legacy/Views/MVMCoreUISwitch.m @@ -61,21 +61,21 @@ const CGFloat SwitchShakeIntensity = 2; } - (instancetype)initWithCoder:(NSCoder *)coder { - if ([super initWithCoder:coder]) { + if (self = [super initWithCoder:coder]) { [self setupView]; } return self; } - (instancetype)initWithFrame:(CGRect)frame { - if ([super initWithFrame:frame]) { + if (self = [super initWithFrame:frame]) { [self setupView]; } return self; } - (instancetype)init { - if ([super init]) { + if (self = [super init]) { [self setupView]; } return self; diff --git a/MVMCoreUI/Legacy/Views/SeparatorView.h b/MVMCoreUI/Legacy/Views/SeparatorView.h index 40489b16..89a9197d 100644 --- a/MVMCoreUI/Legacy/Views/SeparatorView.h +++ b/MVMCoreUI/Legacy/Views/SeparatorView.h @@ -41,7 +41,4 @@ typedef enum : NSUInteger { - (void)setAsLight; - (void)setAsMedium; -/// Returns if the separator should be visible based on the type. -- (BOOL)shouldBeVisible; - @end diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index cc25cd9b..6fc7121f 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -79,7 +79,7 @@ } - (nullable instancetype)initWithTopAlertObject:(nonnull MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nullable id )animationDelegate viewToLayout:(nonnull UIView *)viewTolayout { - if ([self init]) { + if (self = [self init]) { self.animationDelegate = animationDelegate; self.viewToLayout = viewTolayout; @@ -119,7 +119,7 @@ } - (nullable instancetype)initWithTopMessage:(nullable NSString *)topMessage message:(nullable NSString *)message contentColor:(nonnull UIColor *)contentColor buttonTitle:(nullable NSString *)buttonTitle animationDelegate:(nullable id )animationDelegate viewToLayout:(nonnull UIView *)viewTolayout { - if ([self init]) { + if (self = [self init]) { self.animationDelegate = animationDelegate; self.viewToLayout = viewTolayout; [self setupViewWithTopMessage:topMessage message:message subMessage:nil contentColor:contentColor buttonTitle:buttonTitle]; @@ -128,7 +128,7 @@ } - (nullable instancetype)initWithTopMessage:(nullable NSString *)topMessage message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage contentColor:(nonnull UIColor *)contentColor buttonTitle:(nullable NSString *)buttonTitle animationDelegate:(nullable id )animationDelegate viewToLayout:(nonnull UIView *)viewTolayout { - if ([self init]) { + if (self = [self init]) { self.animationDelegate = animationDelegate; self.viewToLayout = viewTolayout; [self setupViewWithTopMessage:topMessage message:message subMessage:subMessage contentColor:contentColor buttonTitle:buttonTitle]; @@ -137,7 +137,7 @@ } - (nullable instancetype)initWithTopMessage:(nullable NSString *)topMessage message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage contentColor:(nonnull UIColor *)contentColor actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData animationDelegate:(nullable id )animationDelegate viewToLayout:(nonnull UIView *)viewTolayout { - if ([self init]) { + if (self = [self init]) { self.animationDelegate = animationDelegate; self.viewToLayout = viewTolayout; [self setupViewWithTopMessage:topMessage message:message subMessage:subMessage contentColor:contentColor actionMap:actionMap additionalData:additionalData]; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m index 5b87d163..4ebfd013 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m @@ -59,7 +59,7 @@ } - (nullable instancetype)initWithTopAlertObject:(nonnull MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nullable id )animationDelegate { - if ([self init]) { + if (self = [self init]) { UIColor *contentColor = topAlertObject.textColor ?: [[MVMCoreUITopAlertView sharedGlobal] getContentColorForType:topAlertObject.type]; self.backgroundColor = topAlertObject.backgroundColor ?: [[MVMCoreUITopAlertView sharedGlobal] getBackgroundColorForType:topAlertObject.type]; [self setupViewWithLabelAndImage:topAlertObject.imageNameOrURL topImage:topAlertObject.aboveTextImageString]; @@ -72,7 +72,7 @@ - (nullable instancetype)initWithColor:(nonnull UIColor *)color contentColor:(nullable UIColor *)contentColor message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData closeButton:(BOOL)closeButton animationDelegate:(nullable id )animationDelegate { // Handles all scenarios. - if ([self init]) { + if (self = [self init]) { self.backgroundColor = color; [self setupViewWithLabelAndImage:nil topImage:nil]; [self setupCloseButton:closeButton animationDelegate:animationDelegate]; @@ -86,7 +86,7 @@ - (nullable instancetype)initWithColor:(nonnull UIColor *)color contentColor:(nullable UIColor *)contentColor imageURL:(nullable NSString *)imageURL message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData closeButton:(BOOL)closeButton animationDelegate:(nullable id )animationDelegate { // Handles all scenarios. - if ([self init]) { + if (self = [self init]) { self.backgroundColor = color; [self setupViewWithLabelAndImage:imageURL topImage:nil]; [self setupCloseButton:closeButton animationDelegate:animationDelegate]; @@ -98,7 +98,7 @@ - (nullable instancetype)initWithColor:(nonnull UIColor *)color contentColor:(nullable UIColor *)contentColor imageURL:(nullable NSString *)imageURL message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage closeButton:(BOOL)closeButton animationDelegate:(nullable id )animationDelegate { // No main button. - if ([self init]) { + if (self = [self init]) { self.backgroundColor = color; [self setupViewWithLabelAndImage:imageURL topImage:nil]; [self setupCloseButton:closeButton animationDelegate:animationDelegate]; @@ -286,7 +286,7 @@ - (nullable instancetype)initWithColor:(nonnull UIColor *)color contentColor:(nonnull UIColor *)contentColor message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData { // No icon or close button. - if ([self init]) { + if (self = [self init]) { self.backgroundColor = color; [self setupViewWithLabelAndImage:nil topImage:nil]; [self setupWithMessage:message subMessage:subMessage color:contentColor actionMap:actionMap additionalData:additionalData]; @@ -297,7 +297,7 @@ - (nullable instancetype)initWithColor:(nonnull UIColor *)color contentColor:(nonnull UIColor *)contentColor message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage closeButton:(BOOL)closeButton animationDelegate:(nullable id )animationDelegate { // No main button. - if ([self init]) { + if (self = [self init]) { self.backgroundColor = color; [self setupViewWithLabelAndImage:nil topImage:nil]; [self setupWithMessage:message subMessage:subMessage color:contentColor buttonTitle:nil userActionHandler:NULL]; @@ -309,7 +309,7 @@ - (nullable instancetype)initWithColor:(nonnull UIColor *)color contentColor:(nonnull UIColor *)contentColor message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler { // No icon or close button. Custom button action. - if ([self init]) { + if (self = [self init]) { self.backgroundColor = color; [self setupViewWithLabelAndImage:nil topImage:nil]; [self setupWithMessage:message subMessage:subMessage color:contentColor buttonTitle:buttonTitle userActionHandler:userActionHandler]; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 930828f6..5a94137a 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -86,7 +86,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; - (void)pinATopViewController:(UIViewController *)viewController { self.statusBarHeightConstraint.active = NO; - id topGuide = viewController.topLayoutGuide; + id topGuide = viewController.view.safeAreaLayoutGuide.topAnchor; self.statusBarBottomConstraint = [NSLayoutConstraint constraintWithItem:self.statusBarView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:topGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; self.statusBarBottomConstraint.active = YES; } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index 4b0278de..bcead7fe 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -150,7 +150,7 @@ } + (CGFloat)getHeightOfView:(nonnull UIView *)view forWidth:(nullable NSNumber *)width { - CGFloat floatWidth = (width ? width.floatValue : [MVMCoreUIUtility getWidth]); + CGFloat floatWidth = (width != nil ? width.floatValue : [MVMCoreUIUtility getWidth]); return [view systemLayoutSizeFittingSize:CGSizeMake(floatWidth, UILayoutFittingCompressedSize.height) withHorizontalFittingPriority:1000 verticalFittingPriority:250].height; } diff --git a/MVMCoreUI/Utility/Sizing/MFSizeObject.m b/MVMCoreUI/Utility/Sizing/MFSizeObject.m index 1acf878b..792e2d81 100644 --- a/MVMCoreUI/Utility/Sizing/MFSizeObject.m +++ b/MVMCoreUI/Utility/Sizing/MFSizeObject.m @@ -30,7 +30,7 @@ CGFloat const MFSizeiPadProLandscapeThreshold = 1300; + (CGFloat)getScaledValue:(CGFloat)value forSize:(CGFloat)size fromBase:(nullable NSNumber *)base { CGFloat baseFloat = 375.0; - if (base) { + if (base != nil) { baseFloat = [base floatValue]; } return value * (size/baseFloat); From f0870bda5d93c926afa5b242c954e18480ab2a6e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 10:09:15 -0400 Subject: [PATCH 068/244] wip --- MVMCoreUI/Atoms/TextFields/EntryField.swift | 3 +-- .../Containers/Views/EntryFieldContainer.swift | 14 +++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atoms/TextFields/EntryField.swift index cafa91be..551d188d 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryField.swift @@ -116,8 +116,7 @@ import UIKit set (newFeedback) { feedbackLabel.text = newFeedback feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true - entryFieldContainer.refreshUI() -// delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + entryFieldContainer.refreshUI(moleculeLayoutUpdated: true) } } diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index 773721f7..3755a411 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -260,14 +260,22 @@ import UIKit refreshUI(bottomBarSize: 1) } - open func refreshUI(bottomBarSize: CGFloat? = nil) { + open func refreshUI(bottomBarSize: CGFloat? = nil, moleculeLayoutUpdated: Bool = false) { if !disableAllBorders { let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) + var heightChanged = false + + if let bottomHeight = bottomBar?.bounds.height { + heightChanged = size != bottomHeight + } bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) - delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) - setNeedsDisplay() + if moleculeLayoutUpdated || heightChanged { + delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + setNeedsDisplay() + } + layoutIfNeeded() } } From a1d43e338cb1376514eff850b9250292e201d207 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 11:01:08 -0400 Subject: [PATCH 069/244] Flip value because it kept going true when nothing changed --- MVMCoreUI/BaseControllers/ViewController.swift | 15 ++++++++------- .../Containers/Views/EntryFieldContainer.swift | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 39226786..4bc6c159 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -27,7 +27,7 @@ import UIKit public var formValidator: FormValidator? - public var needsUpdateUI = true + public var needsUpdateUI = false private var observingForResponses = false private var initialLoadFinished = false private var previousScreenSize = CGSize.zero @@ -36,7 +36,7 @@ import UIKit /// Checks if the screen width has changed open func screenSizeChanged() -> Bool { - return MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) + return !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) } // MARK: - Response handling @@ -276,17 +276,18 @@ import UIKit open override func viewDidLayoutSubviews() { // Add to fix a constraint bug where the width is zero and things get messed up. - guard isViewLoaded, - view.bounds.width > 1 else { - super.viewDidLayoutSubviews() - return + guard isViewLoaded, view.bounds.width > 1 else { + super.viewDidLayoutSubviews() + return } + if needsUpdateUI || screenSizeChanged() { updateViews() needsUpdateUI = false } + previousScreenSize = view.bounds.size; - + super.viewDidLayoutSubviews() } diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index 3755a411..a88e7f67 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -273,9 +273,9 @@ import UIKit if moleculeLayoutUpdated || heightChanged { delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) - setNeedsDisplay() } + setNeedsDisplay() layoutIfNeeded() } } From dbff191a8b1ecb262e2065e52f1daa292aa5935a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 11:04:28 -0400 Subject: [PATCH 070/244] name change --- MVMCoreUI/Atoms/TextFields/EntryField.swift | 2 +- MVMCoreUI/Containers/Views/EntryFieldContainer.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atoms/TextFields/EntryField.swift index 551d188d..48214210 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryField.swift @@ -116,7 +116,7 @@ import UIKit set (newFeedback) { feedbackLabel.text = newFeedback feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true - entryFieldContainer.refreshUI(moleculeLayoutUpdated: true) + entryFieldContainer.refreshUI(updateMoleculeLayout: true) } } diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index a88e7f67..494eaf5c 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -260,7 +260,7 @@ import UIKit refreshUI(bottomBarSize: 1) } - open func refreshUI(bottomBarSize: CGFloat? = nil, moleculeLayoutUpdated: Bool = false) { + open func refreshUI(bottomBarSize: CGFloat? = nil, updateMoleculeLayout: Bool = false) { if !disableAllBorders { let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) @@ -271,7 +271,7 @@ import UIKit } bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) - if moleculeLayoutUpdated || heightChanged { + if updateMoleculeLayout || heightChanged { delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) } From 93bddcd94562ad6da0299f1f78165fe07d13c5d4 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 11:06:25 -0400 Subject: [PATCH 071/244] reset val --- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 4bc6c159..2603e9e7 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -27,7 +27,7 @@ import UIKit public var formValidator: FormValidator? - public var needsUpdateUI = false + public var needsUpdateUI = true private var observingForResponses = false private var initialLoadFinished = false private var previousScreenSize = CGSize.zero From 7a86b0356bdb3b6bb35a1f3dc9376da890b1fd6e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 24 Mar 2020 12:45:01 -0400 Subject: [PATCH 072/244] Further cleaning --- MVMCoreUI.xcodeproj/project.pbxproj | 32 +++++---- .../Atoms/TextFields/TextEntryField.swift | 9 +-- .../TextFields/TextEntryFieldModel.swift | 11 ++- .../Atoms/Views/CheckboxLabelModel.swift | 2 +- .../Atomic/Atoms/Views/Label/Label.swift | 14 ++-- .../Label/LabelAttributeColorModel.swift | 4 +- .../Views/Label/LabelAttributeFontModel.swift | 4 +- .../Atomic/Atoms/Views/Label/LabelModel.swift | 20 ++++-- .../NSLayoutConstraintAxis+Extension.swift | 0 ...llectionViewScrollPosition+Extension.swift | 71 +++++++++++++++++++ .../UIStackViewAlignment+Extension.swift | 0 ...tOneColumnFullWidthTextBodyTextModel.swift | 2 +- .../ListThreeColumnPlanDataDividerModel.swift | 6 +- .../RadioButtonLabelModel.swift | 2 +- .../HeadlineBody.swift | 14 ++-- .../HeadlineBodyCaretLinkImageModel.swift | 2 +- .../HeadlineBodyModel.swift | 10 ++- MVMCoreUI/Atomic/Organisms/Carousel.swift | 17 +---- .../Atomic/Organisms/CarouselModel.swift | 4 +- .../ModelProtocols}/ButtonModelProtocol.swift | 0 .../CarouselItemModelProtocol.swift | 0 .../CarouselPagingModelProtocol.swift | 0 .../ContainerModelProtocol.swift | 0 .../DisableableModelProtocol.swift | 0 .../ListItemModelProtocol.swift | 0 .../MoleculeModelProtocol.swift | 0 .../ModelProtocols/PageModelProtocol.swift | 1 + .../PageModelProtocol.swift.orig | 20 ++++++ .../TemplateModelProtocol.swift | 0 .../Protocols/MoleculeDelegateProtocol.swift | 4 +- .../Protocols/MoleculeViewProtocol.swift | 4 +- .../Atomic/Protocols/TemplateProtocol.swift | 3 +- .../Templates/ListPageTemplateModel.swift | 5 -- .../Templates/MoleculeListCellProtocol.swift | 2 +- .../Templates/StackPageTemplateModel.swift | 5 -- .../Atomic/Templates/TemplateModel.swift | 4 +- .../ThreeLayerPageTemplateModel.swift | 36 +++------- MVMCoreUI/BaseClasses/Control.swift | 1 - MVMCoreUI/BaseClasses/View.swift | 1 - 39 files changed, 194 insertions(+), 116 deletions(-) rename MVMCoreUI/{Utility => Atomic/Extensions}/NSLayoutConstraintAxis+Extension.swift (100%) create mode 100644 MVMCoreUI/Atomic/Extensions/UICollectionViewScrollPosition+Extension.swift rename MVMCoreUI/{Utility => Atomic/Extensions}/UIStackViewAlignment+Extension.swift (100%) rename MVMCoreUI/{BaseClasses => Atomic/Protocols/ModelProtocols}/ButtonModelProtocol.swift (100%) rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/CarouselItemModelProtocol.swift (100%) rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/CarouselPagingModelProtocol.swift (100%) rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/ContainerModelProtocol.swift (100%) rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/DisableableModelProtocol.swift (100%) rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/ListItemModelProtocol.swift (100%) rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/MoleculeModelProtocol.swift (100%) rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/PageModelProtocol.swift (90%) create mode 100644 MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig rename MVMCoreUI/{Models => Atomic/Protocols}/ModelProtocols/TemplateModelProtocol.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b4c2e578..481bfe6c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -192,6 +192,8 @@ C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* ListRVWheel.swift */; }; C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* ListRVWheelModel.swift */; }; + D202AFE4242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D202AFE3242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift */; }; + D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; @@ -573,6 +575,8 @@ C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = ""; }; C7F8012023E8303200396FBD /* ListRVWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRVWheel.swift; sourceTree = ""; }; C7F8012223E846C300396FBD /* ListRVWheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRVWheelModel.swift; sourceTree = ""; }; + D202AFE3242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSTextAlignment+Extension.swift"; sourceTree = ""; }; + D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionViewScrollPosition+Extension.swift"; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; @@ -807,6 +811,7 @@ 011B58EE23A2AA850085F53C /* ModelProtocols */ = { isa = PBXGroup; children = ( + D2E2A9A023E095AB000B42E6 /* ButtonModelProtocol.swift */, 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */, 012A88C3238D86E600FE3DA1 /* CarouselItemModelProtocol.swift */, 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */, @@ -843,14 +848,6 @@ path = CustomPrimitives; sourceTree = ""; }; - 01509D96232803B200EF99AA /* Models */ = { - isa = PBXGroup; - children = ( - 011B58EE23A2AA850085F53C /* ModelProtocols */, - ); - path = Models; - sourceTree = ""; - }; 01C74D87224298E2009C25A3 /* FormUIHelpers */ = { isa = PBXGroup; children = ( @@ -1001,6 +998,17 @@ path = RightVariable; sourceTree = ""; }; + D202AFE2242A5F1400E5BEDF /* Extensions */ = { + isa = PBXGroup; + children = ( + D202AFE3242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift */, + 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */, + D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */, + D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */, + ); + path = Extensions; + sourceTree = ""; + }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -1293,7 +1301,6 @@ isa = PBXGroup; children = ( D2C78CD324252F4E00B69FDE /* Atomic */, - 01509D96232803B200EF99AA /* Models */, 012A88EF23985E0100FE3DA1 /* CustomPrimitives */, D2B18B7D236090D500A9AEDC /* BaseClasses */, 01C74D87224298E2009C25A3 /* FormUIHelpers */, @@ -1459,8 +1466,6 @@ D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */, D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */, 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */, - 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */, - D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */, ); path = Utility; sourceTree = ""; @@ -1678,7 +1683,6 @@ D2B18B7D236090D500A9AEDC /* BaseClasses */ = { isa = PBXGroup; children = ( - D2E2A9A023E095AB000B42E6 /* ButtonModelProtocol.swift */, C003506023AA94CD00B6AC29 /* Button.swift */, D2B18B7E2360913400A9AEDC /* Control.swift */, D2B18B802360945C00A9AEDC /* View.swift */, @@ -1693,6 +1697,7 @@ isa = PBXGroup; children = ( 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, + D202AFE2242A5F1400E5BEDF /* Extensions */, D2C78CD424252F5D00B69FDE /* Protocols */, D29DF10D21E67A70003B2FB9 /* Atoms */, D29DF10E21E67A77003B2FB9 /* Molecules */, @@ -1708,6 +1713,7 @@ 012A88C7238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, + 011B58EE23A2AA850085F53C /* ModelProtocols */, ); path = Protocols; sourceTree = ""; @@ -1920,6 +1926,7 @@ 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */, 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, + D202AFE4242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, @@ -1958,6 +1965,7 @@ 52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */, 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, + D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift index 0ddac135..2ef6f292 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift @@ -291,15 +291,12 @@ import UIKit placeholder = model.placeholder switch model.type { - case "password": + case .password: textField.isSecureTextEntry = true - - case "number": + case .number: textField.keyboardType = .numberPad - - case "email": + case .email: textField.keyboardType = .emailAddress - default: break } diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift index 8b8e582e..c35d812e 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryFieldModel.swift @@ -8,6 +8,13 @@ @objcMembers public class TextEntryFieldModel: EntryFieldModel { + + public enum EntryType: String, Codable { + case password + case number + case email + } + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -19,7 +26,7 @@ public var placeholder: String? public var enabledTextColor: Color? public var disabledTextColor: Color? - public var type: String? + public var type: EntryType? public var regex: String? //-------------------------------------------------- @@ -47,7 +54,7 @@ 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) + type = try typeContainer.decodeIfPresent(EntryType.self, forKey: .type) regex = try typeContainer.decodeIfPresent(String.self, forKey: .regex) } diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift index 5a9d09f0..f3665eb0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift @@ -16,8 +16,8 @@ public enum CheckboxPosition: String, Codable { @objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { public static var identifier: String = "checkboxLabel" + public var moleculeName: String public var backgroundColor: Color? - public var checkboxAlignment: CheckboxPosition? public var checkbox: CheckboxModel public var label: LabelModel diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 3cea5dd8..ab0a0f20 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -323,14 +323,11 @@ public typealias ActionBlock = () -> () hero = labelModel.hero Label.setLabel(self, withHTML: labelModel.html) - let alignment = LabelAlignment(rawValue: labelModel.textAlignment ?? "") - switch alignment { + switch labelModel.textAlignment { case .center: textAlignment = .center - case .right: textAlignment = .right - default: textAlignment = .left } @@ -344,8 +341,7 @@ public typealias ActionBlock = () -> () accessibilityLabel = accessibilityText } - if let fontStyle = labelModel.fontStyle { - MFStyler.styleLabel(self, withStyle: fontStyle) + if let fontStyle = labelModel.fontStyle?.rawValue { MFStyler.styleLabel(self, withStyle: fontStyle, genericScaling: false) standardFontSize = font.pointSize } else { @@ -378,9 +374,9 @@ public typealias ActionBlock = () -> () attributedString.addAttribute(.baselineOffset, value: 0, range: range) case let colorAtt as LabelAttributeColorModel: - if let colorHex = colorAtt.textColor, !colorHex.isEmpty { + if let colorHex = colorAtt.textColor { attributedString.removeAttribute(.foregroundColor, range: range) - attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) + attributedString.addAttribute(.foregroundColor, value: colorHex.uiColor, range: range) } case let imageAtt as LabelAttributeImageModel: @@ -401,7 +397,7 @@ public typealias ActionBlock = () -> () attributedString.insert(mutableString, at: imageAtt.location) case let fontAtt as LabelAttributeFontModel: - if let fontStyle = fontAtt.style { + if let fontStyle = fontAtt.style?.rawValue { let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle) attributedString.removeAttribute(.font, range: range) attributedString.removeAttribute(.foregroundColor, range: range) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift index 01183614..86275d6d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift @@ -17,7 +17,7 @@ import UIKit return "color" } - var textColor: String? + var textColor: Color? //-------------------------------------------------- // MARK: - Keys @@ -33,7 +33,7 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) + textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift index 2e9e6e1c..437bb6f8 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift @@ -18,7 +18,7 @@ import UIKit return "font" } - var style: String? + var style: LabelModel.FontStyle? var name: String? var size: CGFloat? @@ -38,7 +38,7 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + style = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .style) name = try typeContainer.decodeIfPresent(String.self, forKey: .name) size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) try super.init(from: decoder) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 7a04c577..6c9242f9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -10,6 +10,18 @@ import Foundation @objcMembers public class LabelModel: MoleculeModelProtocol { + + public enum FontStyle: String, Codable { + case H1 + case H2 + case H3 + case H32 + case B1 + case B2 + case B3 + case B20 + } + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -19,10 +31,10 @@ import Foundation public var text: String public var accessibilityText: String? public var textColor: Color? - public var fontStyle: String? + public var fontStyle: FontStyle? public var fontName: String? public var fontSize: CGFloat? - public var textAlignment: String? + public var textAlignment: NSTextAlignment? public var attributes: [LabelAttributeModel]? public var html: String? public var hero: Int? @@ -70,10 +82,10 @@ import Foundation accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle) + fontStyle = try typeContainer.decodeIfPresent(FontStyle.self, forKey: .fontStyle) fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) - textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment) + textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment) attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes) html = try typeContainer.decodeIfPresent(String.self, forKey: .html) hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) diff --git a/MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift b/MVMCoreUI/Atomic/Extensions/NSLayoutConstraintAxis+Extension.swift similarity index 100% rename from MVMCoreUI/Utility/NSLayoutConstraintAxis+Extension.swift rename to MVMCoreUI/Atomic/Extensions/NSLayoutConstraintAxis+Extension.swift diff --git a/MVMCoreUI/Atomic/Extensions/UICollectionViewScrollPosition+Extension.swift b/MVMCoreUI/Atomic/Extensions/UICollectionViewScrollPosition+Extension.swift new file mode 100644 index 00000000..d96c9933 --- /dev/null +++ b/MVMCoreUI/Atomic/Extensions/UICollectionViewScrollPosition+Extension.swift @@ -0,0 +1,71 @@ +// +// UICollectionViewScrollPosition+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/24/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +enum ScrollPositionError: Error { + case notAPosition +} + +extension UICollectionView.ScrollPosition: RawRepresentable { + + init?(rawValue: String) { + switch rawValue { + case "left", "leading": + self = .left + case "centeredHorizontally", "center": + self = .centeredHorizontally + case "right", "trailing": + self = .right + case "top": + self = .top + case "bottom": + self = .bottom + case "centeredVertically": + self = .centeredVertically + default: + return nil + } + } + + + var rawValueString: String { + switch self { + case .left: + return "left" + case .centeredHorizontally: + return "centeredHorizontally" + case .right: + return "right" + case .top: + return "top" + case .bottom: + return "bottom" + case .centeredVertically: + return "centeredVertically" + default: + return "" + } + } +} + +extension UICollectionView.ScrollPosition: Codable { + public init(from decoder: Decoder) throws { + let typeContainer = try decoder.singleValueContainer() + let string = try typeContainer.decode(String.self) + guard let position = UICollectionView.ScrollPosition(rawValue: string) else { + throw ScrollPositionError.notAPosition + } + self = position + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(rawValueString) + } +} diff --git a/MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift b/MVMCoreUI/Atomic/Extensions/UIStackViewAlignment+Extension.swift similarity index 100% rename from MVMCoreUI/Utility/UIStackViewAlignment+Extension.swift rename to MVMCoreUI/Atomic/Extensions/UIStackViewAlignment+Extension.swift diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift index 138cc69a..f25870aa 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift @@ -20,7 +20,7 @@ public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeMod // Defaults to set override public func setDefaults() { super.setDefaults() - headlineBody.style = "item" + headlineBody.style = .item } private enum CodingKeys: String, CodingKey { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift index 3ddfe64b..8e718a8a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift @@ -26,9 +26,9 @@ public class ListThreeColumnPlanDataDividerModel: ListItemModel, MoleculeModelPr override public func setDefaults() { super.setDefaults() style = "tallDivider" - leftHeadlineBody.style = "itemHeader" - centerHeadlineBody.style = "itemHeader" - rightHeadlineBody.style = "itemHeader" + leftHeadlineBody.style = .itemHeader + centerHeadlineBody.style = .itemHeader + rightHeadlineBody.style = .itemHeader } private enum CodingKeys: String, CodingKey { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift index 28a0f558..62df9794 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class RadioButtonLabelModel: MoleculeModelProtocol { public static var identifier: String = "radioButtonLabel" public var backgroundColor: Color? - + public var moleculeName: String public var radioButton: RadioButtonModel public var label: LabelModel } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift index 904a3c65..810c26fb 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -23,15 +23,15 @@ open class HeadlineBody: View { } // MARK: - Styling - func style(with styleString: String?) { - guard let styleString = styleString else { return } - - switch styleString { - case "header": + func style(with style: HeadlineBodyModel.Style?) { + switch style { + case .landingHeader: + styleLandingPageHeader() + case .header: stylePageHeader() - case "item": + case .item: styleListItem() - case "itemHeader": + case .itemHeader: styleListItemDivider() default: break } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift index eb8d7c60..f30b89ff 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift @@ -62,7 +62,7 @@ public class HeadlineBodyCaretLinkImageModel: ContainerModel, MoleculeModelProto 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.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(headlineBody, forKey: .headlineBody) try container.encode(image, forKey: .image) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index e715b61e..94c96c2b 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -9,11 +9,19 @@ import Foundation @objcMembers open class HeadlineBodyModel: MoleculeModelProtocol { + /// Convenience styles for common situations. + public enum Style: String, Codable { + case landingHeader + case header + case itemHeader + case item + } + public static var identifier: String = "headlineBody" public var moleculeName: String = HeadlineBodyModel.identifier public var headline: LabelModel? public var body: LabelModel? - public var style: String? + public var style: Style? public var backgroundColor: Color? public init(headline: LabelModel) { diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index d1d3af1b..8409cd24 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -98,7 +98,9 @@ open class Carousel: View { setupLayout(with: carouselModel) prepareMolecules(with: carouselModel) itemWidthPercent = (carouselModel.itemWidthPercent ?? 100) / 100 - setAlignment(with: carouselModel.itemAlignment) + if let alignment = carouselModel.itemAlignment { + itemAlignment = alignment + } if let height = carouselModel.height { collectionViewHeight?.constant = CGFloat(height) @@ -167,19 +169,6 @@ open class Carousel: View { return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) } - /// Sets the alignment from the string. - open func setAlignment(with string: String?) { - switch string { - case "leading": - itemAlignment = .left - case "trailing": - itemAlignment = .right - case "center": - itemAlignment = .centeredHorizontally - default: break - } - } - /// Adds a paging view. Centers it horizontally with the collection view. The position is the vertical distance from the center of the page view to the bottom of the collection view. open func addPaging(view: (UIView & MVMCoreUIPagingProtocol)?, position: CGFloat) { pagingView?.removeFromSuperview() diff --git a/MVMCoreUI/Atomic/Organisms/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/CarouselModel.swift index da12b7b8..8b987a73 100644 --- a/MVMCoreUI/Atomic/Organisms/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/CarouselModel.swift @@ -18,7 +18,7 @@ import UIKit public var loop: Bool? public var height: Float? public var itemWidthPercent: Float? - public var itemAlignment: String? + public var itemAlignment: UICollectionView.ScrollPosition? public var pagingMolecule: CarouselPagingModelProtocol? public init(molecules: [CarouselItemModel]){ @@ -47,7 +47,7 @@ import UIKit 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.itemAlignment = try typeContainer.decode(UICollectionView.ScrollPosition.self, forKey: .itemAlignment) self.pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule) } diff --git a/MVMCoreUI/BaseClasses/ButtonModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/ButtonModelProtocol.swift similarity index 100% rename from MVMCoreUI/BaseClasses/ButtonModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/ButtonModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselItemModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/CarouselItemModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselItemModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselPagingModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/CarouselPagingModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselPagingModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/ContainerModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/ContainerModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/ContainerModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/DisableableModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/DisableableModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/DisableableModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/DisableableModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/ListItemModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/ListItemModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift similarity index 90% rename from MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift index 67e6d057..be4e4e65 100644 --- a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift @@ -10,6 +10,7 @@ import Foundation public protocol PageModelProtocol { var pageType: String { get set } + /// Temporary: for legacy response var screenHeading: String? { get set } var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig new file mode 100644 index 00000000..9cbe5af2 --- /dev/null +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig @@ -0,0 +1,20 @@ +// +// PageModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 1/9/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol PageModelProtocol { + var pageType: String { get set } + var screenHeading: String? { get set } +<<<<<<< HEAD + var navigationItem: NavigationItemModelProtocol? { get set } +======= + var isAtomicTabs: Bool? { get set } + var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } +>>>>>>> 18f86575e604bb7b53b6bdac4fc677951979031f +} diff --git a/MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/TemplateModelProtocol.swift similarity index 100% rename from MVMCoreUI/Models/ModelProtocols/TemplateModelProtocol.swift rename to MVMCoreUI/Atomic/Protocols/ModelProtocols/TemplateModelProtocol.swift diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift index 08d655ae..4f152216 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift @@ -14,10 +14,10 @@ public protocol MoleculeDelegateProtocol: AnyObject { func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? 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. + /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. Mainly used for list or collections. func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) //optional - /// Asks the delegate to add or remove molecules. + /// Asks the delegate to add or remove molecules. Mainly used for list or collections. func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift index 1ee85184..1654a34b 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift @@ -22,10 +22,10 @@ public protocol MoleculeViewProtocol: UIView { /// Resets to default state before set with json is called again. func reset() - /// Allows the molecule to set its name for reuse. Default could be moleculeName. + /// Allows the molecule to set its name for reuse. Default could be moleculeName. Mainly used for list or collections. static func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? - /// For the molecule list to load more efficiently. + /// For the molecule list to load more efficiently. Mainly used for list or collections. static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? /// Can return the required modules diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 4d494fe4..347458b0 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -9,7 +9,7 @@ import Foundation -public protocol TemplateProtocol: class { +public protocol TemplateProtocol: AnyObject { associatedtype TemplateModel: TemplateModelProtocol var templateModel: TemplateModel? { get set } } @@ -20,6 +20,7 @@ public extension TemplateProtocol where Self: ViewController { let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() let templateModel = try decoder.decode(TemplateModel.self, from: data) + print(templateModel.toJSONString() ?? "") self.templateModel = templateModel self.pageModel = templateModel as? MVMControllerModelProtocol } diff --git a/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift index a2cb3473..d2418cbc 100644 --- a/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift @@ -36,15 +36,10 @@ import Foundation //-------------------------------------------------- private enum CodingKeys: String, CodingKey { - case template - case pageType - case screenHeading case molecules case header case footer case line - case isAtomicTabs - case formRules } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListCellProtocol.swift b/MVMCoreUI/Atomic/Templates/MoleculeListCellProtocol.swift index 5d9b9525..b9cfc02f 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListCellProtocol.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListCellProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol MoleculeListCellProtocol { +public protocol MoleculeListCellProtocol: UITableViewCell { /// Can set the separator according to what the moleculeList commands. func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) diff --git a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift index 09045995..2b683d98 100644 --- a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift @@ -24,9 +24,6 @@ import Foundation } private enum CodingKeys: String, CodingKey { - case pageType - case template - case screenHeading case header case footer case stack @@ -43,8 +40,6 @@ 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(pageType, forKey: .pageType) - try container.encode(template, forKey: .template) try container.encode(moleculeStack, forKey: .stack) try container.encodeModelIfPresent(header, forKey: .header) try container.encodeModelIfPresent(footer, forKey: .footer) diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index d49b97ed..dbbbc494 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -38,7 +38,7 @@ import Foundation pageType = try typeContainer.decode(String.self, forKey: .pageType) screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) - // navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem) + navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem) } public func encode(to encoder: Encoder) throws { @@ -47,6 +47,6 @@ import Foundation try container.encode(template, forKey: .template) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeIfPresent(formRules, forKey: .formRules) - //try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem) + try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem) } } diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift index 9ee830e2..61476707 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift @@ -8,60 +8,40 @@ import Foundation -@objcMembers public class ThreeLayerPageTemplateModel: MVMControllerModelProtocol { - - public var formRules: [FormGroupRule]? - public var formValidator: FormValidator? - - public static var identifier: String = "threeLayer" - - public var pageType: String - public var screenHeading: String? - public var isAtomicTabs: Bool? - public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? - +@objcMembers public class ThreeLayerPageTemplateModel: TemplateModel { + public override class var identifier: String { + return "threeLayer" + } public var header: MoleculeModelProtocol? public var middle: MoleculeModelProtocol? public var footer: MoleculeModelProtocol? public init(pageType: String, header: MoleculeModelProtocol?, middle: MoleculeModelProtocol?, footer: MoleculeModelProtocol?) { - self.pageType = pageType + super.init(pageType: pageType) self.header = header self.middle = middle self.footer = footer } private enum CodingKeys: String, CodingKey { - case pageType - case template - case screenHeading case header case footer case middle - case isAtomicTabs - case formRules } 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.decodeModelIfPresent(codingKey: .header) middle = try typeContainer.decodeModelIfPresent(codingKey: .middle) footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) - formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) + try super.init(from: decoder) } - public func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(pageType, forKey: .pageType) - try container.encode(template, forKey: .template) - 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) - try container.encodeIfPresent(formRules, forKey: .formRules) } } diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 29c7bad4..7491f007 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -12,7 +12,6 @@ import UIKit //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var json: [AnyHashable: Any]? open var model: MoleculeModelProtocol? private var initialSetupPerformed = false diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index f68e942b..b5fdc5e7 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -9,7 +9,6 @@ import UIKit @objcMembers open class View: UIView, MoleculeViewProtocol { - open var json: [AnyHashable: Any]? open var model: MoleculeModelProtocol? private var initialSetupPerformed = false From 438277b37fd36ada0d97ffed2a61e340c1f5e364 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 24 Mar 2020 12:50:45 -0400 Subject: [PATCH 073/244] missing file move --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- .../NSTextAlignment+Extension.swift | 89 +++++++++++++++++++ .../Extensions}/UIContentMode+Extension.swift | 0 .../StackCenteredPageTemplateModel.swift | 41 +-------- 4 files changed, 93 insertions(+), 39 deletions(-) create mode 100644 MVMCoreUI/Atomic/Extensions/NSTextAlignment+Extension.swift rename MVMCoreUI/{Categories => Atomic/Extensions}/UIContentMode+Extension.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 481bfe6c..03335a4d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1005,6 +1005,7 @@ 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */, D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */, D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */, + 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */, ); path = Extensions; sourceTree = ""; @@ -1401,7 +1402,6 @@ D29DF11021E6805F003B2FB9 /* Categories */ = { isa = PBXGroup; children = ( - 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */, D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */, D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */, D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */, diff --git a/MVMCoreUI/Atomic/Extensions/NSTextAlignment+Extension.swift b/MVMCoreUI/Atomic/Extensions/NSTextAlignment+Extension.swift new file mode 100644 index 00000000..d7fe2e0e --- /dev/null +++ b/MVMCoreUI/Atomic/Extensions/NSTextAlignment+Extension.swift @@ -0,0 +1,89 @@ +// +// NSTextAlignment+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/24/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +/** + When using this class in codable for a String value from server. + + Example use case.... + + var alignment: NSTextAlignment + + 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 = NSTextAlignment(rawValue: word)! + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(alignment.rawValueString, forKey: .alignment) + } + */ + +enum TextAlignmentError: Error { + case notAnAlignment +} + +extension NSTextAlignment: RawRepresentable { + + init?(rawValue: String) { + switch rawValue { + case "left": + self = .left + case "center": + self = .center + case "right": + self = .right + case "justified": + self = .justified + case "natural": + self = .natural + default: + return nil + } + } + + var rawValueString: String { + switch self { + case .left: + return "left" + case .center: + return "center" + case .right: + return "right" + case .justified: + return "justified" + case .natural: + return "natural" + @unknown default: + return "" + } + } +} + +extension NSTextAlignment: Codable { + public init(from decoder: Decoder) throws { + let typeContainer = try decoder.singleValueContainer() + let string = try typeContainer.decode(String.self) + guard let alignment = NSTextAlignment(rawValue: string) else { + throw TextAlignmentError.notAnAlignment + } + self = alignment + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(rawValueString) + } +} diff --git a/MVMCoreUI/Categories/UIContentMode+Extension.swift b/MVMCoreUI/Atomic/Extensions/UIContentMode+Extension.swift similarity index 100% rename from MVMCoreUI/Categories/UIContentMode+Extension.swift rename to MVMCoreUI/Atomic/Extensions/UIContentMode+Extension.swift diff --git a/MVMCoreUI/Atomic/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackCenteredPageTemplateModel.swift index 22934239..20d727e3 100644 --- a/MVMCoreUI/Atomic/Templates/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/StackCenteredPageTemplateModel.swift @@ -8,43 +8,8 @@ import Foundation -@objcMembers public class StackCenteredPageTemplateModel: MVMControllerModelProtocol { - - public var formRules: [FormGroupRule]? - public var formValidator: FormValidator? - - public static var identifier: String = "stackCenterTemplate" - public var pageType: String - public var screenHeading: String? - public var isAtomicTabs: Bool? - public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? - - public init(pageType: String) { - self.pageType = pageType - } - - private enum CodingKeys: String, CodingKey { - case pageType - case template - case screenHeading - case isAtomicTabs - case formRules - } - - 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) - formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(pageType, forKey: .pageType) - try container.encode(template, forKey: .template) - try container.encodeIfPresent(screenHeading, forKey: .screenHeading) - try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs) - try container.encodeIfPresent(formRules, forKey: .formRules) +@objcMembers public class StackCenteredPageTemplateModel: StackPageTemplateModel { + public override class var identifier: String { + return "stackCenterTemplate" } } From 806f28b40bd39e87f587eb5687cc6e9e8cca4d28 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 14:15:55 -0400 Subject: [PATCH 074/244] priorities, priorities, priorities... --- MVMCoreUI/Atoms/TextFields/DigitEntryField.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index 3d0b69a5..9ecbbe6e 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -207,7 +207,6 @@ import UIKit let digitBox = DigitBox() digitBox.isAccessibilityElement = true - digitBox.digitField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: self) digitBox.digitField.delegate = self digitBox.digitBoxDelegate = self return digitBox @@ -335,6 +334,10 @@ import UIKit numberOfDigits = model.digits setAsSecureTextEntry(model.secureEntry) + for digitBox in digitBoxes { + digitBox.digitField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: delegateObject?.observingTextFieldDelegate ?? self) + } + super.set(with: model, delegateObject, additionalData) } } From 2ae19b76d1c10f7f60b4deba4897d24cf1192290 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 14:32:18 -0400 Subject: [PATCH 075/244] re --- MVMCoreUI/Atoms/TextFields/DigitEntryField.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index 9ecbbe6e..004651d4 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -207,6 +207,7 @@ import UIKit let digitBox = DigitBox() digitBox.isAccessibilityElement = true + digitBox.digitField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: self) digitBox.digitField.delegate = self digitBox.digitBoxDelegate = self return digitBox From f3ed68beeda3098303dc8af1f04370a66fd93ec3 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 15:21:21 -0400 Subject: [PATCH 076/244] accessibilty start --- MVMCoreUI/Atoms/Views/Checkbox.swift | 5 +--- MVMCoreUI/BaseClasses/Control.swift | 4 ++- MVMCoreUI/BaseClasses/TableViewCell.swift | 4 +-- ...tLeftVariableCheckboxAllTextAndLinks.swift | 25 +++++++++++++++---- ...tVariableRadioButtonAndPaymentMethod.swift | 5 +++- .../EyebrowHeadlineBodyLink.swift | 23 +++++++++++++---- .../HeadlineBody.swift | 9 +++++-- MVMCoreUI/Organisms/Stack.swift | 3 +++ 8 files changed, 58 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index f288c4cd..cc6895db 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -158,6 +158,7 @@ import MVMCore super.init(frame: frame) accessibilityTraits = .button + isAccessibilityElement = true accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint") updateAccessibilityLabel() } @@ -198,8 +199,6 @@ import MVMCore open override func setupView() { super.setupView() - guard constraints.isEmpty else { return } - isUserInteractionEnabled = true translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear @@ -394,8 +393,6 @@ import MVMCore widthConstraint?.constant = dimension heightConstraint?.constant = dimension } - - //layoutIfNeeded() } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 265e56b3..9d6ce521 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -12,6 +12,7 @@ import UIKit //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var json: [AnyHashable: Any]? open var model: MoleculeModelProtocol? @@ -78,7 +79,7 @@ extension Control: AppleGuidelinesProtocol { // MARK: - MVMCoreViewProtocol extension Control: MVMCoreViewProtocol { - open func updateView(_ size: CGFloat) {} + open func updateView(_ size: CGFloat) { } /// Will be called only once. open func setupView() { @@ -89,6 +90,7 @@ extension Control: MVMCoreViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol extension Control: MVMCoreUIMoleculeViewProtocol { + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.json = json diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index ebf25a3c..510779b2 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -246,7 +246,7 @@ import UIKit // MARK: - MoleculeListCellProtocol /// For when the separator between cells shows using json and frequency. Default is type: standard, frequency: allExceptTop. - public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?, indexPath: IndexPath) { + public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) { addSeparatorsIfNeeded() if let model = model { topSeparatorView?.set(with: model, delegateObject, additionalData) @@ -258,7 +258,7 @@ import UIKit setSeparatorFrequency(model?.frequency ?? .allExceptTop, indexPath: indexPath) } - public func didSelectCell(at index: 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) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index 8d7fb539..448d76e1 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -9,11 +9,18 @@ import Foundation @objcMembers open class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell { - public let checkbox = Checkbox(frame: .zero) + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public let checkbox = Checkbox() public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) public var stack: Stack + //-------------------------------------------------- // MARK: - Initializers + //-------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: checkbox, model: StackItemModel(horizontalAlignment: .fill)), (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))], @@ -25,17 +32,25 @@ import Foundation fatalError("init(coder:) has not been implemented") } - // MARK: - View Lifecycle + //-------------------------------------------------- + // MARK: - Life Cycle + //-------------------------------------------------- + override open func setupView() { super.setupView() addMolecule(stack) stack.restack() } - // MARK:- MVMCoreUIMoleculeViewProtocol - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return} + + guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return } + checkbox.set(with: model.checkbox, delegateObject, additionalData) eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift index 12ae94fe..ab5a24c0 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift @@ -9,10 +9,10 @@ import UIKit @objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell { - //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- + let radioButton = RadioButton(frame: .zero) let leftImage = MFLoadImageView(pinnedEdges: .all) let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() @@ -21,6 +21,7 @@ import UIKit //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)), (view: leftImage, model: StackItemModel(horizontalAlignment: .fill)), @@ -36,6 +37,7 @@ import UIKit //----------------------------------------------------- // MARK: - View Lifecycle //----------------------------------------------------- + override open func setupView() { super.setupView() addMolecule(stack) @@ -53,6 +55,7 @@ import UIKit //---------------------------------------------------- // MARK: - Molecule //---------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 49b08b44..410112ed 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -19,7 +19,7 @@ import UIKit public let body = Label.commonLabelB2(true) public let link = Link() - var casteModel: EyebrowHeadlineBodyLinkModel? { + var castModel: EyebrowHeadlineBodyLinkModel? { get { return model as? EyebrowHeadlineBodyLinkModel } } @@ -52,6 +52,19 @@ import UIKit body.styleB2(true) } + public func eyebrow(isHidden: Bool) { + + stack.stackModel?.molecules[0].gone = isHidden + + if isHidden { + accessibilityElements = [headline, body, link] + } else { + accessibilityElements = [eyebrow, headline, body, link] + } + + stack.restack() + } + //-------------------------------------------------- // MARK: - ModelMoleculeViewProtocol //-------------------------------------------------- @@ -59,10 +72,10 @@ import UIKit open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - eyebrow.setOptional(with: casteModel?.eyebrow, delegateObject, additionalData) - headline.setOptional(with: casteModel?.headline, delegateObject, additionalData) - body.setOptional(with: casteModel?.body, delegateObject, additionalData) - link.setOptional(with: casteModel?.link, delegateObject, additionalData) + eyebrow.setOptional(with: castModel?.eyebrow, delegateObject, additionalData) + headline.setOptional(with: castModel?.headline, delegateObject, additionalData) + body.setOptional(with: castModel?.body, delegateObject, additionalData) + link.setOptional(with: castModel?.link, delegateObject, additionalData) // Hide labels if neeeded. stack.stackModel?.molecules[0].gone = !eyebrow.hasText diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index a120807d..9cdd9e67 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -9,9 +9,12 @@ import UIKit open class HeadlineBody: View { + let headlineLabel = Label.commonLabelH2(true) let messageLabel = Label.commonLabelB2(true) + var spaceBetweenLabelsConstant = PaddingTwo + var spaceBetweenLabels: NSLayoutConstraint? var leftConstraintTitle: NSLayoutConstraint? var rightConstraintTitle: NSLayoutConstraint? @@ -71,8 +74,6 @@ open class HeadlineBody: View { open override func setupView() { super.setupView() - - guard subviews.isEmpty else { return } backgroundColor = .clear clipsToBounds = true @@ -81,6 +82,10 @@ open class HeadlineBody: View { addSubview(view) NSLayoutConstraint.constraintPinSubview(toSuperview: view) + view.isAccessibilityElement = false + view.shouldGroupAccessibilityChildren = true + view.accessibilityElements = [headlineLabel, messageLabel] + view.addSubview(headlineLabel) view.addSubview(messageLabel) diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 8e6df863..2f3b0f78 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -46,6 +46,9 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto for (index, view) in stackItems.enumerated() { addView(view, stackModel.molecules[index], totalSpacing: totalSpace, lastItem: lastItemIndex == index) } + + isAccessibilityElement = false + accessibilityElements = stackItems } /// Removes all stack items views from the view. From 26a530af2c8f29ab31cfa894849259c8b9053aaa Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 24 Mar 2020 17:20:19 -0400 Subject: [PATCH 077/244] Form Cleaning --- MVMCoreUI.xcodeproj/project.pbxproj | 26 ++-- .../Atomic/Atoms/Buttons/ButtonModel.swift | 10 +- .../Atomic/Atoms/Buttons/PillButton.swift | 6 +- .../Atomic/Atoms/Buttons/RadioButton.swift | 4 +- .../Atoms/Buttons/RadioButtonModel.swift | 17 ++- .../Buttons/RadioButtonSelectionHelper.swift | 4 +- .../Atoms/TextFields/EntryFieldModel.swift | 28 ++-- .../Atoms/TextFields/TextEntryField.swift | 12 +- MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift | 4 +- .../Atomic/Atoms/Views/CheckboxModel.swift | 20 +-- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 4 +- .../Atomic/Atoms/Views/ToggleModel.swift | 26 ++-- .../BaseControllers/ViewController.swift | 6 +- .../FormActionFieldProtocol.swift | 14 -- .../FormUIHelpers/FormFieldProtocol.swift | 6 + .../FormGroupWatcherFieldProtocol.swift | 14 ++ .../FormHolderModelProtocol.swift | 2 +- .../FormUIHelpers/FormItemProtocol.swift | 10 +- .../FormRuleWatcherFieldProtocol.swift | 14 ++ MVMCoreUI/FormUIHelpers/FormValidator.swift | 139 ++++++++++-------- .../Rules/Rules/FormGroupRule.swift | 1 + .../Rules/Rules/RulesProtocol.swift | 30 +--- MVMCoreUI/FormUIHelpers/ValidProtocol.swift | 15 -- .../Controllers/MFViewController+Form.swift | 22 --- .../Controllers/MFViewController+Model.swift | 40 ----- .../Legacy/Controllers/MFViewController.m | 5 - 26 files changed, 214 insertions(+), 265 deletions(-) delete mode 100644 MVMCoreUI/FormUIHelpers/FormActionFieldProtocol.swift create mode 100644 MVMCoreUI/FormUIHelpers/FormGroupWatcherFieldProtocol.swift create mode 100644 MVMCoreUI/FormUIHelpers/FormRuleWatcherFieldProtocol.swift delete mode 100644 MVMCoreUI/FormUIHelpers/ValidProtocol.swift delete mode 100644 MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift delete mode 100644 MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03335a4d..27346789 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -22,13 +22,12 @@ 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */; }; 011D95A3240453F8000E3791 /* RuleRegexModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A2240453F8000E3791 /* RuleRegexModel.swift */; }; 011D95A5240455DC000E3791 /* FormGroupRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A4240455DC000E3791 /* FormGroupRule.swift */; }; - 011D95A924057AC7000E3791 /* FormActionFieldProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */; }; + 011D95A924057AC7000E3791 /* FormGroupWatcherFieldProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A824057AC7000E3791 /* FormGroupWatcherFieldProtocol.swift */; }; 011D95AB2405C553000E3791 /* FormItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95AA2405C553000E3791 /* FormItemProtocol.swift */; }; 011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */; }; 011D95AF2407266E000E3791 /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95AE2407266E000E3791 /* RadioButtonModel.swift */; }; - 011D9602240DA20A000E3791 /* ValidProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D9601240DA20A000E3791 /* ValidProtocol.swift */; }; + 011D9602240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D9601240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift */; }; 011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D9625240EBB16000E3791 /* RadioButtonLabelModel.swift */; }; - 011D9628240EFA1E000E3791 /* MFViewController+Form.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D9627240EFA1E000E3791 /* MFViewController+Form.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 */; }; @@ -52,7 +51,6 @@ 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; }; 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D942327ED1900EF99AA /* HeadlineBodyLinkToggle.swift */; }; 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */; }; - 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */; }; 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */; }; 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; }; @@ -415,13 +413,12 @@ 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleEqualsModel.swift; sourceTree = ""; }; 011D95A2240453F8000E3791 /* RuleRegexModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleRegexModel.swift; sourceTree = ""; }; 011D95A4240455DC000E3791 /* FormGroupRule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormGroupRule.swift; sourceTree = ""; }; - 011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormActionFieldProtocol.swift; sourceTree = ""; }; + 011D95A824057AC7000E3791 /* FormGroupWatcherFieldProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormGroupWatcherFieldProtocol.swift; sourceTree = ""; }; 011D95AA2405C553000E3791 /* FormItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormItemProtocol.swift; sourceTree = ""; }; 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormHolderProtocol.swift; sourceTree = ""; }; 011D95AE2407266E000E3791 /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; - 011D9601240DA20A000E3791 /* ValidProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidProtocol.swift; sourceTree = ""; }; + 011D9601240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormRuleWatcherFieldProtocol.swift; sourceTree = ""; }; 011D9625240EBB16000E3791 /* RadioButtonLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonLabelModel.swift; sourceTree = ""; }; - 011D9627240EFA1E000E3791 /* MFViewController+Form.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFViewController+Form.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 = ""; }; @@ -445,7 +442,6 @@ 01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; 01509D942327ED1900EF99AA /* HeadlineBodyLinkToggle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyLinkToggle.swift; sourceTree = ""; }; 017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonLabel.swift; sourceTree = ""; }; - 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFViewController+Model.swift"; sourceTree = ""; }; 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeViewProtocol.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 = ""; }; @@ -827,13 +823,13 @@ 011D958A24042794000E3791 /* Rules */ = { isa = PBXGroup; children = ( + 011D95A4240455DC000E3791 /* FormGroupRule.swift */, 011D958424042432000E3791 /* RulesProtocol.swift */, 011D959A240451E3000E3791 /* RuleRequiredModel.swift */, 011D959C2404536F000E3791 /* RuleAnyValueChangedModel.swift */, 011D959E240453A1000E3791 /* RuleAllValueChangedModel.swift */, 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */, 011D95A2240453F8000E3791 /* RuleRegexModel.swift */, - 011D95A4240455DC000E3791 /* FormGroupRule.swift */, 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */, ); name = Rules; @@ -855,8 +851,8 @@ 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */, 011D95AA2405C553000E3791 /* FormItemProtocol.swift */, 011D958624042492000E3791 /* FormFieldProtocol.swift */, - 011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */, - 011D9601240DA20A000E3791 /* ValidProtocol.swift */, + 011D95A824057AC7000E3791 /* FormGroupWatcherFieldProtocol.swift */, + 011D9601240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift */, 0105618A224BBE7700E1557D /* FormValidator.swift */, 011D958A24042794000E3791 /* Rules */, ); @@ -1015,8 +1011,6 @@ children = ( D29DF16021E69996003B2FB9 /* MFViewController.h */, D29DF15F21E69996003B2FB9 /* MFViewController.m */, - 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */, - 011D9627240EFA1E000E3791 /* MFViewController+Form.swift */, D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */, D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */, D29DF29121E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h */, @@ -1908,12 +1902,11 @@ D2E2A99423D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */, - 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, - 011D95A924057AC7000E3791 /* FormActionFieldProtocol.swift in Sources */, + 011D95A924057AC7000E3791 /* FormGroupWatcherFieldProtocol.swift in Sources */, D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */, 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, @@ -1935,7 +1928,7 @@ 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, - 011D9602240DA20A000E3791 /* ValidProtocol.swift in Sources */, + 011D9602240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, @@ -2122,7 +2115,6 @@ 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, - 011D9628240EFA1E000E3791 /* MFViewController+Form.swift in Sources */, 0A21DB94235E24ED00C160A2 /* DigitEntryField.swift in Sources */, 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */, D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index ac9d1dc1..02244a69 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -18,8 +18,7 @@ public enum ButtonSize: String, Codable { case tiny } -public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormActionFieldProtocol { - +public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol { public static var identifier: String = "button" public var backgroundColor: Color? public var title: String @@ -33,13 +32,14 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormAction public var disabledFillColor: Color? public var disabledTextColor: Color? public var disabledBorderColor: Color? - public var groupName: String? = FormValidator.defaultGroupName + public var groupName: String = FormValidator.defaultGroupName - public func updateEnable(_ enabled: Bool) { - self.enabled = enabled + public func setValidity(_ valid: Bool, group: FormGroupRule) { + enabled = valid updateUI?() } + /// Temporary binding mechanism for the view to update on enable changes. public var updateUI: (() -> Void)? init(with title: String, action: ActionModelProtocol) { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e3f99862..19f032fc 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -127,10 +127,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { setTitle(model.title, for: .normal) model.updateUI = { [weak self] in - self?.enableField(model.enabled) + MVMCoreDispatchUtility.performBlock(onMainThread: { + self?.enableField(model.enabled) + }) } - FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift index 7dd5976a..56466020 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift @@ -81,7 +81,7 @@ import UIKit } else { isSelected = !isSelected } - FormValidator.validate(delegate: delegateObject?.formHolderDelegate) + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) setNeedsDisplay() } @@ -130,7 +130,7 @@ import UIKit isSelected = model.state let radioButtonModel = RadioButtonSelectionHelper.setupForRadioButtonGroup(model, formValidator: delegateObject?.formHolderDelegate?.formValidator) - FormValidator.setupValidation(molecule: radioButtonModel, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: radioButtonModel, delegate: delegateObject?.formHolderDelegate) } public override func reset() { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift index 581e03f8..579c0ed9 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift @@ -20,11 +20,13 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { public var state: Bool = false public var enabled: Bool = true - public var baseValue: AnyHashable? - public var groupName: String? - public var fieldKey: String? + /// The specific value to send to server. TODO: update this to be more generic. public var fieldValue: String? + public var baseValue: AnyHashable? + public var groupName: String = FormValidator.defaultGroupName + public var fieldKey: String? + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -34,8 +36,8 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { case backgroundColor case state case enabled - case fieldKey case fieldValue + case fieldKey case groupName } @@ -45,6 +47,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { public init(_ state: Bool) { self.state = state + baseValue = state } //-------------------------------------------------- @@ -71,8 +74,12 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + + baseValue = state fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index 263a85a4..a613695a 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -10,10 +10,8 @@ import Foundation import UIKit @objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol { - - public var fieldKey: String? - public var groupName: String? = FormValidator.defaultGroupName + public var groupName: String = FormValidator.defaultGroupName private var selectedRadioButton: RadioButton? private var fieldGroupName: String? public var baseValue: AnyHashable? diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift index 54b441f7..729b3516 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryFieldModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, ValidProtocol { +@objcMembers public class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol { //-------------------------------------------------- // MARK: - Properties @@ -26,9 +26,10 @@ import Foundation public var isEnabled: Bool = true public var isLocked: Bool? public var isSelected: Bool? - public var fieldKey: String? - public var groupName: String? = FormValidator.defaultGroupName public var text: String? + + public var fieldKey: String? + public var groupName: String = FormValidator.defaultGroupName public var baseValue: AnyHashable? public var isValid: Bool? { @@ -36,9 +37,12 @@ import Foundation updateUI?() } } + + /// Temporary binding mechanism for the view to update on enable changes. public var updateUI: (() -> Void)? - public func setValidity(_ isValid: Bool) { - self.isValid = isValid + + public func setValidity(_ valid: Bool, rule: RulesProtocol) { + self.isValid = valid } //-------------------------------------------------- @@ -54,10 +58,10 @@ import Foundation case errorMessage = "errorMsg" case isLocked case isSelected - case fieldKey case isValid case isRequired = "required" case text + case fieldKey case groupName } @@ -69,6 +73,11 @@ import Foundation // MARK: - Initializers //-------------------------------------------------- + public init(with text: String) { + self.text = text + baseValue = text + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) @@ -78,12 +87,13 @@ import Foundation isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? true isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked) isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected) - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid) text = try typeContainer.decodeIfPresent(String.self, forKey: .text) - + + baseValue = text + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - self.groupName = groupName + self.groupName = groupName } } diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift index 2ef6f292..ad5f6392 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift @@ -232,7 +232,7 @@ import UIKit /// Validates the text of the entry field. @objc public func validateTextField() { text = textField.text - FormValidator.validate(delegate: delegateObject?.formHolderDelegate) + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) } @objc public func updateValidation(_ isValid: Bool) { @@ -279,12 +279,14 @@ import UIKit guard let model = model as? TextEntryFieldModel else { return } model.updateUI = { [weak self] in - if self?.isSelected ?? false { - self?.updateValidation(model.isValid ?? true) - } + MVMCoreDispatchUtility.performBlock(onMainThread: { + if self?.isSelected ?? false { + self?.updateValidation(model.isValid ?? true) + } + }) } self.delegateObject = delegateObject - FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) textColor.enabled = model.enabledTextColor?.uiColor textColor.disabled = model.disabledTextColor?.uiColor text = model.text diff --git a/MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift index c76383cb..0ab3bbf3 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift @@ -129,7 +129,7 @@ import MVMCore (model as? CheckboxModel)?.isChecked = isSelected shapeLayer?.removeAllAnimations() updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated) - FormValidator.validate(delegate: delegateObject?.formHolderDelegate) + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) updateAccessibilityLabel() } } @@ -398,7 +398,7 @@ import MVMCore super.set(with: model, delegateObject, additionalData) guard let model = model as? CheckboxModel else { return } self.delegateObject = delegateObject - FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) if let fieldKey = model.fieldKey { self.fieldKey = fieldKey diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift index 13b730a6..423ed1ee 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift @@ -29,10 +29,8 @@ import Foundation public var disabledCheckColor: Color = Color(uiColor: .mvmCoolGray3) public var action: ActionModelProtocol? - public var fieldKey: String? - public var fieldValue: JSONValue? - public var groupName: String? = FormValidator.defaultGroupName + public var groupName: String = FormValidator.defaultGroupName public var baseValue: AnyHashable? //-------------------------------------------------- @@ -41,8 +39,6 @@ import Foundation private enum CodingKeys: String, CodingKey { case moleculeName - case fieldKey - case fieldValue case isChecked = "checked" case isEnabled = "enabled" case isAnimated = "animated" @@ -56,23 +52,25 @@ import Foundation case disabledCheckColor case disabledBorderColor case action + case fieldKey case groupName } - - init(isChecked: Bool = false) {} public func formFieldValue() -> AnyHashable? { return isChecked } + public init(isChecked: Bool = false) { + self.isChecked = isChecked + baseValue = isChecked + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - fieldValue = try typeContainer.decodeIfPresent(JSONValue.self, forKey: .fieldValue) - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) 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) @@ -86,6 +84,9 @@ import Foundation isRound = try typeContainer.decodeIfPresent(Bool.self, forKey: .isRound) ?? false isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? true action = try typeContainer.decodeModelIfPresent(codingKey: .action) + + baseValue = isChecked + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } @@ -95,7 +96,6 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(groupName, forKey: .groupName) - try container.encodeIfPresent(fieldValue, forKey: .fieldValue) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(borderColor, forKey: .borderColor) try container.encode(borderWidth, forKey: .borderWidth) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 3d9a2f21..0f7ff8b1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -102,7 +102,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) } (model as? ToggleModel)?.state = isOn - FormValidator.validate(delegate: delegateObject?.formHolderDelegate) + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff") setNeedsLayout() layoutIfNeeded() @@ -343,7 +343,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) self.model = model self.delegateObject = delegateObject - FormValidator.setupValidation(molecule: toggleModel, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: toggleModel, delegate: delegateObject?.formHolderDelegate) guard let model = model as? ToggleModel else { return } if let color = model.onTintColor?.uiColor { containerTintColor?.on = color diff --git a/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift index 334ba00f..b7febf97 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift @@ -17,14 +17,15 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo public var enabled: Bool = true public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? - public var fieldKey: String? - public var groupName: String? = FormValidator.defaultGroupName - public var baseValue: AnyHashable? public var onTintColor: Color? public var offTintColor: Color? public var onKnobTintColor: Color? public var offKnobTintColor: Color? + public var fieldKey: String? + public var groupName: String = FormValidator.defaultGroupName + public var baseValue: AnyHashable? + private enum CodingKeys: String, CodingKey { case moleculeName case state @@ -32,13 +33,13 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo case enabled case action case backgroundColor - case fieldKey case alternateAction - case groupName case onTintColor case offTintColor case onKnobTintColor case offKnobTintColor + case fieldKey + case groupName } public func formFieldValue() -> AnyHashable? { @@ -47,6 +48,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo public init(_ state: Bool) { self.state = state + baseValue = state } required public init(from decoder: Decoder) throws { @@ -63,14 +65,16 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo action = try typeContainer.decodeModelIfPresent(codingKey: .action) alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - self.groupName = groupName - } onTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onTintColor) offTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offTintColor) onKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onKnobTintColor) offKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offKnobTintColor) + + baseValue = state + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } } public func encode(to encoder: Encoder) throws { @@ -80,11 +84,11 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(state, forKey: .state) - try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(groupName, forKey: .groupName) try container.encodeIfPresent(onTintColor, forKey: .onTintColor) try container.encodeIfPresent(onKnobTintColor, forKey: .onKnobTintColor) try container.encodeIfPresent(onKnobTintColor, forKey: .onKnobTintColor) try container.encodeIfPresent(offKnobTintColor, forKey: .offKnobTintColor) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(groupName, forKey: .groupName) } } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 7a3446d2..024606f4 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -170,8 +170,8 @@ import UIKit navigationModel.line = LineModel(type: .none) } pageModel?.navigationItem = navigationModel - if self.formValidator == nil { - let rules = pageModel?.formRules + if self.formValidator == nil, + let rules = pageModel?.formRules { self.formValidator = FormValidator(rules) } } @@ -244,7 +244,7 @@ import UIKit } open func updateViews() { - formValidator?.validate() + _ = formValidator?.validate() } override open func viewDidLoad() { diff --git a/MVMCoreUI/FormUIHelpers/FormActionFieldProtocol.swift b/MVMCoreUI/FormUIHelpers/FormActionFieldProtocol.swift deleted file mode 100644 index 31208e95..00000000 --- a/MVMCoreUI/FormUIHelpers/FormActionFieldProtocol.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// FormActionFieldProtocol.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 1/31/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public protocol FormActionFieldProtocol: EnableableModelProtocol, FormItemProtocol { - func updateEnable(_ enabled: Bool) - var updateUI: (() -> Void)? { get set } -} diff --git a/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift b/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift index c59ccd08..b9d2defe 100644 --- a/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift @@ -5,13 +5,19 @@ // Created by Suresh, Kamlesh on 1/31/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +// Form fields are items can be interacted with. They have value, and may need to be validated. import Foundation public protocol FormFieldProtocol: FormItemProtocol { + /// How the validator identifies the field when validating rules. var fieldKey: String? { get set } + + /// A place to store the initial value of the field for checking if the value has changed. var baseValue: AnyHashable? { get set } + + /// Returns the value of the field. Used for validations and possibly for sending to server. func formFieldValue() -> AnyHashable? } diff --git a/MVMCoreUI/FormUIHelpers/FormGroupWatcherFieldProtocol.swift b/MVMCoreUI/FormUIHelpers/FormGroupWatcherFieldProtocol.swift new file mode 100644 index 00000000..624ea374 --- /dev/null +++ b/MVMCoreUI/FormUIHelpers/FormGroupWatcherFieldProtocol.swift @@ -0,0 +1,14 @@ +// +// FormGroupWatcherFieldProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 1/31/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// +// Fields that want to be informed of group validity. + +import Foundation + +public protocol FormGroupWatcherFieldProtocol: FormItemProtocol { + func setValidity(_ valid: Bool, group: FormGroupRule) +} diff --git a/MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift b/MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift index a9428a2b..b548024c 100644 --- a/MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/FormHolderModelProtocol.swift @@ -5,7 +5,7 @@ // Created by Suresh, Kamlesh on 2/5/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // -// A protocol for the model of the delegate object that holds the form validator. The rules are stored in the model. +// A protocol for the model of the delegate object that holds the form validator. The rules that need to be validated are stored in the model. import Foundation diff --git a/MVMCoreUI/FormUIHelpers/FormItemProtocol.swift b/MVMCoreUI/FormUIHelpers/FormItemProtocol.swift index 9b671238..0c7f71bd 100644 --- a/MVMCoreUI/FormUIHelpers/FormItemProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/FormItemProtocol.swift @@ -5,15 +5,11 @@ // Created by Suresh, Kamlesh on 2/25/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +// The base form item protocol. Shared by different types of items. In our case, the models (not views) are form items which are registered with the validator. import Foundation public protocol FormItemProtocol { - static var defaultGroupName: String? { get } - var groupName: String? { get set } -} -extension FormItemProtocol{ - public static var defaultGroupName: String? { - return "default" - } + /// The group name to used to group this item for validation, enableability, and value getting. + var groupName: String { get set } } diff --git a/MVMCoreUI/FormUIHelpers/FormRuleWatcherFieldProtocol.swift b/MVMCoreUI/FormUIHelpers/FormRuleWatcherFieldProtocol.swift new file mode 100644 index 00000000..3fc47d25 --- /dev/null +++ b/MVMCoreUI/FormUIHelpers/FormRuleWatcherFieldProtocol.swift @@ -0,0 +1,14 @@ +// +// FormRuleWatcherFieldProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/2/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// +// Fields that want to be informed of rule validity. + +import Foundation + +public protocol FormRuleWatcherFieldProtocol { + func setValidity(_ valid: Bool, rule: RulesProtocol) +} diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index 0a14e027..a38b4b3f 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -12,103 +12,118 @@ import MVMCore @objcMembers public class FormValidator: NSObject { static var defaultGroupName: String = "default" - var extraValidationBlock: (() -> Bool)? - var formRules: [FormGroupRule]? + var formRules: [FormGroupRule] weak var delegate: FormHolderProtocol? - var fieldMolecules: [String: FormFieldProtocol] = [:] - var formActionMolecules: [FormActionFieldProtocol] = [] + var fields: [String: FormFieldProtocol] = [:] + var groupWatchers: [FormGroupWatcherFieldProtocol] = [] var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:] - public init(_ formRules: [FormGroupRule]?) { + public init(_ formRules: [FormGroupRule]) { self.formRules = formRules } - public func insertMolecule(_ molecule: FormItemProtocol) { - if var molecule = molecule as? FormFieldProtocol, - let fieldKey = molecule.fieldKey { - if molecule.baseValue == nil { - molecule.baseValue = molecule.formFieldValue() - } - fieldMolecules[fieldKey] = molecule - } - if let molecule = molecule as? FormActionFieldProtocol { - formActionMolecules.append(molecule) + /// Adds the form field to the validator. + public func add(_ field: FormFieldProtocol) { + if let fieldKey = field.fieldKey { + fields[fieldKey] = field } } - public static func setupValidation(molecule: FormItemProtocol, delegate: FormHolderProtocol?) { + /// Adds the form action to the validator. + public func add(_ action: FormGroupWatcherFieldProtocol) { + groupWatchers.append(action) + } + + /// Determines the type of item and adds it. + private func insert(_ item: FormItemProtocol) { + if let item = item as? FormFieldProtocol { + add(item) + } else if let item = item as? FormGroupWatcherFieldProtocol { + add(item) + } + } + + /// Convenience function. Gets the form validator from the holder and sets up the item with it. + public static func setupValidation(for item: FormItemProtocol, delegate: FormHolderProtocol?) { if let validator = delegate?.formValidator { validator.delegate = delegate - validator.insertMolecule(molecule) + validator.insert(item) } } + + /// Convenience function. Gets the form validator from the holder and asks it to validate. + public static func validate(delegate: FormHolderProtocol?) -> Bool? { + return delegate?.formValidator?.validate() + } + + /// Validates all rule groups. Returns if valid + public func validate() -> Bool { + var valid = true + for group in formRules { + valid = valid && validateGroup(group) + } + return valid + } + + /// Validates a given rule group. Returns if valid + public func validateGroup(_ group: FormGroupRule) -> Bool { + // Validate each rule. + var valid = true + for rule in group.rules { + valid = valid && validateRule(rule) + } + + // Notify the group watchers of validity. + for watcher in groupWatchers { + if watcher.groupName == group.groupName { + watcher.setValidity(valid, group: group) + } + } + + return valid + } - public static func getFormValidatorFor(delegate: FormHolderProtocol?) -> FormValidator? { - return delegate?.formValidator - } - - public static func validate(delegate: FormHolderProtocol?) { - delegate?.formValidator?.validate() - } - - public func validate() { - guard let formRules = formRules else { - return - } - formActionMolecules.forEach { (actionModel) in - if let groupName = actionModel.groupName, - let formRule = formRules.first(where: { $0.groupName == groupName }) { - validate(groupName, actionModel, formRule.rules) - } - } - } - - public func validate(_ groupName: String, _ actionModel: FormActionFieldProtocol, _ rules: [RulesProtocol]) { + /// Validates a given rule. Returns if valid. + public func validateRule(_ rule: RulesProtocol) -> Bool { var valid = true - for rule in rules { - valid = valid && rule.isValid(fieldMolecules) - if !valid { - break - } + for formKey in rule.fields { + guard let formField = fields[formKey] else { continue } + let fieldValidity = rule.isValid(formField) + (formField as? FormRuleWatcherFieldProtocol)?.setValidity(fieldValidity, rule: rule) + valid = valid && fieldValidity } - actionModel.updateEnable(valid) - } - - public func formField(for fieldKey: String) -> FormFieldProtocol? { - return fieldMolecules[fieldKey] + return valid } } -// mark Form params +// mark Form params +// TODO: Temporary hacks, rewrite architecture to support this. @objc public extension FormValidator { @objc func addFormParams(requestParameters: MVMCoreRequestParameters) { - let formButton = getFormButton(forPageType: requestParameters.pageType) - let groupName = formButton?.groupName ?? FormValidator.defaultGroupName + let groupName = getGroupName(forPageType: requestParameters.pageType) ?? FormValidator.defaultGroupName let formParams = self.getFormParams(forGroup: groupName) requestParameters.add(formParams) } @objc func getFormParams( forGroup groupName: String) -> [String: Any] { var extraParam: [String: Any] = [:] - MVMCoreDispatchUtility.performSyncBlock(onMainThread: { - for (fieldKey, molecule) in self.fieldMolecules { - if let formFieldValue = molecule.formFieldValue(), - groupName == molecule.groupName { - extraParam[fieldKey] = formFieldValue - } + for (fieldKey, field) in fields { + if let formFieldValue = field.formFieldValue(), + groupName == field.groupName { + extraParam[fieldKey] = formFieldValue } - }) + } return extraParam } } -// Temporary +// TODO: Temporary hacks, rewrite architecture to support this. public extension FormValidator { - func getFormButton(forPageType pageType: String?) -> ButtonModel? { - for actionItem in formActionMolecules { + func getGroupName(forPageType pageType: String?) -> String? { + for actionItem in groupWatchers { if let buttonModel = actionItem as? ButtonModel, pageType == (buttonModel.action as? ActionOpenPageModel)?.pageType { - return buttonModel + return buttonModel.groupName } } return nil diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift index 34dfb7b8..b40d0460 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift @@ -5,6 +5,7 @@ // Created by Suresh, Kamlesh on 2/24/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +// Used by the form validator for storing the rules for a particular group. import Foundation diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift index 25119e03..6afe5b17 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift @@ -14,16 +14,19 @@ public enum RulesCodingKey: String, CodingKey { } public protocol RulesProtocol: ModelProtocol { - var type: String { get set } + // The type of rule + var type: String { get } + + // The fields that this rule applies to. var fields: [String] { get set } - func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool + + // Returns if a given field is valid according to the rule func isValid(_ formField: FormFieldProtocol) -> Bool - func setValid(_ formField: FormFieldProtocol, _ isValid: Bool) } public extension RulesProtocol { - var ruleType: String? { + var type: String { get { return Self.identifier } } @@ -34,23 +37,4 @@ public extension RulesProtocol { static var categoryName: String { return "\(RulesProtocol.self)" } - - func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { - var valid = true - - for formKey in fields { - guard let formField = fieldMolecules[formKey] else { continue } - let fieldValidity = isValid(formField) - setValid(formField, fieldValidity) - valid = valid && fieldValidity - } - - return valid - } - - func setValid(_ formField: FormFieldProtocol, _ isValid: Bool) { - guard let formFieldValid = formField as? ValidProtocol else { return } - - formFieldValid.setValidity(isValid) - } } diff --git a/MVMCoreUI/FormUIHelpers/ValidProtocol.swift b/MVMCoreUI/FormUIHelpers/ValidProtocol.swift deleted file mode 100644 index 20afd256..00000000 --- a/MVMCoreUI/FormUIHelpers/ValidProtocol.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// ValidProtocol.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 3/2/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public protocol ValidProtocol { - var isValid: Bool? { get set } - func setValidity(_ isValid: Bool) - var updateUI: (() -> Void)? { get set } -} diff --git a/MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift b/MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift deleted file mode 100644 index 2c3b14bf..00000000 --- a/MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// MFViewController+Form.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 3/3/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -extension MFViewController: ObservingTextFieldDelegate { -} - -public extension MFViewController { - @objc func startValidation() { - (self as? FormHolderProtocol)?.formValidator?.validate() - } - - @objc func addFormParams(requestParameters: MVMCoreRequestParameters) { - (self as? FormHolderProtocol)?.formValidator?.addFormParams(requestParameters: requestParameters) - } -} diff --git a/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift b/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift deleted file mode 100644 index 30abf59d..00000000 --- a/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// MFViewController+Model.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/24/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -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(_ moleculeName: String) -> MoleculeModelProtocol? { - guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName), - let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), - let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self) - else { return nil } - - do { - return try modelType.decode(jsonDict: moduleJSON) as? MoleculeModelProtocol - } catch { - MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - } - - return nil - } - - // These are required because swift will call the extension function otherwise. - public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {} - - @objc public func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {} - @objc public func addMolecules(_ molecules: [[AnyHashable : Any]], indexPath: IndexPath, animation: UITableView.RowAnimation) {} - @objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {} -} diff --git a/MVMCoreUI/Legacy/Controllers/MFViewController.m b/MVMCoreUI/Legacy/Controllers/MFViewController.m index febb14cf..68dd75c4 100644 --- a/MVMCoreUI/Legacy/Controllers/MFViewController.m +++ b/MVMCoreUI/Legacy/Controllers/MFViewController.m @@ -467,9 +467,6 @@ - (void)newDataBuildAndUpdate { [MVMCoreDispatchUtility performBlockOnMainThread:^{ [self newDataBuildScreen]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self startValidation]; - }); self.needToUpdateUI = YES; [self.view setNeedsLayout]; }]; @@ -666,8 +663,6 @@ if (requestParameters.openSupportPanel) { [[MVMCoreUISession sharedGlobal].splitViewController.rightPanel willOpenWithActionInformation:actionInformation]; } - - [self addFormParamsWithRequestParameters:requestParameters]; requestParameters.parentPageType = [self.loadObject.pageJSON stringForKey:@"parentPageType"]; [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:[self delegateObject]]; } From f378e66731556bf317a020d2ce722e4a437808d2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 24 Mar 2020 19:53:03 -0400 Subject: [PATCH 078/244] update --- MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift | 13 +++++++++++++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 6 +++--- .../VerticalCombinationViews/HeadlineBody.swift | 2 +- MVMCoreUI/Atomic/Organisms/Carousel.swift | 4 ++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 6c9242f9..74e6efa4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -12,6 +12,19 @@ import Foundation @objcMembers public class LabelModel: MoleculeModelProtocol { public enum FontStyle: String, Codable { + case Title2XLarge + case TitleXLarge + case BoldTitleLarge + case RegularTitleLarge + case BoldTitleMedium + case RegularTitleMedium + case BoldBodyLarge + case RegularBodyLarge + case BoldBodySmall + case RegularBodySmall + case BoldMicro + case RegularMicro + // Legacy case H1 case H2 case H3 diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index e6806e0c..bfa6db01 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -18,18 +18,18 @@ import Foundation } /// Registers the model with the model registry and the view with the mapper. - func register(viewClass: V.Type, viewModelClass: M.Type) { + public func register(viewClass: V.Type, viewModelClass: M.Type) { try? ModelRegistry.register(viewModelClass) moleculeMapping.updateValue(viewClass, forKey: viewModelClass.identifier) } /// Returns the type of molecule view for the given model - func getMoleculeClass(_ model: MoleculeModelProtocol) -> MoleculeViewProtocol.Type? { + public func getMoleculeClass(_ model: MoleculeModelProtocol) -> MoleculeViewProtocol.Type? { return moleculeMapping[model.moleculeName] } /// Creates a molecule with the given model. - func createMolecule(_ model: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> MoleculeViewProtocol? { + public func createMolecule(_ model: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> MoleculeViewProtocol? { guard let type = moleculeMapping[model.moleculeName] else { return nil } return type.init(model: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift index 810c26fb..c5a7f8c6 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -11,7 +11,7 @@ import UIKit open class HeadlineBody: View { let headlineLabel = Label.commonLabelH2(true) let messageLabel = Label.commonLabelB2(true) - var spaceBetweenLabelsConstant = PaddingTwo + var spaceBetweenLabelsConstant = PaddingOne var spaceBetweenLabels: NSLayoutConstraint? var leftConstraintTitle: NSLayoutConstraint? var rightConstraintTitle: NSLayoutConstraint? diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 8409cd24..a7117e33 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -28,11 +28,11 @@ open class Carousel: View { /// The number of pages that there are. Used for the page control and for calculations. Should not include the looping dummy cells. Be sure to set this if subclassing and not using the molecules. open var numberOfPages = 0 - /// The json for the molecules. + /// The models for the molecules. 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 + public var itemAlignment = UICollectionView.ScrollPosition.left /// From 0-1. The item width as a percent of the carousel width. public var itemWidthPercent: Float = 1 From b0ae313d420154f9cf8ae4bd1a966681aefd1f65 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 24 Mar 2020 22:39:44 -0400 Subject: [PATCH 079/244] undo legacy changes --- MVMCoreUI/Legacy/Views/ButtonView.swift | 10 ++++++ MVMCoreUI/Legacy/Views/PrimaryButton.h | 4 +++ MVMCoreUI/Legacy/Views/PrimaryButton.m | 41 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/MVMCoreUI/Legacy/Views/ButtonView.swift b/MVMCoreUI/Legacy/Views/ButtonView.swift index 4c489ae5..3bdb909b 100644 --- a/MVMCoreUI/Legacy/Views/ButtonView.swift +++ b/MVMCoreUI/Legacy/Views/ButtonView.swift @@ -30,6 +30,11 @@ import UIKit primaryButton?.isEnabled = enabled } + public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) { + super.init(frame: .zero) + setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + } + // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) @@ -44,6 +49,11 @@ import UIKit alignCenterHorizontal() } + // MARK: - MVMCoreUIMoleculeViewProtocol + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + primaryButton?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + } + // MARK: - Constraining open override func copyBackgroundColor() -> Bool { return true diff --git a/MVMCoreUI/Legacy/Views/PrimaryButton.h b/MVMCoreUI/Legacy/Views/PrimaryButton.h index 511519be..a93e6fc5 100644 --- a/MVMCoreUI/Legacy/Views/PrimaryButton.h +++ b/MVMCoreUI/Legacy/Views/PrimaryButton.h @@ -10,6 +10,7 @@ #import #import #import +@class MVMCoreUIDelegateObject; typedef enum : NSUInteger { PrimaryButtonTypeRed, @@ -117,6 +118,9 @@ static CGFloat const PrimaryButtonSmallHeight = 30.0; - (void)resetButtonType:(PrimaryButtonType)type small:(BOOL)isSmall bordered:(BOOL)bordered; - (void)resetButtonType:(PrimaryButtonType)type tiny:(BOOL)isTiny bordered:(BOOL)bordered; +// Convenience setter for common keys +- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; + #pragma mark - Handling Validations // Sets the enabled property depending on the validity checks diff --git a/MVMCoreUI/Legacy/Views/PrimaryButton.m b/MVMCoreUI/Legacy/Views/PrimaryButton.m index 7a235fce..ded6bac2 100644 --- a/MVMCoreUI/Legacy/Views/PrimaryButton.m +++ b/MVMCoreUI/Legacy/Views/PrimaryButton.m @@ -655,6 +655,47 @@ return button; } +- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + self.primaryButtonType = PrimaryButtonTypeCustom; + NSString *style = [json string:@"style"]; + if ([style isEqualToString:@"primary"]) { + [self setAsStandardCustom]; + } else if ([style isEqualToString:@"secondary"]) { + [self setAsSecondaryCustom]; + } + + NSString *color = [json string:@"fillColor"]; + if (color) { + self.fillColor = [UIColor mfGetColorForHex:color]; + } + if ((color = [json string:KeyTextColor])) { + self.textColor = [UIColor mfGetColorForHex:color]; + } + if ((color = [json string:@"borderColor"])) { + self.borderColor = [UIColor mfGetColorForHex:color]; + } + _bordered = self.borderColor != nil; + if ((color = [json string:@"disabledFillColor"])) { + self.disabledFillColor = [UIColor mfGetColorForHex:color]; + } + if ((color = [json string:@"disabledTextColor"])) { + self.disabledTextColor = [UIColor mfGetColorForHex:color]; + } + if ((color = [json string:@"disabledBorderColor"])) { + self.disabledBorderColor = [UIColor mfGetColorForHex:color]; + } + + NSString *size = [json string:@"size"]; + if ([size isEqualToString:@"small"]) { + [self setAsSmallButton:YES]; + } else if ([size isEqualToString:@"tiny"]) { + [self setAsTiny:YES]; + } else { + [self setAsSmallButton:NO]; + } + [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; +} + #pragma mark - Constraining Protocol - (UIStackViewAlignment)horizontalAlignment { From 14af105ad725997358de3e9ceada36c7e7370fcb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 09:31:40 -0400 Subject: [PATCH 080/244] fix to margins --- MVMCoreUI/BaseClasses/TableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 36aade11..060c2319 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -8,7 +8,7 @@ import UIKit -@objcMembers open class TableViewCell: UITableViewCell, MoleculeViewProtocol, MoleculeListCellProtocol { +@objcMembers open class TableViewCell: UITableViewCell, MoleculeViewProtocol, MoleculeListCellProtocol, MVMCoreViewProtocol { open var molecule: MoleculeViewProtocol? open var listItemModel: ListItemModelProtocol? From 4d07578865cf420eb7bbba321d0069b0f5e5d11b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 09:46:50 -0400 Subject: [PATCH 081/244] typo fix --- MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift index 4534a506..0c9dec3b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift @@ -46,7 +46,7 @@ import UIKit } public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let moleculeModel = (model as? MoleculeContainerModel)?.molecule, + guard let moleculeModel = (model as? MoleculeListItemModel)?.molecule, let classType = MoleculeObjectMapping.shared()?.getMoleculeClass(moleculeModel), let height = classType.estimatedHeight(with: moleculeModel, delegateObject) else { return 80 } From 809e450c15181ea81066edef15731c6da9e4d09b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 10:00:05 -0400 Subject: [PATCH 082/244] label fix --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index ab0a0f20..40c34b08 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -130,6 +130,7 @@ public typealias ActionBlock = () -> () required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.init(frame: .zero) + setupView() styleB2(true) set(with: model, delegateObject, additionalData) } From e97226fd3f04846575dd16ba34aeca914a1007ce Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 10:27:31 -0400 Subject: [PATCH 083/244] toggle update --- MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift index 334ba00f..9e9e9e4a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift @@ -63,14 +63,14 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo action = try typeContainer.decodeModelIfPresent(codingKey: .action) alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - self.groupName = groupName - } onTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onTintColor) offTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offTintColor) onKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onKnobTintColor) offKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offKnobTintColor) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } } public func encode(to encoder: Encoder) throws { @@ -80,11 +80,13 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(state, forKey: .state) - try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encode(animated, forKey: .animated) + try container.encode(enabled, forKey: .enabled) try container.encodeIfPresent(onTintColor, forKey: .onTintColor) try container.encodeIfPresent(onKnobTintColor, forKey: .onKnobTintColor) try container.encodeIfPresent(onKnobTintColor, forKey: .onKnobTintColor) try container.encodeIfPresent(offKnobTintColor, forKey: .offKnobTintColor) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(groupName, forKey: .groupName) } } From 60ca1be4bed89eeaadae612b303139954d7abcd6 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 11:17:43 -0400 Subject: [PATCH 084/244] for accessibility. --- MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift | 3 ++- MVMCoreUI/Templates/MoleculeListTemplate.swift | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 33229092..75f1f0d8 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -24,6 +24,7 @@ import UIKit (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { addMolecule(moleculeView) + accessibilityElements = [moleculeView] } super.set(with: model, delegateObject, additionalData) } @@ -37,7 +38,7 @@ import UIKit return "\(self)<\(moleculeName)>" } - public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + 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 { return nil } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index d68a1170..1db1593b 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -215,7 +215,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? { guard let listItem = listItem, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) else { return nil } + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) + else { return nil } + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName return (moleculeName, moleculeClass, listItem) } From e563c0133af0c820865f714748f166d459622e55 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 11:58:16 -0400 Subject: [PATCH 085/244] fixes production bug temporary --- .../ToggleMolecules/LabelToggleModel.swift | 22 +++++++++++++++++++ MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index 16f292ed..29e7a609 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -19,4 +19,26 @@ public class LabelToggleModel: MoleculeModelProtocol { self.label = label self.toggle = toggle } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case label + case toggle + } + + 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) + toggle = try typeContainer.decode(ToggleModel.self, forKey:.toggle) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(label, forKey: .label) + try container.encode(toggle, forKey: .toggle) + } } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 5a94137a..930828f6 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -86,7 +86,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; - (void)pinATopViewController:(UIViewController *)viewController { self.statusBarHeightConstraint.active = NO; - id topGuide = viewController.view.safeAreaLayoutGuide.topAnchor; + id topGuide = viewController.topLayoutGuide; self.statusBarBottomConstraint = [NSLayoutConstraint constraintWithItem:self.statusBarView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:topGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; self.statusBarBottomConstraint.active = YES; } From 11069d3f7342bf7d64d2c403c8784e6c3ac9b83e Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 25 Mar 2020 12:59:26 -0400 Subject: [PATCH 086/244] add convenience initializers for creating a legacy footer --- MVMCoreUI.xcodeproj/project.pbxproj | 20 +++++++++++ MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 6 ++-- .../Legacy/Adapters/ActionModelAdapter.swift | 20 +++++++++++ .../Legacy/Adapters/FooterModelAdapter.swift | 36 +++++++++++++++++++ .../Legacy/Adapters/LabelModelAdapter.swift | 33 +++++++++++++++++ 5 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift create mode 100644 MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift create mode 100644 MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5308ee86..0108ffc0 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -110,6 +110,9 @@ 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */; }; 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB423FF18D2004C5109 /* Arrow.swift */; }; 0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */; }; + 279B1567242BBBF200921D6C /* LabelModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1566242BBBF200921D6C /* LabelModelAdapter.swift */; }; + 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; + 279B156D242BBFF100921D6C /* FooterModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B156C242BBFF100921D6C /* FooterModelAdapter.swift */; }; 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; @@ -502,6 +505,9 @@ 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkModel.swift; sourceTree = ""; }; 0AE98BB423FF18D2004C5109 /* Arrow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arrow.swift; sourceTree = ""; }; 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrowModel.swift; sourceTree = ""; }; + 279B1566242BBBF200921D6C /* LabelModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelModelAdapter.swift; sourceTree = ""; }; + 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; + 279B156C242BBFF100921D6C /* FooterModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModelAdapter.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 = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; @@ -917,6 +923,16 @@ path = Link; sourceTree = ""; }; + 279B1565242BBB8500921D6C /* Adapters */ = { + isa = PBXGroup; + children = ( + 279B1566242BBBF200921D6C /* LabelModelAdapter.swift */, + 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */, + 279B156C242BBFF100921D6C /* FooterModelAdapter.swift */, + ); + path = Adapters; + sourceTree = ""; + }; 5206F150241144A900658DC5 /* Headers */ = { isa = PBXGroup; children = ( @@ -1260,6 +1276,7 @@ D22D1F582204D2590077CEC0 /* Legacy */ = { isa = PBXGroup; children = ( + 279B1565242BBB8500921D6C /* Adapters */, D213347523842FF5008E41B3 /* Views */, D213347423842FE3008E41B3 /* Controllers */, ); @@ -2088,6 +2105,7 @@ C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, D29DF29521E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, + 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */, BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, @@ -2113,6 +2131,7 @@ D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, + 279B1567242BBBF200921D6C /* LabelModelAdapter.swift in Sources */, D2C78CD224228BBD00B69FDE /* ActionOpenPanelModel.swift in Sources */, 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */, C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, @@ -2203,6 +2222,7 @@ 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, D260106523D0CEA700764D80 /* StackModel.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, + 279B156D242BBFF100921D6C /* FooterModelAdapter.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index ac9d1dc1..f441ef64 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -42,18 +42,18 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormAction public var updateUI: (() -> Void)? - init(with title: String, action: ActionModelProtocol) { + public init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action } - init(secondaryButtonWith title: String, action: ActionModelProtocol) { + public init(secondaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .secondary } - init(primaryButtonWith title: String, action: ActionModelProtocol) { + public init(primaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .primary diff --git a/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift new file mode 100644 index 00000000..ba0ce96b --- /dev/null +++ b/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift @@ -0,0 +1,20 @@ +// +// ActionModelAdapter.swift +// MVMCoreUI +// +// Created by Kyle on 3/25/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +public extension Dictionary { + + func asActionModel() -> ActionModelProtocol? { + guard let castedSelf = self as? [String: Any], + let actionType = ModelRegistry.getType(for: castedSelf.stringForkey(KeyActionType), with: ActionModelProtocol.self), + let actionModel = try? actionType.decode(jsonDict: castedSelf) as? ActionModelProtocol else { + return nil + } + return actionModel + } + +} diff --git a/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift new file mode 100644 index 00000000..7c923ba0 --- /dev/null +++ b/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift @@ -0,0 +1,36 @@ +// +// FooterModelAdapter.swift +// MVMCoreUI +// +// Created by Kyle on 3/25/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +public extension FooterModel { + + convenience init(withPrimaryAction primaryMap: [AnyHashable: Any]? = nil, secondaryAction secondaryMap: [AnyHashable: Any]? = nil, bottomLinkAction linkMap: [AnyHashable: Any]? = nil) { + + var primaryButtonModel: ButtonModel? + var secondaryButtonModel: ButtonModel? + if let primaryActionModel = primaryMap?.asActionModel() { + primaryButtonModel = ButtonModel(primaryButtonWith: primaryActionModel.title ?? "", action: primaryActionModel) + } + if let secondaryActionModel = secondaryMap?.asActionModel() { + secondaryButtonModel = ButtonModel(secondaryButtonWith: secondaryActionModel.title ?? "", action: secondaryActionModel) + } + let twoButtonModel = TwoButtonViewModel(primaryButtonModel, secondaryButtonModel) + + let footerContentModel: MoleculeModelProtocol + if let linkActionJSON = linkMap { + let labelModel = LabelModel(linkAction: linkActionJSON) + let moleculeStack = MoleculeStackModel(molecules: [MoleculeStackItemModel(with: twoButtonModel), MoleculeStackItemModel(with: labelModel)]) + moleculeStack.spacing = MFStyler.defaultVerticalPaddingForApplicationWidth() + footerContentModel = moleculeStack + } else { + footerContentModel = twoButtonModel + } + + self.init(with: footerContentModel) + } + +} diff --git a/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift new file mode 100644 index 00000000..757b2ccb --- /dev/null +++ b/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift @@ -0,0 +1,33 @@ +// +// LabelModelAdapter.swift +// MVMCoreUI +// +// Created by Kyle on 3/25/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +public extension LabelModel { + + convenience init(linkAction: [AnyHashable: Any]) { + // Concatentate the text. + var titlePrefix = linkAction.stringForkey(KeyTitlePrefix) + var titlePostfix = linkAction.stringForkey(KeyTitlePostfix) + if !titlePrefix.isEmpty { + titlePrefix += " " + } + if !titlePostfix.isEmpty { + titlePostfix += " " + } + let title = linkAction.optionalStringForKey(KeyTitle) ?? "" + let text = "\(titlePrefix)\(title)\(titlePostfix)" + + // Initialize with text. + self.init(text: text) + + // Add action attribute. + if let linkActionModel = linkAction.asActionModel() { + attributes = [LabelAttributeActionModel(titlePrefix.isEmpty ? 0 : titlePrefix.count, title.count, action: linkActionModel)] + } + } + +} From 9589964777876bc435981636d509546775924cb8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 13:21:04 -0400 Subject: [PATCH 087/244] remove orig --- .../PageModelProtocol.swift.orig | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig deleted file mode 100644 index 9cbe5af2..00000000 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift.orig +++ /dev/null @@ -1,20 +0,0 @@ -// -// PageModelProtocol.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 1/9/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public protocol PageModelProtocol { - var pageType: String { get set } - var screenHeading: String? { get set } -<<<<<<< HEAD - var navigationItem: NavigationItemModelProtocol? { get set } -======= - var isAtomicTabs: Bool? { get set } - var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } ->>>>>>> 18f86575e604bb7b53b6bdac4fc677951979031f -} From c7929c509b9e68d8b693eb706d7e409a1b8c5e89 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 13:25:23 -0400 Subject: [PATCH 088/244] review fixes --- .../Atomic/Protocols/TemplateProtocol.swift | 1 - .../ModalMoleculeListTemplate.swift.orig | 30 ------------------- 2 files changed, 31 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 347458b0..56b1a86c 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -20,7 +20,6 @@ public extension TemplateProtocol where Self: ViewController { let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() let templateModel = try decoder.decode(TemplateModel.self, from: data) - print(templateModel.toJSONString() ?? "") self.templateModel = templateModel self.pageModel = templateModel as? MVMControllerModelProtocol } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig deleted file mode 100644 index af43d0af..00000000 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift.orig +++ /dev/null @@ -1,30 +0,0 @@ -// -// ModalMoleculeListTemplate.swift -// MVMCoreUI -// -// Created by Ryan on 3/6/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class ModalMoleculeListTemplate: MoleculeListTemplate { - -<<<<<<< HEAD - override open func handleNewData() { - MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in - if let _ = self { - MVMCoreNavigationHandler.shared()?.removeCurrentViewController() - } -======= - public var closeButton: MFCustomButton? - - override open func newDataBuildScreen() { - super.newDataBuildScreen() - closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in - self?.dismiss() ->>>>>>> develop - }, verticalCentered: false) - super.handleNewData() - } -} From 987bfcae36cd585a1e6179ba8cfbfb32f8b6defa Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 25 Mar 2020 13:32:27 -0400 Subject: [PATCH 089/244] remeove --- .../StackPageTemplateModel.swift.orig | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig diff --git a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig deleted file mode 100644 index 504378cd..00000000 --- a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift.orig +++ /dev/null @@ -1,58 +0,0 @@ -// -// StackPageTemplate.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 11/22/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - - -@objcMembers public class StackPageTemplateModel: TemplateModel { - public override class var identifier: String { - return "stack" - } - - public var header: MoleculeModelProtocol? - public var moleculeStack: MoleculeStackModel - public var footer: MoleculeModelProtocol? - - public init(pageType: String, moleculeStack: MoleculeStackModel) { - self.moleculeStack = moleculeStack - super.init(pageType: pageType) - } - - private enum CodingKeys: String, CodingKey { -<<<<<<< HEAD -======= - case pageType - case template - case screenHeading ->>>>>>> develop - case header - case footer - case stack - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeStack = try typeContainer.decode(MoleculeStackModel.self, forKey: .stack) - header = try typeContainer.decodeModelIfPresent(codingKey: .header) - footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) - 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) -<<<<<<< HEAD -======= - try container.encode(pageType, forKey: .pageType) - try container.encode(template, forKey: .template) ->>>>>>> develop - try container.encode(moleculeStack, forKey: .stack) - try container.encodeModelIfPresent(header, forKey: .header) - try container.encodeModelIfPresent(footer, forKey: .footer) - } -} From 7e89e58cd1186c7ecb9d4c50bfe55c8e731cca9c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 14:47:15 -0400 Subject: [PATCH 090/244] more accessibility stuff. --- MVMCoreUI/Atoms/Views/Label/Label.swift | 2 ++ .../Items/MoleculeTableViewCell.swift | 5 +++- .../ToggleMolecules/LabelToggleModel.swift | 24 ++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index c7e72204..a6a7cfe1 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -316,6 +316,7 @@ public typealias ActionBlock = () -> () text = labelModel.text hero = labelModel.hero Label.setLabel(self, withHTML: labelModel.html) + isAccessibilityElement = hasText let alignment = LabelAlignment(rawValue: labelModel.textAlignment ?? "") switch alignment { @@ -426,6 +427,7 @@ public typealias ActionBlock = () -> () continue } } + attributedText = attributedString originalAttributedString = attributedText } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 75f1f0d8..d04ff3b1 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -24,7 +24,10 @@ import UIKit (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { addMolecule(moleculeView) - accessibilityElements = [moleculeView] + + if ((moleculeView as? Label) != nil) { + accessibilityElements = [moleculeView] + } } super.set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index 16f292ed..64bc7e41 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -14,9 +14,31 @@ public class LabelToggleModel: MoleculeModelProtocol { public var backgroundColor: Color? public var label: LabelModel public var toggle: ToggleModel - + init(_ label: LabelModel, _ toggle: ToggleModel) { self.label = label self.toggle = toggle } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case label + case toggle + } + + 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) + toggle = try typeContainer.decode(ToggleModel.self, forKey:.toggle) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(label, forKey: .label) + try container.encode(toggle, forKey: .toggle) + } } From 7b857414af90d9cf560e807263f20b5d1ee12786 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 17:14:16 -0400 Subject: [PATCH 091/244] didn't carry over --- .../Molecules/Items/DropDownFilterTableViewCell.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index aa581ba1..6b6f5a32 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,16 +29,16 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let model = self.listItemModel as? DropDownListItemModel + let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), + let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], + !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) else { return } if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(model.molecules[self.previousIndex], animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) } - if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) { - self.delegateObject?.moleculeDelegate?.addMolecules(model.molecules[index], indexPath: indexPath, animation: .fade) - } + self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], sender: self, animation: .fade) self.previousIndex = index } } From 60199831a35e698935b7d048194597c5c5b2618c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 17:21:58 -0400 Subject: [PATCH 092/244] apparent merge conflict --- .../Molecules/Items/DropDownFilterTableViewCell.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 6b6f5a32..11e619c6 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,16 +29,21 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), + let model = self.listItemModel as? DropDownListItemModel, let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) else { return } if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(model.molecules[self.previousIndex], animation: .fade) +// self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], animation: .fade) } - self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], sender: self, animation: .fade) + if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) { + self.delegateObject?.moleculeDelegate?.addMolecules(model.molecules[index], indexPath: indexPath, animation: .fade) +// self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], animation: .fade) + } self.previousIndex = index } } From f2f2b179dd6a91e059f411281174bcbafde17496 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 25 Mar 2020 17:34:47 -0400 Subject: [PATCH 093/244] link only handling --- MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift index 7c923ba0..449227e3 100644 --- a/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift +++ b/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift @@ -23,9 +23,13 @@ public extension FooterModel { let footerContentModel: MoleculeModelProtocol if let linkActionJSON = linkMap { let labelModel = LabelModel(linkAction: linkActionJSON) - let moleculeStack = MoleculeStackModel(molecules: [MoleculeStackItemModel(with: twoButtonModel), MoleculeStackItemModel(with: labelModel)]) - moleculeStack.spacing = MFStyler.defaultVerticalPaddingForApplicationWidth() - footerContentModel = moleculeStack + if primaryButtonModel != nil || secondaryButtonModel != nil { + let moleculeStack = MoleculeStackModel(molecules: [MoleculeStackItemModel(with: twoButtonModel), MoleculeStackItemModel(with: labelModel)]) + moleculeStack.spacing = MFStyler.defaultVerticalPaddingForApplicationWidth() + footerContentModel = moleculeStack + } else { + footerContentModel = labelModel + } } else { footerContentModel = twoButtonModel } From 3249c9d68b1c50c181a8260753472dda4c0e1724 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 17:39:33 -0400 Subject: [PATCH 094/244] remvoed --- MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 11e619c6..307f64c9 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -37,12 +37,10 @@ import UIKit if self.previousIndex != NSNotFound { self.delegateObject?.moleculeDelegate?.removeMolecules(model.molecules[self.previousIndex], animation: .fade) -// self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], animation: .fade) } if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) { self.delegateObject?.moleculeDelegate?.addMolecules(model.molecules[index], indexPath: indexPath, animation: .fade) -// self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], animation: .fade) } self.previousIndex = index } From 4846d7ff8719579292230eff0a10074c1f5543bb Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Thu, 26 Mar 2020 17:33:47 +0530 Subject: [PATCH 095/244] Code cleanup - spacing issues. --- .../ListRightVariableTextLinkAllTextAndLinks.swift | 6 +++--- .../ListRightVariableTextLinkAllTextAndLinksModel.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift index d9d04205..5f2bfcfc 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift @@ -15,10 +15,10 @@ import Foundation public var stack: Stack public let link = Link(frame: .zero) public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) - // MARK: - Initializers + // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 5,horizontalAlignment: .leading)), + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading)), (view: link, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .top))],axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -36,7 +36,7 @@ import Foundation stack.restack() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListRightVariableTextLinkAllTextAndLinksModel else { return } link.set(with: model.link, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift index 7541d38d..9f6392fc 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift @@ -7,7 +7,7 @@ // import Foundation -public class ListRightVariableTextLinkAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ +public class ListRightVariableTextLinkAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "listRVLink" public var link: LinkModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel From 874007423d0902d18a91cc0279f2bbf0f69e7781 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 09:03:21 -0400 Subject: [PATCH 096/244] tmp --- MVMCoreUI/Molecules/Items/DropDownListItemModel.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 0cd2f5ef..071014d3 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -24,6 +24,12 @@ import Foundation line = LineModel(type: .none) style = "sectionFooter" } + +// public func verify() throws { +// guard dropDown.options.count != molecules.count else { +// throw +// } +// } //-------------------------------------------------- // MARK: - Initializer @@ -32,6 +38,7 @@ import Foundation public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { self.molecules = molecules self.dropDown = dropDown +// try verify() super.init() } From dd7a339a4390e10e9d47fd4b73bb1c04eaa0ac6a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 10:46:23 -0400 Subject: [PATCH 097/244] correction --- .../MoleculeModelProtocol.swift | 6 +++++ .../Items/DropDownFilterTableViewCell.swift | 5 +--- .../Items/DropDownListItemModel.swift | 24 +++++++++++++------ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index 913c3bd0..dda19b35 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -1,6 +1,12 @@ import Foundation +public enum MolecularError: Swift.Error { + case error(String) + case countImbalance(String) +} + + public protocol MoleculeModelProtocol: ModelProtocol { var moleculeName: String { get } var backgroundColor: Color? { get set } diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 307f64c9..aa581ba1 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,10 +29,7 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let model = self.listItemModel as? DropDownListItemModel, - let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), - let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], - !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) + let model = self.listItemModel as? DropDownListItemModel else { return } if self.previousIndex != NSNotFound { diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 071014d3..deb2374b 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -8,6 +8,7 @@ import Foundation + @objcMembers public class DropDownListItemModel: ListItemModel, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties @@ -17,6 +18,10 @@ import Foundation public var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]] public var dropDown: ItemDropdownEntryFieldModel + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + /// Defaults to set public override func setDefaults() { super.setDefaults() @@ -25,20 +30,24 @@ import Foundation style = "sectionFooter" } -// public func verify() throws { -// guard dropDown.options.count != molecules.count else { -// throw -// } -// } + //-------------------------------------------------- + // MARK: - Functions + //-------------------------------------------------- + + public class func verify(dropdown: ItemDropdownEntryFieldModel, molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]) throws { + guard dropdown.options.count == molecules.count else { + throw MolecularError.countImbalance("dropdown.options.count is not equal to molecules.count") + } + } //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { + public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) throws { self.molecules = molecules self.dropDown = dropDown -// try verify() + try Self.verify(dropdown: dropDown, molecules: molecules) super.init() } @@ -60,6 +69,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeModels2DIfPresent(codingKey: .molecules) ?? [[]] dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) + try Self.verify(dropdown: dropDown, molecules: molecules) try super.init(from: decoder) } From 88349bc651e3be1ed7c6a0305a509577eb28038f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 11:36:18 -0400 Subject: [PATCH 098/244] Adding localized string because I didn't see it there for existing key. Updating Toggle to handle accessibility text. --- MVMCoreUI/Atoms/Views/Toggle.swift | 22 ++++++++-------- MVMCoreUI/Atoms/Views/ToggleModel.swift | 26 ++++++++++++++++++- .../Items/MoleculeTableViewCell.swift | 7 ++--- .../Strings/en.lproj/Localizable.strings | 6 ++++- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 7e45c567..e5d0c00b 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -190,7 +190,10 @@ public typealias ActionBlockConfirmation = () -> (Bool) public override func setupView() { super.setupView() - guard subviews.isEmpty else { return } + isAccessibilityElement = true + accessibilityTraits = .button + accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") + accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") heightConstraint = heightAnchor.constraint(equalToConstant: Self.containerSize.height) heightConstraint?.isActive = true @@ -214,8 +217,6 @@ public typealias ActionBlockConfirmation = () -> (Bool) knobTrailingConstraint = trailingAnchor.constraint(equalTo: knobView.trailingAnchor, constant: 1) knobLeadingConstraint = knobView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 1) knobLeadingConstraint?.isActive = true - - accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") } public override func reset() { @@ -336,16 +337,15 @@ public typealias ActionBlockConfirmation = () -> (Bool) // MARK:- ModelMoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let toggleModel = model as? ToggleModel else { - return - } - - self.model = model self.delegateObject = delegateObject - let toggleModelJSON = toggleModel.toJSON() + self.model = model + + guard let model = model as? ToggleModel else { return } - FormValidator.setupValidation(molecule: toggleModel, delegate: delegateObject?.formHolderDelegate) - setWithJSON(toggleModelJSON, delegateObject: delegateObject, additionalData: additionalData) + accessibilityLabel = model.accessibilityText ?? MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") + + FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) + setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } //TODO: change to setWith Model diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 5e67be8a..ce599083 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -9,16 +9,24 @@ import UIKit public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { - + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "toggle" public var backgroundColor: Color? public var state: Bool = true public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? + public var accessibilityText: String? public var fieldKey: String? public var groupName: String? = FormValidator.defaultGroupName public var baseValue: AnyHashable? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case state @@ -27,16 +35,29 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { case fieldKey case alternateAction case groupName + case accessibilityText } + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + public func formFieldValue() -> AnyHashable? { return state } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(_ state: Bool) { self.state = state } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { @@ -49,6 +70,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } + + accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) } public func encode(to encoder: Encoder) throws { @@ -60,5 +83,6 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { try container.encode(state, forKey: .state) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) } } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index d04ff3b1..d3c83ea7 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -24,10 +24,7 @@ import UIKit (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { addMolecule(moleculeView) - - if ((moleculeView as? Label) != nil) { - accessibilityElements = [moleculeView] - } + accessibilityElements = [moleculeView] } super.set(with: model, delegateObject, additionalData) } @@ -36,7 +33,7 @@ import UIKit guard let moleculeModel = (model as? MoleculeListItemModel)?.molecule else { return "\(self)<>" } let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type - let moleculeName = className?.nameForReuse(with: moleculeModel, delegateObject) ?? moleculeModel.moleculeName ?? "" + let moleculeName = className?.nameForReuse(with: moleculeModel, delegateObject) ?? moleculeModel.moleculeName return "\(self)<\(moleculeName)>" } diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index b9d21b67..cbf2611a 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -31,6 +31,7 @@ // Camera "AccCameraButton" = "Camera Button"; "AccCameraHint" = "Double tap to launch camera for scanning"; + // Checkbox "checkbox_action_hint" = "Double tap to change state"; "checkbox_checked_state" = "Checked"; @@ -43,14 +44,17 @@ "radio_not_selected_state" = "Not Selected"; "radio_desc_state" = "Option"; -// Switch +// Switch / Toggle "mfswitch_buttonlabel" = "Switch Button"; +"Toggle_buttonlabel" = "Toggle Button" "AccOn" = "on"; "AccOff" = "off"; "AccToggleHint" = "double tap to toggle"; + // Carousel "MVMCoreUIPageControl_currentpage_index" = "page %ld of %ld"; "MVMCoreUIPageControlslides_currentpage_index" = "slide %ld of %ld"; + //Styler "CountDownDay" = " day"; "CountDownHour" = " hour"; From f133bad78cf9f7824d0265e33967766386ae5f87 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 12:48:23 -0400 Subject: [PATCH 099/244] accessibile togle --- MVMCoreUI/Atoms/Views/Toggle.swift | 3 ++- MVMCoreUI/Atoms/Views/ToggleModel.swift | 3 ++- MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index e5d0c00b..90a5197d 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -127,6 +127,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) private var widthConstraint: NSLayoutConstraint? private func constrainKnob() { + knobLeadingConstraint?.isActive = !isOn knobTrailingConstraint?.isActive = isOn } @@ -343,7 +344,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) guard let model = model as? ToggleModel else { return } accessibilityLabel = model.accessibilityText ?? MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - + isOn = model.state FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index ce599083..53244dce 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -15,7 +15,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { public static var identifier: String = "toggle" public var backgroundColor: Color? - public var state: Bool = true + public var state: Bool = false public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? public var accessibilityText: String? @@ -60,6 +60,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { self.state = state } diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index cbf2611a..a7f4cdf2 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -46,7 +46,7 @@ // Switch / Toggle "mfswitch_buttonlabel" = "Switch Button"; -"Toggle_buttonlabel" = "Toggle Button" +"Toggle_buttonlabel" = "Toggle Button"; "AccOn" = "on"; "AccOff" = "off"; "AccToggleHint" = "double tap to toggle"; From b6ec314d14c6749d1786ec0d12d8936f9cdde2d9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 15:30:44 -0400 Subject: [PATCH 100/244] replaced --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 8701f6b3..410c3221 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -190,7 +190,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) public override func setupView() { super.setupView() - + guard subviews.isEmpty else { return } isAccessibilityElement = true accessibilityTraits = .button accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") From c7344b166dd7d202aa5e35bfe4ace6e1baccdbc4 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Fri, 27 Mar 2020 18:23:03 +0530 Subject: [PATCH 101/244] MF-18985 - ListFourColumnDataUsageListItem --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../ListFourColumnDataUsageListItem.swift | 72 +++++++++++++++++++ ...ListFourColumnDataUsageListItemModel.swift | 64 +++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03335a4d..ddf36e4b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -130,6 +130,8 @@ 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; + 8D4687E2242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */; }; + 8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */; }; 942C372E241149170066E45E /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */; }; 942C372F241149170066E45E /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */; }; 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; }; @@ -514,6 +516,8 @@ 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; + 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItemModel.swift; sourceTree = ""; }; + 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItem.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-55Rg.otf"; sourceTree = ""; }; @@ -919,6 +923,8 @@ children = ( 525019E42406852100EED91C /* ListFourColumnDataUsageDividerModel.swift */, 525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */, + 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */, + 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */, ); path = FourColumn; sourceTree = ""; @@ -2029,6 +2035,7 @@ D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */, + 8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */, 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, 011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */, @@ -2168,6 +2175,7 @@ BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */, C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, + 8D4687E2242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift in Sources */, D29E28DD23D7404C00ACEA85 /* ContainerHelper.swift in Sources */, 012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index bfa6db01..02829367 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -136,6 +136,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift new file mode 100644 index 00000000..5eb0664d --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift @@ -0,0 +1,72 @@ +// +// ListFourColumnDataUsageListItem.swift +// MVMCoreUI +// +// Created by Kruthika KP on 27/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ListFourColumnDataUsageListItem: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + var stack: Stack + let label1 = Label.commonLabelB2(true) + let label2 = Label.commonLabelB2(true) + let label3 = Label.commonLabelB2(true) + let label4 = Label.commonLabelB2(true) + let arrow = Arrow(frame: .zero) + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: label1, model: StackItemModel(percent: 19, horizontalAlignment: .leading)), + (view: arrow, model: StackItemModel(percent: 4, horizontalAlignment: .leading)), + (view: label2, model: StackItemModel(percent: 40, horizontalAlignment: .leading)), + (view: label3, model: StackItemModel(percent:17,horizontalAlignment: .leading)), + (view: label4, model: StackItemModel(percent:20,horizontalAlignment: .leading))], + axis: .horizontal,spacing: 2) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + arrow.pinHeightAndWidth() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListFourColumnDataUsageListItemModel else { return } + label1.set(with: model.label1, delegateObject, additionalData) + label2.set(with: model.label2, delegateObject, additionalData) + label3.set(with: model.label3, delegateObject, additionalData) + label4.set(with: model.label4, delegateObject, additionalData) + arrow.set(with: model.arrow, delegateObject, additionalData) + stack.restack() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 121 + } + + open override func reset() { + super.reset() + label1.styleB2(true) + label2.styleB2(true) + label3.styleB2(true) + label4.styleB2(true) + arrow.reset() + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift new file mode 100644 index 00000000..dd9e8fa6 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift @@ -0,0 +1,64 @@ +// +// ListFourColumnDataUsageListItemModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 27/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelProtocol { + + public static var identifier: String = "list4C" + public var label1: LabelModel + public var label2: LabelModel + public var label3: LabelModel + public var label4: LabelModel + public var arrow: ArrowModel + + public init(label1:LabelModel, label2:LabelModel, label3:LabelModel,label4:LabelModel, arrow:ArrowModel) { + self.label1 = label1 + self.label2 = label2 + self.label3 = label3 + self.label4 = label4 + self.arrow = arrow + super.init() + } + + public override func setDefaults() { + super.setDefaults() + style = "header" + arrow.degrees = 50 + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case label1 + case label2 + case label3 + case label4 + case arrow + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + label1 = try typeContainer.decode(LabelModel.self, forKey: .label1) + label2 = try typeContainer.decode(LabelModel.self, forKey: .label2) + label3 = try typeContainer.decode(LabelModel.self, forKey: .label3) + label4 = try typeContainer.decode(LabelModel.self, forKey: .label4) + arrow = try typeContainer.decode(ArrowModel.self, forKey: .arrow) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(label1, forKey: .label1) + try container.encode(label2, forKey: .label2) + try container.encode(label3, forKey: .label3) + try container.encode(label4, forKey: .label4) + try container.encode(arrow, forKey: .arrow) + } +} From 70100791e63561556c3b1ac0aa89214566ce7b04 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 27 Mar 2020 09:13:57 -0400 Subject: [PATCH 102/244] remvoing to progess --- MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift index d0267afc..0c9dec3b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift @@ -24,7 +24,6 @@ import UIKit molecule?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(castModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { addMolecule(moleculeView) - accessibilityElements = [moleculeView] } super.set(with: model, delegateObject, additionalData) } From dcbfcf033fecd2ecef36e7461b5395a48277f316 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 30 Mar 2020 09:53:38 -0400 Subject: [PATCH 103/244] latest --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 1 + .../Molecules/Items/StackItemModel.swift | 10 +++++ .../EyebrowHeadlineBodyLink.swift | 24 +++++------ MVMCoreUI/Atomic/Organisms/Stack.swift | 16 +++++--- MVMCoreUI/BaseClasses/Control.swift | 1 + MVMCoreUI/BaseClasses/TableViewCell.swift | 3 ++ .../Views/Container/ContainerModel.swift | 16 ++++++++ .../Strings/en.lproj/Localizable.strings | 41 +++++++++++++------ 8 files changed, 82 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 410c3221..8ab7b07b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -338,6 +338,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) // MARK:- MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) self.delegateObject = delegateObject guard let model = model as? ToggleModel else { return } diff --git a/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift index 12254fb5..436ed9cd 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift @@ -9,6 +9,10 @@ import Foundation @objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "simpleStackItem" public var moleculeName: String = StackItemModel.identifier public var backgroundColor: Color? @@ -16,12 +20,18 @@ import Foundation public var percent: Int? public var gone: Bool = false + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public convenience init(spacing: CGFloat? = nil, percent: Int? = nil, horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil, gone: Bool? = nil) { self.init() + self.horizontalAlignment = horizontalAlignment self.verticalAlignment = verticalAlignment self.spacing = spacing self.percent = percent + if let gone = gone { self.gone = gone } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 9672b789..ff530d92 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -52,18 +52,18 @@ import UIKit body.styleB2(true) } - public func eyebrow(isHidden: Bool) { - - stack.stackModel?.molecules[0].gone = isHidden - - if isHidden { - accessibilityElements = [headline, body, link] - } else { - accessibilityElements = [eyebrow, headline, body, link] - } - - stack.restack() - } +// public func eyebrow(isHidden: Bool) { +// +// stack.stackModel?.molecules[0].gone = isHidden +// +// if isHidden { +// accessibilityElements = [headline, body, link] +// } else { +// accessibilityElements = [eyebrow, headline, body, link] +// } +// +// stack.restack() +// } //-------------------------------------------------- // MARK: - MoleculeViewProtocol diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index b7dab506..e957a2a6 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -15,10 +15,11 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto //-------------------------------------------------- open var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() + open var stackItems: [UIView] = [] + open var stackModel: T? { get { return model as? T } } - open var stackItems: [UIView] = [] //-------------------------------------------------- // MARK: - Helpers @@ -37,18 +38,21 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto guard let stackModel = stackModel else { return } let stackItems = self.stackItems self.stackItems = [] - let lastItemIndex = stackModel.molecules.lastIndex(where: { (item) -> Bool in - return !item.gone - }) + let lastItemIndex = stackModel.molecules.lastIndex { !$0.gone } // Adds the views let totalSpace = getTotalSpace() for (index, view) in stackItems.enumerated() { addView(view, stackModel.molecules[index], totalSpacing: totalSpace, lastItem: lastItemIndex == index) } - + isAccessibilityElement = false - accessibilityElements = stackItems + var accessibleViews: [Any] = [] + for (index, view) in stackItems.enumerated() where !stackModel.molecules[index].gone { + accessibleViews.append(view) + } + + accessibilityElements = accessibleViews } /// Removes all stack items views from the view. diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index b73fcc81..ebb88977 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -12,6 +12,7 @@ import UIKit //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var model: MoleculeModelProtocol? private var initialSetupPerformed = false diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 7af0b57b..dc4d270a 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -197,10 +197,13 @@ import UIKit // MARK: - Caret View /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { + guard accessoryView == nil else { return } let caret = CaretView(lineWidth: 1) caret.translatesAutoresizingMaskIntoConstraints = true + caret.isAccessibilityElement = true + caret.accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccTabHint") caret.size = .small(.vertical) if let size = caret.size?.dimensions() { caret.frame = CGRect(origin: CGPoint.zero, size: size) diff --git a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift index a18e8589..ec6f9769 100644 --- a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift +++ b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift @@ -9,6 +9,10 @@ import Foundation open class ContainerModel: ContainerModelProtocol, Codable { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public var horizontalAlignment: UIStackView.Alignment? public var verticalAlignment: UIStackView.Alignment? public var useHorizontalMargins: Bool? @@ -17,6 +21,10 @@ open class ContainerModel: ContainerModelProtocol, Codable { public var topMarginPadding: CGFloat? public var bottomMarginPadding: CGFloat? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case verticalAlignment case horizontalAlignment @@ -26,6 +34,10 @@ open class ContainerModel: ContainerModelProtocol, Codable { case bottomMarginPadding } + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + public init() {} public convenience init(horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil) { @@ -33,6 +45,10 @@ open class ContainerModel: ContainerModelProtocol, Codable { self.horizontalAlignment = horizontalAlignment self.verticalAlignment = verticalAlignment } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index a7f4cdf2..48cbe3ce 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -6,56 +6,73 @@ Copyright © 2017 myverizon. All rights reserved. */ -//// Accessibility +// MARK: Accessibility "AccCloseButton" = "Close"; "swipe_to_select_with_action_hint" = "swipe up or down to select action, then double tap to select."; -// Tab + + +// MARK: Tab "AccTab" = ", tab"; "AccTabHint" = "Double tap to select."; "AccTabIndex" = ", %ld of %ld"; -// top alert + + +// MARK: Top alert "toptabbar_tab_selected" = ", tab, Selected"; "AccTopAlertClosed" = "Top alert notification is closed."; "top_alert_notification" = "Top alert notification"; -// Textfield + + +// MARK: Textfield "textfield_today_string" = "Today"; "textfield_error_message" = "%@.\n The error message.\n %@"; "textfield_picker_item" = " picker item"; "textfield_regular" = " regular"; "textfield_disabled_state" = "disabled"; -// MDNTextfield + + +// MARK: MDNTextfield "textfield_contacts_barbutton" = "My Contacts"; "textfield_phone_format_error_message" = "Invalid phone number format."; -// DigitTextfield + + +// MARK: DigitTextfield "mfdigittextfield_regular" = " regular"; -// Camera + + +// MARK: Camera "AccCameraButton" = "Camera Button"; "AccCameraHint" = "Double tap to launch camera for scanning"; -// Checkbox + +// MARK: Checkbox "checkbox_action_hint" = "Double tap to change state"; "checkbox_checked_state" = "Checked"; "checkbox_unchecked_state" = "Unchecked"; "checkbox_desc_state" = "%@ CheckBox %@"; -// Radio Button + +// MARK: Radio Button "radio_action_hint" = "Double tap to select"; "radio_selected_state" = "Selected"; "radio_not_selected_state" = "Not Selected"; "radio_desc_state" = "Option"; -// Switch / Toggle + +// MARK: Switch / Toggle "mfswitch_buttonlabel" = "Switch Button"; "Toggle_buttonlabel" = "Toggle Button"; "AccOn" = "on"; "AccOff" = "off"; "AccToggleHint" = "double tap to toggle"; -// Carousel + +// MARK: Carousel "MVMCoreUIPageControl_currentpage_index" = "page %ld of %ld"; "MVMCoreUIPageControlslides_currentpage_index" = "slide %ld of %ld"; -//Styler + +// MARK: Styler "CountDownDay" = " day"; "CountDownHour" = " hour"; "CountDownMin" = " min"; From a38b781c117c590812f6b65e3ea1d057031925af Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 30 Mar 2020 10:42:51 -0400 Subject: [PATCH 104/244] no --- .../EyebrowHeadlineBodyLink.swift | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index ff530d92..82f83530 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -52,19 +52,6 @@ import UIKit body.styleB2(true) } -// public func eyebrow(isHidden: Bool) { -// -// stack.stackModel?.molecules[0].gone = isHidden -// -// if isHidden { -// accessibilityElements = [headline, body, link] -// } else { -// accessibilityElements = [eyebrow, headline, body, link] -// } -// -// stack.restack() -// } - //-------------------------------------------------- // MARK: - MoleculeViewProtocol //-------------------------------------------------- From 710adec0379d2570a881701d2d205e14a62e6ed5 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Mon, 30 Mar 2020 10:58:47 -0400 Subject: [PATCH 105/244] add web view --- MVMCoreUI.xcodeproj/project.pbxproj | 8 + MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 181 ++++++++++++++++++ .../Atomic/Atoms/Views/WebViewModel.swift | 55 ++++++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + 4 files changed, 245 insertions(+) create mode 100644 MVMCoreUI/Atomic/Atoms/Views/WebView.swift create mode 100644 MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03335a4d..9a942945 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -137,6 +137,8 @@ 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 */; }; + 943820842432382400B43AF3 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943820832432382400B43AF3 /* WebView.swift */; }; + 94382086243238D100B43AF3 /* WebViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94382085243238D100B43AF3 /* WebViewModel.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 */; }; @@ -522,6 +524,8 @@ 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 = ""; }; + 943820832432382400B43AF3 /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; + 94382085243238D100B43AF3 /* WebViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewModel.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 = ""; }; @@ -1526,6 +1530,8 @@ 0AA33B392398524F0067DD0F /* Toggle.swift */, 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */, 0AE98BB423FF18D2004C5109 /* Arrow.swift */, + 94382085243238D100B43AF3 /* WebViewModel.swift */, + 943820832432382400B43AF3 /* WebView.swift */, ); path = Views; sourceTree = ""; @@ -1902,6 +1908,7 @@ 0116A4E5228B19640094F3ED /* RadioButtonSelectionHelper.swift in Sources */, 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, + 94382086243238D100B43AF3 /* WebViewModel.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, @@ -1972,6 +1979,7 @@ D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, + 943820842432382400B43AF3 /* WebView.swift in Sources */, 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift new file mode 100644 index 00000000..64343aa7 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -0,0 +1,181 @@ +// +// MVMCoreUIWebView.swift +// MVMCoreUI +// +// Created by Ryan on 8/29/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit +import WebKit + +@objcMembers open class WebView: View, MVMCoreUIViewConstrainingProtocol { + + public let loadingSpinner = MFLoadingSpinner(frame: .zero) + + var delegateObject: MVMCoreUIDelegateObject? + var webView: WKWebView? + var webViewHeight: NSLayoutConstraint? + var dynamicHeight: Bool = true + + var callHandlerName: String? + + override open func setupView() { + super.setupView() + let webView = createWebView(messageHandler: nil, jsScript: nil) + addSubview(webView) + NSLayoutConstraint.constraintPinSubview(toSuperview: webView) + self.webView = webView + pinSpinnerView() + } + + func createWebView(messageHandler: String?, jsScript:String?) -> WKWebView { + let wkUserController = WKUserContentController() + if let messageHandlerName = messageHandler { + wkUserController.add(self, name: messageHandlerName) + } + //inital-scale is necessary to update display correct scale + let source: String = "var meta = document.createElement('meta');" + + "meta.name = 'viewport';" + + //depends on how much clint driven + "meta.content = 'initial-scale=1.0';" + + "var head = document.getElementsByTagName('head')[0];" + "head.appendChild(meta);"; + let wkScript = WKUserScript(source: source, injectionTime: .atDocumentEnd, forMainFrameOnly: true) + wkUserController.addUserScript(wkScript) + + //server driven addition script + if let jsScript = jsScript { + let wkScript = WKUserScript(source: jsScript, injectionTime: .atDocumentStart, forMainFrameOnly: true) + wkUserController.addUserScript(wkScript) + } + + let wkConfig = WKWebViewConfiguration() + wkConfig.userContentController = wkUserController + let webView = WKWebView(frame: .zero, configuration: wkConfig) + webView.translatesAutoresizingMaskIntoConstraints = false + webView.uiDelegate = self + webView.navigationDelegate = self + return webView + } + + + // MARK: - MVMCoreUIMoleculeViewProtocol + override open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? WebViewModel else { return } + self.delegateObject = delegateObject + + if model.callHandler != nil || model.jsScript != nil { +/* + webView's configuration property is immutable. + In order to add call handler into webview, need to create a new webview. + callHanlder + */ + webView?.removeFromSuperview() + let webView = createWebView(messageHandler: model.callHandler, jsScript:model.jsScript) + addSubview(webView) + NSLayoutConstraint.constraintPinSubview(toSuperview: webView) + self.webView = webView + } + //init height for loading spinner + webViewHeight = webView?.heightAnchor.constraint(equalToConstant: 50) + webViewHeight?.isActive = true + + if let height = model.height { + webViewHeight?.constant = height + dynamicHeight = false + } + if let url = model.url { + webView?.load(URLRequest(url: url)) + } else if let htmlString = model.htmlString { + webView?.loadHTMLString(htmlString, baseURL: nil) + } + bringSubviewToFront(loadingSpinner) + //TO DO: local path? + } + + func pinSpinnerView() { + addSubview(loadingSpinner) + // Setup spinner. + loadingSpinner.clipsToBounds = true + loadingSpinner.translatesAutoresizingMaskIntoConstraints = false + + loadingSpinner.heightAnchor.constraint(equalToConstant: 50.0).isActive = true + loadingSpinner.widthAnchor.constraint(equalToConstant: 50.0).isActive = true + loadingSpinner.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true + loadingSpinner.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true + loadingSpinner.resumeSpinner() + } +} + + +// MARK: - WKUIDelegate +extension WebView : WKUIDelegate { + public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + // hide loading + loadingSpinner.pause() + + if !dynamicHeight { + return + } + //update webview's heigth when webview is ready + webView.evaluateJavaScript("document.readyState", completionHandler: { [weak self] (result, error) in + if result == nil || error != nil { + return + } + webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { (result, error) in + guard let height = result as? CGFloat else { return } + self?.webViewHeight?.constant = height + self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!) + }) + }) + } + + public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { + // show loading + loadingSpinner.resumeSpinner() + } + public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { + // hide loading + loadingSpinner.pause() + } + +} + + +// MARK: - WKNavigationDelegate +extension WebView : WKNavigationDelegate { + public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + //validate request url + //all validated link should be open in safari + if (navigationAction.navigationType == .linkActivated), let urlString = navigationAction.request.url?.absoluteString.removingPercentEncoding, !urlString.contains("#") { + MVMCoreActionHandler.shared()?.openURL(inWebView: navigationAction.request.url, actionInformation: nil, additionalData: nil, delegateObject: nil) + decisionHandler(.cancel) + } else { + decisionHandler(.allow) + } + } +} + + +// MARK: - WKScriptMessageHandler +extension WebView: WKScriptMessageHandler { + public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { + if message.name == callHandlerName, let text = message.body as? String { + /* + receiving JavaScript func webkit.messageHandlers.{callHandler}.postMessage(body); + if body is dictionary string + MVMCoreActionHanlder handleAction + */ + if let data = text.data(using: .utf8) { + do { + let actionMap = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObject) + } catch { + // if post message is not dictionary string + print(error.localizedDescription) + } + } + } + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift new file mode 100644 index 00000000..bb141b57 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift @@ -0,0 +1,55 @@ +// +// WebviewModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 09/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class WebViewModel: MoleculeModelProtocol { + public static var identifier: String = "webview" + public var moleculeName: String = WebViewModel.identifier + public var backgroundColor: Color? + public var url: URL? + public var htmlString: String? + public var height: CGFloat? + public var jsScript: String? + public var callHandler: String? + public var buttonMap: [String: ButtonModel]? + + private enum CodingKeys: String, CodingKey{ + case moleculeName + case backgroundColor + case url + case htmlString + case height + case buttonMap + case jsScript + case callHandler + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + url = try typeContainer.decodeIfPresent(URL.self, forKey: .url) + htmlString = try typeContainer.decodeIfPresent(String.self, forKey: .htmlString) + height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height) + buttonMap = try typeContainer.decodeIfPresent([String: ButtonModel].self, forKey: .buttonMap) + jsScript = try typeContainer.decodeIfPresent(String.self, forKey: .jsScript) + callHandler = try typeContainer.decodeIfPresent(String.self, forKey: .callHandler) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(url, forKey: .url) + try container.encodeIfPresent(htmlString, forKey: .htmlString) + try container.encodeIfPresent(height, forKey: .height) + try container.encodeIfPresent(jsScript, forKey: .jsScript) + try container.encodeIfPresent(callHandler, forKey: .callHandler) + + } +} diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index bfa6db01..ba650ca8 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -80,6 +80,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) MoleculeObjectMapping.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: WebView.self, viewModelClass: WebViewModel.self) // Horizontal Combination Molecules MoleculeObjectMapping.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) From 16810482796bf8ec5cfff76bc6ae1ee7532d66d1 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Mon, 30 Mar 2020 12:10:27 -0400 Subject: [PATCH 106/244] remove initial scale jscript --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 46 +++++++++++----------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 64343aa7..b3016e00 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -19,6 +19,9 @@ import WebKit var dynamicHeight: Bool = true var callHandlerName: String? + var webviewModel: WebViewModel? { + return model as? WebViewModel + } override open func setupView() { super.setupView() @@ -34,14 +37,6 @@ import WebKit if let messageHandlerName = messageHandler { wkUserController.add(self, name: messageHandlerName) } - //inital-scale is necessary to update display correct scale - let source: String = "var meta = document.createElement('meta');" + - "meta.name = 'viewport';" + - //depends on how much clint driven - "meta.content = 'initial-scale=1.0';" + - "var head = document.getElementsByTagName('head')[0];" + "head.appendChild(meta);"; - let wkScript = WKUserScript(source: source, injectionTime: .atDocumentEnd, forMainFrameOnly: true) - wkUserController.addUserScript(wkScript) //server driven addition script if let jsScript = jsScript { @@ -65,12 +60,11 @@ import WebKit guard let model = model as? WebViewModel else { return } self.delegateObject = delegateObject - if model.callHandler != nil || model.jsScript != nil { + if model.callHandler != nil || model.jsScript != nil { /* webView's configuration property is immutable. In order to add call handler into webview, need to create a new webview. - callHanlder - */ +*/ webView?.removeFromSuperview() let webView = createWebView(messageHandler: model.callHandler, jsScript:model.jsScript) addSubview(webView) @@ -91,7 +85,6 @@ import WebKit webView?.loadHTMLString(htmlString, baseURL: nil) } bringSubviewToFront(loadingSpinner) - //TO DO: local path? } func pinSpinnerView() { @@ -115,20 +108,29 @@ extension WebView : WKUIDelegate { // hide loading loadingSpinner.pause() + //update webview's heigth when webview is ready if !dynamicHeight { return } - //update webview's heigth when webview is ready - webView.evaluateJavaScript("document.readyState", completionHandler: { [weak self] (result, error) in - if result == nil || error != nil { - return - } - webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { (result, error) in - guard let height = result as? CGFloat else { return } - self?.webViewHeight?.constant = height - self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!) + if let _ = webviewModel?.jsScript { +/* evaluateJavaScript only works when webview contains userscrpt. + otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred" + */ + webView.evaluateJavaScript("document.readyState", completionHandler: { [weak self] (result, error) in + if result == nil || error != nil { + return + } + webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { (result, error) in + guard let height = result as? CGFloat else { return } + self?.webViewHeight?.constant = height + self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!) + }) }) - }) + } else { + //get webview's content viewheight when no javescript setup + self.webViewHeight?.constant = webView.scrollView.contentSize.height + self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + } } public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { From ab18db4a9690f362bf518865f6475167d95fe251 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Tue, 31 Mar 2020 11:31:45 +0530 Subject: [PATCH 107/244] Merge conflicts resolved --- MVMCoreUI.xcodeproj/project.pbxproj | 16 +++--- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 + ...RightVariableTextLinkAllTextAndLinks.swift | 49 +++++++++++++++++++ ...VariableTextLinkAllTextAndLinksModel.swift | 41 ++++++++++++++++ 4 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f93bf655..f6f1ec92 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -173,14 +173,14 @@ AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; + BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */; }; + BB2C969224330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C969124330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift */; }; BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */; }; BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; - BB6C6ADC24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ADB24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift */; }; - BB6C6ADE24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ADD24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift */; }; 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 */; }; @@ -558,14 +558,14 @@ AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; + BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinksModel.swift; sourceTree = ""; }; + BB2C969124330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinks.swift; sourceTree = ""; }; BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTallModel.swift; sourceTree = ""; }; BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; - BB6C6ADB24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinksModel.swift; sourceTree = ""; }; - BB6C6ADD24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinks.swift; 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 = ""; }; @@ -992,8 +992,8 @@ AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( - BB6C6ADB24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift */, - BB6C6ADD24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift */, + BB2C969124330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift */, + BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */, AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, 8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */, @@ -2007,7 +2007,6 @@ 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, - BB6C6ADE24233090005F7224 /* ListRightVariableTextLinkAllTextAndLinks.swift in Sources */, 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, @@ -2070,6 +2069,7 @@ 526A265E240D200500B0D828 /* ListTwoColumnCompareChanges.swift in Sources */, 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, + BB2C969224330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift in Sources */, D2D90B42240463E100DD6EC9 /* MoleculeHeaderModel.swift in Sources */, 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, @@ -2078,8 +2078,8 @@ D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, - BB6C6ADC24233065005F7224 /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */, C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, + BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */, D29DF29521E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index bfa6db01..b0577203 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -99,6 +99,8 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTextLinkAllTextAndLinks.self, viewModelClass: ListRightVariableTextLinkAllTextAndLinksModel.self) + // List items MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift new file mode 100644 index 00000000..5f2bfcfc --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift @@ -0,0 +1,49 @@ +// +// ListRightVariableTextLinkAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 19/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListRightVariableTextLinkAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + public var stack: Stack + public let link = Link(frame: .zero) + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading)), + (view: link, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .top))],axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableTextLinkAllTextAndLinksModel else { return } + link.set(with: model.link, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift new file mode 100644 index 00000000..9f6392fc --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift @@ -0,0 +1,41 @@ +// +// ListRightVariableTextLinkAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 19/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListRightVariableTextLinkAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "listRVLink" + public var link: LinkModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + public init(link: LinkModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.link = link + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case link + case eyebrowHeadlineBodyLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + link = try typeContainer.decode(LinkModel.self, forKey: .link) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(link, forKey: .link) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + } +} From bffd2475dff004940835422a953712ccc8f04999 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Wed, 1 Apr 2020 12:42:41 +0530 Subject: [PATCH 108/244] Initial Commit of List - Three Column - International Data - Divider --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + ...tThreeColumnInternationalDataDivider.swift | 66 +++++++++++++++++++ ...eColumnInternationalDataDividerModel.swift | 52 +++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03335a4d..142d72ec 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -129,6 +129,8 @@ 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */; }; 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; + 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */; }; + 8D3BA9BF2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */; }; 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; 942C372E241149170066E45E /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */; }; 942C372F241149170066E45E /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */; }; @@ -513,6 +515,8 @@ 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyText.swift; sourceTree = ""; }; 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; + 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDividerModel.swift; sourceTree = ""; }; + 8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDivider.swift; sourceTree = ""; }; 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; @@ -1244,6 +1248,8 @@ children = ( 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, + 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */, + 8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -1884,6 +1890,7 @@ 8D070BB0241B56530099AC56 /* ListRightVariableTotalDataModel.swift in Sources */, 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */, + 8D3BA9BF2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift in Sources */, 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */, D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, @@ -2181,6 +2188,7 @@ 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, + 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, 011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */, 011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index bfa6db01..13c61445 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -143,6 +143,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalDataDivider.self, viewModelClass: ListThreeColumnInternationalDataDividerModel.self) // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift new file mode 100644 index 00000000..89868806 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift @@ -0,0 +1,66 @@ +// +// ListThreeColumnInternationalDataDivider.swift +// MVMCoreUI +// +// Created by Kruthika KP on 31/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnInternationalDataDivider: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + let leftLabel = Label.createLabelBoldBodySmall(true) + let centerLabel = Label.createLabelBoldBodySmall(true) + let rightLabel = Label.createLabelBoldBodySmall(true) + var stack: Stack + + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 27, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent: 40, horizontalAlignment: .center))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - MFViewProtocol + //----------------------------------------------------- + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + //----------------------------------------------------- + // MARK: - ModelMoleculeViewProtocol + //----------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnInternationalDataDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + //----------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //----------------------------------------------------- + override open func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + centerLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift new file mode 100644 index 00000000..51786004 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift @@ -0,0 +1,52 @@ +// +// ListThreeColumnInternationalDataDividerModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 31/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnInternationalDataDividerModel : ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list3CIntDataDiv" + public var leftLabel: LabelModel + public var centerLabel: LabelModel + public var rightLabel: LabelModel + + public init (leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} From a9ca55c7382f800e4ba62cb285eaf956abdfc9e4 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Wed, 1 Apr 2020 16:01:00 +0530 Subject: [PATCH 109/244] alignment changes --- .../ListThreeColumnInternationalDataDivider.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift index 89868806..42d3d39f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift @@ -19,9 +19,9 @@ import Foundation var stack: Stack public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), - (view: centerLabel, model: StackItemModel(percent: 27, horizontalAlignment: .leading)), - (view: rightLabel, model: StackItemModel(percent: 40, horizontalAlignment: .center))], + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 40, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .center))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } From 3b8fd4167c523137b8465046fceef7159a19933b Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 1 Apr 2020 19:27:18 +0530 Subject: [PATCH 110/244] initial commit --- MVMCoreUI.xcodeproj/project.pbxproj | 16 +++ .../Views/RadioBoxCollectionViewCell.swift | 87 +++++++++++++ .../Atomic/Atoms/Views/RadioBoxModel.swift | 54 ++++++++ MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 122 ++++++++++++++++++ .../Atomic/Atoms/Views/RadioBoxesModel.swift | 57 ++++++++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 + 6 files changed, 338 insertions(+) create mode 100644 MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift create mode 100644 MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift create mode 100644 MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift create mode 100644 MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03335a4d..df815789 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -173,8 +173,12 @@ AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; + BB2C969424331C46006FF80C /* RadioBoxes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C969324331C46006FF80C /* RadioBoxes.swift */; }; + BB2C969624331C74006FF80C /* RadioBoxesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C969524331C74006FF80C /* RadioBoxesModel.swift */; }; + BB2C969824331F8E006FF80C /* RadioBoxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C969724331F8E006FF80C /* RadioBoxModel.swift */; }; BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; + BB54C519243459280038326C /* RadioBoxCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB54C518243459280038326C /* RadioBoxCollectionViewCell.swift */; }; BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */; }; BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; @@ -556,8 +560,12 @@ AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; + BB2C969324331C46006FF80C /* RadioBoxes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxes.swift; sourceTree = ""; }; + BB2C969524331C74006FF80C /* RadioBoxesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxesModel.swift; sourceTree = ""; }; + BB2C969724331F8E006FF80C /* RadioBoxModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxModel.swift; sourceTree = ""; }; BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; + BB54C518243459280038326C /* RadioBoxCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxCollectionViewCell.swift; sourceTree = ""; }; BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTallModel.swift; sourceTree = ""; }; BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; @@ -1499,6 +1507,10 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( + BB2C969324331C46006FF80C /* RadioBoxes.swift */, + BB54C518243459280038326C /* RadioBoxCollectionViewCell.swift */, + BB2C969524331C74006FF80C /* RadioBoxesModel.swift */, + BB2C969724331F8E006FF80C /* RadioBoxModel.swift */, 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, 01509D922327ECFB00EF99AA /* ProgressBar.swift */, 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, @@ -2079,8 +2091,10 @@ D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, + BB2C969424331C46006FF80C /* RadioBoxes.swift in Sources */, 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, + BB2C969624331C74006FF80C /* RadioBoxesModel.swift in Sources */, 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */, @@ -2132,6 +2146,7 @@ 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */, + BB2C969824331F8E006FF80C /* RadioBoxModel.swift in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, 525239C22407BD1000454969 /* ListTwoColumnPriceDetails.swift in Sources */, @@ -2160,6 +2175,7 @@ 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */, D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, + BB54C519243459280038326C /* RadioBoxCollectionViewCell.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift new file mode 100644 index 00000000..532ff34f --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift @@ -0,0 +1,87 @@ +// +// RadioBoxCollectionViewCell.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 01/04/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtocol { + + public let bodyLabel = Label.commonLabelB2(true) + public let lineView = View(frame: .zero) + + + var bottomView = MVMCoreUICommonViewsUtility.commonView() + + public var lineViewHeight: NSLayoutConstraint? + + + open override var isSelected: Bool{ + didSet{ + lineViewHeight?.constant = isSelected ? 4.0 : 0 + bottomView.layer.borderColor = isSelected ? UIColor.mfGet(forHex: "#0000").cgColor:UIColor.mfGet(forHex: "#747676").cgColor + + } + } + public override init(frame: CGRect) { + super.init(frame: .zero) + setupView() + } + + public required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setupView() + } + + public func setupView() { + guard bottomView.superview == nil else { + return + } + isAccessibilityElement = false + contentView.isAccessibilityElement = false + insetsLayoutMarginsFromSafeArea = false + contentView.insetsLayoutMarginsFromSafeArea = false + contentView.preservesSuperviewLayoutMargins = false + + contentView.addSubview(bottomView) + NSLayoutConstraint.constraintPinSubview(toSuperview: bottomView) + + lineView.translatesAutoresizingMaskIntoConstraints = false + bottomView.addSubview(lineView) + NSLayoutConstraint.constraintPinSubview(lineView, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true) + lineViewHeight = lineView.heightAnchor.constraint(equalToConstant: 0) + lineViewHeight?.isActive = true + + + bodyLabel.translatesAutoresizingMaskIntoConstraints = false + bottomView.addSubview(bodyLabel) + NSLayoutConstraint.constraintPinSubview(bodyLabel, pinTop: false, topConstant:0 , pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 12, pinRight: true, rightConstant: 12) + bodyLabel.topAnchor.constraint(equalTo: lineView.bottomAnchor, constant: 12).isActive = true + bodyLabel.bottomAnchor.constraint(greaterThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true + + bottomView.layer.borderWidth = 1.0 + bottomView.layer.borderColor = UIColor.mfGet(forHex: "#747676").cgColor + + + + } + + + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let collectionModel = model as? RadioBoxModel else { return } + + if let backgroundColor = collectionModel.backgroundColor { + self.bottomView.backgroundColor = backgroundColor.uiColor + } +// self.bottomView.backgroundColor = .red + lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor + bodyLabel.text = collectionModel.text + + + + } + + +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift new file mode 100644 index 00000000..21adcb13 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -0,0 +1,54 @@ +// +// RadioBoxModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 31/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers public class RadioBoxModel: MoleculeModelProtocol { + public static var identifier: String = "radioBox" + public var text: String + public var backgroundColor: Color? = Color(uiColor: .white) + public var selectedAccentColor: Color? = Color(uiColor: .red) + public var selected: Bool? = false + public var fieldValue: String? + + private enum CodingKeys: String, CodingKey { + case moleculeName + case text + case selectedAccentColor + case backgroundColor + case selected + case fieldValue + + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + text = try typeContainer.decode(String.self, forKey: .text) + + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor) { + selectedAccentColor = color + } + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { + backgroundColor = color + } + if let isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .selected) { + selected = isSelected + } + fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) + + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(selectedAccentColor, forKey: .selectedAccentColor) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(selected, forKey: .selected) + try container.encodeIfPresent(fieldValue, forKey: .fieldValue) + + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift new file mode 100644 index 00000000..9cc6ae5f --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -0,0 +1,122 @@ +// +// RadioBoxes.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 31/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +open class RadioBoxes: View { + + public let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + + /// The models for the molecules. + var molecules: [MoleculeModelProtocol]? + + + /// The height of the carousel. Default is 300. + public var collectionViewHeight: NSLayoutConstraint? + + public var delegateObject: MVMCoreUIDelegateObject? + + + + // MARK: - MVMCoreViewProtocol + open override func setupView() { + super.setupView() + guard collectionView.superview == nil else { + return + } + collectionView.translatesAutoresizingMaskIntoConstraints = false + collectionView.dataSource = self + collectionView.delegate = self + collectionView.showsHorizontalScrollIndicator = false + collectionView.backgroundColor = .clear + collectionView.isAccessibilityElement = false + addSubview(collectionView) + + collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) + collectionViewHeight?.isActive = true + NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView) + + } + + + + // MARK: - MoleculeViewProtocol + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + self.delegateObject = delegateObject + super.set(with: model, delegateObject, additionalData) + guard let radioBoxesModel = model as? RadioBoxesModel else { return } + backgroundColor = .white + + registerCells() + setupLayout(with: radioBoxesModel) + prepareMolecules(with: radioBoxesModel) + collectionView.reloadData() + } + + // MARK: - JSON Setters + /// Updates the layout being used + + func setupLayout(with carouselModel: RadioBoxesModel?) { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.minimumLineSpacing = 10 + layout.minimumInteritemSpacing = 10 + collectionView.collectionViewLayout = layout + } + + func prepareMolecules(with radioBoxesModel: RadioBoxesModel?) { + guard let newMolecules = radioBoxesModel?.boxes else { + molecules = nil + return + } + molecules = newMolecules + collectionView.reloadData() + + } + + + /// Registers the cells with the collection view + func registerCells() { + + collectionView.register(RadioBoxCollectionViewCell.self, forCellWithReuseIdentifier: "RadioBoxCollectionViewCell") + } + + + // MARK: - Convenience + /// Returns the (identifier, class) of the molecule for the given map. + func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? { + guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { + return nil + } + return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) + } + + +} +extension RadioBoxes: UICollectionViewDelegateFlowLayout { + open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let itemWidth = (collectionView.bounds.width - 30)/2 + return CGSize(width: itemWidth, height: 64) + } + + +} + +extension RadioBoxes: UICollectionViewDataSource { + open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return molecules?.count ?? 0 + } + + open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let molecule = molecules?[indexPath.row], let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RadioBoxCollectionViewCell", for: indexPath) as? RadioBoxCollectionViewCell else { + return UICollectionViewCell() + } + cell.set(with: molecule, delegateObject, nil) + (cell as? MVMCoreViewProtocol)?.updateView(collectionView.bounds.width) + return cell + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift new file mode 100644 index 00000000..80425bde --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift @@ -0,0 +1,57 @@ +// +// RadioBoxesModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 31/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers public class RadioBoxesModel: MoleculeModelProtocol { + public static var identifier: String = "radioBoxes" + public var backgroundColor: Color? = Color(uiColor: .white) + public var selectedAccentColor: Color? = Color(uiColor: .red) + public var enabled: Bool? = true + public var boxes: [RadioBoxModel] + public var fieldKey: String? + public var groupName: String? + + private enum CodingKeys: String, CodingKey { + case moleculeName + case selectedAccentColor + case backgroundColor + case enabled + case boxes + case fieldKey + case groupName + + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor) { + selectedAccentColor = color + } + if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { + backgroundColor = color + } + if let isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + enabled = isEnabled + } + boxes = try typeContainer.decode([RadioBoxModel].self, forKey: .boxes) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) + + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(selectedAccentColor, forKey: .selectedAccentColor) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(enabled, forKey: .enabled) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(groupName, forKey: .groupName) + + } +} diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index bfa6db01..f0ea8a63 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -67,6 +67,8 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) // Other Atoms + MoleculeObjectMapping.shared()?.register(viewClass: RadioBoxes.self, viewModelClass: RadioBoxesModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ProgressBar.self, viewModelClass: ProgressBarModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MultiProgress.self, viewModelClass: MultiProgressBarModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CaretView.self, viewModelClass: CaretViewModel.self) From dccf576f7adf8b818b6de025532a442876f83207 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 10:05:32 -0400 Subject: [PATCH 111/244] Minor fixs --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++++++ .../FourColumn/ListFourColumnDataUsageListItem.swift | 5 ++--- .../ListFourColumnDataUsageListItemModel.swift | 9 +-------- MVMCoreUI/Categories/UIStackView+Extension.swift | 6 ++++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ddf36e4b..227d5f92 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1016,6 +1016,13 @@ path = Extensions; sourceTree = ""; }; + D20492F12434CB5F00A5EED6 /* FourColumn */ = { + isa = PBXGroup; + children = ( + ); + path = FourColumn; + sourceTree = ""; + }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -1213,6 +1220,7 @@ D22B38EA23F4E08B00490EF6 /* List */ = { isa = PBXGroup; children = ( + D20492F12434CB5F00A5EED6 /* FourColumn */, D22D8396241FDE4700D3DF69 /* TwoColumn */, 52267A0523FFE0A900906CBA /* OneColumn */, AA4FC2A323F4F69600E251DB /* RightVariable */, diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift index 5eb0664d..8c499cac 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift @@ -29,7 +29,7 @@ import Foundation (view: label2, model: StackItemModel(percent: 40, horizontalAlignment: .leading)), (view: label3, model: StackItemModel(percent:17,horizontalAlignment: .leading)), (view: label4, model: StackItemModel(percent:20,horizontalAlignment: .leading))], - axis: .horizontal,spacing: 2) + axis: .horizontal,spacing: 8) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -44,6 +44,7 @@ import Foundation super.setupView() addMolecule(stack) arrow.pinHeightAndWidth() + stack.restack() } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { @@ -54,7 +55,6 @@ import Foundation label3.set(with: model.label3, delegateObject, additionalData) label4.set(with: model.label4, delegateObject, additionalData) arrow.set(with: model.arrow, delegateObject, additionalData) - stack.restack() } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -67,6 +67,5 @@ import Foundation label2.styleB2(true) label3.styleB2(true) label4.styleB2(true) - arrow.reset() } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift index dd9e8fa6..bf82bb5f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift @@ -9,13 +9,12 @@ import Foundation public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "list4C" public var label1: LabelModel + public var arrow: ArrowModel public var label2: LabelModel public var label3: LabelModel public var label4: LabelModel - public var arrow: ArrowModel public init(label1:LabelModel, label2:LabelModel, label3:LabelModel,label4:LabelModel, arrow:ArrowModel) { self.label1 = label1 @@ -26,12 +25,6 @@ public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelP super.init() } - public override func setDefaults() { - super.setDefaults() - style = "header" - arrow.degrees = 50 - } - private enum CodingKeys: String, CodingKey { case moleculeName case label1 diff --git a/MVMCoreUI/Categories/UIStackView+Extension.swift b/MVMCoreUI/Categories/UIStackView+Extension.swift index a793635a..b88dfb51 100644 --- a/MVMCoreUI/Categories/UIStackView+Extension.swift +++ b/MVMCoreUI/Categories/UIStackView+Extension.swift @@ -8,13 +8,15 @@ import Foundation -extension UIStackView: MoleculeViewProtocol { +extension UIStackView: MVMCoreViewProtocol { public func updateView(_ size: CGFloat) { for view in arrangedSubviews { (view as? MVMCoreViewProtocol)?.updateView(size) } } - +} + +extension UIStackView: MoleculeViewProtocol { public func reset() { for view in arrangedSubviews { (view as? MoleculeViewProtocol)?.reset() From df16745911b60a19f57f391099b5acac2c70b48f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 10:20:55 -0400 Subject: [PATCH 112/244] use another stack --- .../FourColumn/ListFourColumnDataUsageListItem.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift index 8c499cac..2377a1f2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift @@ -19,14 +19,19 @@ import Foundation let label3 = Label.commonLabelB2(true) let label4 = Label.commonLabelB2(true) let arrow = Arrow(frame: .zero) + let arrowAndLabel2Stack: Stack //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + arrowAndLabel2Stack = Stack.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)), + (view: label2, model: StackItemModel(horizontalAlignment: .leading))], + axis: .horizontal, spacing: 4) + label2.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + label2.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) stack = Stack.createStack(with: [(view: label1, model: StackItemModel(percent: 19, horizontalAlignment: .leading)), - (view: arrow, model: StackItemModel(percent: 4, horizontalAlignment: .leading)), - (view: label2, model: StackItemModel(percent: 40, horizontalAlignment: .leading)), + (view: arrowAndLabel2Stack, model: StackItemModel(percent: 44, horizontalAlignment: .fill)), (view: label3, model: StackItemModel(percent:17,horizontalAlignment: .leading)), (view: label4, model: StackItemModel(percent:20,horizontalAlignment: .leading))], axis: .horizontal,spacing: 8) @@ -44,6 +49,7 @@ import Foundation super.setupView() addMolecule(stack) arrow.pinHeightAndWidth() + arrowAndLabel2Stack.restack() stack.restack() } From a3f81511b6cfde863407b9b8d15f9dbfb71866f2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 10:21:42 -0400 Subject: [PATCH 113/244] move files --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- .../FourColumn/ListFourColumnDataUsageListItem.swift | 0 .../FourColumn/ListFourColumnDataUsageListItemModel.swift | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename MVMCoreUI/Atomic/Molecules/DesignedComponents/{SectionDividers => List}/FourColumn/ListFourColumnDataUsageListItem.swift (100%) rename MVMCoreUI/Atomic/Molecules/DesignedComponents/{SectionDividers => List}/FourColumn/ListFourColumnDataUsageListItemModel.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 227d5f92..18c6317e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -923,8 +923,6 @@ children = ( 525019E42406852100EED91C /* ListFourColumnDataUsageDividerModel.swift */, 525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */, - 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */, - 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */, ); path = FourColumn; sourceTree = ""; @@ -1019,6 +1017,8 @@ D20492F12434CB5F00A5EED6 /* FourColumn */ = { isa = PBXGroup; children = ( + 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */, + 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */, ); path = FourColumn; sourceTree = ""; diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/FourColumn/ListFourColumnDataUsageListItem.swift similarity index 100% rename from MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItem.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/FourColumn/ListFourColumnDataUsageListItem.swift diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/FourColumn/ListFourColumnDataUsageListItemModel.swift similarity index 100% rename from MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageListItemModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/FourColumn/ListFourColumnDataUsageListItemModel.swift From bcf09b6fb86f21f471d58e5e51dcc502f19bf3ef Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 10:42:12 -0400 Subject: [PATCH 114/244] move files --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + ...RightVariableTextLinkAllTextAndLinks.swift | 50 +++++++++++++++++++ ...VariableTextLinkAllTextAndLinksModel.swift | 41 +++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 02829367..dca0bef7 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -131,6 +131,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTextLinkAllTextAndLinks.self, viewModelClass: ListRightVariableTextLinkAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift new file mode 100644 index 00000000..88d9448b --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift @@ -0,0 +1,50 @@ +// +// ListRightVariableTextLinkAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 19/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListRightVariableTextLinkAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + public var stack: Stack + public let link = Link(frame: .zero) + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), + (view: link, model: StackItemModel(horizontalAlignment:.fill, verticalAlignment: .top))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableTextLinkAllTextAndLinksModel else { return } + link.set(with: model.link, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift new file mode 100644 index 00000000..9f6392fc --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift @@ -0,0 +1,41 @@ +// +// ListRightVariableTextLinkAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 19/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListRightVariableTextLinkAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "listRVLink" + public var link: LinkModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + public init(link: LinkModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.link = link + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case link + case eyebrowHeadlineBodyLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + link = try typeContainer.decode(LinkModel.self, forKey: .link) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(link, forKey: .link) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + } +} From 779c33108215f94f014c28210ac9a49bbcd458d6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 10:46:19 -0400 Subject: [PATCH 115/244] move files --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 - ...RightVariableTextLinkAllTextAndLinks.swift | 49 ------------------- ...VariableTextLinkAllTextAndLinksModel.swift | 41 ---------------- 3 files changed, 92 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 02660f1a..dca0bef7 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -99,8 +99,6 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTextLinkAllTextAndLinks.self, viewModelClass: ListRightVariableTextLinkAllTextAndLinksModel.self) - // List items MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift deleted file mode 100644 index 5f2bfcfc..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift +++ /dev/null @@ -1,49 +0,0 @@ -// -// ListRightVariableTextLinkAllTextAndLinks.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 19/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -@objcMembers open class ListRightVariableTextLinkAllTextAndLinks: TableViewCell { - - //----------------------------------------------------- - // MARK: - Outlets - //----------------------------------------------------- - public var stack: Stack - public let link = Link(frame: .zero) - public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) - - // MARK: - Initializers - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading)), - (view: link, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .top))],axis: .horizontal) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - //----------------------------------------------------- - // MARK: - View Lifecycle - //----------------------------------------------------- - override open func setupView() { - super.setupView() - addMolecule(stack) - stack.restack() - } - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListRightVariableTextLinkAllTextAndLinksModel else { return } - link.set(with: model.link, delegateObject, additionalData) - eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 90 - } -} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift deleted file mode 100644 index 9f6392fc..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// ListRightVariableTextLinkAllTextAndLinksModel.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 19/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -public class ListRightVariableTextLinkAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "listRVLink" - public var link: LinkModel - public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel - - public init(link: LinkModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { - self.link = link - self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink - super.init() - } - - private enum CodingKeys: String, CodingKey { - case moleculeName - case link - case eyebrowHeadlineBodyLink - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - link = try typeContainer.decode(LinkModel.self, forKey: .link) - eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(link, forKey: .link) - try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) - } -} From b0ab074675e1f515b8c87478f17dc1cd9cfe2192 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 10:46:54 -0400 Subject: [PATCH 116/244] move files --- 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 9df66969..7ae72de5 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -996,8 +996,8 @@ AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( - BB2C969124330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift */, BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */, + BB2C969124330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift */, AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, 8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */, From aaec6da3275b2accb419e8a5668ad10c064ec126 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 1 Apr 2020 20:17:17 +0530 Subject: [PATCH 117/244] Button changes committed --- MVMCoreUI.xcodeproj/project.pbxproj | 17 ++++--- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 + ...stRightVariableButtonAllTextAndLinks.swift | 51 +++++++++++++++++++ ...htVariableButtonAllTextAndLinksModel.swift | 49 ++++++++++++++++++ 4 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index e20f5b3e..aa3712fa 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */; }; 011D958524042432000E3791 /* RulesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D958424042432000E3791 /* RulesProtocol.swift */; }; 011D958724042492000E3791 /* FormFieldProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D958624042492000E3791 /* FormFieldProtocol.swift */; }; - 011D95892404249B000E3791 /* FormProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95882404249B000E3791 /* FormProtocol.swift */; }; + 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95882404249B000E3791 /* FormHolderModelProtocol.swift */; }; 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959A240451E3000E3791 /* RuleRequiredModel.swift */; }; 011D959D2404536F000E3791 /* RuleAnyValueChangedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959C2404536F000E3791 /* RuleAnyValueChangedModel.swift */; }; 011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959E240453A1000E3791 /* RuleAllValueChangedModel.swift */; }; @@ -175,12 +175,12 @@ AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */; }; BB47A588241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */; }; + BB54C5202434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB54C51E2434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift */; }; + BB54C5212434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB54C51F2434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift */; }; BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */; }; BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; - BB6C6AE1242492F2005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ADF242492C0005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */; }; - BB6C6AE2242492F2005F7224 /* ListRightVariableButtonAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AE0242492F1005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */; }; 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 */; }; @@ -560,12 +560,12 @@ AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; BB47A585241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsectionModel.swift; sourceTree = ""; }; BB47A587241615FA002BB23C /* ListOneColumnFullWidthTextDividerSubsection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextDividerSubsection.swift; sourceTree = ""; }; + BB54C51E2434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinks.swift; sourceTree = ""; }; + BB54C51F2434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinksModel.swift; sourceTree = ""; }; BB6C6ABE242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTallModel.swift; sourceTree = ""; }; BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; - BB6C6ADF242492C0005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinksModel.swift; sourceTree = ""; }; - BB6C6AE0242492F1005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableButtonAllTextAndLinks.swift; 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 = ""; }; @@ -992,8 +992,8 @@ AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( - BB6C6ADF242492C0005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift */, - BB6C6AE0242492F1005F7224 /* ListRightVariableButtonAllTextAndLinks.swift */, + BB54C51E2434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift */, + BB54C51F2434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift */, AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, 8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */, @@ -1977,7 +1977,6 @@ 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, - BB6C6AE1242492F2005F7224 /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, @@ -2033,6 +2032,7 @@ D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D260105D23D0BCD400764D80 /* Stack.swift in Sources */, 0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */, + BB54C5212434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */, @@ -2139,6 +2139,7 @@ 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */, + BB54C5202434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, 525239C22407BD1000454969 /* ListTwoColumnPriceDetails.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index bfa6db01..3bf7c839 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -143,6 +143,8 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableButtonAllTextAndLinksModel.self) + // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift new file mode 100644 index 00000000..c5f66b9a --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -0,0 +1,51 @@ +// +// ListRightVariableButtonAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 17/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListRightVariableButtonAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + public var stack: Stack + public let button = PillButton(frame: .zero) + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 0, horizontalAlignment: .leading)), + (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .center))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableButtonAllTextAndLinksModel else { return } + button.set(with: model.button, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } +} + diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift new file mode 100644 index 00000000..466456b4 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -0,0 +1,49 @@ +// +// ListRightVariableButtonAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 17/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ + public static var identifier: String = "listRVBtn" + public var button: ButtonModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + public init(button: ButtonModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.button = button + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + self.button.size = .tiny + self.button.style = ButtonStyle.secondary + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case button + case eyebrowHeadlineBodyLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + button = try typeContainer.decode(ButtonModel.self, forKey: .button) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(button, forKey: .button) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + } +} + From d961e4d5dc27f471f71743e1baba6d4288081b2c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 11:52:01 -0400 Subject: [PATCH 118/244] more additions for radio label --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ .../Atomic/Atoms/Buttons/RadioButton.swift | 2 +- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 3 +- .../ListLeftVariableRadioButtonBodyText.swift | 67 +++++++++++++++++++ ...LeftVariableRadioButtonBodyTextModel.swift | 59 ++++++++++++++++ .../HeadlineBodyModel.swift | 25 +++++-- 6 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03335a4d..9c3efc00 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -87,6 +87,8 @@ 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; + 0A6682A22434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */; }; + 0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */; }; 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; }; 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; @@ -468,6 +470,8 @@ 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; + 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyText.swift; sourceTree = ""; }; + 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyTextModel.swift; sourceTree = ""; }; 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = ""; }; 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -1224,6 +1228,8 @@ 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */, 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, + 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */, + 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */, ); path = LeftVariable; sourceTree = ""; @@ -1904,6 +1910,7 @@ D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, + 0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D2E2A99423D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, @@ -2177,6 +2184,7 @@ 525019DD2406430800EED91C /* ListProgressBarDataModel.swift in Sources */, C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */, 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */, + 0A6682A22434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift index 4158cb3f..588cefcb 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift @@ -28,7 +28,7 @@ import UIKit } lazy public var radioGroupName: String? = { - [unowned self] in return radioModel?.fieldKey + return radioModel?.fieldKey }() lazy public var radioButtonSelectionHelper: RadioButtonSelectionHelper? = { diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index bfa6db01..760e6eb1 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -136,13 +136,14 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift new file mode 100644 index 00000000..9b45eec7 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift @@ -0,0 +1,67 @@ +// +// ListLeftVariableRadioButtonBodyText.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/1/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + + +open class ListLeftVariableRadioButtonBodyText: TableViewCell { + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + + let radioButton = RadioButton(frame: .zero) + let headlineBody = HeadlineBody() + var stack: Stack + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)), + (view: headlineBody, model: StackItemModel(horizontalAlignment: .leading))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + + override open func setupView() { + super.setupView() + + addMolecule(stack) + stack.restack() + } + + //---------------------------------------------------- + // MARK: - Molecule + //---------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + + guard let model = model as? ListLeftVariableRadioButtonBodyTextModel else { return } + + radioButton.set(with: model.radioButton, delegateObject, additionalData) + headlineBody.set(with: model.headlineBody, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + radioButton.tapAction() + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift new file mode 100644 index 00000000..359beafd --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift @@ -0,0 +1,59 @@ +// +// ListLeftVariableRadioButtonBodyTextModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/1/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +open class ListLeftVariableRadioButtonBodyTextModel: ListItemModel, MoleculeModelProtocol { + //----------------------------------------------------- + // MARK: - Properties + //----------------------------------------------------- + + public static var identifier: String = "listLVRBBdy" + public var radioButton: RadioButtonModel + public var headlineBody: HeadlineBodyModel + + //----------------------------------------------------- + // MARK: - Initializer + //----------------------------------------------------- + + public init(radioButton: RadioButtonModel, headlineBody: HeadlineBodyModel) { + self.radioButton = radioButton + self.headlineBody = headlineBody + super.init() + } + + //----------------------------------------------------- + // MARK: - Keys + //----------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case radioButton + case headlineBody + } + + //----------------------------------------------------- + // MARK: - Codec + //----------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + radioButton = try typeContainer.decode(RadioButtonModel.self, forKey: .radioButton) + headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(radioButton, forKey: .radioButton) + try container.encode(headlineBody, forKey: .headlineBody) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 94c96c2b..ebc5614e 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -8,7 +8,23 @@ import Foundation + @objcMembers open class HeadlineBodyModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "headlineBody" + public var moleculeName: String = HeadlineBodyModel.identifier + public var headline: LabelModel? + public var body: LabelModel? + public var style: Style? + public var backgroundColor: Color? + + //-------------------------------------------------- + // MARK: - Enum + //-------------------------------------------------- + /// Convenience styles for common situations. public enum Style: String, Codable { case landingHeader @@ -17,12 +33,9 @@ import Foundation case item } - public static var identifier: String = "headlineBody" - public var moleculeName: String = HeadlineBodyModel.identifier - public var headline: LabelModel? - public var body: LabelModel? - public var style: Style? - public var backgroundColor: Color? + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- public init(headline: LabelModel) { self.headline = headline From 7d2d1366796367544d5d8d06f1c858e2458f3bb2 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 12:08:59 -0400 Subject: [PATCH 119/244] more --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 760e6eb1..32736c2e 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -136,8 +136,8 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) + // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) From b97c35fe91e6f9f639a6ba31fdfd03267bc5b98c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 12:11:02 -0400 Subject: [PATCH 120/244] more --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 32736c2e..61beb08a 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -143,7 +143,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) From bfe706908f23c960104735a0829632e6fb4527f4 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 12:59:54 -0400 Subject: [PATCH 121/244] update web view with default call handler --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 47 ++++++++-------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index b3016e00..c5cc0cf9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -10,7 +10,9 @@ import UIKit import WebKit @objcMembers open class WebView: View, MVMCoreUIViewConstrainingProtocol { - + + let mvmWebViewMessageHandler = "mvmWebViewMessageHandler" + public let loadingSpinner = MFLoadingSpinner(frame: .zero) var delegateObject: MVMCoreUIDelegateObject? @@ -25,7 +27,7 @@ import WebKit override open func setupView() { super.setupView() - let webView = createWebView(messageHandler: nil, jsScript: nil) + let webView = createWebView(messageHandler: mvmWebViewMessageHandler, jsScript: nil) addSubview(webView) NSLayoutConstraint.constraintPinSubview(toSuperview: webView) self.webView = webView @@ -112,24 +114,16 @@ extension WebView : WKUIDelegate { if !dynamicHeight { return } - if let _ = webviewModel?.jsScript { -/* evaluateJavaScript only works when webview contains userscrpt. - otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred" - */ - webView.evaluateJavaScript("document.readyState", completionHandler: { [weak self] (result, error) in - if result == nil || error != nil { - return - } - webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { (result, error) in - guard let height = result as? CGFloat else { return } - self?.webViewHeight?.constant = height - self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!) - }) + + /* was using "document.readyState" to check the state, while evaluateJavaScript "document.readyState",only works when webview contains userscrpt.otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred". + so webView.isLoading to check load finished state + */ + if !webView.isLoading { + webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in + guard let self = self, let height = result as? CGFloat else { return } + self.webViewHeight?.constant = height + self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) }) - } else { - //get webview's content viewheight when no javescript setup - self.webViewHeight?.constant = webView.scrollView.contentSize.height - self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) } } @@ -163,21 +157,14 @@ extension WebView : WKNavigationDelegate { // MARK: - WKScriptMessageHandler extension WebView: WKScriptMessageHandler { public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { - if message.name == callHandlerName, let text = message.body as? String { + if message.name == mvmWebViewMessageHandler, let actionMap = message.body as? [AnyHashable: Any] { /* receiving JavaScript func webkit.messageHandlers.{callHandler}.postMessage(body); - if body is dictionary string + if body is dictionary MVMCoreActionHanlder handleAction */ - if let data = text.data(using: .utf8) { - do { - let actionMap = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObject) - } catch { - // if post message is not dictionary string - print(error.localizedDescription) - } - } + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObject) + } } } From 29465f82815c76c51d5704e538e80cecd7d7517a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 14:18:51 -0400 Subject: [PATCH 122/244] refresh styler --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Styles/Styler.swift | 1207 +++++++++++++++++++++++++++ 2 files changed, 1211 insertions(+) create mode 100644 MVMCoreUI/Styles/Styler.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 7ae72de5..3f13e17b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -87,6 +87,7 @@ 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; + 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A92435125F00AD3CA1 /* Styler.swift */; }; 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; }; 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; @@ -472,6 +473,7 @@ 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; + 0A6682A92435125F00AD3CA1 /* Styler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styler.swift; sourceTree = ""; }; 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = ""; }; 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -1466,6 +1468,7 @@ children = ( D29DF13821E68636003B2FB9 /* MFStyler.h */, D29DF13921E68637003B2FB9 /* MFStyler.m */, + 0A6682A92435125F00AD3CA1 /* Styler.swift */, ); path = Styles; sourceTree = ""; @@ -2210,6 +2213,7 @@ 011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, D260106523D0CEA700764D80 /* StackModel.swift in Sources */, + 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift new file mode 100644 index 00000000..f5b90149 --- /dev/null +++ b/MVMCoreUI/Styles/Styler.swift @@ -0,0 +1,1207 @@ +// +// Styler.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/1/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +public protocol VogueProtocol { + +} + +public protocol VogueViewProtocol { + +} + +public protocol VogueTextProtocol: VogueProtocol { + func styleFont(_ font: UIFont) + func styleTextColor(_ textColor: UIColor) +} + + +struct Padding { + + static let One: CGFloat = 6 + static let Two: CGFloat = 12 + static let Three: CGFloat = 18 + static let Four: CGFloat = 24 + static let Five: CGFloat = 30 + static let Six: CGFloat = 36 + static let Seven: CGFloat = 42 + static let Eight: CGFloat = 48 + static let Nine: CGFloat = 54 + static let Ten: CGFloat = 60 + + static let TableCellParagraphSpace: CGFloat = 3 + static let FooterLabelParagraphSpace: CGFloat = 4 + static let WebViewInset: CGFloat = 8 + static let HeightTableSeperatorHeight: CGFloat = 1 + static let MFHeightForSwitch: CGFloat = 22 + static let MFWidthForSwitch: CGFloat = 42 + static let DisableOppacity: CGFloat = 0.5 + static let PaymentMethodViewHeightWidthMultiplier: CGFloat = 0.55 + static let MinCellHeight: CGFloat = 96 + static let HeightIphone5: CGFloat = 568 + static let DefaultOptionCellHeight: CGFloat = 120 + static let PromoViewHeight: CGFloat = 41.9 + static let BetweenFields: CGFloat = 24 + static let LabelWithInternalButtonLineSpace: CGFloat = 2 + static let PrimaryButtonTop: CGFloat = 36 + + struct Default { + static let Standard: CGFloat = 24 + static let HorizontalSpacing: CGFloat = 32 + static let VerticalSpacing: CGFloat = 32 + static let VerticalSpacing3: CGFloat = 24 + } + + struct Horizontal { + static let HeadlineWhiteView: CGFloat = 60 + static let Large: CGFloat = 72 + static let BetweenRelatedItems: CGFloat = 16 + } + + struct Vertical { + static let WhiteGrayView: CGFloat = 72 + static let HeadlineAlternate: CGFloat = 48 + } +} + + +public class Styler { + + enum MFViewBorder: Int { + case top + case left + case bottom + case right + } + + enum MFTimeFormatUnit: Int { + case mfTimeFormatColon = 0 //!{days} : {hour} : {minutes} : {seconds} + case mfTimeFormatNormal = 1 // will end with days hours minutes seconds, when left days less than 2, it will change to 'day' + } + + //-------------------------------------------------- + // MARK: - Enum + //-------------------------------------------------- + + public enum Style: String { + case H1 + case H2 + case H3 + case H32 + case B1 + case B2 + case B3 + case B20 + + func font(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 0 + + switch self { + case .H1: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 40 + return MFFonts.mfFont75Bd(size) + + case .H2: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 25 + return MFFonts.mfFont75Bd(size) + + case .H3: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 18 + return MFFonts.mfFont75Bd(size) + + case .H32: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 32 + return MFFonts.mfFont75Bd(size) + + case .B1: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 13 + return MFFonts.mfFont75Bd(size) + + case .B2: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 13 + return MFFonts.mfFont55Rg(size) + + case .B3: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 11 + return MFFonts.mfFont55Rg(size) + + case .B20: + size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 20 + return MFFonts.mfFont55Rg(size) + } + } + } + + public enum Tier { + case primary + case secondary + case ternary + case quaternary + } + + //-------------------------------------------------- + // MARK: - Functions + //-------------------------------------------------- + + class func splitTextFieldWidth() -> CGFloat { + return splitTextFieldWidth(forViewWidth: MVMCoreUISplitViewController.getDetailViewWidth()) + } + + class func splitTextFieldWidth(forViewWidth width: CGFloat) -> CGFloat { + return (width - CGFloat(PaddingOne)) / 2 - defaultHorizontalPaddingForApplicationWidth() + } + + class func sizeObjectGeneric(forCurrentDevice size: CGFloat) -> MFSizeObject? { + + let sizeObject = MFSizeObject(standardSize: size, standardiPadPortraitSize: size * 1.3) + sizeObject?.addLargerThanCustomSize(size * 1.4, forThreshold: MFSizeStandardiPadLandscapeThreshold) + sizeObject?.addLargerThanCustomSize(size * 1.5, forThreshold: MFSizeiPadProLandscapeThreshold) + return sizeObject + } + + class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat { + return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? 0 + } + + //-------------------------------------------------- + // MARK: - Spacing + //-------------------------------------------------- + + class func defaultHorizontalPaddingForApplicationWidth() -> CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 + } + + class func defaultVerticalPaddingForApplicationWidth() -> CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 + } + + class func defaultHorizontalPadding(forSize size: CGFloat) -> CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBased(onSize: size) ?? 0 + } + + class func defaultVerticalPadding(forSize size: CGFloat) -> CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBased(onSize: size) ?? 0 + } + + class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat) { + setDefaultMarginsFor(view, size: size, horizontal: true, vertical: false) + } + + class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool, vertical: Bool) { + + let horizontalPadding: CGFloat = horizontal ? defaultHorizontalPadding(forSize: size) : 0 + let verticalPadding: CGFloat = vertical ? PaddingDefaultVerticalSpacing3 : 0 + + DispatchQueue.main.async { + MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: verticalPadding, trailing: horizontalPadding, bottom: verticalPadding) + } + } + + class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) { + + let horizontalPadding: CGFloat = horizontal ? defaultHorizontalPadding(forSize: size) : 0 + + DispatchQueue.main.async { + MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: top, trailing: horizontalPadding, bottom: bottom) + } + } + + //-------------------------------------------------- + // MARK: - Fonts + //-------------------------------------------------- + + class func fontH1(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 40 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontH2(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 25 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontH3(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 18 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontH32(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 32 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontB1(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 13 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontB2(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 13 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func fontB3(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 11 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func fontB20(_ genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 20 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + //-------------------------------------------------- + // MARK: - Styles + //-------------------------------------------------- + + class func styleLabel(_ label: VogueTextProtocol, withStyle style: Style, genericScaling: Bool) { + + switch style { + case .H1: + styleLabelH1(label, genericScaling: genericScaling) + + case .H2: + styleLabelH2(label, genericScaling: genericScaling) + + case .H3: + styleLabelH3(label, genericScaling: genericScaling) + + case .H32: + styleLabelH32(label, genericScaling: genericScaling) + + case .B1: + styleLabelB1(label, genericScaling: genericScaling) + + case .B2: + styleLabelB2(label, genericScaling: genericScaling) + + case .B3: + styleLabelB3(label, genericScaling: genericScaling) + + case .B20: + styleLabelB20(label, genericScaling: genericScaling) + } + } + + class func styleLabel(_ label: UILabel, withStyle style: Style) { + styleLabel(label, withStyle: style, genericScaling: true) + } + + class func styleLabelH1(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.black) + + if let h1 = fontH1(genericScaling) { + label.styleFont(h1) + } + } + + class func styleLabelH2(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.black) + + if let h2 = fontH2(genericScaling) { + label.styleFont(h2) + } + } + + class func styleLabelH3(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.black) + + if let h3 = fontH3(genericScaling) { + label.styleFont(h3) + } + } + + class func styleLabelH32(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.black) + + if let h32 = fontH32(genericScaling) { + label.styleFont(h32) + } + } + + class func styleLabelB1(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.black) + + if let b1 = fontB1(genericScaling) { + label.styleFont(b1) + } + } + + class func styleLabelB2(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.black) + + if let b2 = fontB2(genericScaling) { + label.styleFont(b2) + } + } + + class func styleLabelB2(_ label: UILabel, size: CGFloat, genericScaling: Bool = true) { + label.font = fontForBody(withSize: size, genericScaling: genericScaling) + } + + class func styleLabelB3(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.mfBackgroundGray()) + + if let b3 = fontB3(genericScaling) { + label.styleFont(b3) + } + } + + class func styleLabelB20(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.black) + + if let b20 = fontB20(genericScaling) { + label.styleFont(b20) + } + } + + class func styleLabelTextStyle2(_ label: VogueTextProtocol, genericScaling: Bool = true) { + + label.styleTextColor(.mfBattleshipGrey()) + + if let b2 = fontB2(genericScaling) { + label.styleFont(b2) + } + } + + class func fontForBody(withSize size: CGFloat, genericScaling: Bool) -> UIFont? { + + var size = size + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func fontForBody(withSize size: CGFloat, forWidth width: CGFloat) -> UIFont? { + + let size = sizeObjectGeneric(forCurrentDevice: size)?.getValueBased(onSize: width) ?? size + + return MFFonts.mfFont55Rg(size) + } + + //-------------------------------------------------- + // MARK: - 1.0 Fonts + //-------------------------------------------------- + + class func font(forPlan genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 100 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func font(forBiggerHeadLine genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 48 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func font(forHeadlineSmall genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 15 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func font(forHeadlineSmall2 genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 16 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontForHeadlineSmall2(forWidth size: CGFloat) -> UIFont? { + + var pointSize: CGFloat = 16 + pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) + + return MFFonts.mfFont75Bd(pointSize) + } + + class func fontB1(forWidth size: CGFloat) -> UIFont? { + + var pointSize: CGFloat = 13 + pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) + + return MFFonts.mfFont75Bd(pointSize) + } + + //-------------------------------------------------- + // MARK: - 1.0 Styles + //-------------------------------------------------- + + class func styleFeedCardTitleLabel(_ label: UILabel) { + + label.font = Styler.fontForFeedCardTitle() + label.textColor = .black + } + + class func styleFeedCardTagLabel(_ label: UILabel) { + + label.font = Styler.fontB3() + label.textColor = .mfBrownishGrey() + } + + class func styleStandardSeparatorView(_ view: UIView) { + + view.backgroundColor = .mfBackgroundGray() + } + + class func styleLabelHeadlineSmall(_ label: UILabel, genericScaling: Bool) { + + label.font = Styler.font(forHeadlineSmall: genericScaling) + label.textColor = .black + } + + class func styleFeedCardTitleLabel(_ label: UILabel, genericScaling: Bool) { + + label.font = Styler.font(forFeedCardTitle: genericScaling) + label.textColor = UIColor.black + } + + class func styleFeedCardTagLabel(_ label: UILabel, genericScaling: Bool) { + + label.font = Styler.fontB3(genericScaling) + label.textColor = UIColor.mfBrownishGrey() + } + + class func fontB2(forWidth size: CGFloat) -> UIFont? { + + var pointSize: CGFloat = 13 + + pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) + + return MFFonts.mfFont55Rg(pointSize) + } + + class func fontforChatText(_ genericScaling: Bool = false) -> UIFont? { + + var size: CGFloat = 14 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func font(forAccountLandingGreeting genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 16 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func font(forProgressBarBottomLabel genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 10 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func font(forFeedCardTitle genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 16 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func font(forPrimaryButton genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 14 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontForPrimaryButton(forWidth size: CGFloat) -> UIFont? { + + var pointSize: CGFloat = 14 + pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) + return MFFonts.mfFont75Bd(pointSize) + } + + class func font(forSmallButton genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 11 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontForSmallButton(forWidth size: CGFloat) -> UIFont? { + + var pointSize: CGFloat = 11 + pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) + + return MFFonts.mfFont75Bd(pointSize) + } + + class func font(forTextField genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 16 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func font(forTextFieldUnderLabel genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 12 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func fontForUnreadMessage(onSupport genericScaling: Bool = false) -> UIFont? { + + var size: CGFloat = 10 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func font5GMessage(_ genericScaling: Bool) -> UIFont? { + + var size: CGFloat = 16 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func font5GMessage() -> UIFont? { + return font5GMessage(true) + } + + class func font(forHeadlineAlternative genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 24 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func fontForHeadlineAlternative(forWidth size: CGFloat) -> UIFont? { + + var pointSize: CGFloat = 24 + pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) + + return MFFonts.mfFont55Rg(pointSize) + } + + class func fontH255(_ genericScaling: Bool) -> UIFont? { + + var size: CGFloat = 25 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func font(forLargeLoyaltyHeaderTitle genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 60 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func font(forLoyaltyTitleSmall genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 42 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func font(forLoyaltyMessage genericScaling: Bool = true) -> UIFont? { + + var size: CGFloat = 20 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont55Rg(size) + } + + class func font(forPtPCard genericScaling: Bool) -> UIFont? { + + var size: CGFloat = 22 + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontForLabelWithTopLeftCircle(withSize size: CGFloat, genericScaling: Bool) -> UIFont? { + + var size = size + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFont75Bd(size) + } + + class func fontOcratxtWitSize(_ size: CGFloat, genericScaling: Bool) -> UIFont? { + + var size = size + + if genericScaling { + size = sizeFontGeneric(forCurrentDevice: size) + } + + return MFFonts.mfFontOcratxt(size) + } + + class func boldFont(forScaledSize size: CGFloat) -> UIFont { + return MFFonts.mfFont75Bd(sizeFontGeneric(forCurrentDevice: size))! + } + + class func regularFont(forScaledSize size: CGFloat) -> UIFont { + return MFFonts.mfFont55Rg(sizeFontGeneric(forCurrentDevice: size))! + } + + //-------------------------------------------------- + // MARK: - 1.0 Attributed Strings Style + //-------------------------------------------------- + + class func styleGetAttributedString(_ string: String?, withStyle style: String?) -> NSAttributedString { + return styleGetAttributedString(string, withStyle: Styler.Style(rawValue: style!)!, genericScaling: true) + } + + class func styleGetAttributedString(_ string: String?, withStyle style: Style, genericScaling: Bool) -> NSAttributedString { + + switch style { + case .H1: + return styleGetH1AttributedString(string, genericScaling: genericScaling) + + case .H2: + return styleGetH2AttributedString(string, genericScaling: genericScaling) + + case .H3: + return styleGetH3AttributedString(string, genericScaling: genericScaling) + + case .H32: + return styleGetH32AttributedString(string, genericScaling: genericScaling) + + case .B1: + return styleGetB1AttributedString(string, genericScaling: genericScaling) + + case .B2: + return styleGetB2AttributedString(string, genericScaling: genericScaling) + + case .B3: + return styleGetB3AttributedString(string, genericScaling: genericScaling) + + case .B20: + return styleGetB20AttributedString(string, genericScaling: genericScaling) + } + } + + class func styleGetAttributedString(_ string: String?, font: UIFont, color: UIColor) -> NSAttributedString { + + var attributedString: NSAttributedString? = nil + + if let string = string, !string.isEmpty { + attributedString = NSAttributedString(string: string, attributes: [NSAttributedString.Key.font: font, + NSAttributedString.Key.foregroundColor: color]) + } else { + attributedString = NSAttributedString(string: "") + } + + return attributedString! + } + + class func styleGetH1AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontH1(genericScaling)!, color: .black) + } + + class func styleGetH2AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontH2(genericScaling)!, color: .black) + } + + class func styleGetH3AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontH3(genericScaling)!, color: .black) + } + + class func styleGetH32AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontH32(genericScaling)!, color: .black) + } + + class func styleGetB1AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontB1(genericScaling)!, color: .black) + } + + class func styleGetB2AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontB2(genericScaling)!, color: .black) + } + + class func styleGetB3AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontB3(genericScaling)!, color: .mfBattleshipGrey()) + } + + class func styleGetB20AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { + return styleGetAttributedString(string, font: fontB20(genericScaling)!, color: .black) + } + + class func styleGetTopAlignedAttributeString(withLeftStringRightTop left: String?, center: String, rightString right: String?, withCenterStringFontSize fontSize: CGFloat, andColor color: UIColor) -> NSAttributedString { + + var left = left ?? "" + var center = center + var right = right ?? "" + + let text = "\(left)\(center)\(right)" + let attribs = [NSAttributedString.Key.foregroundColor: color] + var attributedText = NSMutableAttributedString(string: text, attributes: attribs) + + let centerRange = (text as NSString).range(of: center) + let centerFont = MFFonts.mfFont75Bd(fontSize) + let centerHeight = centerFont?.capHeight ?? 0.0 + attributedText.addAttributes([NSAttributedString.Key.font: MFFonts.mfFont75Bd(fontSize) as Any], range: centerRange) + + let leftRange = (text as NSString).range(of: left) + let leftFont = MFFonts.mfFont75Bd(fontSize * 0.34) + let leftHeight = leftFont?.capHeight ?? 0.0 + + if let leftFont = leftFont { + attributedText.addAttributes([NSAttributedString.Key.font: leftFont, + NSAttributedString.Key.baselineOffset: NSNumber(value: Float(centerHeight - leftHeight))], range: leftRange) + } + + let rightRange = NSRange(location: centerRange.location + centerRange.length, length: right.count ) + let rightFont = MFFonts.mfFont75Bd(fontSize * 0.34) + + let offset = Float((centerFont?.pointSize ?? 0.0) - (centerFont?.capHeight ?? 0.0) + (rightFont?.pointSize ?? 0.0) / 2) + + if let rightFont = rightFont { + attributedText.addAttributes([NSAttributedString.Key.font: rightFont, + NSAttributedString.Key.baselineOffset: offset], + range: rightRange) + } + + return attributedText + } + + class func styleGetAlignCenteredAttrituedString(_ string: inout NSMutableAttributedString?) { + + if let string = string, string.length > 0 { + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.alignment = .center + string.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: string.length)) + } + } + + class func styleGetBoldString(with inputFont: UIFont?, from inputString: String?) -> NSAttributedString? { + + let openingRange = (inputString as NSString?)?.range(of: "{") + let closingRange = (inputString as NSString?)?.range(of: "}") + let attrString = NSMutableAttributedString(string: inputString ?? "") + + if openingRange?.location != NSNotFound && closingRange?.location != NSNotFound { + let boldLength = (closingRange?.location ?? 0) - (openingRange?.location ?? 0) + if let inputFont = inputFont { + attrString.setAttributes([NSAttributedString.Key.font: inputFont], range: NSRange(location: openingRange?.location ?? 0, length: boldLength)) + } + + if let closingRange = closingRange { + attrString.replaceCharacters(in: closingRange, with: "") + } + + if let openingRange = openingRange { + attrString.replaceCharacters(in: openingRange, with: "") + } + } + + return attrString + } + + //-------------------------------------------------- + // MARK: - Gradient Colors + //-------------------------------------------------- + + class func gradientSpecialTicketGold() -> [AnyHashable] { + return [UIColor(red: 0.72, green: 0.6, blue: 0.33, alpha: 1), + UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1), + UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1), + UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1), + UIColor(red: 0.6, green: 0.42, blue: 0.07, alpha: 1)] + } + + class func gradientSpecialTicketGoldCGColor() -> [AnyHashable] { + return [UIColor(red: 0.72, green: 0.6, blue: 0.33, alpha: 1).cgColor, + UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor, + UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor, + UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor, + UIColor(red: 0.6, green: 0.42, blue: 0.07, alpha: 1).cgColor].compactMap { $0 } + } + + class func styleGetLowCaseSpace(_ inputString: String?) -> String? { + + if (inputString?.count ?? 0) > 0 { + let trimmedString = inputString?.lowercased().trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) + return trimmedString + } + + return "" + } + + class func labelStrokeAttributes(_ color: UIColor?) -> [AnyHashable : Any]? { + + guard let color = color else { return nil } + + return [NSAttributedString.Key.strokeColor: color, + NSAttributedString.Key.strokeWidth: -1.0] + } + + class func mfStyleBlackPageControl(_ pageControl: UIPageControl?) { + + pageControl?.pageIndicatorTintColor = .mfLighterGray() + pageControl?.currentPageIndicatorTintColor = .black + } + + //-------------------------------------------------- + // MARK: - Custom Styling Views + //-------------------------------------------------- + + class func styleView(_ view: UIView, show border: MFViewBorder, with color: UIColor?, borderLineWidth: CGFloat, borderLineLength borderLineLengh: CGFloat) { + + let borderLine = UIView(frame: .zero) + borderLine.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(borderLine) + + switch border { + case .top: + NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: true, pinBottom: false, pinLeft: false, pinRight: false) + NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineWidth, widthConstraint: true, widthConstant: borderLineLengh) + NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: true, pinCenterY: false) + + case .left: + NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: false, pinLeft: true, pinRight: false) + NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineLengh, widthConstraint: true, widthConstant: borderLineWidth) + NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: false, pinCenterY: true) + + case .bottom: + NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: true, pinLeft: false, pinRight: false) + NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineWidth, widthConstraint: true, widthConstant: borderLineLengh) + NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: true, pinCenterY: false) + + case .right: + NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true) + NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineLengh, widthConstraint: true, widthConstant: borderLineWidth) + NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: false, pinCenterY: true) + + default: + break + } + + borderLine.backgroundColor = color + } + + class func mfStylePageControl(_ pageControl: UIPageControl?) { + + pageControl?.pageIndicatorTintColor = .mfLighterGray() + pageControl?.currentPageIndicatorTintColor = .mfRed() + } + + class func styleTextField(_ textField: UITextField) { + + textField.font = fontForTextField() + // As per AKQA + /* If the length of the text field exceeds the amount of space, the size of the text drops down. + So, the entire line of copy can be read. + 16 point font size is the lowest recommended size. + */ + textField.minimumFontSize = 16 + textField.adjustsFontSizeToFitWidth = true // default is NO. if YES, text will shrink to minFontSize along baseline + } + /* + class func setGradientTo(_ label: UILabel, withColors colors: [AnyHashable]) { + + var textSize: CGSize? = nil + + if let font = UIFont(name: label.font.fontName, size: label.font.lineHeight) { + textSize = label.text?.size(withAttributes: [NSAttributedString.Key.baselineOffset: 0, + NSAttributedString.Key.font: font]) + } + + let width = (textSize?.width ?? 0.0) > 1024 ? 1024 : textSize?.width ?? 0.0 // max 1024 due to Core Graphics limitations + let height = (textSize?.height ?? 0.0) > 1024 ? 1024 : textSize?.height ?? 0.0 // max 1024 due to Core Graphics limitations + + // create a new bitmap image context + UIGraphicsBeginImageContext(CGSize(width: width, height: height)) + + let context = UIGraphicsGetCurrentContext() + + // push context to make it current (need to do this manually because we are not drawing in a UIView) + if let context = context { + UIGraphicsPushContext(context) + } + + var glossGradient: CGGradient? + var rgbColorspace: CGColorSpace? + let num_locations = colors.count + var locations = [CGFloat](repeating: 0.0, count: colors.count) + let components = [CGFloat](repeating: 0.0, count: colors.count * 4) + var componentIndex = 0 + + for i in 0.. UIImage? { + + UIGraphicsBeginImageContextWithOptions(image?.size ?? CGSize.zero, _: true, _: 1.0) + let imageRect = CGRect(x: 0, y: 0, width: image?.size.width ?? 0.0, height: image?.size.height ?? 0.0) + + // Draw the image with the luminosity blend mode. + // On top of a white background, this will give a black and white image. + image?.draw(in: imageRect, blendMode: .luminosity, alpha: 1.0) + + // Get the resulting image. + let filteredImage = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext() + + return filteredImage + } + /* + class func getCountTime(_ leftTime: Int, timeformat timeFormat: String?, time timeUnit: MFTimeFormatUnit, timeSuffix suffix: String?) -> String? { + + var seconds = leftTime % 60 + var minutes = (leftTime / 60) % 60 + var hours = (leftTime / 3600) % 24 + let days = leftTime / 86400 + + guard let times = timeFormat?.components(separatedBy: ":") else { return nil } + var timeString = "" + + if times.contains("DD") { + timeString += String(format: "%02ld", days) + + if timeUnit == .mfTimeFormatNormal { + let dayKey = (days <= 1) ? "CountDownDay" : "CountDownDays" + let dayUnit = MVMCoreUIUtility.hardcodedString(withKey: dayKey) + timeString += dayUnit! + + } else if timeUnit == MFTimeFormatColon && times?.last != "DD" { + timeString += " : " + } + + if times.last != "DD" && suffix != nil { + timeString += suffix ?? "" + } + } + + if times.contains("HH") { + if !times.contains("DD") { + hours = leftTime / 3600 + } + + timeString += String(format: "%02d", hours) + + if timeUnit == .mfTimeFormatNormal { + let hourKey = (hours <= 1) ? "CountDownHour" : "CountDownHours" + let hourUnit = MVMCoreUIUtility.hardcodedString(withKey: hourKey)! + timeString += hourUnit + + } else if timeUnit == MFTimeFormatColon && times?.last != "HH" { + timeString += " : " + } + + if times.last != "HH" && suffix != nil { + timeString += suffix ?? "" + } + } + + if times.contains("MM") { + if !times.contains("HH") { + if !times.contains("DD") { + minutes = leftTime / 60 + } else { + minutes = (leftTime - days * 86400) / 60 + } + } + + timeString += String(format: "%02d", minutes) + + if times.contains("SS") { + if !times.contains("MM") { + if !times.contains("HH") { + if !times.contains("DD") { + seconds = leftTime + } else { + seconds = leftTime % 86400 + } + } else { + seconds = leftTime % 3600 + } + } + + timeString += String(format: "%02d", seconds) + + if timeUnit == .mfTimeFormatNormal { + let secondKey = (seconds <= 1) ? "CountDownSec" : "CountDownSecs" + let secondUnit = MVMCoreUIUtility.hardcodedString(withKey: secondKey) + timeString += secondUnit! + } + } + return timeString + } + } + */ +} From 1957f4d354a6bf6cb8d31764edc5a0a1942fbe38 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 14:47:47 -0400 Subject: [PATCH 123/244] pulling in new changes --- MVMCoreUI/Styles/Styler.swift | 318 ++++++++++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index f5b90149..0a38e6f0 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -214,6 +214,170 @@ public class Styler { } } + //-------------------------------------------------- + // MARK: - 3.0 fonts + //-------------------------------------------------- + + class func getMVA3FontSize(_ size: CGFloat, bold isBold: Bool) -> UIFont { + if isBold { + if size >= 15 { + return MFFonts.mfFontDSBold(size) + } else { + return MFFonts.mfFontTXBold(size) + } + } else { + if size >= 15 { + return MFFonts.mfFontDSRegular(size) + } else { + return MFFonts.mfFontTXRegular(size) + } + } + } + + class func fontTitle2XLarge(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 36 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: true) + } + + class func fontTitle2XLarge() -> UIFont { + return self.fontTitle2XLarge(true) + } + + class func fontTitleXLarge(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 32 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: true) + } + + class func fontTitleXLarge() -> UIFont { + return self.fontTitleXLarge(true) + } + + class func fontBoldTitleLarge(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 24 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: true) + } + + class func fontBoldTitleLarge() -> UIFont { + return self.fontBoldTitleLarge(true) + } + + class func fontRegularTitleLarge(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 24 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: false) + } + + class func fontRegularTitleLarge() -> UIFont { + return self.fontRegularTitleLarge(true) + } + + class func fontBoldTitleMedium(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 20 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: true) + } + + class func fontBoldTitleMedium() -> UIFont { + return self.fontBoldTitleMedium(true) + } + + class func fontRegularTitleMedium(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 20 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: false) + } + + class func fontRegularTitleMedium() -> UIFont { + return self.fontRegularTitleMedium(true) + } + + class func fontBoldBodyLarge(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 16 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: true) + } + + class func fontBoldBodyLarge() -> UIFont { + return self.fontBoldBodyLarge(true) + } + + class func fontRegularBodyLarge(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 16 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: false) + } + + class func fontRegularBodyLarge() -> UIFont { + return self.fontRegularBodyLarge(true) + } + + class func fontBoldBodySmall(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 13 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: true) + } + + class func fontBoldBodySmall() -> UIFont { + return self.fontBoldBodySmall(true) + } + + class func fontRegularBodySmall(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 13 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: false) + } + + class func fontRegularBodySmall() -> UIFont { + return self.fontRegularBodySmall(true) + } + + class func fontBoldMicro(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 11 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: true) + } + + class func fontBoldMicro() -> UIFont { + return self.fontBoldMicro(true) + } + + class func fontRegularMicro(_ genericScaling: Bool) -> UIFont { + var size: CGFloat = 11 + if genericScaling { + size = self.sizeFontGeneric(forCurrentDevice: size) + } + return self.getMVA3FontSize(size, bold: false) + } + + class func fontRegularMicro() -> UIFont { + return self.fontRegularMicro(true) + } + //-------------------------------------------------- // MARK: - Fonts //-------------------------------------------------- @@ -306,6 +470,160 @@ public class Styler { return MFFonts.mfFont55Rg(size) } + //-------------------------------------------------- + // MARK: - 3.0 Styles + //-------------------------------------------------- + + class func styleLabelTitle2XLarge(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontTitle2XLarge(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelTitle2XLarge(_ label: UILabel) { + self.styleLabelTitle2XLarge(label, genericScaling: true) + } + + class func styleLabelTitleXLarge(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontTitleXLarge(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelTitleXLarge(_ label: UILabel) { + self.styleLabelTitleXLarge(label, genericScaling: true) + } + + class func styleLabelBoldTitleLarge(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontBoldTitleLarge(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelBoldTitleLarge(_ label: UILabel) { + self.styleLabelBoldTitleLarge(label, genericScaling: true) + } + + class func styleLabelRegularTitleLarge(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontRegularTitleLarge(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelRegularTitleLarge(_ label: UILabel) { + self.styleLabelBoldTitleLarge(label, genericScaling: true) + } + + class func styleLabelBoldTitleMedium(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontBoldTitleMedium(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelBoldTitleMedium(_ label: UILabel) { + self.styleLabelBoldTitleMedium(label, genericScaling: true) + } + + class func styleLabelRegularTitleMedium(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontRegularTitleMedium(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelRegularTitleMedium(_ label: UILabel) { + self.styleLabelRegularTitleMedium(label, genericScaling: true) + } + + class func styleLabelBoldBodyLarge(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontBoldBodyLarge(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelBoldBodyLarge(_ label: UILabel) { + self.styleLabelBoldBodyLarge(label, genericScaling: true) + } + + class func styleLabelRegularBodyLarge(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontRegularBodyLarge(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelRegularBodyLarge(_ label: UILabel) { + self.styleLabelRegularBodyLarge(label, genericScaling: true) + } + + class func styleLabelBoldBodySmall(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontBoldBodySmall(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelBoldBodySmall(_ label: UILabel) { + self.styleLabelBoldBodySmall(label, genericScaling: true) + } + + class func styleLabelRegularBodySmall(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontRegularBodySmall(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelRegularBodySmall(_ label: UILabel) { + self.styleLabelRegularBodySmall(label, genericScaling: true) + } + + class func styleLabelBoldMicro(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontBoldMicro(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelBoldMicro(_ label: UILabel) { + self.styleLabelBoldMicro(label, genericScaling: true) + } + + class func styleLabelRegularMicro(_ label: UILabel, genericScaling: Bool) { + label.font = MFStyler.fontRegularMicro(genericScaling) + label.textColor = UIColor.black + } + + class func styleLabelRegularMicro(_ label: UILabel) { + self.styleLabelRegularMicro(label, genericScaling: true) + } + + class func styleMVA3Label(_ label: UILabel, withStyle style: String?, genericScaling: Bool) -> Bool { + if (style == "Title2XLarge") { + self.styleLabelTitle2XLarge(label, genericScaling: genericScaling) + return true + } else if (style == "TitleXLarge") { + self.styleLabelTitleXLarge(label, genericScaling: genericScaling) + return true + } else if (style == "BoldTitleLarge") { + self.styleLabelBoldTitleLarge(label, genericScaling: genericScaling) + return true + } else if (style == "RegularTitleLarge") { + self.styleLabelRegularTitleLarge(label, genericScaling: genericScaling) + return true + } else if (style == "BoldTitleMedium") { + self.styleLabelBoldTitleMedium(label, genericScaling: genericScaling) + return true + } else if (style == "RegularTitleMedium") { + self.styleLabelRegularTitleMedium(label, genericScaling: genericScaling) + return true + } else if (style == "BoldBodyLarge") { + self.styleLabelBoldBodyLarge(label, genericScaling: genericScaling) + return true + } else if (style == "RegularBodyLarge") { + self.styleLabelRegularBodyLarge(label, genericScaling: genericScaling) + return true + } else if (style == "BoldBodySmall") { + self.styleLabelBoldBodySmall(label, genericScaling: genericScaling) + return true + } else if (style == "RegularBodySmall") { + self.styleLabelRegularBodySmall(label, genericScaling: genericScaling) + return true + } else if (style == "BoldMicro") { + self.styleLabelBoldMicro(label, genericScaling: genericScaling) + return true + } else if (style == "RegularMicro") { + self.styleLabelRegularMicro(label, genericScaling: genericScaling) + return true + } else { + return false + } + } + //-------------------------------------------------- // MARK: - Styles //-------------------------------------------------- From ae4855e358ff68451e0d36d5daf6270c73a12a43 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 1 Apr 2020 15:40:16 -0400 Subject: [PATCH 124/244] rules are optional --- MVMCoreUI/BaseControllers/ViewController.swift | 4 ++-- MVMCoreUI/FormUIHelpers/FormValidator.swift | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 024606f4..3376cf76 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -170,8 +170,8 @@ import UIKit navigationModel.line = LineModel(type: .none) } pageModel?.navigationItem = navigationModel - if self.formValidator == nil, - let rules = pageModel?.formRules { + if self.formValidator == nil { + let rules = pageModel?.formRules self.formValidator = FormValidator(rules) } } diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index a38b4b3f..7012e64d 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -12,13 +12,13 @@ import MVMCore @objcMembers public class FormValidator: NSObject { static var defaultGroupName: String = "default" - var formRules: [FormGroupRule] + var formRules: [FormGroupRule]? weak var delegate: FormHolderProtocol? var fields: [String: FormFieldProtocol] = [:] var groupWatchers: [FormGroupWatcherFieldProtocol] = [] var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:] - public init(_ formRules: [FormGroupRule]) { + public init(_ formRules: [FormGroupRule]?) { self.formRules = formRules } @@ -59,6 +59,9 @@ import MVMCore /// Validates all rule groups. Returns if valid public func validate() -> Bool { var valid = true + guard let formRules = formRules else { + return valid + } for group in formRules { valid = valid && validateGroup(group) } From cd3889cf55ebb7ecaf2f6068534ac81f8b65bcea Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 16:11:17 -0400 Subject: [PATCH 125/244] typo fix --- MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift | 2 +- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index f40a2dd1..3decadb5 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -33,7 +33,7 @@ import UIKit if radioButtonModel.state { radioButtonSelectionHelper.selectedRadioButton = radioButton } - FormValidator.setupValidation(molecule: radioButtonSelectionHelper, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: radioButtonSelectionHelper, delegate: delegateObject?.formHolderDelegate) } public func selected(_ radioButton: RadioButton) { diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 1a27200f..487ad32f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -342,7 +342,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) guard let model = model as? ToggleModel else { return } - FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) if let color = model.onTintColor?.uiColor { containerTintColor?.on = color From a8e411472fe65c1208a9b474abb75d62f72eea49 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 16:40:58 -0400 Subject: [PATCH 126/244] dramatic alteration --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Styles/Padding.swift | 74 ++ MVMCoreUI/Styles/Styler.swift | 1407 ++------------------------- 3 files changed, 169 insertions(+), 1316 deletions(-) create mode 100644 MVMCoreUI/Styles/Padding.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3f13e17b..ddb3307c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -88,6 +88,7 @@ 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A92435125F00AD3CA1 /* Styler.swift */; }; + 0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AB243531C300AD3CA1 /* Padding.swift */; }; 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; }; 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; @@ -474,6 +475,7 @@ 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; 0A6682A92435125F00AD3CA1 /* Styler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styler.swift; sourceTree = ""; }; + 0A6682AB243531C300AD3CA1 /* Padding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Padding.swift; sourceTree = ""; }; 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = ""; }; 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -1469,6 +1471,7 @@ D29DF13821E68636003B2FB9 /* MFStyler.h */, D29DF13921E68637003B2FB9 /* MFStyler.m */, 0A6682A92435125F00AD3CA1 /* Styler.swift */, + 0A6682AB243531C300AD3CA1 /* Padding.swift */, ); path = Styles; sourceTree = ""; @@ -2051,6 +2054,7 @@ 0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, + 0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */, 942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */, 8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */, 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */, diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift new file mode 100644 index 00000000..bdd65837 --- /dev/null +++ b/MVMCoreUI/Styles/Padding.swift @@ -0,0 +1,74 @@ +// +// Padding.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/1/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +public struct Padding { + + public static let One: CGFloat = 6 + public static let Two: CGFloat = 12 + public static let Three: CGFloat = 18 + public static let Four: CGFloat = 24 + public static let Five: CGFloat = 30 + public static let Six: CGFloat = 36 + public static let Seven: CGFloat = 42 + public static let Eight: CGFloat = 48 + public static let Nine: CGFloat = 54 + public static let Ten: CGFloat = 60 + + public static let TableCellParagraphSpace: CGFloat = 3 + public static let FooterLabelParagraphSpace: CGFloat = 4 + public static let WebViewInset: CGFloat = 8 + public static let HeightTableSeperatorHeight: CGFloat = 1 + public static let MFHeightForSwitch: CGFloat = 22 + public static let MFWidthForSwitch: CGFloat = 42 + public static let DisableOppacity: CGFloat = 0.5 + public static let PaymentMethodViewHeightWidthMultiplier: CGFloat = 0.55 + public static let MinCellHeight: CGFloat = 96 + public static let HeightIphone5: CGFloat = 568 + public static let DefaultOptionCellHeight: CGFloat = 120 + public static let PromoViewHeight: CGFloat = 41.9 + public static let BetweenFields: CGFloat = 24 + public static let LabelWithInternalButtonLineSpace: CGFloat = 2 + public static let PrimaryButtonTop: CGFloat = 36 + + public struct Default { + public static let Standard: CGFloat = 24 + public static let HorizontalSpacing: CGFloat = 32 + public static let VerticalSpacing: CGFloat = 32 + public static let VerticalSpacing3: CGFloat = 24 + + public static var HorizontalPaddingForApplicationWidth: CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 + } + + public static var VerticalPaddingForApplicationWidth: CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 + } + + public static func horizontalPadding(forSize size: CGFloat) -> CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBased(onSize: size) ?? 0 + } + + public static func verticalPadding(forSize size: CGFloat) -> CGFloat { + return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBased(onSize: size) ?? 0 + } + } + + public struct Horizontal { + public static let HeadlineWhiteView: CGFloat = 60 + public static let Large: CGFloat = 72 + public static let BetweenRelatedItems: CGFloat = 16 + } + + public struct Vertical { + public static let WhiteGrayView: CGFloat = 72 + public static let HeadlineAlternate: CGFloat = 48 + } +} diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 0a38e6f0..a43bc47a 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -9,6 +9,7 @@ import Foundation import MVMCore + public protocol VogueProtocol { } @@ -23,56 +24,13 @@ public protocol VogueTextProtocol: VogueProtocol { } -struct Padding { - - static let One: CGFloat = 6 - static let Two: CGFloat = 12 - static let Three: CGFloat = 18 - static let Four: CGFloat = 24 - static let Five: CGFloat = 30 - static let Six: CGFloat = 36 - static let Seven: CGFloat = 42 - static let Eight: CGFloat = 48 - static let Nine: CGFloat = 54 - static let Ten: CGFloat = 60 - - static let TableCellParagraphSpace: CGFloat = 3 - static let FooterLabelParagraphSpace: CGFloat = 4 - static let WebViewInset: CGFloat = 8 - static let HeightTableSeperatorHeight: CGFloat = 1 - static let MFHeightForSwitch: CGFloat = 22 - static let MFWidthForSwitch: CGFloat = 42 - static let DisableOppacity: CGFloat = 0.5 - static let PaymentMethodViewHeightWidthMultiplier: CGFloat = 0.55 - static let MinCellHeight: CGFloat = 96 - static let HeightIphone5: CGFloat = 568 - static let DefaultOptionCellHeight: CGFloat = 120 - static let PromoViewHeight: CGFloat = 41.9 - static let BetweenFields: CGFloat = 24 - static let LabelWithInternalButtonLineSpace: CGFloat = 2 - static let PrimaryButtonTop: CGFloat = 36 - - struct Default { - static let Standard: CGFloat = 24 - static let HorizontalSpacing: CGFloat = 32 - static let VerticalSpacing: CGFloat = 32 - static let VerticalSpacing3: CGFloat = 24 - } - - struct Horizontal { - static let HeadlineWhiteView: CGFloat = 60 - static let Large: CGFloat = 72 - static let BetweenRelatedItems: CGFloat = 16 - } - - struct Vertical { - static let WhiteGrayView: CGFloat = 72 - static let HeadlineAlternate: CGFloat = 48 - } -} -public class Styler { +open class Styler { + + //-------------------------------------------------- + // MARK: - Enums + //-------------------------------------------------- enum MFViewBorder: Int { case top @@ -81,63 +39,81 @@ public class Styler { case right } - enum MFTimeFormatUnit: Int { - case mfTimeFormatColon = 0 //!{days} : {hour} : {minutes} : {seconds} - case mfTimeFormatNormal = 1 // will end with days hours minutes seconds, when left days less than 2, it will change to 'day' - } - - //-------------------------------------------------- - // MARK: - Enum - //-------------------------------------------------- - - public enum Style: String { - case H1 - case H2 - case H3 - case H32 - case B1 - case B2 - case B3 - case B20 + public enum FontStyle: String { + case Title2XLarge + case TitleXLarge + case BoldTitleLarge + case RegularTitleLarge + case BoldTitleMedium + case RegularTitleMedium + case BoldBodyLarge + case RegularBodyLarge + case BoldBodySmall + case RegularBodySmall + case BoldMicro + case RegularMicro - func font(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 0 + func pointSize() -> CGFloat { + switch self { + case .Title2XLarge: + return 36 + + case .TitleXLarge: + return 32 + + case .BoldTitleLarge, + .RegularTitleLarge: + return 24 + + case .BoldTitleMedium, + .RegularTitleMedium: + return 20 + + case .BoldBodyLarge, + .RegularBodyLarge: + return 16 + + case .BoldBodySmall, + .RegularBodySmall: + return 13 + + case .BoldMicro, .RegularMicro: + return 11 + } + } + + func isBold() -> Bool { switch self { - case .H1: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 40 - return MFFonts.mfFont75Bd(size) + case .Title2XLarge, + .TitleXLarge, + .RegularTitleLarge, + .RegularTitleMedium, + .RegularBodyLarge, + .RegularBodySmall, + .RegularMicro: + return false - case .H2: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 25 - return MFFonts.mfFont75Bd(size) - - case .H3: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 18 - return MFFonts.mfFont75Bd(size) - - case .H32: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 32 - return MFFonts.mfFont75Bd(size) - - case .B1: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 13 - return MFFonts.mfFont75Bd(size) - - case .B2: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 13 - return MFFonts.mfFont55Rg(size) - - case .B3: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 11 - return MFFonts.mfFont55Rg(size) - - case .B20: - size = genericScaling ? sizeFontGeneric(forCurrentDevice: size) : 20 - return MFFonts.mfFont55Rg(size) + case .BoldTitleLarge, + .BoldTitleMedium, + .BoldBodyLarge, + .BoldBodySmall, + .BoldMicro: + return true } } + + func getFont(_ genericScaling: Bool = true) -> UIFont? { + + let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize() + return getMVA3FontSize(size, bold: isBold()) + } + + func styleLabel(_ label: UILabel, genericScaling: Bool = true) { + + label.font = getFont(genericScaling) + label.textColor = .black + } } public enum Tier { @@ -156,7 +132,7 @@ public class Styler { } class func splitTextFieldWidth(forViewWidth width: CGFloat) -> CGFloat { - return (width - CGFloat(PaddingOne)) / 2 - defaultHorizontalPaddingForApplicationWidth() + return (width - CGFloat(PaddingOne)) / 2 - Padding.Default.HorizontalPaddingForApplicationWidth } class func sizeObjectGeneric(forCurrentDevice size: CGFloat) -> MFSizeObject? { @@ -175,29 +151,9 @@ public class Styler { // MARK: - Spacing //-------------------------------------------------- - class func defaultHorizontalPaddingForApplicationWidth() -> CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 - } - - class func defaultVerticalPaddingForApplicationWidth() -> CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 - } - - class func defaultHorizontalPadding(forSize size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBased(onSize: size) ?? 0 - } - - class func defaultVerticalPadding(forSize size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBased(onSize: size) ?? 0 - } - - class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat) { - setDefaultMarginsFor(view, size: size, horizontal: true, vertical: false) - } - - class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool, vertical: Bool) { + class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) { - let horizontalPadding: CGFloat = horizontal ? defaultHorizontalPadding(forSize: size) : 0 + let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0 let verticalPadding: CGFloat = vertical ? PaddingDefaultVerticalSpacing3 : 0 DispatchQueue.main.async { @@ -207,7 +163,7 @@ public class Styler { class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) { - let horizontalPadding: CGFloat = horizontal ? defaultHorizontalPadding(forSize: size) : 0 + let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0 DispatchQueue.main.async { MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: top, trailing: horizontalPadding, bottom: bottom) @@ -219,1023 +175,27 @@ public class Styler { //-------------------------------------------------- class func getMVA3FontSize(_ size: CGFloat, bold isBold: Bool) -> UIFont { + if isBold { - if size >= 15 { - return MFFonts.mfFontDSBold(size) - } else { - return MFFonts.mfFontTXBold(size) - } + return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) + } else { - if size >= 15 { - return MFFonts.mfFontDSRegular(size) - } else { - return MFFonts.mfFontTXRegular(size) - } + return size >= 15 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) } } - class func fontTitle2XLarge(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 36 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: true) - } - - class func fontTitle2XLarge() -> UIFont { - return self.fontTitle2XLarge(true) - } - - class func fontTitleXLarge(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 32 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: true) - } - - class func fontTitleXLarge() -> UIFont { - return self.fontTitleXLarge(true) - } - - class func fontBoldTitleLarge(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 24 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: true) - } - - class func fontBoldTitleLarge() -> UIFont { - return self.fontBoldTitleLarge(true) - } - - class func fontRegularTitleLarge(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 24 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: false) - } - - class func fontRegularTitleLarge() -> UIFont { - return self.fontRegularTitleLarge(true) - } - - class func fontBoldTitleMedium(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 20 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: true) - } - - class func fontBoldTitleMedium() -> UIFont { - return self.fontBoldTitleMedium(true) - } - - class func fontRegularTitleMedium(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 20 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: false) - } - - class func fontRegularTitleMedium() -> UIFont { - return self.fontRegularTitleMedium(true) - } - - class func fontBoldBodyLarge(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 16 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: true) - } - - class func fontBoldBodyLarge() -> UIFont { - return self.fontBoldBodyLarge(true) - } - - class func fontRegularBodyLarge(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 16 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: false) - } - - class func fontRegularBodyLarge() -> UIFont { - return self.fontRegularBodyLarge(true) - } - - class func fontBoldBodySmall(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 13 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: true) - } - - class func fontBoldBodySmall() -> UIFont { - return self.fontBoldBodySmall(true) - } - - class func fontRegularBodySmall(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 13 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: false) - } - - class func fontRegularBodySmall() -> UIFont { - return self.fontRegularBodySmall(true) - } - - class func fontBoldMicro(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 11 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: true) - } - - class func fontBoldMicro() -> UIFont { - return self.fontBoldMicro(true) - } - - class func fontRegularMicro(_ genericScaling: Bool) -> UIFont { - var size: CGFloat = 11 - if genericScaling { - size = self.sizeFontGeneric(forCurrentDevice: size) - } - return self.getMVA3FontSize(size, bold: false) - } - - class func fontRegularMicro() -> UIFont { - return self.fontRegularMicro(true) - } - - //-------------------------------------------------- - // MARK: - Fonts - //-------------------------------------------------- - - class func fontH1(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 40 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontH2(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 25 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontH3(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 18 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontH32(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 32 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontB1(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 13 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontB2(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 13 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func fontB3(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 11 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func fontB20(_ genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 20 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - //-------------------------------------------------- - // MARK: - 3.0 Styles - //-------------------------------------------------- - - class func styleLabelTitle2XLarge(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontTitle2XLarge(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelTitle2XLarge(_ label: UILabel) { - self.styleLabelTitle2XLarge(label, genericScaling: true) - } - - class func styleLabelTitleXLarge(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontTitleXLarge(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelTitleXLarge(_ label: UILabel) { - self.styleLabelTitleXLarge(label, genericScaling: true) - } - - class func styleLabelBoldTitleLarge(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontBoldTitleLarge(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelBoldTitleLarge(_ label: UILabel) { - self.styleLabelBoldTitleLarge(label, genericScaling: true) - } - - class func styleLabelRegularTitleLarge(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontRegularTitleLarge(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelRegularTitleLarge(_ label: UILabel) { - self.styleLabelBoldTitleLarge(label, genericScaling: true) - } - - class func styleLabelBoldTitleMedium(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontBoldTitleMedium(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelBoldTitleMedium(_ label: UILabel) { - self.styleLabelBoldTitleMedium(label, genericScaling: true) - } - - class func styleLabelRegularTitleMedium(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontRegularTitleMedium(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelRegularTitleMedium(_ label: UILabel) { - self.styleLabelRegularTitleMedium(label, genericScaling: true) - } - - class func styleLabelBoldBodyLarge(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontBoldBodyLarge(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelBoldBodyLarge(_ label: UILabel) { - self.styleLabelBoldBodyLarge(label, genericScaling: true) - } - - class func styleLabelRegularBodyLarge(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontRegularBodyLarge(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelRegularBodyLarge(_ label: UILabel) { - self.styleLabelRegularBodyLarge(label, genericScaling: true) - } - - class func styleLabelBoldBodySmall(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontBoldBodySmall(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelBoldBodySmall(_ label: UILabel) { - self.styleLabelBoldBodySmall(label, genericScaling: true) - } - - class func styleLabelRegularBodySmall(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontRegularBodySmall(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelRegularBodySmall(_ label: UILabel) { - self.styleLabelRegularBodySmall(label, genericScaling: true) - } - - class func styleLabelBoldMicro(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontBoldMicro(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelBoldMicro(_ label: UILabel) { - self.styleLabelBoldMicro(label, genericScaling: true) - } - - class func styleLabelRegularMicro(_ label: UILabel, genericScaling: Bool) { - label.font = MFStyler.fontRegularMicro(genericScaling) - label.textColor = UIColor.black - } - - class func styleLabelRegularMicro(_ label: UILabel) { - self.styleLabelRegularMicro(label, genericScaling: true) - } - - class func styleMVA3Label(_ label: UILabel, withStyle style: String?, genericScaling: Bool) -> Bool { - if (style == "Title2XLarge") { - self.styleLabelTitle2XLarge(label, genericScaling: genericScaling) - return true - } else if (style == "TitleXLarge") { - self.styleLabelTitleXLarge(label, genericScaling: genericScaling) - return true - } else if (style == "BoldTitleLarge") { - self.styleLabelBoldTitleLarge(label, genericScaling: genericScaling) - return true - } else if (style == "RegularTitleLarge") { - self.styleLabelRegularTitleLarge(label, genericScaling: genericScaling) - return true - } else if (style == "BoldTitleMedium") { - self.styleLabelBoldTitleMedium(label, genericScaling: genericScaling) - return true - } else if (style == "RegularTitleMedium") { - self.styleLabelRegularTitleMedium(label, genericScaling: genericScaling) - return true - } else if (style == "BoldBodyLarge") { - self.styleLabelBoldBodyLarge(label, genericScaling: genericScaling) - return true - } else if (style == "RegularBodyLarge") { - self.styleLabelRegularBodyLarge(label, genericScaling: genericScaling) - return true - } else if (style == "BoldBodySmall") { - self.styleLabelBoldBodySmall(label, genericScaling: genericScaling) - return true - } else if (style == "RegularBodySmall") { - self.styleLabelRegularBodySmall(label, genericScaling: genericScaling) - return true - } else if (style == "BoldMicro") { - self.styleLabelBoldMicro(label, genericScaling: genericScaling) - return true - } else if (style == "RegularMicro") { - self.styleLabelRegularMicro(label, genericScaling: genericScaling) - return true - } else { - return false - } - } - //-------------------------------------------------- // MARK: - Styles //-------------------------------------------------- - class func styleLabel(_ label: VogueTextProtocol, withStyle style: Style, genericScaling: Bool) { - - switch style { - case .H1: - styleLabelH1(label, genericScaling: genericScaling) - - case .H2: - styleLabelH2(label, genericScaling: genericScaling) - - case .H3: - styleLabelH3(label, genericScaling: genericScaling) - - case .H32: - styleLabelH32(label, genericScaling: genericScaling) - - case .B1: - styleLabelB1(label, genericScaling: genericScaling) - - case .B2: - styleLabelB2(label, genericScaling: genericScaling) - - case .B3: - styleLabelB3(label, genericScaling: genericScaling) - - case .B20: - styleLabelB20(label, genericScaling: genericScaling) - } - } - - class func styleLabel(_ label: UILabel, withStyle style: Style) { - styleLabel(label, withStyle: style, genericScaling: true) - } - - class func styleLabelH1(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.black) - - if let h1 = fontH1(genericScaling) { - label.styleFont(h1) - } - } - - class func styleLabelH2(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.black) - - if let h2 = fontH2(genericScaling) { - label.styleFont(h2) - } - } - - class func styleLabelH3(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.black) - - if let h3 = fontH3(genericScaling) { - label.styleFont(h3) - } - } - - class func styleLabelH32(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.black) - - if let h32 = fontH32(genericScaling) { - label.styleFont(h32) - } - } - - class func styleLabelB1(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.black) - - if let b1 = fontB1(genericScaling) { - label.styleFont(b1) - } - } - - class func styleLabelB2(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.black) - - if let b2 = fontB2(genericScaling) { - label.styleFont(b2) - } - } - - class func styleLabelB2(_ label: UILabel, size: CGFloat, genericScaling: Bool = true) { - label.font = fontForBody(withSize: size, genericScaling: genericScaling) - } - - class func styleLabelB3(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.mfBackgroundGray()) - - if let b3 = fontB3(genericScaling) { - label.styleFont(b3) - } - } - - class func styleLabelB20(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.black) - - if let b20 = fontB20(genericScaling) { - label.styleFont(b20) - } - } - - class func styleLabelTextStyle2(_ label: VogueTextProtocol, genericScaling: Bool = true) { - - label.styleTextColor(.mfBattleshipGrey()) - - if let b2 = fontB2(genericScaling) { - label.styleFont(b2) - } - } - - class func fontForBody(withSize size: CGFloat, genericScaling: Bool) -> UIFont? { - - var size = size - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func fontForBody(withSize size: CGFloat, forWidth width: CGFloat) -> UIFont? { - - let size = sizeObjectGeneric(forCurrentDevice: size)?.getValueBased(onSize: width) ?? size - - return MFFonts.mfFont55Rg(size) - } - - //-------------------------------------------------- - // MARK: - 1.0 Fonts - //-------------------------------------------------- - - class func font(forPlan genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 100 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func font(forBiggerHeadLine genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 48 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func font(forHeadlineSmall genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 15 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func font(forHeadlineSmall2 genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 16 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontForHeadlineSmall2(forWidth size: CGFloat) -> UIFont? { - - var pointSize: CGFloat = 16 - pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) - - return MFFonts.mfFont75Bd(pointSize) - } - - class func fontB1(forWidth size: CGFloat) -> UIFont? { - - var pointSize: CGFloat = 13 - pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) - - return MFFonts.mfFont75Bd(pointSize) - } - - //-------------------------------------------------- - // MARK: - 1.0 Styles - //-------------------------------------------------- - - class func styleFeedCardTitleLabel(_ label: UILabel) { - - label.font = Styler.fontForFeedCardTitle() - label.textColor = .black - } - - class func styleFeedCardTagLabel(_ label: UILabel) { - - label.font = Styler.fontB3() - label.textColor = .mfBrownishGrey() - } - - class func styleStandardSeparatorView(_ view: UIView) { - - view.backgroundColor = .mfBackgroundGray() - } - - class func styleLabelHeadlineSmall(_ label: UILabel, genericScaling: Bool) { - - label.font = Styler.font(forHeadlineSmall: genericScaling) - label.textColor = .black - } - - class func styleFeedCardTitleLabel(_ label: UILabel, genericScaling: Bool) { - - label.font = Styler.font(forFeedCardTitle: genericScaling) - label.textColor = UIColor.black - } - - class func styleFeedCardTagLabel(_ label: UILabel, genericScaling: Bool) { - - label.font = Styler.fontB3(genericScaling) - label.textColor = UIColor.mfBrownishGrey() - } - - class func fontB2(forWidth size: CGFloat) -> UIFont? { - - var pointSize: CGFloat = 13 - - pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) - - return MFFonts.mfFont55Rg(pointSize) - } - - class func fontforChatText(_ genericScaling: Bool = false) -> UIFont? { - - var size: CGFloat = 14 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func font(forAccountLandingGreeting genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 16 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func font(forProgressBarBottomLabel genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 10 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func font(forFeedCardTitle genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 16 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func font(forPrimaryButton genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 14 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontForPrimaryButton(forWidth size: CGFloat) -> UIFont? { - - var pointSize: CGFloat = 14 - pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) - return MFFonts.mfFont75Bd(pointSize) - } - - class func font(forSmallButton genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 11 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontForSmallButton(forWidth size: CGFloat) -> UIFont? { - - var pointSize: CGFloat = 11 - pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) - - return MFFonts.mfFont75Bd(pointSize) - } - - class func font(forTextField genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 16 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func font(forTextFieldUnderLabel genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 12 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func fontForUnreadMessage(onSupport genericScaling: Bool = false) -> UIFont? { - - var size: CGFloat = 10 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func font5GMessage(_ genericScaling: Bool) -> UIFont? { - - var size: CGFloat = 16 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func font5GMessage() -> UIFont? { - return font5GMessage(true) - } - - class func font(forHeadlineAlternative genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 24 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func fontForHeadlineAlternative(forWidth size: CGFloat) -> UIFont? { - - var pointSize: CGFloat = 24 - pointSize = Styler.sizeObjectGeneric(forCurrentDevice: pointSize)!.getValueBased(onSize: size) - - return MFFonts.mfFont55Rg(pointSize) - } - - class func fontH255(_ genericScaling: Bool) -> UIFont? { - - var size: CGFloat = 25 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func font(forLargeLoyaltyHeaderTitle genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 60 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func font(forLoyaltyTitleSmall genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 42 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func font(forLoyaltyMessage genericScaling: Bool = true) -> UIFont? { - - var size: CGFloat = 20 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont55Rg(size) - } - - class func font(forPtPCard genericScaling: Bool) -> UIFont? { - - var size: CGFloat = 22 - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontForLabelWithTopLeftCircle(withSize size: CGFloat, genericScaling: Bool) -> UIFont? { - - var size = size - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFont75Bd(size) - } - - class func fontOcratxtWitSize(_ size: CGFloat, genericScaling: Bool) -> UIFont? { - - var size = size - - if genericScaling { - size = sizeFontGeneric(forCurrentDevice: size) - } - - return MFFonts.mfFontOcratxt(size) - } - - class func boldFont(forScaledSize size: CGFloat) -> UIFont { - return MFFonts.mfFont75Bd(sizeFontGeneric(forCurrentDevice: size))! - } - - class func regularFont(forScaledSize size: CGFloat) -> UIFont { - return MFFonts.mfFont55Rg(sizeFontGeneric(forCurrentDevice: size))! - } - - //-------------------------------------------------- - // MARK: - 1.0 Attributed Strings Style - //-------------------------------------------------- - - class func styleGetAttributedString(_ string: String?, withStyle style: String?) -> NSAttributedString { - return styleGetAttributedString(string, withStyle: Styler.Style(rawValue: style!)!, genericScaling: true) - } - - class func styleGetAttributedString(_ string: String?, withStyle style: Style, genericScaling: Bool) -> NSAttributedString { - - switch style { - case .H1: - return styleGetH1AttributedString(string, genericScaling: genericScaling) - - case .H2: - return styleGetH2AttributedString(string, genericScaling: genericScaling) - - case .H3: - return styleGetH3AttributedString(string, genericScaling: genericScaling) - - case .H32: - return styleGetH32AttributedString(string, genericScaling: genericScaling) - - case .B1: - return styleGetB1AttributedString(string, genericScaling: genericScaling) - - case .B2: - return styleGetB2AttributedString(string, genericScaling: genericScaling) - - case .B3: - return styleGetB3AttributedString(string, genericScaling: genericScaling) - - case .B20: - return styleGetB20AttributedString(string, genericScaling: genericScaling) - } - } - - class func styleGetAttributedString(_ string: String?, font: UIFont, color: UIColor) -> NSAttributedString { - - var attributedString: NSAttributedString? = nil - - if let string = string, !string.isEmpty { - attributedString = NSAttributedString(string: string, attributes: [NSAttributedString.Key.font: font, - NSAttributedString.Key.foregroundColor: color]) - } else { - attributedString = NSAttributedString(string: "") - } - - return attributedString! - } - - class func styleGetH1AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontH1(genericScaling)!, color: .black) - } - - class func styleGetH2AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontH2(genericScaling)!, color: .black) - } - - class func styleGetH3AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontH3(genericScaling)!, color: .black) - } - - class func styleGetH32AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontH32(genericScaling)!, color: .black) - } - - class func styleGetB1AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontB1(genericScaling)!, color: .black) - } - - class func styleGetB2AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontB2(genericScaling)!, color: .black) - } - - class func styleGetB3AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontB3(genericScaling)!, color: .mfBattleshipGrey()) - } - - class func styleGetB20AttributedString(_ string: String?, genericScaling: Bool = true) -> NSAttributedString { - return styleGetAttributedString(string, font: fontB20(genericScaling)!, color: .black) - } - - class func styleGetTopAlignedAttributeString(withLeftStringRightTop left: String?, center: String, rightString right: String?, withCenterStringFontSize fontSize: CGFloat, andColor color: UIColor) -> NSAttributedString { - - var left = left ?? "" - var center = center - var right = right ?? "" - - let text = "\(left)\(center)\(right)" - let attribs = [NSAttributedString.Key.foregroundColor: color] - var attributedText = NSMutableAttributedString(string: text, attributes: attribs) - - let centerRange = (text as NSString).range(of: center) - let centerFont = MFFonts.mfFont75Bd(fontSize) - let centerHeight = centerFont?.capHeight ?? 0.0 - attributedText.addAttributes([NSAttributedString.Key.font: MFFonts.mfFont75Bd(fontSize) as Any], range: centerRange) - - let leftRange = (text as NSString).range(of: left) - let leftFont = MFFonts.mfFont75Bd(fontSize * 0.34) - let leftHeight = leftFont?.capHeight ?? 0.0 - - if let leftFont = leftFont { - attributedText.addAttributes([NSAttributedString.Key.font: leftFont, - NSAttributedString.Key.baselineOffset: NSNumber(value: Float(centerHeight - leftHeight))], range: leftRange) - } - - let rightRange = NSRange(location: centerRange.location + centerRange.length, length: right.count ) - let rightFont = MFFonts.mfFont75Bd(fontSize * 0.34) - - let offset = Float((centerFont?.pointSize ?? 0.0) - (centerFont?.capHeight ?? 0.0) + (rightFont?.pointSize ?? 0.0) / 2) - - if let rightFont = rightFont { - attributedText.addAttributes([NSAttributedString.Key.font: rightFont, - NSAttributedString.Key.baselineOffset: offset], - range: rightRange) - } - - return attributedText - } - class func styleGetAlignCenteredAttrituedString(_ string: inout NSMutableAttributedString?) { if let string = string, string.length > 0 { let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = .center - string.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: string.length)) + string.addAttribute(.paragraphStyle, + value: paragraphStyle, + range: NSRange(location: 0, length: string.length)) } } @@ -1248,7 +208,9 @@ public class Styler { if openingRange?.location != NSNotFound && closingRange?.location != NSNotFound { let boldLength = (closingRange?.location ?? 0) - (openingRange?.location ?? 0) if let inputFont = inputFont { - attrString.setAttributes([NSAttributedString.Key.font: inputFont], range: NSRange(location: openingRange?.location ?? 0, length: boldLength)) + attrString.setAttributes([NSAttributedString.Key.font: inputFont], + range: NSRange(location: openingRange?.location ?? 0, + length: boldLength)) } if let closingRange = closingRange { @@ -1286,14 +248,14 @@ public class Styler { class func styleGetLowCaseSpace(_ inputString: String?) -> String? { if (inputString?.count ?? 0) > 0 { - let trimmedString = inputString?.lowercased().trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) + let trimmedString = inputString?.lowercased().trimmingCharacters(in: .whitespacesAndNewlines) return trimmedString } return "" } - class func labelStrokeAttributes(_ color: UIColor?) -> [AnyHashable : Any]? { + class func labelStrokeAttributes(_ color: UIColor?) -> [AnyHashable: Any]? { guard let color = color else { return nil } @@ -1301,12 +263,6 @@ public class Styler { NSAttributedString.Key.strokeWidth: -1.0] } - class func mfStyleBlackPageControl(_ pageControl: UIPageControl?) { - - pageControl?.pageIndicatorTintColor = .mfLighterGray() - pageControl?.currentPageIndicatorTintColor = .black - } - //-------------------------------------------------- // MARK: - Custom Styling Views //-------------------------------------------------- @@ -1337,189 +293,8 @@ public class Styler { NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true) NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineLengh, widthConstraint: true, widthConstant: borderLineWidth) NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: false, pinCenterY: true) - - default: - break } borderLine.backgroundColor = color } - - class func mfStylePageControl(_ pageControl: UIPageControl?) { - - pageControl?.pageIndicatorTintColor = .mfLighterGray() - pageControl?.currentPageIndicatorTintColor = .mfRed() - } - - class func styleTextField(_ textField: UITextField) { - - textField.font = fontForTextField() - // As per AKQA - /* If the length of the text field exceeds the amount of space, the size of the text drops down. - So, the entire line of copy can be read. - 16 point font size is the lowest recommended size. - */ - textField.minimumFontSize = 16 - textField.adjustsFontSizeToFitWidth = true // default is NO. if YES, text will shrink to minFontSize along baseline - } - /* - class func setGradientTo(_ label: UILabel, withColors colors: [AnyHashable]) { - - var textSize: CGSize? = nil - - if let font = UIFont(name: label.font.fontName, size: label.font.lineHeight) { - textSize = label.text?.size(withAttributes: [NSAttributedString.Key.baselineOffset: 0, - NSAttributedString.Key.font: font]) - } - - let width = (textSize?.width ?? 0.0) > 1024 ? 1024 : textSize?.width ?? 0.0 // max 1024 due to Core Graphics limitations - let height = (textSize?.height ?? 0.0) > 1024 ? 1024 : textSize?.height ?? 0.0 // max 1024 due to Core Graphics limitations - - // create a new bitmap image context - UIGraphicsBeginImageContext(CGSize(width: width, height: height)) - - let context = UIGraphicsGetCurrentContext() - - // push context to make it current (need to do this manually because we are not drawing in a UIView) - if let context = context { - UIGraphicsPushContext(context) - } - - var glossGradient: CGGradient? - var rgbColorspace: CGColorSpace? - let num_locations = colors.count - var locations = [CGFloat](repeating: 0.0, count: colors.count) - let components = [CGFloat](repeating: 0.0, count: colors.count * 4) - var componentIndex = 0 - - for i in 0.. UIImage? { - - UIGraphicsBeginImageContextWithOptions(image?.size ?? CGSize.zero, _: true, _: 1.0) - let imageRect = CGRect(x: 0, y: 0, width: image?.size.width ?? 0.0, height: image?.size.height ?? 0.0) - - // Draw the image with the luminosity blend mode. - // On top of a white background, this will give a black and white image. - image?.draw(in: imageRect, blendMode: .luminosity, alpha: 1.0) - - // Get the resulting image. - let filteredImage = UIGraphicsGetImageFromCurrentImageContext() - UIGraphicsEndImageContext() - - return filteredImage - } - /* - class func getCountTime(_ leftTime: Int, timeformat timeFormat: String?, time timeUnit: MFTimeFormatUnit, timeSuffix suffix: String?) -> String? { - - var seconds = leftTime % 60 - var minutes = (leftTime / 60) % 60 - var hours = (leftTime / 3600) % 24 - let days = leftTime / 86400 - - guard let times = timeFormat?.components(separatedBy: ":") else { return nil } - var timeString = "" - - if times.contains("DD") { - timeString += String(format: "%02ld", days) - - if timeUnit == .mfTimeFormatNormal { - let dayKey = (days <= 1) ? "CountDownDay" : "CountDownDays" - let dayUnit = MVMCoreUIUtility.hardcodedString(withKey: dayKey) - timeString += dayUnit! - - } else if timeUnit == MFTimeFormatColon && times?.last != "DD" { - timeString += " : " - } - - if times.last != "DD" && suffix != nil { - timeString += suffix ?? "" - } - } - - if times.contains("HH") { - if !times.contains("DD") { - hours = leftTime / 3600 - } - - timeString += String(format: "%02d", hours) - - if timeUnit == .mfTimeFormatNormal { - let hourKey = (hours <= 1) ? "CountDownHour" : "CountDownHours" - let hourUnit = MVMCoreUIUtility.hardcodedString(withKey: hourKey)! - timeString += hourUnit - - } else if timeUnit == MFTimeFormatColon && times?.last != "HH" { - timeString += " : " - } - - if times.last != "HH" && suffix != nil { - timeString += suffix ?? "" - } - } - - if times.contains("MM") { - if !times.contains("HH") { - if !times.contains("DD") { - minutes = leftTime / 60 - } else { - minutes = (leftTime - days * 86400) / 60 - } - } - - timeString += String(format: "%02d", minutes) - - if times.contains("SS") { - if !times.contains("MM") { - if !times.contains("HH") { - if !times.contains("DD") { - seconds = leftTime - } else { - seconds = leftTime % 86400 - } - } else { - seconds = leftTime % 3600 - } - } - - timeString += String(format: "%02d", seconds) - - if timeUnit == .mfTimeFormatNormal { - let secondKey = (seconds <= 1) ? "CountDownSec" : "CountDownSecs" - let secondUnit = MVMCoreUIUtility.hardcodedString(withKey: secondKey) - timeString += secondUnit! - } - } - return timeString - } - } - */ } From 1758192edfbe87bb4a71937f42cfa28cb10988f6 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 17:03:03 -0400 Subject: [PATCH 127/244] decent state --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Styles/Styler.swift | 182 ++------------------------- MVMCoreUI/Styles/VogueProtocol.swift | 23 ++++ 3 files changed, 39 insertions(+), 170 deletions(-) create mode 100644 MVMCoreUI/Styles/VogueProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ddb3307c..101d0c8d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -89,6 +89,7 @@ 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A92435125F00AD3CA1 /* Styler.swift */; }; 0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AB243531C300AD3CA1 /* Padding.swift */; }; + 0A6682AE243538DB00AD3CA1 /* VogueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */; }; 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; }; 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; @@ -476,6 +477,7 @@ 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; 0A6682A92435125F00AD3CA1 /* Styler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styler.swift; sourceTree = ""; }; 0A6682AB243531C300AD3CA1 /* Padding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Padding.swift; sourceTree = ""; }; + 0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VogueProtocol.swift; sourceTree = ""; }; 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = ""; }; 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -1472,6 +1474,7 @@ D29DF13921E68637003B2FB9 /* MFStyler.m */, 0A6682A92435125F00AD3CA1 /* Styler.swift */, 0A6682AB243531C300AD3CA1 /* Padding.swift */, + 0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */, ); path = Styles; sourceTree = ""; @@ -2005,6 +2008,7 @@ AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, 011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */, + 0A6682AE243538DB00AD3CA1 /* VogueProtocol.swift in Sources */, AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index a43bc47a..62af40fe 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -7,39 +7,14 @@ // import Foundation -import MVMCore - - -public protocol VogueProtocol { - -} - -public protocol VogueViewProtocol { - -} - -public protocol VogueTextProtocol: VogueProtocol { - func styleFont(_ font: UIFont) - func styleTextColor(_ textColor: UIColor) -} - - open class Styler { - //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- - enum MFViewBorder: Int { - case top - case left - case bottom - case right - } - - public enum FontStyle: String { + public enum Font: String { case Title2XLarge case TitleXLarge case BoldTitleLarge @@ -53,7 +28,7 @@ open class Styler { case BoldMicro case RegularMicro - func pointSize() -> CGFloat { + public func pointSize() -> CGFloat { switch self { case .Title2XLarge: return 36 @@ -82,7 +57,7 @@ open class Styler { } } - func isBold() -> Bool { + public func isBold() -> Bool { switch self { case .Title2XLarge, @@ -103,39 +78,24 @@ open class Styler { } } - func getFont(_ genericScaling: Bool = true) -> UIFont? { + public func getFont(_ genericScaling: Bool = true) -> UIFont? { let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize() return getMVA3FontSize(size, bold: isBold()) } - func styleLabel(_ label: UILabel, genericScaling: Bool = true) { + public func styleLabel(_ label: UILabel, genericScaling: Bool = true) { label.font = getFont(genericScaling) label.textColor = .black } } - - public enum Tier { - case primary - case secondary - case ternary - case quaternary - } - + //-------------------------------------------------- // MARK: - Functions //-------------------------------------------------- - class func splitTextFieldWidth() -> CGFloat { - return splitTextFieldWidth(forViewWidth: MVMCoreUISplitViewController.getDetailViewWidth()) - } - - class func splitTextFieldWidth(forViewWidth width: CGFloat) -> CGFloat { - return (width - CGFloat(PaddingOne)) / 2 - Padding.Default.HorizontalPaddingForApplicationWidth - } - - class func sizeObjectGeneric(forCurrentDevice size: CGFloat) -> MFSizeObject? { + open class func sizeObjectGeneric(forCurrentDevice size: CGFloat) -> MFSizeObject? { let sizeObject = MFSizeObject(standardSize: size, standardiPadPortraitSize: size * 1.3) sizeObject?.addLargerThanCustomSize(size * 1.4, forThreshold: MFSizeStandardiPadLandscapeThreshold) @@ -143,7 +103,7 @@ open class Styler { return sizeObject } - class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat { + open class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat { return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? 0 } @@ -151,7 +111,7 @@ open class Styler { // MARK: - Spacing //-------------------------------------------------- - class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) { + open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) { let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0 let verticalPadding: CGFloat = vertical ? PaddingDefaultVerticalSpacing3 : 0 @@ -161,7 +121,7 @@ open class Styler { } } - class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) { + open class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) { let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0 @@ -169,12 +129,8 @@ open class Styler { MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: top, trailing: horizontalPadding, bottom: bottom) } } - - //-------------------------------------------------- - // MARK: - 3.0 fonts - //-------------------------------------------------- - - class func getMVA3FontSize(_ size: CGFloat, bold isBold: Bool) -> UIFont { + + open class func getMVA3FontSize(_ size: CGFloat, bold isBold: Bool) -> UIFont { if isBold { return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) @@ -183,118 +139,4 @@ open class Styler { return size >= 15 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) } } - - //-------------------------------------------------- - // MARK: - Styles - //-------------------------------------------------- - - class func styleGetAlignCenteredAttrituedString(_ string: inout NSMutableAttributedString?) { - - if let string = string, string.length > 0 { - let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.alignment = .center - string.addAttribute(.paragraphStyle, - value: paragraphStyle, - range: NSRange(location: 0, length: string.length)) - } - } - - class func styleGetBoldString(with inputFont: UIFont?, from inputString: String?) -> NSAttributedString? { - - let openingRange = (inputString as NSString?)?.range(of: "{") - let closingRange = (inputString as NSString?)?.range(of: "}") - let attrString = NSMutableAttributedString(string: inputString ?? "") - - if openingRange?.location != NSNotFound && closingRange?.location != NSNotFound { - let boldLength = (closingRange?.location ?? 0) - (openingRange?.location ?? 0) - if let inputFont = inputFont { - attrString.setAttributes([NSAttributedString.Key.font: inputFont], - range: NSRange(location: openingRange?.location ?? 0, - length: boldLength)) - } - - if let closingRange = closingRange { - attrString.replaceCharacters(in: closingRange, with: "") - } - - if let openingRange = openingRange { - attrString.replaceCharacters(in: openingRange, with: "") - } - } - - return attrString - } - - //-------------------------------------------------- - // MARK: - Gradient Colors - //-------------------------------------------------- - - class func gradientSpecialTicketGold() -> [AnyHashable] { - return [UIColor(red: 0.72, green: 0.6, blue: 0.33, alpha: 1), - UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1), - UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1), - UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1), - UIColor(red: 0.6, green: 0.42, blue: 0.07, alpha: 1)] - } - - class func gradientSpecialTicketGoldCGColor() -> [AnyHashable] { - return [UIColor(red: 0.72, green: 0.6, blue: 0.33, alpha: 1).cgColor, - UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor, - UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor, - UIColor(red: 1, green: 0.85, blue: 0.52, alpha: 1).cgColor, - UIColor(red: 0.6, green: 0.42, blue: 0.07, alpha: 1).cgColor].compactMap { $0 } - } - - class func styleGetLowCaseSpace(_ inputString: String?) -> String? { - - if (inputString?.count ?? 0) > 0 { - let trimmedString = inputString?.lowercased().trimmingCharacters(in: .whitespacesAndNewlines) - return trimmedString - } - - return "" - } - - class func labelStrokeAttributes(_ color: UIColor?) -> [AnyHashable: Any]? { - - guard let color = color else { return nil } - - return [NSAttributedString.Key.strokeColor: color, - NSAttributedString.Key.strokeWidth: -1.0] - } - - //-------------------------------------------------- - // MARK: - Custom Styling Views - //-------------------------------------------------- - - class func styleView(_ view: UIView, show border: MFViewBorder, with color: UIColor?, borderLineWidth: CGFloat, borderLineLength borderLineLengh: CGFloat) { - - let borderLine = UIView(frame: .zero) - borderLine.translatesAutoresizingMaskIntoConstraints = false - view.addSubview(borderLine) - - switch border { - case .top: - NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: true, pinBottom: false, pinLeft: false, pinRight: false) - NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineWidth, widthConstraint: true, widthConstant: borderLineLengh) - NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: true, pinCenterY: false) - - case .left: - NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: false, pinLeft: true, pinRight: false) - NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineLengh, widthConstraint: true, widthConstant: borderLineWidth) - NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: false, pinCenterY: true) - - case .bottom: - NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: true, pinLeft: false, pinRight: false) - NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineWidth, widthConstraint: true, widthConstant: borderLineLengh) - NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: true, pinCenterY: false) - - case .right: - NSLayoutConstraint.constraintPinSubview(borderLine, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true) - NSLayoutConstraint.constraintPinView(borderLine, heightConstraint: true, heightConstant: borderLineLengh, widthConstraint: true, widthConstant: borderLineWidth) - NSLayoutConstraint.constraintPinSubview(borderLine, pinCenterX: false, pinCenterY: true) - } - - borderLine.backgroundColor = color - } } diff --git a/MVMCoreUI/Styles/VogueProtocol.swift b/MVMCoreUI/Styles/VogueProtocol.swift new file mode 100644 index 00000000..1bd8e6a8 --- /dev/null +++ b/MVMCoreUI/Styles/VogueProtocol.swift @@ -0,0 +1,23 @@ +// +// VogueProtocol.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/1/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +public protocol VogueProtocol { + +} + +public protocol VogueViewProtocol { + +} + +public protocol VogueTextProtocol: VogueProtocol { + func styleFont(_ font: UIFont) + func styleTextColor(_ textColor: UIColor) +} From c26eea8cddd13666efad0cb8eaca40a94c0a9baf Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Apr 2020 17:12:26 -0400 Subject: [PATCH 128/244] small change --- MVMCoreUI/Styles/Styler.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 62af40fe..75d81b89 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -81,7 +81,7 @@ open class Styler { public func getFont(_ genericScaling: Bool = true) -> UIFont? { let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize() - return getMVA3FontSize(size, bold: isBold()) + return getMVA3FontSize(size, isBold: isBold()) } public func styleLabel(_ label: UILabel, genericScaling: Bool = true) { @@ -130,7 +130,7 @@ open class Styler { } } - open class func getMVA3FontSize(_ size: CGFloat, bold isBold: Bool) -> UIFont { + open class func getMVA3FontSize(_ size: CGFloat, isBold: Bool) -> UIFont { if isBold { return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) From 83e04f0a1202776acf69a73a270bc46885e781e3 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 17:16:23 -0400 Subject: [PATCH 129/244] update with message handler string --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 61 +++++++++---------- .../Atomic/Atoms/Views/WebViewModel.swift | 13 ++-- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index c5cc0cf9..3d870f53 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -27,25 +27,19 @@ import WebKit override open func setupView() { super.setupView() - let webView = createWebView(messageHandler: mvmWebViewMessageHandler, jsScript: nil) + let webView = createWebView(messageHandler: mvmWebViewMessageHandler) addSubview(webView) NSLayoutConstraint.constraintPinSubview(toSuperview: webView) self.webView = webView pinSpinnerView() } - func createWebView(messageHandler: String?, jsScript:String?) -> WKWebView { + func createWebView(messageHandler: String?) -> WKWebView { let wkUserController = WKUserContentController() if let messageHandlerName = messageHandler { wkUserController.add(self, name: messageHandlerName) } - //server driven addition script - if let jsScript = jsScript { - let wkScript = WKUserScript(source: jsScript, injectionTime: .atDocumentStart, forMainFrameOnly: true) - wkUserController.addUserScript(wkScript) - } - let wkConfig = WKWebViewConfiguration() wkConfig.userContentController = wkUserController let webView = WKWebView(frame: .zero, configuration: wkConfig) @@ -59,33 +53,29 @@ import WebKit // MARK: - MVMCoreUIMoleculeViewProtocol override open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) - guard let model = model as? WebViewModel else { return } self.delegateObject = delegateObject - - if model.callHandler != nil || model.jsScript != nil { -/* - webView's configuration property is immutable. - In order to add call handler into webview, need to create a new webview. -*/ - webView?.removeFromSuperview() - let webView = createWebView(messageHandler: model.callHandler, jsScript:model.jsScript) - addSubview(webView) - NSLayoutConstraint.constraintPinSubview(toSuperview: webView) - self.webView = webView - } //init height for loading spinner - webViewHeight = webView?.heightAnchor.constraint(equalToConstant: 50) + webViewHeight = webView?.heightAnchor.constraint(equalToConstant: 44) webViewHeight?.isActive = true - if let height = model.height { + if let height = webviewModel?.height { webViewHeight?.constant = height dynamicHeight = false } - if let url = model.url { + if let url = webviewModel?.url { webView?.load(URLRequest(url: url)) - } else if let htmlString = model.htmlString { + } else if let htmlString = webviewModel?.htmlString { webView?.loadHTMLString(htmlString, baseURL: nil) } + + if let borderColor = webviewModel?.borderColor?.cgColor { + webView?.layer.borderWidth = 1.0 + webView?.layer.borderColor = borderColor + } else { + webView?.layer.borderWidth = 0.0 + webView?.layer.borderColor = UIColor.clear.cgColor + } + bringSubviewToFront(loadingSpinner) } @@ -95,8 +85,8 @@ import WebKit loadingSpinner.clipsToBounds = true loadingSpinner.translatesAutoresizingMaskIntoConstraints = false - loadingSpinner.heightAnchor.constraint(equalToConstant: 50.0).isActive = true - loadingSpinner.widthAnchor.constraint(equalToConstant: 50.0).isActive = true + loadingSpinner.heightAnchor.constraint(equalToConstant: 44.0).isActive = true + loadingSpinner.widthAnchor.constraint(equalToConstant: 44.0).isActive = true loadingSpinner.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true loadingSpinner.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true loadingSpinner.resumeSpinner() @@ -114,7 +104,6 @@ extension WebView : WKUIDelegate { if !dynamicHeight { return } - /* was using "document.readyState" to check the state, while evaluateJavaScript "document.readyState",only works when webview contains userscrpt.otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred". so webView.isLoading to check load finished state */ @@ -157,14 +146,20 @@ extension WebView : WKNavigationDelegate { // MARK: - WKScriptMessageHandler extension WebView: WKScriptMessageHandler { public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { - if message.name == mvmWebViewMessageHandler, let actionMap = message.body as? [AnyHashable: Any] { + if message.name == mvmWebViewMessageHandler, let text = message.body as? String { /* receiving JavaScript func webkit.messageHandlers.{callHandler}.postMessage(body); - if body is dictionary - MVMCoreActionHanlder handleAction + if body is string, will decode to actionmodel. + use legacy MVMCoreActionHanlder handleAction method for now */ - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObject) - + if let data = text.data(using: .utf8) { + do { + let actionMap = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObject) + } catch { + //actionModel should report error when actionhandler is finshed with actionmodel + } + } } } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift index bb141b57..d20a5007 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift @@ -15,8 +15,7 @@ import Foundation public var url: URL? public var htmlString: String? public var height: CGFloat? - public var jsScript: String? - public var callHandler: String? + public var borderColor: Color? public var buttonMap: [String: ButtonModel]? private enum CodingKeys: String, CodingKey{ @@ -26,8 +25,7 @@ import Foundation case htmlString case height case buttonMap - case jsScript - case callHandler + case borderColor } required public init(from decoder: Decoder) throws { @@ -37,8 +35,7 @@ import Foundation htmlString = try typeContainer.decodeIfPresent(String.self, forKey: .htmlString) height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height) buttonMap = try typeContainer.decodeIfPresent([String: ButtonModel].self, forKey: .buttonMap) - jsScript = try typeContainer.decodeIfPresent(String.self, forKey: .jsScript) - callHandler = try typeContainer.decodeIfPresent(String.self, forKey: .callHandler) + borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) } public func encode(to encoder: Encoder) throws { @@ -48,8 +45,6 @@ import Foundation try container.encodeIfPresent(url, forKey: .url) try container.encodeIfPresent(htmlString, forKey: .htmlString) try container.encodeIfPresent(height, forKey: .height) - try container.encodeIfPresent(jsScript, forKey: .jsScript) - try container.encodeIfPresent(callHandler, forKey: .callHandler) - + try container.encodeIfPresent(borderColor, forKey: .borderColor) } } From 3e7a1a3250e2eb52e7ed13a6eba09d29d018cf3f Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 17:30:06 -0400 Subject: [PATCH 130/244] move some code --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 3d870f53..59306739 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -14,7 +14,6 @@ import WebKit let mvmWebViewMessageHandler = "mvmWebViewMessageHandler" public let loadingSpinner = MFLoadingSpinner(frame: .zero) - var delegateObject: MVMCoreUIDelegateObject? var webView: WKWebView? var webViewHeight: NSLayoutConstraint? @@ -27,26 +26,24 @@ import WebKit override open func setupView() { super.setupView() - let webView = createWebView(messageHandler: mvmWebViewMessageHandler) - addSubview(webView) - NSLayoutConstraint.constraintPinSubview(toSuperview: webView) - self.webView = webView + createWebView(messageHandler: mvmWebViewMessageHandler) pinSpinnerView() } - func createWebView(messageHandler: String?) -> WKWebView { + func createWebView(messageHandler: String?) { let wkUserController = WKUserContentController() if let messageHandlerName = messageHandler { wkUserController.add(self, name: messageHandlerName) } - let wkConfig = WKWebViewConfiguration() wkConfig.userContentController = wkUserController let webView = WKWebView(frame: .zero, configuration: wkConfig) webView.translatesAutoresizingMaskIntoConstraints = false webView.uiDelegate = self webView.navigationDelegate = self - return webView + self.webView = webView + addSubview(webView) + NSLayoutConstraint.constraintPinSubview(toSuperview: webView) } From 9851050aca094a2b61ae094ad29f3d070b78f6f0 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 17:31:40 -0400 Subject: [PATCH 131/244] move some code --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 59306739..6e22d3f5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -13,16 +13,15 @@ import WebKit let mvmWebViewMessageHandler = "mvmWebViewMessageHandler" - public let loadingSpinner = MFLoadingSpinner(frame: .zero) - var delegateObject: MVMCoreUIDelegateObject? - var webView: WKWebView? - var webViewHeight: NSLayoutConstraint? - var dynamicHeight: Bool = true - - var callHandlerName: String? var webviewModel: WebViewModel? { return model as? WebViewModel } + var webView: WKWebView? + public let loadingSpinner = MFLoadingSpinner(frame: .zero) + var delegateObject: MVMCoreUIDelegateObject? + var webViewHeight: NSLayoutConstraint? + var dynamicHeight: Bool = true + override open func setupView() { super.setupView() From 322f5caee52dbfd161bd72d275b150485bbc66bd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 18:10:48 -0400 Subject: [PATCH 132/244] removing redundant code. --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 5 +- ...stRightVariableButtonAllTextAndLinks.swift | 6 +-- ...htVariableButtonAllTextAndLinksModel.swift | 2 +- ...stRightVariableButtonAllTextAndLinks.swift | 50 ------------------- ...htVariableButtonAllTextAndLinksModel.swift | 48 ------------------ 6 files changed, 7 insertions(+), 106 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinks.swift delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f11e633f..60829e96 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1000,8 +1000,8 @@ AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( - BB54C51E2434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift */, BB54C51F2434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift */, + BB54C51E2434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift */, BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */, BB2C969124330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift */, AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 3e242905..7f56f142 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -128,17 +128,18 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTextLinkAllTextAndLinks.self, viewModelClass: ListRightVariableTextLinkAllTextAndLinksModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableButtonAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) @@ -146,8 +147,6 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableButtonAllTextAndLinksModel.self) - // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index c5f66b9a..25885044 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -18,8 +18,8 @@ import Foundation // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 0, horizontalAlignment: .leading)), - (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .center))], + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading)), + (view: button, model: StackItemModel(horizontalAlignment:.fill))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -37,7 +37,7 @@ import Foundation stack.restack() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListRightVariableButtonAllTextAndLinksModel else { return } button.set(with: model.button, delegateObject, additionalData) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index 466456b4..41d4ec72 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -7,7 +7,7 @@ // import Foundation -public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ +public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "listRVBtn" public var button: ButtonModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinks.swift deleted file mode 100644 index 0fd7fdad..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ /dev/null @@ -1,50 +0,0 @@ -// -// ListRightVariableButtonAllTextAndLinks.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 17/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -@objcMembers open class ListRightVariableButtonAllTextAndLinks: TableViewCell { - - //----------------------------------------------------- - // MARK: - Outlets - //----------------------------------------------------- - public var stack: Stack - public let button = PrimaryButton.button() - public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) - - // MARK: - Initializers - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 0, horizontalAlignment: .leading)), - (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .center))], - axis: .horizontal) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - //----------------------------------------------------- - // MARK: - View Lifecycle - //----------------------------------------------------- - override open func setupView() { - super.setupView() - addMolecule(stack) - stack.restack() - } - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListRightVariableButtonAllTextAndLinksModel else { return } - button.set(with: model.button, delegateObject, additionalData) - eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 90 - } -} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift deleted file mode 100644 index a306a86c..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// ListRightVariableButtonAllTextAndLinksModel.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 17/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ - public static var identifier: String = "listRVBtn" - public var button: ButtonModel - public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel - - public init(button: ButtonModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { - self.button = button - self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink - super.init() - } - - /// Defaults to set - override public func setDefaults() { - super.setDefaults() - self.button.size = .tiny - self.button.style = ButtonStyle.secondary - } - - private enum CodingKeys: String, CodingKey { - case moleculeName - case button - case eyebrowHeadlineBodyLink - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - button = try typeContainer.decode(ButtonModel.self, forKey: .button) - eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(button, forKey: .button) - try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) - } -} From 56dfb07949f6bdfbecb959d80db786d6343527fd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 1 Apr 2020 18:13:22 -0400 Subject: [PATCH 133/244] remove extra file --- .../OtherHandlers/MoleculeObjectMapping.swift | 144 ------------------ 1 file changed, 144 deletions(-) delete mode 100644 MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift deleted file mode 100644 index d4f79cc8..00000000 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject+ModelMapping.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -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: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) - - // Label - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - // need to move labelattributemodel to different method - try? ModelRegistry.register(LabelAttributeFontModel.self) - try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... - try? ModelRegistry.register(LabelAttributeUnderlineModel.self) - try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - try? ModelRegistry.register(LabelAttributeActionModel.self) - - // Buttons - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) - - // Entry Field - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - - // Other Atoms - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) - - // 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: HeadlineBodyLink.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: LabelToggle.self, viewModelClass: LabelToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - - // List items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.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: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.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) - - // Designed List Items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableButtonAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - - // Designed Section Dividers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - - // Designed Headers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) - - // TODO: Need model - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - - // TODO: Need View - try? ModelRegistry.register(TabsModel.self) - - // Helper models - try? ModelRegistry.register(RuleRequiredModel.self) - try? ModelRegistry.register(RuleAnyRequiredModel.self) - try? ModelRegistry.register(RuleAnyValueChangedModel.self) - try? ModelRegistry.register(RuleAllValueChangedModel.self) - try? ModelRegistry.register(RuleEqualsModel.self) - try? ModelRegistry.register(RuleRegexModel.self) - - // Actions - try? ModelRegistry.register(ActionTopAlertModel.self) - try? ModelRegistry.register(ActionCollapseNotificationModel.self) - try? ModelRegistry.register(ActionOpenPanelModel.self) - } -} From 9cb75817e5f56695e6bf67e4112ae87bb1ae1930 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 19:15:49 -0400 Subject: [PATCH 134/244] check previous content --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 41 +++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 6e22d3f5..72c8c33a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -27,6 +27,10 @@ import WebKit super.setupView() createWebView(messageHandler: mvmWebViewMessageHandler) pinSpinnerView() + + //init height for loading spinner + webViewHeight = webView?.heightAnchor.constraint(equalToConstant: 44) + webViewHeight?.isActive = true } func createWebView(messageHandler: String?) { @@ -44,24 +48,37 @@ import WebKit addSubview(webView) NSLayoutConstraint.constraintPinSubview(toSuperview: webView) } - // MARK: - MVMCoreUIMoleculeViewProtocol override open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + + //store the previous webview properties + let previousHtmlString = webviewModel?.htmlString + let previousURL = webView?.url + super.set(with: model, delegateObject, additionalData) self.delegateObject = delegateObject - //init height for loading spinner - webViewHeight = webView?.heightAnchor.constraint(equalToConstant: 44) - webViewHeight?.isActive = true if let height = webviewModel?.height { webViewHeight?.constant = height dynamicHeight = false } if let url = webviewModel?.url { - webView?.load(URLRequest(url: url)) + if let previousUrl = previousURL, url == previousUrl { + //dont load the new + } else { + webView?.load(URLRequest(url: url)) + webViewHeight?.constant = 44 + loadingSpinner.resumeSpinner() + } } else if let htmlString = webviewModel?.htmlString { - webView?.loadHTMLString(htmlString, baseURL: nil) + if let previousHTML = previousHtmlString, previousHTML == htmlString { + //dont load the new html since they are the same html string as preivous + } else { + webViewHeight?.constant = 44 + webView?.loadHTMLString(htmlString, baseURL: nil) + loadingSpinner.resumeSpinner() + } } if let borderColor = webviewModel?.borderColor?.cgColor { @@ -105,8 +122,16 @@ extension WebView : WKUIDelegate { */ if !webView.isLoading { webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in - guard let self = self, let height = result as? CGFloat else { return } - self.webViewHeight?.constant = height + guard let self = self else { + return + } + if let height = result as? CGFloat { + self.webViewHeight?.constant = height + } else { + //if failed to get height from javascript, using scrollview.contensize's height + let scrollHeight = self.webView?.scrollView.contentSize.height + self.webViewHeight?.constant = scrollHeight ?? 44 + } self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) }) } From 95d305254f937995d67b1bf3faf81910e7be3e71 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 19:28:31 -0400 Subject: [PATCH 135/244] add overlay --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 72c8c33a..dd8b9776 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -17,6 +17,7 @@ import WebKit return model as? WebViewModel } var webView: WKWebView? + var overLayer = MVMCoreUICommonViewsUtility.commonView() public let loadingSpinner = MFLoadingSpinner(frame: .zero) var delegateObject: MVMCoreUIDelegateObject? var webViewHeight: NSLayoutConstraint? @@ -26,6 +27,7 @@ import WebKit override open func setupView() { super.setupView() createWebView(messageHandler: mvmWebViewMessageHandler) + setupOverLayer() pinSpinnerView() //init height for loading spinner @@ -69,6 +71,7 @@ import WebKit } else { webView?.load(URLRequest(url: url)) webViewHeight?.constant = 44 + overLayer.isHidden = false loadingSpinner.resumeSpinner() } } else if let htmlString = webviewModel?.htmlString { @@ -77,6 +80,7 @@ import WebKit } else { webViewHeight?.constant = 44 webView?.loadHTMLString(htmlString, baseURL: nil) + overLayer.isHidden = false loadingSpinner.resumeSpinner() } } @@ -88,8 +92,6 @@ import WebKit webView?.layer.borderWidth = 0.0 webView?.layer.borderColor = UIColor.clear.cgColor } - - bringSubviewToFront(loadingSpinner) } func pinSpinnerView() { @@ -104,6 +106,12 @@ import WebKit loadingSpinner.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true loadingSpinner.resumeSpinner() } + + func setupOverLayer() { + addSubview(overLayer) + overLayer.backgroundColor = .white + NSLayoutConstraint.constraintPinSubview(toSuperview: overLayer) + } } @@ -111,6 +119,7 @@ import WebKit extension WebView : WKUIDelegate { public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { // hide loading + overLayer.isHidden = true loadingSpinner.pause() //update webview's heigth when webview is ready From 4abfeef11ac426a8209e5c9bff2b1af2b5afa894 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 19:32:36 -0400 Subject: [PATCH 136/244] add stop loading, although it not loading --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index dd8b9776..997f0f96 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -69,6 +69,7 @@ import WebKit if let previousUrl = previousURL, url == previousUrl { //dont load the new } else { + webView?.stopLoading() webView?.load(URLRequest(url: url)) webViewHeight?.constant = 44 overLayer.isHidden = false @@ -78,6 +79,7 @@ import WebKit if let previousHTML = previousHtmlString, previousHTML == htmlString { //dont load the new html since they are the same html string as preivous } else { + webView?.stopLoading() webViewHeight?.constant = 44 webView?.loadHTMLString(htmlString, baseURL: nil) overLayer.isHidden = false From 0edc7a8f00472e07d2c58e1fe02e43fe9f9c4971 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Wed, 1 Apr 2020 19:51:19 -0400 Subject: [PATCH 137/244] update based on Scott's comment --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 8 ++++---- MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 997f0f96..4244c330 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -60,8 +60,9 @@ import WebKit super.set(with: model, delegateObject, additionalData) self.delegateObject = delegateObject - + var webViewHeightConstant: CGFloat = 44 if let height = webviewModel?.height { + webViewHeightConstant = height webViewHeight?.constant = height dynamicHeight = false } @@ -71,7 +72,7 @@ import WebKit } else { webView?.stopLoading() webView?.load(URLRequest(url: url)) - webViewHeight?.constant = 44 + webViewHeight?.constant = webViewHeightConstant overLayer.isHidden = false loadingSpinner.resumeSpinner() } @@ -80,7 +81,7 @@ import WebKit //dont load the new html since they are the same html string as preivous } else { webView?.stopLoading() - webViewHeight?.constant = 44 + webViewHeight?.constant = webViewHeightConstant webView?.loadHTMLString(htmlString, baseURL: nil) overLayer.isHidden = false loadingSpinner.resumeSpinner() @@ -106,7 +107,6 @@ import WebKit loadingSpinner.widthAnchor.constraint(equalToConstant: 44.0).isActive = true loadingSpinner.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true loadingSpinner.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true - loadingSpinner.resumeSpinner() } func setupOverLayer() { diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift index d20a5007..25142fa5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift @@ -16,7 +16,6 @@ import Foundation public var htmlString: String? public var height: CGFloat? public var borderColor: Color? - public var buttonMap: [String: ButtonModel]? private enum CodingKeys: String, CodingKey{ case moleculeName @@ -24,7 +23,6 @@ import Foundation case url case htmlString case height - case buttonMap case borderColor } @@ -33,8 +31,10 @@ import Foundation backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) url = try typeContainer.decodeIfPresent(URL.self, forKey: .url) htmlString = try typeContainer.decodeIfPresent(String.self, forKey: .htmlString) + if url == nil, htmlString == nil { + throw ModelRegistry.Error.decoderErrorModelNotMapped + } height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height) - buttonMap = try typeContainer.decodeIfPresent([String: ButtonModel].self, forKey: .buttonMap) borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) } From c723d96cbf470870dc62e8978d01df411f082140 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 2 Apr 2020 08:48:24 -0400 Subject: [PATCH 138/244] removed comment --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index e74e57de..a630f63a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -760,8 +760,6 @@ public typealias ActionBlock = () -> () */ static func getTextAttachmentImage(name: String = "externalLink", dimension: CGFloat) -> NSTextAttachment { -// let dimension = round(dimension * 0.8) - let imageAttachment = NSTextAttachment() imageAttachment.image = MVMCoreUIUtility.imageNamed(name) imageAttachment.bounds = CGRect(x: 0, y: 0, width: dimension, height: dimension) From 39e2001533a08dcdf136acebd3baa3ef90579f73 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 2 Apr 2020 10:18:40 -0400 Subject: [PATCH 139/244] fiix --- MVMCoreUI/FormUIHelpers/FormValidator.swift | 3 +++ MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index 7012e64d..592132f5 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -48,6 +48,9 @@ import MVMCore if let validator = delegate?.formValidator { validator.delegate = delegate validator.insert(item) + + // TODO: Temporary hacks, rewrite architecture to support this. + _ = validator.validate() } } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift index 3900249a..cfff35eb 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift @@ -11,7 +11,7 @@ import Foundation public class RuleRequiredModel: RulesProtocol { - public static var identifier: String = "required" + public static var identifier: String = "allRequired" public var type: String = RuleRequiredModel.identifier public var fields: [String] From 614a2b89c8c6df204644e31cff10652720d5b199 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 2 Apr 2020 10:42:23 -0400 Subject: [PATCH 140/244] code review --- MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift | 14 +++++++++----- MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift | 8 ++++---- MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift index ba0ce96b..5e45b6ed 100644 --- a/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift +++ b/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift @@ -8,11 +8,15 @@ public extension Dictionary { - func asActionModel() -> ActionModelProtocol? { - guard let castedSelf = self as? [String: Any], - let actionType = ModelRegistry.getType(for: castedSelf.stringForkey(KeyActionType), with: ActionModelProtocol.self), - let actionModel = try? actionType.decode(jsonDict: castedSelf) as? ActionModelProtocol else { - return nil + func asActionModel() throws -> ActionModelProtocol { + guard let castedSelf = self as? [String: Any] else { + throw ModelRegistry.Error.decoderOther(message: "Dictionary is not of type [String: Any]") + } + guard let actionType = ModelRegistry.getType(for: castedSelf.stringForkey(KeyActionType), with: ActionModelProtocol.self) else { + throw ModelRegistry.Error.decoderErrorModelNotMapped + } + guard let actionModel = try actionType.decode(jsonDict: castedSelf) as? ActionModelProtocol else { + throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol") } return actionModel } diff --git a/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift index 449227e3..3672a21f 100644 --- a/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift +++ b/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift @@ -12,11 +12,11 @@ public extension FooterModel { var primaryButtonModel: ButtonModel? var secondaryButtonModel: ButtonModel? - if let primaryActionModel = primaryMap?.asActionModel() { - primaryButtonModel = ButtonModel(primaryButtonWith: primaryActionModel.title ?? "", action: primaryActionModel) + if let primaryActionModel = try? primaryMap?.asActionModel(), let title = primaryActionModel.title { + primaryButtonModel = ButtonModel(primaryButtonWith: title, action: primaryActionModel) } - if let secondaryActionModel = secondaryMap?.asActionModel() { - secondaryButtonModel = ButtonModel(secondaryButtonWith: secondaryActionModel.title ?? "", action: secondaryActionModel) + if let secondaryActionModel = try? secondaryMap?.asActionModel(), let title = secondaryActionModel.title { + secondaryButtonModel = ButtonModel(secondaryButtonWith: title, action: secondaryActionModel) } let twoButtonModel = TwoButtonViewModel(primaryButtonModel, secondaryButtonModel) diff --git a/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift index 757b2ccb..396de6ea 100644 --- a/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift +++ b/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift @@ -16,7 +16,7 @@ public extension LabelModel { titlePrefix += " " } if !titlePostfix.isEmpty { - titlePostfix += " " + titlePostfix = " " + titlePostfix } let title = linkAction.optionalStringForKey(KeyTitle) ?? "" let text = "\(titlePrefix)\(title)\(titlePostfix)" @@ -25,7 +25,7 @@ public extension LabelModel { self.init(text: text) // Add action attribute. - if let linkActionModel = linkAction.asActionModel() { + if let linkActionModel = try? linkAction.asActionModel() { attributes = [LabelAttributeActionModel(titlePrefix.isEmpty ? 0 : titlePrefix.count, title.count, action: linkActionModel)] } } From 8788d98323186ac52a025bbaafb058ddb5e4a21f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 2 Apr 2020 11:20:17 -0400 Subject: [PATCH 141/244] updates --- MVMCoreUI/Styles/Padding.swift | 5 +---- MVMCoreUI/Styles/Styler.swift | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift index bdd65837..b47a64c5 100644 --- a/MVMCoreUI/Styles/Padding.swift +++ b/MVMCoreUI/Styles/Padding.swift @@ -24,7 +24,6 @@ public struct Padding { public static let TableCellParagraphSpace: CGFloat = 3 public static let FooterLabelParagraphSpace: CGFloat = 4 - public static let WebViewInset: CGFloat = 8 public static let HeightTableSeperatorHeight: CGFloat = 1 public static let MFHeightForSwitch: CGFloat = 22 public static let MFWidthForSwitch: CGFloat = 42 @@ -33,9 +32,7 @@ public struct Padding { public static let MinCellHeight: CGFloat = 96 public static let HeightIphone5: CGFloat = 568 public static let DefaultOptionCellHeight: CGFloat = 120 - public static let PromoViewHeight: CGFloat = 41.9 public static let BetweenFields: CGFloat = 24 - public static let LabelWithInternalButtonLineSpace: CGFloat = 2 public static let PrimaryButtonTop: CGFloat = 36 public struct Default { @@ -45,7 +42,7 @@ public struct Padding { public static let VerticalSpacing3: CGFloat = 24 public static var HorizontalPaddingForApplicationWidth: CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 + return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalSpacing } public static var VerticalPaddingForApplicationWidth: CGFloat { diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 75d81b89..46210b9c 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -104,7 +104,7 @@ open class Styler { } open class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat { - return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? 0 + return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? size } //-------------------------------------------------- From 3279ef91fdcd6b4be45b8a4d3b3655e80a2a6939 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Thu, 2 Apr 2020 13:40:24 -0400 Subject: [PATCH 142/244] update did fail method --- MVMCoreUI/Atomic/Atoms/Views/WebView.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift index 4244c330..1ce2b123 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebView.swift @@ -148,12 +148,11 @@ extension WebView : WKUIDelegate { } } - public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { - // show loading - loadingSpinner.resumeSpinner() - } - public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { - // hide loading + + public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { + //actually no error handle page show in webview. We can handle the error display view by our self. + //or stop loading by default + overLayer.isHidden = true loadingSpinner.pause() } From c9bb3ce1f389553ae05be14af7b42cf1c4aeac1b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 2 Apr 2020 17:16:04 -0400 Subject: [PATCH 143/244] including 2.0 legacy as it's being used in some molecular at the moment. --- .../Views/Label/LabelAttributeFontModel.swift | 4 +- .../Atomic/Atoms/Views/Label/LabelModel.swift | 29 +---- MVMCoreUI/Styles/Styler.swift | 104 +++++++++++++++--- 3 files changed, 90 insertions(+), 47 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift index 437bb6f8..862f8f9b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift @@ -18,7 +18,7 @@ import UIKit return "font" } - var style: LabelModel.FontStyle? + var style: Styler.Font? var name: String? var size: CGFloat? @@ -38,7 +38,7 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - style = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .style) + style = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .style) name = try typeContainer.decodeIfPresent(String.self, forKey: .name) size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) try super.init(from: decoder) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 74e6efa4..4ec23ad6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -10,31 +10,6 @@ import Foundation @objcMembers public class LabelModel: MoleculeModelProtocol { - - public enum FontStyle: String, Codable { - case Title2XLarge - case TitleXLarge - case BoldTitleLarge - case RegularTitleLarge - case BoldTitleMedium - case RegularTitleMedium - case BoldBodyLarge - case RegularBodyLarge - case BoldBodySmall - case RegularBodySmall - case BoldMicro - case RegularMicro - // Legacy - case H1 - case H2 - case H3 - case H32 - case B1 - case B2 - case B3 - case B20 - } - //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -44,7 +19,7 @@ import Foundation public var text: String public var accessibilityText: String? public var textColor: Color? - public var fontStyle: FontStyle? + public var fontStyle: Styler.Font? public var fontName: String? public var fontSize: CGFloat? public var textAlignment: NSTextAlignment? @@ -95,7 +70,7 @@ import Foundation accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - fontStyle = try typeContainer.decodeIfPresent(FontStyle.self, forKey: .fontStyle) + fontStyle = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .fontStyle) fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 46210b9c..57b0ad18 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -14,7 +14,7 @@ open class Styler { // MARK: - Enums //-------------------------------------------------- - public enum Font: String { + public enum Font: String, Codable { case Title2XLarge case TitleXLarge case BoldTitleLarge @@ -28,31 +28,56 @@ open class Styler { case BoldMicro case RegularMicro + // Legacy Fonts + case H1 + case H2 + case H3 + case H32 + case B1 + case B2 + case B3 + case B20 + public func pointSize() -> CGFloat { switch self { + case .H1: + return 40 + case .Title2XLarge: return 36 - case .TitleXLarge: + case .TitleXLarge, + .H32: return 32 + case .H2: + return 25 + case .BoldTitleLarge, .RegularTitleLarge: return 24 case .BoldTitleMedium, - .RegularTitleMedium: + .RegularTitleMedium, + .B20: return 20 + case .H3: + return 18 + case .BoldBodyLarge, .RegularBodyLarge: return 16 case .BoldBodySmall, - .RegularBodySmall: + .RegularBodySmall, + .B1, + .B2: return 13 - case .BoldMicro, .RegularMicro: + case .BoldMicro, + .RegularMicro, + .B3: return 11 } } @@ -66,14 +91,51 @@ open class Styler { .RegularTitleMedium, .RegularBodyLarge, .RegularBodySmall, - .RegularMicro: + .RegularMicro, + .B2, + .B3, + .B20: return false case .BoldTitleLarge, + .BoldTitleMedium, + .BoldBodyLarge, + .BoldBodySmall, + .BoldMicro, + .H1, + .H2, + .H3, + .H32, + .B1: + return true + } + } + + public func isLegacyFont() -> Bool { + + switch self { + case .Title2XLarge, + .TitleXLarge, + .RegularTitleLarge, + .RegularTitleMedium, + .RegularBodyLarge, + .RegularBodySmall, + .RegularMicro, + .BoldTitleLarge, .BoldTitleMedium, .BoldBodyLarge, .BoldBodySmall, .BoldMicro: + return false + + case .H1, + .H2, + .H3, + .H32, + .B1, + .B2, + .B3, + .B20: return true } } @@ -81,7 +143,23 @@ open class Styler { public func getFont(_ genericScaling: Bool = true) -> UIFont? { let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize() - return getMVA3FontSize(size, isBold: isBold()) + + if isLegacyFont() { + switch self { + case .B2, .B3, .B20: + return MFFonts.mfFont55Rg(size) + + default: + return MFFonts.mfFont75Bd(size) + } + } else { + if isBold() { + return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) + + } else { + return size >= 15 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) + } + } } public func styleLabel(_ label: UILabel, genericScaling: Bool = true) { @@ -90,7 +168,7 @@ open class Styler { label.textColor = .black } } - + //-------------------------------------------------- // MARK: - Functions //-------------------------------------------------- @@ -129,14 +207,4 @@ open class Styler { MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: top, trailing: horizontalPadding, bottom: bottom) } } - - open class func getMVA3FontSize(_ size: CGFloat, isBold: Bool) -> UIFont { - - if isBold { - return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) - - } else { - return size >= 15 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) - } - } } From 5098bc911bda89e417c9f3fd0b7e2c7dfec719d9 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 2 Apr 2020 17:51:19 -0400 Subject: [PATCH 144/244] code review - extra spacing --- MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift index 396de6ea..6b94f63e 100644 --- a/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift +++ b/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift @@ -10,15 +10,15 @@ public extension LabelModel { convenience init(linkAction: [AnyHashable: Any]) { // Concatentate the text. + let title = linkAction.stringForkey(KeyTitle) var titlePrefix = linkAction.stringForkey(KeyTitlePrefix) var titlePostfix = linkAction.stringForkey(KeyTitlePostfix) - if !titlePrefix.isEmpty { + if !titlePrefix.isEmpty && (!title.isEmpty || !titlePostfix.isEmpty) { titlePrefix += " " } - if !titlePostfix.isEmpty { + if !titlePostfix.isEmpty && !title.isEmpty { titlePostfix = " " + titlePostfix } - let title = linkAction.optionalStringForKey(KeyTitle) ?? "" let text = "\(titlePrefix)\(title)\(titlePostfix)" // Initialize with text. From bcffe0bbd207eb8326d0c60c1324dc10473d05a1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 2 Apr 2020 20:28:47 -0400 Subject: [PATCH 145/244] Percent update --- .../ThreeColumn/ListThreeColumnInternationalDataDivider.swift | 4 ++-- .../ListThreeColumnInternationalDataDividerModel.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift index 42d3d39f..7b6af23d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDivider.swift @@ -20,8 +20,8 @@ import Foundation public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading)), - (view: centerLabel, model: StackItemModel(percent: 40, horizontalAlignment: .leading)), - (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .center))], + (view: centerLabel, model: StackItemModel(percent: 50, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent: 20, horizontalAlignment: .leading))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift index 51786004..a5f3bcf6 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift @@ -8,13 +8,13 @@ import Foundation -public class ListThreeColumnInternationalDataDividerModel : ListItemModel, MoleculeModelProtocol { +public class ListThreeColumnInternationalDataDividerModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "list3CIntDataDiv" public var leftLabel: LabelModel public var centerLabel: LabelModel public var rightLabel: LabelModel - public init (leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel) { + public init (leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { self.leftLabel = leftLabel self.centerLabel = centerLabel self.rightLabel = rightLabel From 96115b7a5da4f8ef79d07ff76c0f8981a18629d1 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Fri, 3 Apr 2020 12:45:32 +0530 Subject: [PATCH 146/244] border changes updated --- .../Views/RadioBoxCollectionViewCell.swift | 82 +++++++++++++------ .../Atomic/Atoms/Views/RadioBoxModel.swift | 8 +- MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 73 ++++++++--------- .../Atomic/Atoms/Views/RadioBoxesModel.swift | 1 - 4 files changed, 96 insertions(+), 68 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift index 532ff34f..c709cf4b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift @@ -8,28 +8,37 @@ import Foundation open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtocol { - + public let bodyLabel = Label.commonLabelB2(true) public let lineView = View(frame: .zero) - - var bottomView = MVMCoreUICommonViewsUtility.commonView() - public var lineViewHeight: NSLayoutConstraint? + public var fieldValue: String? open override var isSelected: Bool{ didSet{ - lineViewHeight?.constant = isSelected ? 4.0 : 0 - bottomView.layer.borderColor = isSelected ? UIColor.mfGet(forHex: "#0000").cgColor:UIColor.mfGet(forHex: "#747676").cgColor - + self.lineViewHeight?.constant = self.isSelected ? 4.0 : 0 + self.bottomView.layer.sublayers?.filter({$0.name == "border"}).forEach({$0.removeFromSuperlayer()}) + if(self.isSelected){ + self.bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) + self.bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) + self.bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) + } + else { + self.addBordertoView() + } } } public override init(frame: CGRect) { super.init(frame: .zero) setupView() } - + open override func layoutSubviews() { + super.layoutSubviews() + addBordertoView() + + } public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) setupView() @@ -44,7 +53,6 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco insetsLayoutMarginsFromSafeArea = false contentView.insetsLayoutMarginsFromSafeArea = false contentView.preservesSuperviewLayoutMargins = false - contentView.addSubview(bottomView) NSLayoutConstraint.constraintPinSubview(toSuperview: bottomView) @@ -54,34 +62,58 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco lineViewHeight = lineView.heightAnchor.constraint(equalToConstant: 0) lineViewHeight?.isActive = true - bodyLabel.translatesAutoresizingMaskIntoConstraints = false + bodyLabel.numberOfLines = 0 bottomView.addSubview(bodyLabel) NSLayoutConstraint.constraintPinSubview(bodyLabel, pinTop: false, topConstant:0 , pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 12, pinRight: true, rightConstant: 12) bodyLabel.topAnchor.constraint(equalTo: lineView.bottomAnchor, constant: 12).isActive = true - bodyLabel.bottomAnchor.constraint(greaterThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true - - bottomView.layer.borderWidth = 1.0 - bottomView.layer.borderColor = UIColor.mfGet(forHex: "#747676").cgColor - - + bodyLabel.bottomAnchor.constraint(lessThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true } - - + private func addBordertoView(){ + bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) + bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) + bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) + bottomView.layer.addBorder(edge: .top, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) + } + + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let collectionModel = model as? RadioBoxModel else { return } - if let backgroundColor = collectionModel.backgroundColor { self.bottomView.backgroundColor = backgroundColor.uiColor } -// self.bottomView.backgroundColor = .red lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor bodyLabel.text = collectionModel.text - - - + isSelected = collectionModel.selected ?? false + fieldValue = collectionModel.fieldValue } - - +} +extension CALayer { + + func addBorder(edge: UIRectEdge, color: UIColor, thickness: CGFloat) { + + let border = CALayer() + border.name = "border" + switch edge { + case UIRectEdge.top: + border.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: thickness) + break + case UIRectEdge.bottom: + border.frame = CGRect(x: 0, y: self.frame.height - thickness, width: self.frame.width, height: thickness) + break + case UIRectEdge.left: + border.frame = CGRect(x: 0, y: 0, width: thickness, height: self.frame.height) + break + case UIRectEdge.right: + border.frame = CGRect(x: self.frame.width - thickness, y: 0, width: thickness, height: self.frame.height) + break + default: + break + } + + border.backgroundColor = color.cgColor; + self.addSublayer(border) + } + } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift index 21adcb13..0e72f6e5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -11,8 +11,9 @@ import Foundation public static var identifier: String = "radioBox" public var text: String public var backgroundColor: Color? = Color(uiColor: .white) - public var selectedAccentColor: Color? = Color(uiColor: .red) + public var selectedAccentColor: Color? = try? Color(colorString: "#D52B1E") public var selected: Bool? = false + public var strikethrough: Bool? = false public var fieldValue: String? private enum CodingKeys: String, CodingKey { @@ -21,6 +22,7 @@ import Foundation case selectedAccentColor case backgroundColor case selected + case strikethrough case fieldValue } @@ -38,6 +40,9 @@ import Foundation if let isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .selected) { selected = isSelected } + if let isStrikeTrough = try typeContainer.decodeIfPresent(Bool.self, forKey: .strikethrough) { + strikethrough = isStrikeTrough + } fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) } @@ -48,6 +53,7 @@ import Foundation try container.encode(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(selected, forKey: .selected) + try container.encodeIfPresent(strikethrough, forKey: .strikethrough) try container.encodeIfPresent(fieldValue, forKey: .fieldValue) } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift index 9cc6ae5f..39f03c40 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -7,21 +7,23 @@ // import Foundation -open class RadioBoxes: View { +open class RadioBoxes: View { + public let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) /// The models for the molecules. - var molecules: [MoleculeModelProtocol]? + var boxes: [RadioBoxModel]? + public var fieldKey: String? + public var groupName: String? + public var enabled: Bool? - - /// The height of the carousel. Default is 300. public var collectionViewHeight: NSLayoutConstraint? - - public var delegateObject: MVMCoreUIDelegateObject? + private let boxWidth: Double = 151.0 + private let boxHeight: Double = 64.0 + private let itemSpacing: Double = 10.0 + private let leadingSpacing: Double = 0 - - // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() @@ -35,22 +37,21 @@ open class RadioBoxes: View { collectionView.backgroundColor = .clear collectionView.isAccessibilityElement = false addSubview(collectionView) - + NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView) collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) collectionViewHeight?.isActive = true - NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView) - + } - // MARK: - MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - self.delegateObject = delegateObject super.set(with: model, delegateObject, additionalData) guard let radioBoxesModel = model as? RadioBoxesModel else { return } - backgroundColor = .white - + backgroundColor = radioBoxesModel.backgroundColor?.uiColor + fieldKey = radioBoxesModel.fieldKey + groupName = radioBoxesModel.groupName + enabled = radioBoxesModel.enabled registerCells() setupLayout(with: radioBoxesModel) prepareMolecules(with: radioBoxesModel) @@ -59,64 +60,54 @@ open class RadioBoxes: View { // MARK: - JSON Setters /// Updates the layout being used - + func setupLayout(with carouselModel: RadioBoxesModel?) { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical + layout.sectionInset = UIEdgeInsets.init(top: CGFloat(leadingSpacing), left: CGFloat(leadingSpacing), bottom: CGFloat(leadingSpacing), right: CGFloat(leadingSpacing)) layout.minimumLineSpacing = 10 layout.minimumInteritemSpacing = 10 collectionView.collectionViewLayout = layout } - + func prepareMolecules(with radioBoxesModel: RadioBoxesModel?) { guard let newMolecules = radioBoxesModel?.boxes else { - molecules = nil + boxes = nil return } - molecules = newMolecules - collectionView.reloadData() - + boxes = newMolecules + let height = Double(round(Double((boxes?.count ?? Int(0.0)))/2.0))*(boxHeight+10.0) + collectionViewHeight?.constant = CGFloat(height) + collectionViewHeight?.isActive = true } - - + /// Registers the cells with the collection view func registerCells() { collectionView.register(RadioBoxCollectionViewCell.self, forCellWithReuseIdentifier: "RadioBoxCollectionViewCell") } - - - // MARK: - Convenience - /// Returns the (identifier, class) of the molecule for the given map. - func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? { - guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { - return nil - } - return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) - } } extension RadioBoxes: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let itemWidth = (collectionView.bounds.width - 30)/2 - return CGSize(width: itemWidth, height: 64) + let itemWidth = (Double(collectionView.bounds.width) - itemSpacing)/2 + return CGSize(width: CGFloat(150.5), height: CGFloat(boxHeight)) } - - } extension RadioBoxes: UICollectionViewDataSource { open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return molecules?.count ?? 0 + return boxes?.count ?? 0 } open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let molecule = molecules?[indexPath.row], let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RadioBoxCollectionViewCell", for: indexPath) as? RadioBoxCollectionViewCell else { - return UICollectionViewCell() + guard let molecule = boxes?[indexPath.row], let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RadioBoxCollectionViewCell", for: indexPath) as? RadioBoxCollectionViewCell else { + return UICollectionViewCell() } - cell.set(with: molecule, delegateObject, nil) + cell.set(with: molecule, nil, nil) (cell as? MVMCoreViewProtocol)?.updateView(collectionView.bounds.width) + cell.layoutIfNeeded() return cell } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift index 80425bde..ab2b4728 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift @@ -24,7 +24,6 @@ import Foundation case boxes case fieldKey case groupName - } required public init(from decoder: Decoder) throws { From e88e661e1f738ff311f1694a3c8e56e8bc070803 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 3 Apr 2020 14:38:24 +0530 Subject: [PATCH 147/244] Resolving conflicts --- MVMCoreUI.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b751919b..49ac139e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -177,8 +177,6 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; - AA72AF172424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA72AF162424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift */; }; - AA72AF192424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA72AF182424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */; }; @@ -572,8 +570,6 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; - AA72AF162424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestDivider.swift; sourceTree = ""; }; - AA72AF182424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestDividerModel.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinksModel.swift; sourceTree = ""; }; @@ -1284,8 +1280,6 @@ 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */, 8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */, - AA72AF162424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift */, - AA72AF182424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -2146,7 +2140,6 @@ 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */, 94C0150A24215643005811A9 /* ActionTopAlertModel.swift in Sources */, - AA72AF172424838E00BFA6C2 /* ListThreeColumnSpeedTestDivider.swift in Sources */, 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, @@ -2179,7 +2172,6 @@ D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, 94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */, - AA72AF192424839F00BFA6C2 /* ListThreeColumnSpeedTestDividerModel.swift in Sources */, 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, From e122b8ce237b87202fb309e1e874a6ab6fc0335b Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Fri, 3 Apr 2020 16:17:40 +0530 Subject: [PATCH 148/244] files added --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 49ac139e..0e68c506 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -189,6 +189,8 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; + BBBBC87C24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBBBC87A24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift */; }; + BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */; }; 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 */; }; @@ -582,6 +584,8 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; + BBBBC87A24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillChangesDivider.swift; sourceTree = ""; }; + BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillChangesDividerModel.swift; 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 = ""; }; @@ -1276,6 +1280,8 @@ D22B38ED23F4E11100490EF6 /* ThreeColumn */ = { isa = PBXGroup; children = ( + BBBBC87A24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift */, + BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */, 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */, @@ -1978,6 +1984,7 @@ 011D9602240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, + BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */, @@ -2155,6 +2162,7 @@ D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */, + BBBBC87C24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, From dae31e77da5d7b59ad7ed0ff7b291664dfa07c16 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 3 Apr 2020 16:40:40 +0530 Subject: [PATCH 149/244] 19180(List - Three Column - Speed Test - Divider) commit --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../ListThreeColumnSpeedTestDivider.swift | 63 +++++++++++++++++++ ...ListThreeColumnSpeedTestDividerModel.swift | 53 ++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 49ac139e..9ec54660 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -177,6 +177,8 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; + AA1EC59724373985003D6F50 /* ListThreeColumnSpeedTestDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA1EC59624373985003D6F50 /* ListThreeColumnSpeedTestDividerModel.swift */; }; + AA1EC59924373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA1EC59824373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */; }; @@ -570,6 +572,8 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; + AA1EC59624373985003D6F50 /* ListThreeColumnSpeedTestDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestDividerModel.swift; sourceTree = ""; }; + AA1EC59824373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestDivider.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinksModel.swift; sourceTree = ""; }; @@ -1280,6 +1284,8 @@ 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */, 8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */, + AA1EC59624373985003D6F50 /* ListThreeColumnSpeedTestDividerModel.swift */, + AA1EC59824373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -1985,6 +1991,7 @@ D2E2A99F23E07F8A000B42E6 /* PillButton.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, + AA1EC59724373985003D6F50 /* ListThreeColumnSpeedTestDividerModel.swift in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */, 014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */, @@ -2070,6 +2077,7 @@ BB54C5212434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, + AA1EC59924373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift in Sources */, 942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */, 8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */, 01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 438f652b..90c3c19d 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -149,6 +149,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalDataDivider.self, viewModelClass: ListThreeColumnInternationalDataDividerModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnSpeedTestDivider.self, viewModelClass: ListThreeColumnSpeedTestDividerModel.self) // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift new file mode 100644 index 00000000..fd1ec64f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift @@ -0,0 +1,63 @@ +// +// ListThreeColumnSpeedTestDivider.swift +// MVMCoreUI +// +// Created by Lekshmi S on 03/04/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnSpeedTestDivider: TableViewCell { + + //------------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + let leftLabel = Label.createLabelBoldBodySmall(true) + let centerLabel = Label.createLabelBoldBodySmall(true) + let rightLabel = Label.createLabelBoldBodySmall(true) + var stack: Stack + + //------------------------------------------------------- + // MARK: - Initializers + //------------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal, spacing: 8) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + //------------------------------------------------------ + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnSpeedTestDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + open override func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + centerLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift new file mode 100644 index 00000000..6e590529 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift @@ -0,0 +1,53 @@ +// +// ListThreeColumnSpeedTestDividerModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 03/04/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnSpeedTestDividerModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list3CSpdTstDiv" + public var leftLabel: LabelModel + public var centerLabel: LabelModel + public var rightLabel: LabelModel + + public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} From 1efffcf33dbbb588043a3170669cfabaf405f42b Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 3 Apr 2020 17:40:46 +0530 Subject: [PATCH 150/244] Removed spacing --- .../ThreeColumn/ListThreeColumnSpeedTestDivider.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift index fd1ec64f..aa9fbc2d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift @@ -22,7 +22,7 @@ import Foundation // MARK: - Initializers //------------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal, spacing: 8) + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } From de6fe50c82776cef7d13c0ec3e922730d1349de8 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 3 Apr 2020 11:19:51 -0400 Subject: [PATCH 151/244] updates --- MVMCoreUI.xcodeproj/project.pbxproj | 12 +++------ MVMCoreUI/Styles/Padding.swift | 37 +++++----------------------- MVMCoreUI/Styles/Styler.swift | 17 ++++++++++--- MVMCoreUI/Styles/VogueProtocol.swift | 23 ----------------- 4 files changed, 23 insertions(+), 66 deletions(-) delete mode 100644 MVMCoreUI/Styles/VogueProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2679f3f0..f7bdfec3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -85,11 +85,10 @@ 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; - 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A92435125F00AD3CA1 /* Styler.swift */; }; - 0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AB243531C300AD3CA1 /* Padding.swift */; }; - 0A6682AE243538DB00AD3CA1 /* VogueProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */; }; 0A6682A22434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */; }; 0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */; }; + 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A92435125F00AD3CA1 /* Styler.swift */; }; + 0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AB243531C300AD3CA1 /* Padding.swift */; }; 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; }; 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; @@ -479,11 +478,10 @@ 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; - 0A6682A92435125F00AD3CA1 /* Styler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styler.swift; sourceTree = ""; }; - 0A6682AB243531C300AD3CA1 /* Padding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Padding.swift; sourceTree = ""; }; - 0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VogueProtocol.swift; sourceTree = ""; }; 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyText.swift; sourceTree = ""; }; 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyTextModel.swift; sourceTree = ""; }; + 0A6682A92435125F00AD3CA1 /* Styler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styler.swift; sourceTree = ""; }; + 0A6682AB243531C300AD3CA1 /* Padding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Padding.swift; sourceTree = ""; }; 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = ""; }; 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -1490,7 +1488,6 @@ D29DF13921E68637003B2FB9 /* MFStyler.m */, 0A6682A92435125F00AD3CA1 /* Styler.swift */, 0A6682AB243531C300AD3CA1 /* Padding.swift */, - 0A6682AD243538DB00AD3CA1 /* VogueProtocol.swift */, ); path = Styles; sourceTree = ""; @@ -2029,7 +2026,6 @@ AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, 011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */, - 0A6682AE243538DB00AD3CA1 /* VogueProtocol.swift in Sources */, AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift index b47a64c5..1c3bba53 100644 --- a/MVMCoreUI/Styles/Padding.swift +++ b/MVMCoreUI/Styles/Padding.swift @@ -22,50 +22,25 @@ public struct Padding { public static let Nine: CGFloat = 54 public static let Ten: CGFloat = 60 - public static let TableCellParagraphSpace: CGFloat = 3 - public static let FooterLabelParagraphSpace: CGFloat = 4 - public static let HeightTableSeperatorHeight: CGFloat = 1 - public static let MFHeightForSwitch: CGFloat = 22 - public static let MFWidthForSwitch: CGFloat = 42 - public static let DisableOppacity: CGFloat = 0.5 - public static let PaymentMethodViewHeightWidthMultiplier: CGFloat = 0.55 - public static let MinCellHeight: CGFloat = 96 - public static let HeightIphone5: CGFloat = 568 - public static let DefaultOptionCellHeight: CGFloat = 120 - public static let BetweenFields: CGFloat = 24 - public static let PrimaryButtonTop: CGFloat = 36 - public struct Default { public static let Standard: CGFloat = 24 public static let HorizontalSpacing: CGFloat = 32 public static let VerticalSpacing: CGFloat = 32 - public static let VerticalSpacing3: CGFloat = 24 public static var HorizontalPaddingForApplicationWidth: CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalSpacing + return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalSpacing } public static var VerticalPaddingForApplicationWidth: CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBasedOnApplicationWidth() ?? 0 + return MFSizeObject(scalingStandardSize: VerticalSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalSpacing } - public static func horizontalPadding(forSize size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultHorizontalSpacing)?.getValueBased(onSize: size) ?? 0 + public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat { + return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBased(onSize: size) ?? VerticalSpacing } - public static func verticalPadding(forSize size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: PaddingDefaultVerticalSpacing)?.getValueBased(onSize: size) ?? 0 + public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat { + return MFSizeObject(scalingStandardSize: VerticalSpacing)?.getValueBased(onSize: size) ?? VerticalSpacing } } - - public struct Horizontal { - public static let HeadlineWhiteView: CGFloat = 60 - public static let Large: CGFloat = 72 - public static let BetweenRelatedItems: CGFloat = 16 - } - - public struct Vertical { - public static let WhiteGrayView: CGFloat = 72 - public static let HeadlineAlternate: CGFloat = 48 - } } diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 57b0ad18..06a4b41f 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -178,6 +178,7 @@ open class Styler { let sizeObject = MFSizeObject(standardSize: size, standardiPadPortraitSize: size * 1.3) sizeObject?.addLargerThanCustomSize(size * 1.4, forThreshold: MFSizeStandardiPadLandscapeThreshold) sizeObject?.addLargerThanCustomSize(size * 1.5, forThreshold: MFSizeiPadProLandscapeThreshold) + return sizeObject } @@ -191,20 +192,28 @@ open class Styler { open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) { - let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0 + let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPaddingForSize(size) : 0 let verticalPadding: CGFloat = vertical ? PaddingDefaultVerticalSpacing3 : 0 DispatchQueue.main.async { - MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: verticalPadding, trailing: horizontalPadding, bottom: verticalPadding) + MVMCoreUIUtility.setMarginsFor(view, + leading: horizontalPadding, + top: verticalPadding, + trailing: horizontalPadding, + bottom: verticalPadding) } } open class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) { - let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPadding(forSize: size) : 0 + let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPaddingForSize(size) : 0 DispatchQueue.main.async { - MVMCoreUIUtility.setMarginsFor(view, leading: horizontalPadding, top: top, trailing: horizontalPadding, bottom: bottom) + MVMCoreUIUtility.setMarginsFor(view, + leading: horizontalPadding, + top: top, + trailing: horizontalPadding, + bottom: bottom) } } } diff --git a/MVMCoreUI/Styles/VogueProtocol.swift b/MVMCoreUI/Styles/VogueProtocol.swift deleted file mode 100644 index 1bd8e6a8..00000000 --- a/MVMCoreUI/Styles/VogueProtocol.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// VogueProtocol.swift -// MVMCoreUI -// -// Created by Kevin Christiano on 4/1/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - - -public protocol VogueProtocol { - -} - -public protocol VogueViewProtocol { - -} - -public protocol VogueTextProtocol: VogueProtocol { - func styleFont(_ font: UIFont) - func styleTextColor(_ textColor: UIColor) -} From c0d85694c68269980e578917edcfdeeac048a26f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 3 Apr 2020 11:25:29 -0400 Subject: [PATCH 152/244] more updates --- MVMCoreUI/Styles/Styler.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 06a4b41f..24a1d94c 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -162,6 +162,7 @@ open class Styler { } } + /// Styles the provided label to the declared enum Font case. public func styleLabel(_ label: UILabel, genericScaling: Bool = true) { label.font = getFont(genericScaling) From cf6db73acbdf05cfa45789725c1f3e6a60cd2d22 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 3 Apr 2020 11:28:05 -0400 Subject: [PATCH 153/244] comments --- MVMCoreUI/Styles/Styler.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 24a1d94c..2815873b 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -38,6 +38,7 @@ open class Styler { case B3 case B20 + /// Returns the font size of the current enum case. public func pointSize() -> CGFloat { switch self { case .H1: @@ -82,6 +83,7 @@ open class Styler { } } + /// Determines if the selected font case is bold or regular. public func isBold() -> Bool { switch self { @@ -111,6 +113,7 @@ open class Styler { } } + /// Determines if the current enum is a legacy or modern font. public func isLegacyFont() -> Bool { switch self { @@ -140,6 +143,7 @@ open class Styler { } } + /// Returns the font based on the declared enum case. public func getFont(_ genericScaling: Bool = true) -> UIFont? { let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize() From 1331c34579ccb8ce23425b3ad22d5c6cb2fca7e5 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 3 Apr 2020 13:10:14 -0400 Subject: [PATCH 154/244] changes made --- MVMCoreUI/Styles/Padding.swift | 3 ++- MVMCoreUI/Styles/Styler.swift | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift index 1c3bba53..6ef0cc62 100644 --- a/MVMCoreUI/Styles/Padding.swift +++ b/MVMCoreUI/Styles/Padding.swift @@ -26,6 +26,7 @@ public struct Padding { public static let Standard: CGFloat = 24 public static let HorizontalSpacing: CGFloat = 32 public static let VerticalSpacing: CGFloat = 32 + public static let VerticalSpacing3: CGFloat = 24 public static var HorizontalPaddingForApplicationWidth: CGFloat { return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalSpacing @@ -36,7 +37,7 @@ public struct Padding { } public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBased(onSize: size) ?? VerticalSpacing + return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBased(onSize: size) ?? HorizontalSpacing } public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat { diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 2815873b..75d0b9ee 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -195,10 +195,14 @@ open class Styler { // MARK: - Spacing //-------------------------------------------------- - open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat, horizontal: Bool = true, vertical: Bool = false) { + open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat?, horizontal: Bool = true, vertical: Bool = false) { - let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPaddingForSize(size) : 0 - let verticalPadding: CGFloat = vertical ? PaddingDefaultVerticalSpacing3 : 0 + var horizontalPadding: CGFloat = Padding.Default.HorizontalSpacing + let verticalPadding: CGFloat = vertical ? Padding.Default.VerticalSpacing3 : 0 + + if let size = size { + horizontalPadding = horizontal ? Padding.Default.horizontalPaddingForSize(size) : 0 + } DispatchQueue.main.async { MVMCoreUIUtility.setMarginsFor(view, From e4f561ca7d0aca90d99d96081d31e7e607b439cf Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 3 Apr 2020 13:16:50 -0400 Subject: [PATCH 155/244] lowercasd --- MVMCoreUI/Styles/Padding.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift index 6ef0cc62..ca99d5dc 100644 --- a/MVMCoreUI/Styles/Padding.swift +++ b/MVMCoreUI/Styles/Padding.swift @@ -28,11 +28,11 @@ public struct Padding { public static let VerticalSpacing: CGFloat = 32 public static let VerticalSpacing3: CGFloat = 24 - public static var HorizontalPaddingForApplicationWidth: CGFloat { + public static var horizontalPaddingForApplicationWidth: CGFloat { return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalSpacing } - public static var VerticalPaddingForApplicationWidth: CGFloat { + public static var verticalPaddingForApplicationWidth: CGFloat { return MFSizeObject(scalingStandardSize: VerticalSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalSpacing } From e0395bea0d2ceaa81abec9a699c384583e2aa109 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 3 Apr 2020 13:34:42 -0400 Subject: [PATCH 156/244] removed requested colors --- MVMCoreUI/Categories/UIColor+Extension.swift | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 81fe6743..76d5041e 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -33,7 +33,6 @@ extension UIColor { "green": (.mvmGreen, "#008330"), "green33": (.mvmGreen33, "#ABE4BF"), "green66": (.mvmGreen66, "#57C880"), - "greenShade1": (.mvmGreenShade1, "#178437"), "greenShade2": (.mvmGreenShade2, "#0F5B25"), "orange": (.mvmOrange, "#ED7000"), "orange66": (.mvmOrange66, "#F3A157"), @@ -47,10 +46,6 @@ extension UIColor { "blueShade1": (.mvmBlueShade1, "#136598"), "blueShade2": (.mvmBlueShade2, "#0B4467"), "yellow": (.mvmYellow, "#FFBC3D"), - "yellow33": (.mvmYellow33, "#FFE9BF"), - "yellow66": (.mvmYellow66, "#FFD37F"), - "yellowShade1": (.mvmYellowShade1, "#CC9630"), - "yellowShade2": (.mvmYellowShade2, "#997126"), "coolGray1": (.mvmCoolGray1, "#F6F6F6"), "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), @@ -149,9 +144,6 @@ extension UIColor { /// HEX: #57C880 public static let mvmGreen66 = UIColor.color8Bits(red: 87, green: 200, blue: 128) - /// HEX: #178437 - public static let mvmGreenShade1 = UIColor.color8Bits(red: 23, green: 132, blue: 55) - /// HEX: #0F5B25 public static let mvmGreenShade2 = UIColor.color8Bits(red: 15, green: 91, blue: 37) @@ -181,18 +173,6 @@ extension UIColor { /// HEX: #FFBC3D public static let mvmYellow = UIColor.color8Bits(red: 255, green: 188, blue: 61) - /// HEX: #FFE9BF - public static let mvmYellow33 = UIColor.color8Bits(red: 255, green: 233, blue: 191) - - /// HEX: #FFD37F - public static let mvmYellow66 = UIColor.color8Bits(red: 255, green: 211, blue: 127) - - /// HEX: #CC9630 - public static let mvmYellowShade1 = UIColor.color8Bits(red: 204, green: 150, blue: 48) - - /// HEX: #997126 - public static let mvmYellowShade2 = UIColor.color8Bits(red: 153, green: 113, blue: 38) - //-------------------------------------------------- // MARK: - Gray //-------------------------------------------------- From 3d85f826dcb6765cd3de9ca391a9b94be7922719 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 3 Apr 2020 13:48:59 -0400 Subject: [PATCH 157/244] updated blue hex --- MVMCoreUI/Categories/UIColor+Extension.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 76d5041e..1ef2e217 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -41,7 +41,7 @@ extension UIColor { "orangeShade2": (.mvmOrangeShade2, "#984700"), "orangeAA": (.mvmOrangeAA, "#CC4D0F"), "blue": (.mvmBlue, "#0077B4"), - "blue33": (.mvmBlue33, "#B1D8EF"), + "blue33": (.mvmBlue33, "#ABD8EF"), "blue66": (.mvmBlue66, "#57B1DF"), "blueShade1": (.mvmBlueShade1, "#136598"), "blueShade2": (.mvmBlueShade2, "#0B4467"), @@ -154,8 +154,8 @@ extension UIColor { /// HEX: #0077B4 public static let mvmBlue = UIColor.color8Bits(red: 0, green: 119, blue: 180) - /// HEX: #B1D8EF - public static let mvmBlue33 = UIColor.color8Bits(red: 87, green: 177, blue: 223) + /// HEX: #ABD8EF + public static let mvmBlue33 = UIColor.color8Bits(red: 171, green: 216, blue: 239) /// HEX: #57B1DF public static let mvmBlue66 = UIColor.color8Bits(red: 87, green: 177, blue: 223) From 29805d347a7e38c1a265a3e1a8c1e51cdfd15418 Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Fri, 3 Apr 2020 14:41:22 -0400 Subject: [PATCH 158/244] use new font for legacy --- MVMCoreUI/Utility/MFFonts.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Utility/MFFonts.m b/MVMCoreUI/Utility/MFFonts.m index 533b3a87..24c62a9a 100644 --- a/MVMCoreUI/Utility/MFFonts.m +++ b/MVMCoreUI/Utility/MFFonts.m @@ -85,14 +85,20 @@ NSString * const DS55Rg = @"NHaasGroteskDSStd-55Rg"; + (nonnull UIFont *)mfFont75Bd:(CGFloat)size { [self loadMVMFonts]; - UIFont *font = [UIFont fontWithName:DS75Bd size:size]; - return font ?: [UIFont boldSystemFontOfSize:size]; + if (size >= 15) { + return [MFFonts mfFontDSBold:size]; + } else { + return [MFFonts mfFontTXBold:size]; + } } + (nonnull UIFont *)mfFont55Rg:(CGFloat)size { [self loadMVMFonts]; - UIFont *font = [UIFont fontWithName:DS55Rg size:size]; - return font ?: [UIFont systemFontOfSize:size]; + if (size >= 15) { + return [MFFonts mfFontDSRegular:size]; + } else { + return [MFFonts mfFontTXRegular:size]; + } } + (nullable UIFont *)mfFontOcratxt:(CGFloat)size { From 39b76823237f7a726bd5c04bcbe5270f1cbae76f Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Sat, 4 Apr 2020 00:17:29 +0530 Subject: [PATCH 159/244] BGImageHeadlineBodyButton molecule for 3.0 Addons banner --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../BGImageHeadlineBodyButton.swift | 90 +++++++++++++++++++ .../BGImageHeadlineBodyButtonModel.swift | 75 ++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift create mode 100644 MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 49ac139e..3b64a728 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -407,6 +407,8 @@ DBC4391B224421A0001AB423 /* CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretLink.swift */; }; DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */; }; DBEFFA04225A829700230692 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; }; + EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */; }; + EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -813,6 +815,8 @@ DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = ""; }; DBC4391A224421A0001AB423 /* CaretLink.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretLink.swift; sourceTree = ""; }; DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelWithInternalButton.swift; sourceTree = ""; }; + EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButton.swift; sourceTree = ""; }; + EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButtonModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1157,6 +1161,8 @@ C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */, D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */, 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */, + EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */, + EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */, ); path = VerticalCombinationViews; sourceTree = ""; @@ -2032,6 +2038,7 @@ D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */, 01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */, D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, + EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, @@ -2224,6 +2231,7 @@ C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */, 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */, 0A6682A22434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift in Sources */, + EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 438f652b..53f8fbcf 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -92,6 +92,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: EyebrowHeadlineBodyLink.self, viewModelClass: EyebrowHeadlineBodyLinkModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLink.self, viewModelClass: HeadlineBodyLinkModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyButton.self, viewModelClass: HeadlineBodyButtonModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: BGImageHeadlineBodyButton.self, viewModelClass: BGImageHeadlineBodyButtonModel.self) // Left Right Molecules MoleculeObjectMapping.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift new file mode 100644 index 00000000..8a62409b --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift @@ -0,0 +1,90 @@ +// +// BGImageHeadlineBodyButton.swift +// MVMCoreUI +// +// Created by Khan, Arshad on 02/04/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class BGImageHeadlineBodyButton: Container { + let headlineBody = HeadlineBody(frame: .zero) + let button = PillButton(frame: .zero) + let backgroundImageView = MFLoadImageView(pinnedEdges: .all) + 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) + headlineBody.updateView(size) + button.updateView(size) + backgroundImageView.updateView(size) + backgroundImageView.alignFillHorizontal() + backgroundImageView.alignFillVertical() + } + + open override func setupView() { + super.setupView() + heightConstraint = heightAnchor.constraint(equalToConstant: Self.heightConstant) + heightConstraint?.isActive = true + + backgroundImageView.addSizeConstraintsForAspectRatio = true + + let container = MVMCoreUICommonViewsUtility.commonView() + addAndContain(container) + + container.addSubview(headlineBody) + container.addSubview(button) + + //Headline view + headlineBody.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 0).isActive = true + headlineBody.topAnchor.constraint(equalTo: container.topAnchor, constant: 0).isActive = true + + headlineBody.widthAnchor.constraint(equalTo: container.widthAnchor, multiplier: 0.67).isActive = true + let headLineBodyWidth = headlineBody.widthAnchor.constraint(lessThanOrEqualToConstant: maxWidth) + headLineBodyWidth.priority = UILayoutPriority(250) + headLineBodyWidth.isActive = true + + //Caret view + button.translatesAutoresizingMaskIntoConstraints = false + button.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 0).isActive = true + container.bottomAnchor.constraint(greaterThanOrEqualTo: button.bottomAnchor, constant: 0).isActive = true + + button.topAnchor.constraint(equalTo: headlineBody.bottomAnchor, constant: PaddingDefault).isActive = true + + //Background image view + backgroundImageView.translatesAutoresizingMaskIntoConstraints = false + backgroundImageView.imageView.contentMode = .scaleAspectFill + backgroundImageView.alignFillHorizontal() + backgroundImageView.alignFillVertical() + addSubview(backgroundImageView) + NSLayoutConstraint.constraintPinSubview(toSuperview: backgroundImageView) + sendSubviewToBack(backgroundImageView) + } + + // MARK: - MoleculeViewProtocol + open override func reset() { + super.reset() + headlineBody.reset() + backgroundImageView.reset() + } + + // MARK:- MoleculeViewProtocol + public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 320 + } + + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? BGImageHeadlineBodyButtonModel else { return } + headlineBody.set(with: model.headlineBody, delegateObject, additionalData) + button.setOptional(with: model.button, delegateObject, additionalData) + button.isHidden = model.button == nil + backgroundImageView.set(with: model.image, delegateObject, additionalData) + backgroundImageView.alignFillHorizontal() + backgroundImageView.alignFillVertical() + } +} diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift new file mode 100644 index 00000000..650e4875 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift @@ -0,0 +1,75 @@ +// +// BGImageHeadlineBodyButtonModel.swift +// MVMCoreUI +// +// Created by Khan, Arshad on 02/04/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +import UIKit + +public class BGImageHeadlineBodyButtonModel: ContainerModel, MoleculeModelProtocol { + public static var identifier: String = "bgImageHeadlineBodyButton" + public var backgroundColor: Color? + public var button: ButtonModel? + 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 = BGImageHeadlineBodyButton.heightConstant + } + button?.size = .tiny + button?.style = .secondary + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case headlineBody + case image + case button + } + + 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) + button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button) + 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(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(headlineBody, forKey: .headlineBody) + try container.encode(image, forKey: .image) + try container.encodeIfPresent(button, forKey: .button) + } +} + From 74258f642d6ed027b196daa44b76c1b03972c782 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 3 Apr 2020 15:13:07 -0400 Subject: [PATCH 160/244] move Footer and Label adapters to MF --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ---- .../Legacy/Adapters/FooterModelAdapter.swift | 40 ------------------- .../Legacy/Adapters/LabelModelAdapter.swift | 33 --------------- 3 files changed, 81 deletions(-) delete mode 100644 MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift delete mode 100644 MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 72c1db81..a63b50e6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -106,9 +106,7 @@ 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */; }; 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB423FF18D2004C5109 /* Arrow.swift */; }; 0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */; }; - 279B1567242BBBF200921D6C /* LabelModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1566242BBBF200921D6C /* LabelModelAdapter.swift */; }; 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; - 279B156D242BBFF100921D6C /* FooterModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B156C242BBFF100921D6C /* FooterModelAdapter.swift */; }; 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; @@ -503,9 +501,7 @@ 0AE98BB223FF0934004C5109 /* ExternalLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkModel.swift; sourceTree = ""; }; 0AE98BB423FF18D2004C5109 /* Arrow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arrow.swift; sourceTree = ""; }; 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrowModel.swift; sourceTree = ""; }; - 279B1566242BBBF200921D6C /* LabelModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelModelAdapter.swift; sourceTree = ""; }; 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; - 279B156C242BBFF100921D6C /* FooterModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModelAdapter.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 = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; @@ -923,9 +919,7 @@ 279B1565242BBB8500921D6C /* Adapters */ = { isa = PBXGroup; children = ( - 279B1566242BBBF200921D6C /* LabelModelAdapter.swift */, 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */, - 279B156C242BBFF100921D6C /* FooterModelAdapter.swift */, ); path = Adapters; sourceTree = ""; @@ -2162,7 +2156,6 @@ D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, - 279B1567242BBBF200921D6C /* LabelModelAdapter.swift in Sources */, D2C78CD224228BBD00B69FDE /* ActionOpenPanelModel.swift in Sources */, C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, @@ -2254,7 +2247,6 @@ 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, D260106523D0CEA700764D80 /* StackModel.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, - 279B156D242BBFF100921D6C /* FooterModelAdapter.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift deleted file mode 100644 index 3672a21f..00000000 --- a/MVMCoreUI/Legacy/Adapters/FooterModelAdapter.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// FooterModelAdapter.swift -// MVMCoreUI -// -// Created by Kyle on 3/25/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -public extension FooterModel { - - convenience init(withPrimaryAction primaryMap: [AnyHashable: Any]? = nil, secondaryAction secondaryMap: [AnyHashable: Any]? = nil, bottomLinkAction linkMap: [AnyHashable: Any]? = nil) { - - var primaryButtonModel: ButtonModel? - var secondaryButtonModel: ButtonModel? - if let primaryActionModel = try? primaryMap?.asActionModel(), let title = primaryActionModel.title { - primaryButtonModel = ButtonModel(primaryButtonWith: title, action: primaryActionModel) - } - if let secondaryActionModel = try? secondaryMap?.asActionModel(), let title = secondaryActionModel.title { - secondaryButtonModel = ButtonModel(secondaryButtonWith: title, action: secondaryActionModel) - } - let twoButtonModel = TwoButtonViewModel(primaryButtonModel, secondaryButtonModel) - - let footerContentModel: MoleculeModelProtocol - if let linkActionJSON = linkMap { - let labelModel = LabelModel(linkAction: linkActionJSON) - if primaryButtonModel != nil || secondaryButtonModel != nil { - let moleculeStack = MoleculeStackModel(molecules: [MoleculeStackItemModel(with: twoButtonModel), MoleculeStackItemModel(with: labelModel)]) - moleculeStack.spacing = MFStyler.defaultVerticalPaddingForApplicationWidth() - footerContentModel = moleculeStack - } else { - footerContentModel = labelModel - } - } else { - footerContentModel = twoButtonModel - } - - self.init(with: footerContentModel) - } - -} diff --git a/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift deleted file mode 100644 index 6b94f63e..00000000 --- a/MVMCoreUI/Legacy/Adapters/LabelModelAdapter.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// LabelModelAdapter.swift -// MVMCoreUI -// -// Created by Kyle on 3/25/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -public extension LabelModel { - - convenience init(linkAction: [AnyHashable: Any]) { - // Concatentate the text. - let title = linkAction.stringForkey(KeyTitle) - var titlePrefix = linkAction.stringForkey(KeyTitlePrefix) - var titlePostfix = linkAction.stringForkey(KeyTitlePostfix) - if !titlePrefix.isEmpty && (!title.isEmpty || !titlePostfix.isEmpty) { - titlePrefix += " " - } - if !titlePostfix.isEmpty && !title.isEmpty { - titlePostfix = " " + titlePostfix - } - let text = "\(titlePrefix)\(title)\(titlePostfix)" - - // Initialize with text. - self.init(text: text) - - // Add action attribute. - if let linkActionModel = try? linkAction.asActionModel() { - attributes = [LabelAttributeActionModel(titlePrefix.isEmpty ? 0 : titlePrefix.count, title.count, action: linkActionModel)] - } - } - -} From bebc0e11bde3fd5174f6abbf6cba559ddb1f0c98 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Sun, 5 Apr 2020 10:51:13 -0400 Subject: [PATCH 161/244] align with anroid changes --- .../LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift index 359beafd..8f2ab081 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift @@ -46,6 +46,7 @@ open class ListLeftVariableRadioButtonBodyTextModel: ListItemModel, MoleculeMode let typeContainer = try decoder.container(keyedBy: CodingKeys.self) radioButton = try typeContainer.decode(RadioButtonModel.self, forKey: .radioButton) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) + headlineBody.headline?.fontStyle = LabelModel.FontStyle.BoldMicro try super.init(from: decoder) } From 3ec2150afe5f5a0b0abe31b6ebaf40c5d5bb2abb Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Mon, 6 Apr 2020 17:15:43 +0530 Subject: [PATCH 162/244] List Three Column International Data - List Item - Added files --- MVMCoreUI.xcodeproj/project.pbxproj | 30 +++++--- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 +- .../ListThreeColumnInternationalData.swift | 68 +++++++++++++++++++ ...istThreeColumnInternationalDataModel.swift | 59 ++++++++++++++++ 4 files changed, 150 insertions(+), 9 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5fa8c961..b5a06ab1 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -135,8 +135,10 @@ 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; 8D4687E2242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */; }; 8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */; }; - 8DFB6D8B242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFB6D8A242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift */; }; - 8DFB6D8D242A138000A3F715 /* ListThreeColumnInternationalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFB6D8C242A138000A3F715 /* ListThreeColumnInternationalData.swift */; }; + 8DD1E36E243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1E36D243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift */; }; + 8DD1E370243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1E36F243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift */; }; + 8DFB6D8B242A137600A3F715 /* (null) in Sources */ = {isa = PBXBuildFile; }; + 8DFB6D8D242A138000A3F715 /* (null) in Sources */ = {isa = PBXBuildFile; }; 942C372E241149170066E45E /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */; }; 942C372F241149170066E45E /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */; }; 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; }; @@ -532,6 +534,8 @@ 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = ""; }; 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItemModel.swift; sourceTree = ""; }; 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItem.swift; sourceTree = ""; }; + 8DD1E36D243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataModel.swift; sourceTree = ""; }; + 8DD1E36F243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalData.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-55Rg.otf"; sourceTree = ""; }; @@ -985,11 +989,18 @@ path = TwoColumn; sourceTree = ""; }; + 8DD1E36C243B3CD900D8F2DF /* ThreeColumn */ = { + isa = PBXGroup; + children = ( + 8DD1E36D243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift */, + 8DD1E36F243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift */, + ); + path = ThreeColumn; + sourceTree = ""; + }; 8DFB6D89242A134600A3F715 /* ThreeColumn */ = { isa = PBXGroup; children = ( - 8DFB6D8A242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift */, - 8DFB6D8C242A138000A3F715 /* ListThreeColumnInternationalData.swift */, ); name = ThreeColumn; path = ../ThreeColumn; @@ -1261,9 +1272,10 @@ D22B38EA23F4E08B00490EF6 /* List */ = { isa = PBXGroup; children = ( - D20492F12434CB5F00A5EED6 /* FourColumn */, - D22D8396241FDE4700D3DF69 /* TwoColumn */, 52267A0523FFE0A900906CBA /* OneColumn */, + D22D8396241FDE4700D3DF69 /* TwoColumn */, + 8DD1E36C243B3CD900D8F2DF /* ThreeColumn */, + D20492F12434CB5F00A5EED6 /* FourColumn */, AA4FC2A323F4F69600E251DB /* RightVariable */, D22B38EB23F4E0AE00490EF6 /* LeftVariable */, ); @@ -1952,7 +1964,7 @@ D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, - 8DFB6D8D242A138000A3F715 /* ListThreeColumnInternationalData.swift in Sources */, + 8DFB6D8D242A138000A3F715 /* (null) in Sources */, 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, @@ -2093,6 +2105,7 @@ D260105D23D0BCD400764D80 /* Stack.swift in Sources */, 0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */, BB54C5212434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, + 8DD1E370243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */, @@ -2176,6 +2189,7 @@ D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, 8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, + 8DD1E36E243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift in Sources */, D243859923A16B1800332775 /* Container.swift in Sources */, D2C521A923EDE79E00CA2634 /* ViewController.swift in Sources */, D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */, @@ -2233,7 +2247,7 @@ D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, - 8DFB6D8B242A137600A3F715 /* ListThreeColumnInternationalDataModel.swift in Sources */, + 8DFB6D8B242A137600A3F715 /* (null) in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, 011D959D2404536F000E3791 /* RuleAnyValueChangedModel.swift in Sources */, D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 438f652b..30995284 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -141,7 +141,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) - + MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift new file mode 100644 index 00000000..1f0be954 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift @@ -0,0 +1,68 @@ +// +// ListThreeColumnInternationalData.swift +// MVMCoreUI +// +// Created by Kruthika KP on 06/04/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ListThreeColumnInternationalData: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + var stack: Stack + let leftLabel = Label.createLabelRegularBodySmall(true) + let centerLabel = Label.createLabelRegularBodySmall(true) + let rightLabel = Label.createLabelRegularBodySmall(true) + let arrow = Arrow(frame: .zero) + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading)), + (view: arrow, model: StackItemModel(percent: 4, horizontalAlignment: .trailing)), + (view: centerLabel, model: StackItemModel(percent: 46, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent:20,horizontalAlignment: .leading))], + axis: .horizontal,spacing: 2) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + arrow.pinHeightAndWidth() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnInternationalDataModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + arrow.set(with: model.arrow, delegateObject, additionalData) + stack.restack() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + leftLabel.styleRegularBodySmall(true) + centerLabel.styleRegularBodySmall(true) + rightLabel.styleRegularBodySmall(true) + arrow.reset() + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift new file mode 100644 index 00000000..976a6361 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift @@ -0,0 +1,59 @@ +// +// ListThreeColumnInternationalDataModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 06/04/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModelProtocol { + + public static var identifier: String = "list3CIntData" + public var leftLabel: LabelModel + public var centerLabel: LabelModel + public var rightLabel: LabelModel + public var arrow: ArrowModel + + public init(leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel, arrow:ArrowModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + self.arrow = arrow + super.init() + } + + public override func setDefaults() { + super.setDefaults() + arrow.degrees = 50 + arrow.color = Color.init(uiColor: .mvmGreen) + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + case arrow + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + arrow = try typeContainer.decode(ArrowModel.self, forKey: .arrow) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + try container.encode(arrow, forKey: .arrow) + } +} From 51f6dc417c8db0c43ad1fe481e06ae6b6b5aff53 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 6 Apr 2020 09:35:32 -0400 Subject: [PATCH 163/244] revised to common patteren --- .../ListLeftVariableRadioButtonBodyTextModel.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift index 8f2ab081..710a1ef6 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift @@ -26,6 +26,16 @@ open class ListLeftVariableRadioButtonBodyTextModel: ListItemModel, MoleculeMode self.radioButton = radioButton self.headlineBody = headlineBody super.init() + setDefaults() + } + + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + open override func setDefaults() { + super.setDefaults() + headlineBody.style = .item } //----------------------------------------------------- @@ -46,7 +56,6 @@ open class ListLeftVariableRadioButtonBodyTextModel: ListItemModel, MoleculeMode let typeContainer = try decoder.container(keyedBy: CodingKeys.self) radioButton = try typeContainer.decode(RadioButtonModel.self, forKey: .radioButton) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) - headlineBody.headline?.fontStyle = LabelModel.FontStyle.BoldMicro try super.init(from: decoder) } From 47c5343219ae9f42cc417fc3d87bc468ab61d45b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 6 Apr 2020 09:38:27 -0400 Subject: [PATCH 164/244] removed --- .../LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift | 1 - .../ThreeColumn/ListThreeColumnPlanDataDividerModel.swift | 1 - 2 files changed, 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift index 710a1ef6..bb8e7ded 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyTextModel.swift @@ -26,7 +26,6 @@ open class ListLeftVariableRadioButtonBodyTextModel: ListItemModel, MoleculeMode self.radioButton = radioButton self.headlineBody = headlineBody super.init() - setDefaults() } //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift index 8e718a8a..e727a1c6 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift @@ -19,7 +19,6 @@ public class ListThreeColumnPlanDataDividerModel: ListItemModel, MoleculeModelPr self.centerHeadlineBody = centerHeadlineBody self.rightHeadlineBody = rightHeadlineBody super.init() - setDefaults() } /// Defaults to set From 4d03ef2447bd974b5dbf1b4837c14f537e3d151b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 6 Apr 2020 11:48:55 -0400 Subject: [PATCH 165/244] mild entryfield changes --- MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift | 6 +++--- MVMCoreUI/Containers/Views/EntryFieldContainer.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift index a02f87ee..7fb3a458 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift @@ -21,7 +21,7 @@ import UIKit public private(set) var titleLabel: Label = { let label = Label() label.font = MFStyler.fontB3() - label.textColor = .mfBattleshipGrey() + label.textColor = .mvmCoolGray6 label.setContentCompressionResistancePriority(.required, for: .vertical) return label }() @@ -32,7 +32,7 @@ import UIKit public private(set) var feedbackLabel: Label = { let label = Label() label.font = MFStyler.fontForTextFieldUnderLabel() - label.textColor = .black + label.textColor = .mvmBlack label.setContentCompressionResistancePriority(.required, for: .vertical) return label }() @@ -178,7 +178,7 @@ import UIKit isAccessibilityElement = false setContentCompressionResistancePriority(.required, for: .vertical) accessibilityElements = [titleLabel, feedbackLabel] - backgroundColor = .clear + backgroundColor = .mvmWhite addSubview(titleLabel) diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index c7e5c3a7..cf56fb9d 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -256,7 +256,7 @@ import UIKit isUserInteractionEnabled = false hideBorders = false borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.mfSilver().cgColor + bottomBar?.backgroundColor = UIColor.mvmCoolGray3.cgColor refreshUI(bottomBarSize: 1) } From a601041c5fdead31f534b8844393982f462df6f6 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 6 Apr 2020 11:54:14 -0400 Subject: [PATCH 166/244] cleanup --- MVMCoreUI.xcodeproj/project.pbxproj | 9 ------- .../ListThreeColumnInternationalData.swift | 27 +++++++++++-------- ...istThreeColumnInternationalDataModel.swift | 9 +------ 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b5a06ab1..540d8ec0 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -946,7 +946,6 @@ 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */, 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */, - 8DFB6D89242A134600A3F715 /* ThreeColumn */, ); path = OneColumn; sourceTree = ""; @@ -998,14 +997,6 @@ path = ThreeColumn; sourceTree = ""; }; - 8DFB6D89242A134600A3F715 /* ThreeColumn */ = { - isa = PBXGroup; - children = ( - ); - name = ThreeColumn; - path = ../ThreeColumn; - sourceTree = ""; - }; 94C01508242155FE005811A9 /* Actions */ = { isa = PBXGroup; children = ( diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift index 1f0be954..5fc836d1 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalData.swift @@ -13,21 +13,26 @@ import Foundation //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - var stack: Stack - let leftLabel = Label.createLabelRegularBodySmall(true) - let centerLabel = Label.createLabelRegularBodySmall(true) - let rightLabel = Label.createLabelRegularBodySmall(true) - let arrow = Arrow(frame: .zero) - + open var stack: Stack + public let leftLabel = Label.createLabelRegularBodySmall(true) + public let centerLabel = Label.createLabelRegularBodySmall(true) + public let rightLabel = Label.createLabelRegularBodySmall(true) + public let arrow = Arrow(frame: .zero) + public let arrowAndLabel2Stack: Stack + //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + arrowAndLabel2Stack = Stack.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)), + (view: centerLabel, model: StackItemModel(horizontalAlignment: .leading))], + axis: .horizontal, spacing: 4) + centerLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + centerLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading)), - (view: arrow, model: StackItemModel(percent: 4, horizontalAlignment: .trailing)), - (view: centerLabel, model: StackItemModel(percent: 46, horizontalAlignment: .leading)), + (view: arrowAndLabel2Stack, model: StackItemModel(percent: 50, horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(percent:20,horizontalAlignment: .leading))], - axis: .horizontal,spacing: 2) + axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -42,6 +47,8 @@ import Foundation super.setupView() addMolecule(stack) arrow.pinHeightAndWidth() + arrowAndLabel2Stack.restack() + stack.restack() } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { @@ -51,7 +58,6 @@ import Foundation centerLabel.set(with: model.centerLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) arrow.set(with: model.arrow, delegateObject, additionalData) - stack.restack() } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -63,6 +69,5 @@ import Foundation leftLabel.styleRegularBodySmall(true) centerLabel.styleRegularBodySmall(true) rightLabel.styleRegularBodySmall(true) - arrow.reset() } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift index 976a6361..d0cd3791 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnInternationalDataModel.swift @@ -9,7 +9,6 @@ import Foundation public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "list3CIntData" public var leftLabel: LabelModel public var centerLabel: LabelModel @@ -24,12 +23,6 @@ public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModel super.init() } - public override func setDefaults() { - super.setDefaults() - arrow.degrees = 50 - arrow.color = Color.init(uiColor: .mvmGreen) - } - private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel @@ -47,7 +40,7 @@ public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModel try super.init(from: decoder) } - public override func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) From 79dd73ed4433fe4bd74bf500a5d555f82e2eef33 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 6 Apr 2020 11:57:38 -0400 Subject: [PATCH 167/244] toggle --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 487ad32f..1e072faf 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -25,13 +25,13 @@ public typealias ActionBlockConfirmation = () -> (Bool) //-------------------------------------------------- /// Holds the on and off colors for the container. - public var containerTintColor: (on: UIColor?, off: UIColor?)? = (on: .mfShamrock(), off: .black) + public var containerTintColor: (on: UIColor?, off: UIColor?)? = (on: .mvmGreen, off: .black) /// Holds the on and off colors for the knob. public var knobTintColor: (on: UIColor?, off: UIColor?)? = (on: .white, off: .white) /// Holds the on and off colors for the disabled state.. - public var disabledTintColor: (container: UIColor?, knob: UIColor?)? = (container: .mfSilver(), knob: .white) + public var disabledTintColor: (container: UIColor?, knob: UIColor?)? = (container: .mvmCoolGray3, knob: .white) /// Set this flag to false if you do not want to animate state changes. public var isAnimated = true From d6d1046cd884d73d6597866c4c68829860de9b2e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 6 Apr 2020 11:57:40 -0400 Subject: [PATCH 168/244] cleanup mistakes --- MVMCoreUI.xcodeproj/project.pbxproj | 4 -- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 3 +- .../ListThreeColumnInternationalData.swift | 70 ------------------- ...istThreeColumnInternationalDataModel.swift | 59 ---------------- 4 files changed, 2 insertions(+), 134 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalData.swift delete mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 540d8ec0..9fde090d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -137,8 +137,6 @@ 8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */; }; 8DD1E36E243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1E36D243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift */; }; 8DD1E370243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1E36F243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift */; }; - 8DFB6D8B242A137600A3F715 /* (null) in Sources */ = {isa = PBXBuildFile; }; - 8DFB6D8D242A138000A3F715 /* (null) in Sources */ = {isa = PBXBuildFile; }; 942C372E241149170066E45E /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */; }; 942C372F241149170066E45E /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */; }; 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; }; @@ -1955,7 +1953,6 @@ D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, - 8DFB6D8D242A138000A3F715 /* (null) in Sources */, 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, @@ -2238,7 +2235,6 @@ D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, - 8DFB6D8B242A137600A3F715 /* (null) in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, 011D959D2404536F000E3791 /* RuleAnyValueChangedModel.swift in Sources */, D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 30995284..760a7a6c 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -140,8 +140,9 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) + // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalData.swift deleted file mode 100644 index 948bdb9b..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalData.swift +++ /dev/null @@ -1,70 +0,0 @@ -// -// ListThreeColumnInternationalData.swift -// MVMCoreUI -// -// Created by Kruthika KP on 24/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - - -@objcMembers public class ListThreeColumnInternationalData: TableViewCell { - - //----------------------------------------------------- - // MARK: - Outlets - //----------------------------------------------------- - var stack: Stack - let leftLabel = Label.createLabelRegularBodySmall(true) - let centerLabel = Label.createLabelRegularBodySmall(true) - let rightLabel = Label.createLabelRegularBodySmall(true) - let arrow = Arrow(frame: .zero) - - //----------------------------------------------------- - // MARK: - Initializers - //----------------------------------------------------- - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading)), - (view: arrow, model: StackItemModel(percent: 4, horizontalAlignment: .trailing)), - (view: centerLabel, model: StackItemModel(percent: 46, horizontalAlignment: .leading)), - (view: rightLabel, model: StackItemModel(percent:30,horizontalAlignment: .center))], - axis: .horizontal,spacing: 2) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - //----------------------------------------------------- - // MARK: - View Lifecycle - //----------------------------------------------------- - override open func setupView() { - super.setupView() - addMolecule(stack) - arrow.pinHeightAndWidth() - } - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListThreeColumnInternationalDataModel else { return } - leftLabel.set(with: model.leftLabel, delegateObject, additionalData) - centerLabel.set(with: model.centerLabel, delegateObject, additionalData) - rightLabel.set(with: model.rightLabel, delegateObject, additionalData) - arrow.set(with: model.arrow, delegateObject, additionalData) - stack.restack() - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 90 - } - - open override func reset() { - super.reset() - leftLabel.styleRegularBodySmall(true) - centerLabel.styleRegularBodySmall(true) - rightLabel.styleRegularBodySmall(true) - arrow.reset() - } - -} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataModel.swift deleted file mode 100644 index 5a2ceff2..00000000 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataModel.swift +++ /dev/null @@ -1,59 +0,0 @@ -// -// ListThreeColumnInternationalDataModel.swift -// MVMCoreUI -// -// Created by Kruthika KP on 24/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModelProtocol { - - public static var identifier: String = "list3CIntData" - public var leftLabel: LabelModel - public var centerLabel: LabelModel - public var rightLabel: LabelModel - public var arrow: ArrowModel - - public init(leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel,arrow:ArrowModel){ - self.leftLabel = leftLabel - self.centerLabel = centerLabel - self.rightLabel = rightLabel - self.arrow = arrow - super.init() - } - - public override func setDefaults() { - super.setDefaults() - arrow.degrees = 50 - arrow.color = Color.init(uiColor: .mvmGreen) - } - - private enum CodingKeys: String, CodingKey{ - case moleculeName - case leftLabel - case centerLabel - case rightLabel - case arrow - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) - centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) - rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - arrow = try typeContainer.decode(ArrowModel.self, forKey: .arrow) - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(leftLabel, forKey: .leftLabel) - try container.encode(centerLabel, forKey: .centerLabel) - try container.encode(rightLabel, forKey: .rightLabel) - try container.encode(arrow, forKey: .arrow) - } -} From 8e0641c547e5342f6de019b80bed279e3167e08c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 6 Apr 2020 12:00:08 -0400 Subject: [PATCH 169/244] remove bad commit --- .../OtherHandlers/MoleculeObjectMapping.swift | 144 ------------------ 1 file changed, 144 deletions(-) delete mode 100644 MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift deleted file mode 100644 index 666a5c61..00000000 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject+ModelMapping.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -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: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) - - // Label - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - // need to move labelattributemodel to different method - try? ModelRegistry.register(LabelAttributeFontModel.self) - try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... - try? ModelRegistry.register(LabelAttributeUnderlineModel.self) - try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - try? ModelRegistry.register(LabelAttributeActionModel.self) - - // Buttons - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) - - // Entry Field - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - - // Other Atoms - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) - - // 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: HeadlineBodyLink.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: LabelToggle.self, viewModelClass: LabelToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - - // List items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.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: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.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) - - // Designed List Items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) - - // Designed Section Dividers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - - // Designed Headers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) - - // TODO: Need model - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - - // TODO: Need View - try? ModelRegistry.register(TabsModel.self) - - // Helper models - try? ModelRegistry.register(RuleRequiredModel.self) - try? ModelRegistry.register(RuleAnyRequiredModel.self) - try? ModelRegistry.register(RuleAnyValueChangedModel.self) - try? ModelRegistry.register(RuleAllValueChangedModel.self) - try? ModelRegistry.register(RuleEqualsModel.self) - try? ModelRegistry.register(RuleRegexModel.self) - - // Actions - try? ModelRegistry.register(ActionTopAlertModel.self) - try? ModelRegistry.register(ActionCollapseNotificationModel.self) - try? ModelRegistry.register(ActionOpenPanelModel.self) - } -} From 7d740c5cceedb8cf9e992790da6243d4bbbeaa77 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Mon, 6 Apr 2020 22:39:19 +0530 Subject: [PATCH 170/244] changing the priority as per feedback. --- .../BGImageHeadlineBodyButton.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift index 8a62409b..f1ec076c 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButton.swift @@ -43,10 +43,10 @@ import Foundation headlineBody.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 0).isActive = true headlineBody.topAnchor.constraint(equalTo: container.topAnchor, constant: 0).isActive = true - headlineBody.widthAnchor.constraint(equalTo: container.widthAnchor, multiplier: 0.67).isActive = true - let headLineBodyWidth = headlineBody.widthAnchor.constraint(lessThanOrEqualToConstant: maxWidth) - headLineBodyWidth.priority = UILayoutPriority(250) + let headLineBodyWidth = headlineBody.widthAnchor.constraint(equalTo: container.widthAnchor, multiplier: 0.67) + headLineBodyWidth.priority = UILayoutPriority(rawValue: 999) headLineBodyWidth.isActive = true + headlineBody.widthAnchor.constraint(lessThanOrEqualToConstant: maxWidth).isActive = true //Caret view button.translatesAutoresizingMaskIntoConstraints = false From 9f07e155789fe497fc78aebffbf647e3428d4852 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 6 Apr 2020 14:31:53 -0400 Subject: [PATCH 171/244] color added. --- MVMCoreUI/Categories/UIColor+MFConvenience.h | 1 + MVMCoreUI/Categories/UIColor+MFConvenience.m | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index c3c78c7a..92b28a36 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -24,6 +24,7 @@ + (nonnull UIColor *)mvmOrange; + (nonnull UIColor *)mfPumpkinColor; + (nonnull UIColor *)mfShamrock; ++ (nonnull UIColor *)mvmGreen; + (nonnull UIColor *)mfCerulean; + (nonnull UIColor *)mfWhiteTwo; diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index 6ff8f70f..33df3848 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -61,6 +61,10 @@ return [UIColor mfColor8bitsWithRed:0 green:134 blue:49 alpha:1.0]; } ++ (nonnull UIColor *)mvmGreen { + return [UIColor mfColor8bitsWithRed:0 green:134 blue:48 alpha:1.0]; +} + + (nonnull UIColor *)mfCerulean { return [UIColor mfColor8bitsWithRed:0 green:122 blue:184 alpha:1.0]; } From 7a221da7ba330d8e5cb5ee5eb97560f7704b6277 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 6 Apr 2020 14:32:55 -0400 Subject: [PATCH 172/244] asd --- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 930828f6..4e79ee6f 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -117,7 +117,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; if ([type isEqualToString:ValueTypeError]) { return [UIColor mvmOrange]; } else { - return [UIColor mfShamrock]; + return [UIColor mvmGreen]; } } From ade0e043a4822cb3ca28cc8087cc09d5c5a1fbfb Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Tue, 7 Apr 2020 07:51:44 +0530 Subject: [PATCH 173/244] fixed box sizes issues --- .../Views/RadioBoxCollectionViewCell.swift | 54 ++++++++++++++++--- MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 18 +++++-- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift index c709cf4b..f29c6bb1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift @@ -14,11 +14,14 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco var bottomView = MVMCoreUICommonViewsUtility.commonView() public var lineViewHeight: NSLayoutConstraint? public var fieldValue: String? - + open override var isSelected: Bool{ didSet{ self.lineViewHeight?.constant = self.isSelected ? 4.0 : 0 + UIView.animate(withDuration: 0.5) { + self.layoutIfNeeded() + } self.bottomView.layer.sublayers?.filter({$0.name == "border"}).forEach({$0.removeFromSuperlayer()}) if(self.isSelected){ self.bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) @@ -30,15 +33,23 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco } } } + var isOutofStock: Bool = false{ + didSet{ + DispatchQueue.main.async { [weak self] in + guard let strongSelf = self else { + return + } + strongSelf.bottomView.layer.sublayers?.filter({$0.name == "outofstock"}).forEach({$0.removeFromSuperlayer()}) + if(strongSelf.isOutofStock){ + strongSelf.addOutofstockLine() + } + } + } + } public override init(frame: CGRect) { super.init(frame: .zero) setupView() } - open override func layoutSubviews() { - super.layoutSubviews() - addBordertoView() - - } public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) setupView() @@ -53,6 +64,7 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco insetsLayoutMarginsFromSafeArea = false contentView.insetsLayoutMarginsFromSafeArea = false contentView.preservesSuperviewLayoutMargins = false + bottomView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(bottomView) NSLayoutConstraint.constraintPinSubview(toSuperview: bottomView) @@ -70,25 +82,51 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco bodyLabel.bottomAnchor.constraint(lessThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true } + public func updateView(_ size: CGFloat) { + self.setNeedsLayout() + self.bottomView.setNeedsLayout() + self.bottomView.layer.sublayers?.filter({$0.name == "border"}).forEach({$0.removeFromSuperlayer()}) + DispatchQueue.main.async { [weak self] in + self?.addBordertoView() + } + + } + + + private func addBordertoView(){ bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) bottomView.layer.addBorder(edge: .top, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) } - + private func addOutofstockLine(){ + + let path = UIBezierPath() + path.move(to: CGPoint(x: 0, y: bottomView.bounds.height)) + path.addLine(to: CGPoint(x: bottomView.bounds.width, y: 0)) + + let shapeLayer = CAShapeLayer() + shapeLayer.name = "outofstock" + shapeLayer.path = path.cgPath + shapeLayer.strokeColor = UIColor.darkGray.cgColor + shapeLayer.lineWidth = 0.5 + bottomView.layer.addSublayer(shapeLayer) + } public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let collectionModel = model as? RadioBoxModel else { return } if let backgroundColor = collectionModel.backgroundColor { - self.bottomView.backgroundColor = backgroundColor.uiColor + bottomView.backgroundColor = backgroundColor.uiColor } lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor bodyLabel.text = collectionModel.text isSelected = collectionModel.selected ?? false fieldValue = collectionModel.fieldValue + isOutofStock = collectionModel.strikethrough ?? false } } + extension CALayer { func addBorder(edge: UIRectEdge, color: UIColor, thickness: CGFloat) { diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift index 39f03c40..7dcd2acc 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -57,11 +57,23 @@ open class RadioBoxes: View { prepareMolecules(with: radioBoxesModel) collectionView.reloadData() } + @objc override open func updateView(_ size: CGFloat) { + + collectionView.collectionViewLayout.invalidateLayout() + + DispatchQueue.main.async { [weak self] in + self?.setNeedsDisplay() + self?.collectionView.layoutIfNeeded() + self?.collectionView.reloadData() + + } + } + // MARK: - JSON Setters /// Updates the layout being used - func setupLayout(with carouselModel: RadioBoxesModel?) { + func setupLayout(with radioBoxesModel: RadioBoxesModel?) { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical layout.sectionInset = UIEdgeInsets.init(top: CGFloat(leadingSpacing), left: CGFloat(leadingSpacing), bottom: CGFloat(leadingSpacing), right: CGFloat(leadingSpacing)) @@ -92,7 +104,7 @@ open class RadioBoxes: View { extension RadioBoxes: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let itemWidth = (Double(collectionView.bounds.width) - itemSpacing)/2 - return CGSize(width: CGFloat(150.5), height: CGFloat(boxHeight)) + return CGSize(width: CGFloat(itemWidth), height: CGFloat(boxHeight)) } } @@ -106,7 +118,7 @@ extension RadioBoxes: UICollectionViewDataSource { return UICollectionViewCell() } cell.set(with: molecule, nil, nil) - (cell as? MVMCoreViewProtocol)?.updateView(collectionView.bounds.width) + cell.updateView(collectionView.bounds.width) cell.layoutIfNeeded() return cell } From dda506f94a0afd9894e138a1541e4b3fb58dcf94 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 7 Apr 2020 12:08:30 +0530 Subject: [PATCH 174/244] Removed duplicate files. --- .../ListThreeColumnSpeedTestDivider.swift | 63 -------- ...ListThreeColumnSpeedTestDividerModel.swift | 53 ------- .../OtherHandlers/MoleculeObjectMapping.swift | 144 ------------------ 3 files changed, 260 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift delete mode 100644 MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift delete mode 100644 MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift deleted file mode 100644 index b278185d..00000000 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift +++ /dev/null @@ -1,63 +0,0 @@ -// -// ListThreeColumnSpeedTestDivider.swift -// MVMCoreUI -// -// Created by Lekshmi S on 20/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers open class ListThreeColumnSpeedTestDivider: TableViewCell { - - //------------------------------------------------------- - // MARK: - Outlets - //------------------------------------------------------- - let leftLabel = Label.createLabelBoldBodySmall(true) - let centerLabel = Label.createLabelBoldBodySmall(true) - let rightLabel = Label.createLabelBoldBodySmall(true) - var stack: Stack - - //------------------------------------------------------- - // MARK: - Initializers - //------------------------------------------------------- - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal, spacing: 8) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - //------------------------------------------------------- - // MARK: - View Lifecycle - //------------------------------------------------------- - open override func setupView() { - super.setupView() - addMolecule(stack) - stack.restack() - } - - //------------------------------------------------------ - // MARK: - Molecule - //------------------------------------------------------ - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListThreeColumnSpeedTestDividerModel else { return } - leftLabel.set(with: model.leftLabel, delegateObject, additionalData) - centerLabel.set(with: model.centerLabel, delegateObject, additionalData) - rightLabel.set(with: model.rightLabel, delegateObject, additionalData) - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 121 - } - - open override func reset() { - super.reset() - leftLabel.styleBoldBodySmall(true) - centerLabel.styleBoldBodySmall(true) - rightLabel.styleBoldBodySmall(true) - } -} diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift deleted file mode 100644 index 44f697ad..00000000 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// ListThreeColumnSpeedTestDividerModel.swift -// MVMCoreUI -// -// Created by Lekshmi S on 20/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class ListThreeColumnSpeedTestDividerModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "list3CSpdTstDiv" - public var leftLabel: LabelModel - public var centerLabel: LabelModel - public var rightLabel: LabelModel - - public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { - self.leftLabel = leftLabel - self.centerLabel = centerLabel - self.rightLabel = rightLabel - super.init() - } - - /// Defaults to set - override public func setDefaults() { - super.setDefaults() - style = "tallDivider" - } - - private enum CodingKeys: String, CodingKey { - case moleculeName - case leftLabel - case centerLabel - case rightLabel - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) - centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) - rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(leftLabel, forKey: .leftLabel) - try container.encode(centerLabel, forKey: .centerLabel) - try container.encode(rightLabel, forKey: .rightLabel) - } -} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift deleted file mode 100644 index a364e216..00000000 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject+ModelMapping.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -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: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) - - // Label - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - // need to move labelattributemodel to different method - try? ModelRegistry.register(LabelAttributeFontModel.self) - try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... - try? ModelRegistry.register(LabelAttributeUnderlineModel.self) - try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - try? ModelRegistry.register(LabelAttributeActionModel.self) - - // Buttons - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) - - // Entry Field - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - - // Other Atoms - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) - - // 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: HeadlineBodyLink.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: LabelToggle.self, viewModelClass: LabelToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - - // List items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.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: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.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) - - // Designed List Items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - - // Designed Section Dividers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnSpeedTestDivider.self, viewModelClass: ListThreeColumnSpeedTestDividerModel.self) - - // Designed Headers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) - - // TODO: Need model - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - - // TODO: Need View - try? ModelRegistry.register(TabsModel.self) - - // Helper models - try? ModelRegistry.register(RuleRequiredModel.self) - try? ModelRegistry.register(RuleAnyRequiredModel.self) - try? ModelRegistry.register(RuleAnyValueChangedModel.self) - try? ModelRegistry.register(RuleAllValueChangedModel.self) - try? ModelRegistry.register(RuleEqualsModel.self) - try? ModelRegistry.register(RuleRegexModel.self) - - // Actions - try? ModelRegistry.register(ActionTopAlertModel.self) - try? ModelRegistry.register(ActionCollapseNotificationModel.self) - try? ModelRegistry.register(ActionOpenPanelModel.self) - } -} From 5be18cb66efb6b2f099ad57d9f6945391b4deff0 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 7 Apr 2020 13:24:48 +0530 Subject: [PATCH 175/244] Code changes after merge --- MVMCoreUI.xcodeproj/project.pbxproj | 32 +++++++++---------- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../ListTwoColumnSubsectionDivider.swift | 4 +-- .../ListTwoColumnSubsectionDividerModel.swift | 2 +- 4 files changed, 20 insertions(+), 19 deletions(-) rename MVMCoreUI/Atomic/Molecules/{HorizontalCombinationViews/DesignedComponents/SectionDividers => DesignedComponents/SectionDividers/TwoColumn}/ListTwoColumnSubsectionDivider.swift (95%) rename MVMCoreUI/Atomic/Molecules/{HorizontalCombinationViews/DesignedComponents/SectionDividers => DesignedComponents/SectionDividers/TwoColumn}/ListTwoColumnSubsectionDividerModel.swift (97%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ddef5586..fad8faf2 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -180,6 +180,8 @@ 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; + AA56A20F243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA56A20E243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift */; }; + AA56A211243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA56A210243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; BB2C968F24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */; }; @@ -192,8 +194,6 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; - AAE131E1242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE131E0242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift */; }; - AAE131E3242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE131E2242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift */; }; 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 */; }; @@ -580,6 +580,8 @@ 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; + AA56A20E243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTwoColumnSubsectionDividerModel.swift; sourceTree = ""; }; + AA56A210243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTwoColumnSubsectionDivider.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRightVariableTextLinkAllTextAndLinksModel.swift; sourceTree = ""; }; @@ -592,8 +594,6 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; - AAE131E0242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ListTwoColumnSubsectionDivider.swift; path = MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift; sourceTree = SOURCE_ROOT; }; - AAE131E2242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ListTwoColumnSubsectionDividerModel.swift; path = MVMCoreUI/Molecules/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift; sourceTree = SOURCE_ROOT; }; 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 = ""; }; @@ -987,15 +987,6 @@ path = OneColumn; sourceTree = ""; }; - 526A265A240D1FCE00B0D828 /* TwoColumn */ = { - isa = PBXGroup; - children = ( - AAE131E0242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift */, - AAE131E2242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift */, - ); - path = TwoColumn; - sourceTree = ""; - }; 8DD1E36C243B3CD900D8F2DF /* ThreeColumn */ = { isa = PBXGroup; children = ( @@ -1055,6 +1046,15 @@ path = RightVariable; sourceTree = ""; }; + AA56A20D243C5EDA00303286 /* TwoColumn */ = { + isa = PBXGroup; + children = ( + AA56A20E243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift */, + AA56A210243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift */, + ); + path = TwoColumn; + sourceTree = ""; + }; D202AFE2242A5F1400E5BEDF /* Extensions */ = { isa = PBXGroup; children = ( @@ -1301,8 +1301,8 @@ D22B38EC23F4E10700490EF6 /* SectionDividers */ = { isa = PBXGroup; children = ( + AA56A20D243C5EDA00303286 /* TwoColumn */, 525665CB24211FD5007BF25F /* OneColumn */, - 526A265A240D1FCE00B0D828 /* TwoColumn */, 525019E3240684E500EED91C /* FourColumn */, D22B38ED23F4E11100490EF6 /* ThreeColumn */, ); @@ -1969,6 +1969,7 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */, + AA56A20F243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift in Sources */, 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, @@ -2133,7 +2134,6 @@ 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, 011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */, - AAE131E1242088A200CDE1B4 /* ListTwoColumnSubsectionDivider.swift in Sources */, 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, @@ -2162,7 +2162,6 @@ 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */, BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, - AAE131E3242088B400CDE1B4 /* ListTwoColumnSubsectionDividerModel.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, @@ -2211,6 +2210,7 @@ D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, 0A21DB94235E24ED00C160A2 /* DigitEntryField.swift in Sources */, + AA56A211243C5EFC00303286 /* ListTwoColumnSubsectionDivider.swift in Sources */, 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */, D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 94bbc61f..b6b21218 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -151,6 +151,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalDataDivider.self, viewModelClass: ListThreeColumnInternationalDataDividerModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnSubsectionDivider.self, viewModelClass: ListTwoColumnSubsectionDividerModel.self) // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDivider.swift similarity index 95% rename from MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDivider.swift index b051fcab..d26da0f4 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDivider.swift @@ -2,7 +2,7 @@ // ListTwoColumnSubsectionDivider.swift // MVMCoreUI // -// Created by Lekshmi S on 17/03/20. +// Created by Lekshmi S on 07/04/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // @@ -23,7 +23,7 @@ import Foundation public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 75, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 25, horizontalAlignment: .leading))], - axis: .horizontal, spacing: 8) + axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDividerModel.swift similarity index 97% rename from MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDividerModel.swift index 51d17cde..c296b851 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ListTwoColumnSubsectionDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDividerModel.swift @@ -2,7 +2,7 @@ // ListTwoColumnSubsectionDividerModel.swift // MVMCoreUI // -// Created by Lekshmi S on 17/03/20. +// Created by Lekshmi S on 07/04/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // From d131694444d78b68044508bdf432b012f43d6e62 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Tue, 7 Apr 2020 14:26:14 +0530 Subject: [PATCH 176/244] duplicate files removed. --- .../ListThreeColumnBillChangesDivider.swift | 49 ------ ...stThreeColumnBillChangesDividerModel.swift | 55 ------- .../OtherHandlers/MoleculeObjectMapping.swift | 145 ------------------ 3 files changed, 249 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift delete mode 100644 MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift delete mode 100644 MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift deleted file mode 100644 index e4949e21..00000000 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift +++ /dev/null @@ -1,49 +0,0 @@ -// -// ListThreeColumnBillChangesDivider.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 20/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -@objcMembers open class ListThreeColumnBillChangesDivider: TableViewCell { - - public let leftLabel = Label(frame: .zero) - public let centerLabel = Label(frame: .zero) - public let rightLabel = Label(frame: .zero) - var stack: Stack - - // MARK: - Initializers - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), - (view: centerLabel, model: StackItemModel(percent: 34, horizontalAlignment: .center)), - (view: rightLabel, model: StackItemModel(percent: 33, horizontalAlignment: .trailing))], - axis: .horizontal) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - // MARK: - MFViewProtocol - open override func setupView() { - super.setupView() - addMolecule(stack) - stack.restack() - } - - // MARK: - ModelMoleculeViewProtocol - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListThreeColumnBillChangesDividerModel else { return } - leftLabel.set(with: model.leftLabel, delegateObject, additionalData) - centerLabel.set(with: model.centerLabel, delegateObject, additionalData) - rightLabel.set(with: model.rightLabel, delegateObject, additionalData) - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 120 - } -} diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift deleted file mode 100644 index c40e2c5c..00000000 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// ListThreeColumnBillChangesDividerModel.swift -// MVMCoreUI -// -// Created by Dhamodaram Nandi on 20/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -public class ListThreeColumnBillChangesDividerModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "list3CBillChgDiv" - public var leftLabel: LabelModel - public var centerLabel: LabelModel - public var rightLabel: LabelModel - - public init(leftLabel: LabelModel, centerLabel:LabelModel, rightLabel: LabelModel) { - self.leftLabel = leftLabel - self.centerLabel = centerLabel - self.rightLabel = rightLabel - super.init() - } - - /// Defaults to set - override public func setDefaults() { - super.setDefaults() - style = "tallDivider" - leftLabel.fontStyle = "BoldBodySmall" - rightLabel.fontStyle = "BoldBodySmall" - centerLabel.fontStyle = "BoldBodySmall" - } - - private enum CodingKeys: String, CodingKey { - case moleculeName - case leftLabel - case centerLabel - case rightLabel - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) - centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) - rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - try super.init(from: decoder) - } - - public override func encode(to encoder: Encoder) throws { - try super.encode(to: encoder) - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(leftLabel, forKey: .leftLabel) - try container.encode(centerLabel, forKey: .centerLabel) - try container.encode(rightLabel, forKey: .rightLabel) - } -} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift deleted file mode 100644 index 88e9d538..00000000 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ /dev/null @@ -1,145 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject+ModelMapping.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -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: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) - - // Label - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - // need to move labelattributemodel to different method - try? ModelRegistry.register(LabelAttributeFontModel.self) - try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... - try? ModelRegistry.register(LabelAttributeUnderlineModel.self) - try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - try? ModelRegistry.register(LabelAttributeActionModel.self) - - // Buttons - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) - - // Entry Field - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - - // Other Atoms - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) - - // 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: HeadlineBodyLink.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: LabelToggle.self, viewModelClass: LabelToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - - // List items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.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: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.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) - - // Designed List Items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - - // Designed Section Dividers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnBillChangesDivider.self, viewModelClass: ListThreeColumnBillChangesDividerModel.self) - - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - - // Designed Headers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) - - // TODO: Need model - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - - // TODO: Need View - try? ModelRegistry.register(TabsModel.self) - - // Helper models - try? ModelRegistry.register(RuleRequiredModel.self) - try? ModelRegistry.register(RuleAnyRequiredModel.self) - try? ModelRegistry.register(RuleAnyValueChangedModel.self) - try? ModelRegistry.register(RuleAllValueChangedModel.self) - try? ModelRegistry.register(RuleEqualsModel.self) - try? ModelRegistry.register(RuleRegexModel.self) - - // Actions - try? ModelRegistry.register(ActionTopAlertModel.self) - try? ModelRegistry.register(ActionCollapseNotificationModel.self) - try? ModelRegistry.register(ActionOpenPanelModel.self) - } -} From ced8dd54e194f57e1cfae378c97d0ef7c20939df Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Tue, 7 Apr 2020 15:30:42 +0530 Subject: [PATCH 177/244] file paths added --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c0a56ebc..65c8b408 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -192,6 +192,10 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; + BBA326A9243C85550011D1F6 /* RadioBoxesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA326A5243C85540011D1F6 /* RadioBoxesModel.swift */; }; + BBA326AA243C85550011D1F6 /* RadioBoxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA326A6243C85540011D1F6 /* RadioBoxModel.swift */; }; + BBA326AB243C85550011D1F6 /* RadioBoxCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA326A7243C85540011D1F6 /* RadioBoxCollectionViewCell.swift */; }; + BBA326AC243C85550011D1F6 /* RadioBoxes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA326A8243C85550011D1F6 /* RadioBoxes.swift */; }; 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 */; }; @@ -590,6 +594,10 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; + BBA326A5243C85540011D1F6 /* RadioBoxesModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxesModel.swift; sourceTree = ""; }; + BBA326A6243C85540011D1F6 /* RadioBoxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxModel.swift; sourceTree = ""; }; + BBA326A7243C85540011D1F6 /* RadioBoxCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxCollectionViewCell.swift; sourceTree = ""; }; + BBA326A8243C85550011D1F6 /* RadioBoxes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxes.swift; 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 = ""; }; @@ -1566,6 +1574,10 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( + BBA326A5243C85540011D1F6 /* RadioBoxesModel.swift */, + BBA326A8243C85550011D1F6 /* RadioBoxes.swift */, + BBA326A6243C85540011D1F6 /* RadioBoxModel.swift */, + BBA326A7243C85540011D1F6 /* RadioBoxCollectionViewCell.swift */, 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, 01509D922327ECFB00EF99AA /* ProgressBar.swift */, 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, @@ -1986,6 +1998,7 @@ D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, 011D95A924057AC7000E3791 /* FormGroupWatcherFieldProtocol.swift in Sources */, D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */, + BBA326AC243C85550011D1F6 /* RadioBoxes.swift in Sources */, 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */, @@ -2038,6 +2051,7 @@ D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, + BBA326AB243C85550011D1F6 /* RadioBoxCollectionViewCell.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, @@ -2085,6 +2099,7 @@ D2B18B812360945C00A9AEDC /* View.swift in Sources */, C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, + BBA326A9243C85550011D1F6 /* RadioBoxesModel.swift in Sources */, 525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */, 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */, 94FB966323D797DA003D482B /* MFTextButton.m in Sources */, @@ -2243,6 +2258,7 @@ D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, + BBA326AA243C85550011D1F6 /* RadioBoxModel.swift in Sources */, 011D959D2404536F000E3791 /* RuleAnyValueChangedModel.swift in Sources */, D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */, BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */, From f251b550047d6085754a5868503471e90484efa0 Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Tue, 7 Apr 2020 19:15:10 +0530 Subject: [PATCH 178/244] alignment changes --- .../Views/RadioBoxCollectionViewCell.swift | 39 ++++++++----------- .../Atomic/Atoms/Views/RadioBoxModel.swift | 16 ++++---- MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 14 +------ .../Atomic/Atoms/Views/RadioBoxesModel.swift | 10 +---- 4 files changed, 29 insertions(+), 50 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift index f29c6bb1..67068c85 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift @@ -15,7 +15,6 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco public var lineViewHeight: NSLayoutConstraint? public var fieldValue: String? - open override var isSelected: Bool{ didSet{ self.lineViewHeight?.constant = self.isSelected ? 4.0 : 0 @@ -33,23 +32,24 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco } } } - var isOutofStock: Bool = false{ + + var isOutOfStock: Bool = false { didSet{ DispatchQueue.main.async { [weak self] in - guard let strongSelf = self else { - return - } - strongSelf.bottomView.layer.sublayers?.filter({$0.name == "outofstock"}).forEach({$0.removeFromSuperlayer()}) - if(strongSelf.isOutofStock){ - strongSelf.addOutofstockLine() + guard let self = self else { return } + self.bottomView.layer.sublayers?.filter({$0.name == "outofstock"}).forEach({$0.removeFromSuperlayer()}) + if(self.isOutOfStock) { + self.addOutOfStockLine() } } } } + public override init(frame: CGRect) { super.init(frame: .zero) setupView() } + public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) setupView() @@ -68,20 +68,18 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco contentView.addSubview(bottomView) NSLayoutConstraint.constraintPinSubview(toSuperview: bottomView) - lineView.translatesAutoresizingMaskIntoConstraints = false bottomView.addSubview(lineView) NSLayoutConstraint.constraintPinSubview(lineView, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true) lineViewHeight = lineView.heightAnchor.constraint(equalToConstant: 0) lineViewHeight?.isActive = true - bodyLabel.translatesAutoresizingMaskIntoConstraints = false - bodyLabel.numberOfLines = 0 + bodyLabel.numberOfLines = 1 bottomView.addSubview(bodyLabel) NSLayoutConstraint.constraintPinSubview(bodyLabel, pinTop: false, topConstant:0 , pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 12, pinRight: true, rightConstant: 12) bodyLabel.topAnchor.constraint(equalTo: lineView.bottomAnchor, constant: 12).isActive = true bodyLabel.bottomAnchor.constraint(lessThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true - } + public func updateView(_ size: CGFloat) { self.setNeedsLayout() self.bottomView.setNeedsLayout() @@ -89,23 +87,19 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco DispatchQueue.main.async { [weak self] in self?.addBordertoView() } - } - - - + private func addBordertoView(){ bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) bottomView.layer.addBorder(edge: .top, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) } - private func addOutofstockLine(){ - + + private func addOutOfStockLine(){ let path = UIBezierPath() path.move(to: CGPoint(x: 0, y: bottomView.bounds.height)) path.addLine(to: CGPoint(x: bottomView.bounds.width, y: 0)) - let shapeLayer = CAShapeLayer() shapeLayer.name = "outofstock" shapeLayer.path = path.cgPath @@ -119,11 +113,13 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco if let backgroundColor = collectionModel.backgroundColor { bottomView.backgroundColor = backgroundColor.uiColor } + self.isUserInteractionEnabled = collectionModel.enabled lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor bodyLabel.text = collectionModel.text - isSelected = collectionModel.selected ?? false + isSelected = collectionModel.selected fieldValue = collectionModel.fieldValue - isOutofStock = collectionModel.strikethrough ?? false + isOutOfStock = collectionModel.strikethrough + } } @@ -153,5 +149,4 @@ extension CALayer { border.backgroundColor = color.cgColor; self.addSublayer(border) } - } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift index 0e72f6e5..31f58e53 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -12,8 +12,9 @@ import Foundation public var text: String public var backgroundColor: Color? = Color(uiColor: .white) public var selectedAccentColor: Color? = try? Color(colorString: "#D52B1E") - public var selected: Bool? = false - public var strikethrough: Bool? = false + public var selected: Bool = false + public var enabled: Bool = true + public var strikethrough: Bool = false public var fieldValue: String? private enum CodingKeys: String, CodingKey { @@ -22,15 +23,14 @@ import Foundation case selectedAccentColor case backgroundColor case selected + case enabled case strikethrough case fieldValue - } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) text = try typeContainer.decode(String.self, forKey: .text) - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor) { selectedAccentColor = color } @@ -40,21 +40,23 @@ import Foundation if let isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .selected) { selected = isSelected } + if let isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { + enabled = isEnabled + } if let isStrikeTrough = try typeContainer.decodeIfPresent(Bool.self, forKey: .strikethrough) { strikethrough = isStrikeTrough } fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) - } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(selectedAccentColor, forKey: .selectedAccentColor) + try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(selected, forKey: .selected) + try container.encodeIfPresent(enabled, forKey: .enabled) try container.encodeIfPresent(strikethrough, forKey: .strikethrough) try container.encodeIfPresent(fieldValue, forKey: .fieldValue) - } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift index 7dcd2acc..90a0d684 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -16,8 +16,6 @@ open class RadioBoxes: View { var boxes: [RadioBoxModel]? public var fieldKey: String? public var groupName: String? - public var enabled: Bool? - public var collectionViewHeight: NSLayoutConstraint? private let boxWidth: Double = 151.0 private let boxHeight: Double = 64.0 @@ -40,10 +38,8 @@ open class RadioBoxes: View { NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView) collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) collectionViewHeight?.isActive = true - } - // MARK: - MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) @@ -51,25 +47,21 @@ open class RadioBoxes: View { backgroundColor = radioBoxesModel.backgroundColor?.uiColor fieldKey = radioBoxesModel.fieldKey groupName = radioBoxesModel.groupName - enabled = radioBoxesModel.enabled registerCells() setupLayout(with: radioBoxesModel) prepareMolecules(with: radioBoxesModel) collectionView.reloadData() } + @objc override open func updateView(_ size: CGFloat) { - collectionView.collectionViewLayout.invalidateLayout() - DispatchQueue.main.async { [weak self] in self?.setNeedsDisplay() self?.collectionView.layoutIfNeeded() self?.collectionView.reloadData() - } } - // MARK: - JSON Setters /// Updates the layout being used @@ -95,12 +87,10 @@ open class RadioBoxes: View { /// Registers the cells with the collection view func registerCells() { - collectionView.register(RadioBoxCollectionViewCell.self, forCellWithReuseIdentifier: "RadioBoxCollectionViewCell") } - - } + extension RadioBoxes: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let itemWidth = (Double(collectionView.bounds.width) - itemSpacing)/2 diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift index ab2b4728..4e690ffa 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift @@ -11,7 +11,6 @@ import Foundation public static var identifier: String = "radioBoxes" public var backgroundColor: Color? = Color(uiColor: .white) public var selectedAccentColor: Color? = Color(uiColor: .red) - public var enabled: Bool? = true public var boxes: [RadioBoxModel] public var fieldKey: String? public var groupName: String? @@ -20,7 +19,6 @@ import Foundation case moleculeName case selectedAccentColor case backgroundColor - case enabled case boxes case fieldKey case groupName @@ -34,23 +32,17 @@ import Foundation if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { backgroundColor = color } - if let isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) { - enabled = isEnabled - } boxes = try typeContainer.decode([RadioBoxModel].self, forKey: .boxes) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) - } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(selectedAccentColor, forKey: .selectedAccentColor) + try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(enabled, forKey: .enabled) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) - } } From b0be1dbce3de6a9f8f0e979dfd9ebd79619c4a9d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 7 Apr 2020 10:08:07 -0400 Subject: [PATCH 179/244] Collection changes --- MVMCoreUI.xcodeproj/project.pbxproj | 32 +- .../Molecules/Items/CarouselItemModel.swift | 12 +- .../Items/CollectionItemModelProtocol.swift | 13 + .../Items/MoleculeCollectionItemModel.swift | 66 ++++ .../Items/MoleculeCollectionViewCell.swift | 133 ++------ MVMCoreUI/Atomic/Organisms/Carousel.swift | 30 +- .../Atomic/Organisms/CarouselModel.swift | 14 +- .../CarouselPagingModelProtocol.swift | 2 +- .../Atomic/Templates/CollectionTemplate.swift | 15 + .../Templates/CollectionTemplateModel.swift | 67 ++++ .../Atomic/Templates/ThreeLayerTemplate.swift | 4 - .../BaseClasses/CollectionViewCell.swift | 77 +++++ .../ThreeLayerCollectionViewController.swift | 289 ++++++++++++++++++ .../MVMCoreUIViewControllerMappingObject.m | 3 +- 14 files changed, 613 insertions(+), 144 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift create mode 100644 MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift create mode 100644 MVMCoreUI/Atomic/Templates/CollectionTemplate.swift create mode 100644 MVMCoreUI/Atomic/Templates/CollectionTemplateModel.swift create mode 100644 MVMCoreUI/BaseClasses/CollectionViewCell.swift create mode 100644 MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c0a56ebc..e1310f0d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -210,6 +210,10 @@ D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; + D21B7F71243BAC1600051ABF /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */; }; + D21B7F73243BAC6800051ABF /* CollectionItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21B7F72243BAC6800051ABF /* CollectionItemModelProtocol.swift */; }; + D21B7F75243BAC8900051ABF /* CarouselItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21B7F74243BAC8900051ABF /* CarouselItem.swift */; }; + D21B7F77243BB70700051ABF /* MoleculeCollectionItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21B7F76243BB70700051ABF /* MoleculeCollectionItemModel.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelToggle.swift */; }; D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224798B231450C8003FCCF9 /* HeadlineBodyToggle.swift */; }; @@ -242,6 +246,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, ); }; }; + D264FA8C243BCD8E00D98315 /* CollectionTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */; }; + D264FA8E243BCD9A00D98315 /* CollectionTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */; }; + D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; }; @@ -608,6 +615,10 @@ D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; + D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = ""; }; + D21B7F72243BAC6800051ABF /* CollectionItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionItemModelProtocol.swift; sourceTree = ""; }; + D21B7F74243BAC8900051ABF /* CarouselItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItem.swift; sourceTree = ""; }; + D21B7F76243BB70700051ABF /* MoleculeCollectionItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeCollectionItemModel.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggle.swift; sourceTree = ""; }; D224798B231450C8003FCCF9 /* HeadlineBodyToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyToggle.swift; sourceTree = ""; }; @@ -640,6 +651,9 @@ 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 = ""; }; + D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplateModel.swift; sourceTree = ""; }; + D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplate.swift; sourceTree = ""; }; + D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerCollectionViewController.swift; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; @@ -1236,8 +1250,6 @@ D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */, 01EB368923609801006832FA /* MoleculeListItemModel.swift */, 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */, - 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, - D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */, D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, D28A837C23CCA86A00DFE4FC /* TabsListItemModel.swift */, @@ -1249,6 +1261,11 @@ D260105E23D0BFFC00764D80 /* StackItem.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */, + D21B7F72243BAC6800051ABF /* CollectionItemModelProtocol.swift */, + D21B7F76243BB70700051ABF /* MoleculeCollectionItemModel.swift */, + D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, + 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, + D21B7F74243BAC8900051ABF /* CarouselItem.swift */, ); path = Items; sourceTree = ""; @@ -1403,6 +1420,8 @@ 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */, 014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */, D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */, + D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */, + D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */, ); path = Templates; sourceTree = ""; @@ -1458,6 +1477,7 @@ D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */, D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */, + D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */, D2C521A823EDE79E00CA2634 /* ViewController.swift */, D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */, D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */, @@ -1757,6 +1777,7 @@ D2B18B802360945C00A9AEDC /* View.swift */, 0AE14F63238315D2005417F8 /* TextField.swift */, D2755D7A23689C7500485468 /* TableViewCell.swift */, + D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */, 0A5D59C323AD488600EFD9E9 /* Protocols */, ); path = BaseClasses; @@ -2005,6 +2026,7 @@ D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */, + D21B7F77243BB70700051ABF /* MoleculeCollectionItemModel.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, 011D9602240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, @@ -2022,6 +2044,7 @@ 0A21DB91235E0EDB00C160A2 /* DigitBox.swift in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */, + D21B7F71243BAC1600051ABF /* CollectionViewCell.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, @@ -2076,6 +2099,7 @@ D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, + D264FA8E243BCD9A00D98315 /* CollectionTemplate.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */, 0A1B4A96233BB18F005B3FB4 /* CheckboxLabel.swift in Sources */, @@ -2203,6 +2227,7 @@ D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, 0A21DB94235E24ED00C160A2 /* DigitEntryField.swift in Sources */, + D264FA8C243BCD8E00D98315 /* CollectionTemplateModel.swift in Sources */, 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */, D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, 0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */, @@ -2229,10 +2254,12 @@ 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */, C003506123AA94CD00B6AC29 /* Button.swift in Sources */, DBC4391B224421A0001AB423 /* CaretLink.swift in Sources */, + D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */, BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */, 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */, + D21B7F73243BAC6800051ABF /* CollectionItemModelProtocol.swift in Sources */, C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, @@ -2262,6 +2289,7 @@ EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, + D21B7F75243BAC8900051ABF /* CarouselItem.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift index 9fc218a7..ab6a1cbd 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemModel.swift @@ -9,22 +9,20 @@ import Foundation -@objcMembers public class CarouselItemModel: MoleculeContainerModel, CarouselItemModelProtocol { - public static var identifier: String = "carouselItem" - public var backgroundColor: Color? +@objcMembers public class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol { + public override class var identifier: String { + return "carouselItem" + } public var peakingUI: Bool? public var peakingArrowColor: Color? private enum CodingKeys: String, CodingKey { - case moleculeName - case backgroundColor case peakingUI case peakingArrowColor } required public init(from decoder: Decoder) throws { 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) try super.init(from: decoder) @@ -33,8 +31,6 @@ 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/Atomic/Molecules/Items/CollectionItemModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift new file mode 100644 index 00000000..c8bfb7d7 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift @@ -0,0 +1,13 @@ +// +// CollectionItemModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol CollectionItemModelProtocol: ContainerModelProtocol { + +} diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift new file mode 100644 index 00000000..8d236f4b --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift @@ -0,0 +1,66 @@ +// +// MoleculeCollectionItemModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers open class MoleculeCollectionItemModel: CollectionItemModelProtocol, MoleculeModelProtocol { + open class var identifier: String { + return "collectionItem" + } + open var molecule: MoleculeModelProtocol + public var backgroundColor: Color? + + 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? + + /// Defaults to set + open func setDefaults() { + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } + if topMarginPadding == nil { + topMarginPadding = PaddingDefault + } + if bottomMarginPadding == nil { + bottomMarginPadding = PaddingDefault + } + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + case backgroundColor + } + + public init(with moleculeModel: MoleculeModelProtocol) { + molecule = moleculeModel + setDefaults() + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + molecule = try typeContainer.decodeModel(codingKey: .molecule) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + setDefaults() + } + + open func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeModel(molecule, forKey: .molecule) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift index 219617ec..0ae515f5 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift @@ -8,90 +8,15 @@ import UIKit -open class MoleculeCollectionViewCell: UICollectionViewCell, MoleculeViewProtocol { - - open var molecule: MoleculeViewProtocol? - public let containerHelper = ContainerHelper() - - // In updateView, will set padding to default. - open var updateViewHorizontalDefaults = true - open var updateViewVerticalDefaults = true - - open var allowsPeaking = false - var peakingLeftArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) - var peakingRightArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) - var peakingCover = MVMCoreUICommonViewsUtility.commonView() - - public override init(frame: CGRect) { - super.init(frame: .zero) - setupView() - } - - public required init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - setupView() - } - - public func setupView() { - guard peakingCover.superview == nil else { - return - } - isAccessibilityElement = false - contentView.isAccessibilityElement = false - insetsLayoutMarginsFromSafeArea = false - contentView.insetsLayoutMarginsFromSafeArea = false - contentView.preservesSuperviewLayoutMargins = false - - // Covers the card when peaking. - peakingCover.backgroundColor = .white - peakingCover.alpha = 0 - contentView.addSubview(peakingCover) - NSLayoutConstraint.constraintPinSubview(toSuperview: peakingCover) - - // A small arrow on the next card for when peaking. - let ratio: CGFloat = 0.015 - peakingLeftArrow.translatesAutoresizingMaskIntoConstraints = false - peakingLeftArrow.alpha = 0 - peakingLeftArrow.tintColor = .black - contentView.addSubview(peakingLeftArrow) - peakingLeftArrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true - NSLayoutConstraint.scalingPinViewLeft(toSuper: peakingLeftArrow, ratio: ratio, anchor: contentView.widthAnchor) - - peakingRightArrow.translatesAutoresizingMaskIntoConstraints = false - peakingRightArrow.transform = CGAffineTransform(scaleX: -1, y: 1) // Flip - peakingRightArrow.alpha = 0 - peakingRightArrow.tintColor = .black - contentView.addSubview(peakingRightArrow) - peakingRightArrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true - NSLayoutConstraint.scalingPinViewRight(toSuper: peakingRightArrow, ratio: ratio, anchor: contentView.widthAnchor) - } - - - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let collectionModel = model as? CarouselItemModel else { return } - if let useHorizontalMargins = collectionModel.useHorizontalMargins { - updateViewHorizontalDefaults = useHorizontalMargins - } - if let useVerticalMargins = collectionModel.useVerticalMargins { - updateViewVerticalDefaults = useVerticalMargins - } - // Handles peaking. - allowsPeaking = collectionModel.peakingUI ?? false - if let peakingArrowColor = collectionModel.peakingArrowColor { - let color = peakingArrowColor.uiColor - peakingLeftArrow.tintColor = color - peakingRightArrow.tintColor = color - } - - if let backgroundColor = collectionModel.backgroundColor { - self.backgroundColor = backgroundColor.uiColor - } +open class MoleculeCollectionViewCell: CollectionViewCell { + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let collectionModel = model as? MoleculeCollectionItemModel else { return } if molecule == nil { if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(collectionModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { - contentView.insertSubview(moleculeView, at: 0) - containerHelper.constrainView(moleculeView) - molecule = moleculeView + addMolecule(moleculeView) + contentView.sendSubviewToBack(moleculeView) } } else { molecule?.set(with: collectionModel.molecule, delegateObject, additionalData) @@ -102,39 +27,33 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco accessibilityElements = molecule.subviews } - public func reset() { + open override func reset() { + super.reset() molecule?.reset() - updateViewVerticalDefaults = true - updateViewHorizontalDefaults = true backgroundColor = .white } - public class func nameForReuse(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - guard let molecule = (model as? CarouselItemModel)?.molecule, - let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { - return nil - } - return moleculeClass.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName + open class func nameForReuse(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let moleculeModel = (model as? MoleculeCollectionItemModel)?.molecule else { return "\(self)<>" } + let className = MoleculeObjectMapping.shared()?.getMoleculeClass(moleculeModel) + let moleculeName = className?.nameForReuse(with: moleculeModel, delegateObject) ?? moleculeModel.moleculeName + return "\(self)<\(moleculeName)>" } - public func updateView(_ size: CGFloat) { - (molecule as? MVMCoreViewProtocol)?.updateView(size) - MFStyler.setDefaultMarginsFor(contentView, size: size, horizontal: updateViewHorizontalDefaults, vertical: updateViewVerticalDefaults) + open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + guard let moleculeModel = (model as? MoleculeCollectionItemModel)?.molecule, + let theClass = MoleculeObjectMapping.shared()?.getMoleculeClass(moleculeModel) + else { return nil } + + return theClass.requiredModules(with: moleculeModel, delegateObject, error: error) } - public func setPeaking(_ peaking: Bool, animated: Bool) { - guard allowsPeaking else { - return - } - let animation = {() in - self.peakingRightArrow.alpha = peaking ? 1 : 0 - self.peakingLeftArrow.alpha = peaking ? 1 : 0 - self.peakingCover.alpha = peaking ? 0.5 : 0 - } - if animated { - UIView.animate(withDuration: 0.4, animations: animation) - } else { - animation() - } + open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + guard let model = model as? MoleculeCollectionItemModel, + let classType = MoleculeObjectMapping.shared()?.getMoleculeClass(model.molecule), + let height = classType.estimatedHeight(with: model.molecule, delegateObject) + else { return 100 } + + return height + (model.topMarginPadding ?? 0) + (model.bottomMarginPadding ?? 0) } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index a7117e33..05a28a51 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -52,12 +52,11 @@ open class Carousel: View { public var delegateObject: MVMCoreUIDelegateObject? + private var size: CGFloat? + // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() - guard collectionView.superview == nil else { - return - } collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.dataSource = self collectionView.delegate = self @@ -73,6 +72,7 @@ open class Carousel: View { open override func updateView(_ size: CGFloat) { super.updateView(size) + self.size = size collectionView.collectionViewLayout.invalidateLayout() showPeaking(false) @@ -143,7 +143,7 @@ open class Carousel: View { } /// Sets up the paging molecule - open func setupPagingMolecule(_ molecule: CarouselPagingModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) { + open func setupPagingMolecule(_ molecule: (CarouselPagingModelProtocol & MoleculeModelProtocol)?, delegateObject: MVMCoreUIDelegateObject?) { var pagingView: (UIView & MVMCoreUIPagingProtocol)? = nil if let molecule = molecule { pagingView = MoleculeObjectMapping.shared()?.createMolecule(molecule, delegateObject: delegateObject) as? (UIView & MVMCoreUIPagingProtocol) @@ -208,15 +208,15 @@ open class Carousel: View { // Show overlay and arrow in peaking Cell let visibleItemsPaths = collectionView.indexPathsForVisibleItems.sorted { $0.row < $1.row } if let firstItem = visibleItemsPaths.first, firstItem.row != currentIndex { - (collectionView.cellForItem(at: firstItem) as? MoleculeCollectionViewCell)?.setPeaking(true, animated: true) + (collectionView.cellForItem(at: firstItem) as? CarouselItem)?.setPeaking(true, animated: true) } if let lastItem = visibleItemsPaths.last, lastItem.row != currentIndex { - (collectionView.cellForItem(at: lastItem) as? MoleculeCollectionViewCell)?.setPeaking(true, animated: true) + (collectionView.cellForItem(at: lastItem) as? CarouselItem)?.setPeaking(true, animated: true) } } else { // Hide peaking. for item in collectionView.visibleCells { - (item as? MoleculeCollectionViewCell)?.setPeaking(false, animated: true) + (item as? CarouselItem)?.setPeaking(false, animated: true) } } } @@ -229,10 +229,12 @@ open class Carousel: View { cell.accessibilityElementsHidden = false var array = cell.accessibilityElements - if let acc = pagingView?.accessibilityElements { - array?.append(contentsOf: acc) - } else { - array?.append(pagingView!) + if let pagingView = pagingView { + if let acc = pagingView.accessibilityElements { + array?.append(contentsOf: acc) + } else { + array?.append(pagingView) + } } self.accessibilityElements = array @@ -244,12 +246,12 @@ open class Carousel: View { extension Carousel: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let itemWidth = collectionView.bounds.width * CGFloat(itemWidthPercent) + let itemWidth = (size ?? collectionView.bounds.width) * CGFloat(itemWidthPercent) return CGSize(width: itemWidth, height: collectionView.bounds.height) } open func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { - (cell as? MoleculeCollectionViewCell)?.setPeaking(false, animated: false) + (cell as? CarouselItem)?.setPeaking(false, animated: false) } } @@ -268,7 +270,7 @@ extension Carousel: UICollectionViewDataSource { protocolCell.reset() protocolCell.set(with: moleculeInfo.molecule, delegateObject, nil) } - (cell as? MVMCoreViewProtocol)?.updateView(collectionView.bounds.width) + (cell as? MVMCoreViewProtocol)?.updateView(size ?? collectionView.bounds.width) setAccessiblity(cell, index: indexPath.row) return cell } diff --git a/MVMCoreUI/Atomic/Organisms/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/CarouselModel.swift index 8b987a73..9fb4fe3b 100644 --- a/MVMCoreUI/Atomic/Organisms/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/CarouselModel.swift @@ -19,7 +19,7 @@ import UIKit public var height: Float? public var itemWidthPercent: Float? public var itemAlignment: UICollectionView.ScrollPosition? - public var pagingMolecule: CarouselPagingModelProtocol? + public var pagingMolecule: (CarouselPagingModelProtocol & MoleculeModelProtocol)? public init(molecules: [CarouselItemModel]){ self.molecules = molecules @@ -42,12 +42,12 @@ import UIKit let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) 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) - self.height = try typeContainer.decode(Float.self, forKey: .height) - self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent) - self.itemAlignment = try typeContainer.decode(UICollectionView.ScrollPosition.self, forKey: .itemAlignment) + self.spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) + self.border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) + self.loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop) + self.height = try typeContainer.decodeIfPresent(Float.self, forKey: .height) + self.itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent) + self.itemAlignment = try typeContainer.decodeIfPresent(UICollectionView.ScrollPosition.self, forKey: .itemAlignment) self.pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule) } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselPagingModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselPagingModelProtocol.swift index 94b1277a..72138290 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselPagingModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/CarouselPagingModelProtocol.swift @@ -9,6 +9,6 @@ import Foundation -public protocol CarouselPagingModelProtocol: MoleculeModelProtocol { +public protocol CarouselPagingModelProtocol { var position: Float? { get } } diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift new file mode 100644 index 00000000..ce135631 --- /dev/null +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -0,0 +1,15 @@ +// +// CollectionTemplate.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objc open class CollectionTemplate: ThreeLayerCollectionViewController, TemplateProtocol { + public typealias TemplateModel = CollectionTemplateModel + public var templateModel: CollectionTemplateModel? + +} diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplateModel.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplateModel.swift new file mode 100644 index 00000000..56c56456 --- /dev/null +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplateModel.swift @@ -0,0 +1,67 @@ +// +// CollectionTemplateModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class CollectionTemplateModel: TemplateModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { + return "collection" + } + public var header: MoleculeModelProtocol? + public var molecules: [CollectionItemModelProtocol & MoleculeModelProtocol]? + public var footer: MoleculeModelProtocol? + public var columns: Int? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(pageType: String, screenHeading: String?, molecules: [CollectionItemModelProtocol & MoleculeModelProtocol]) { + super.init(pageType: pageType) + self.screenHeading = screenHeading + self.molecules = molecules + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case molecules + case header + case footer + case columns + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + molecules = try typeContainer.decodeModelsIfPresent(codingKey: .molecules) + header = try typeContainer.decodeModelIfPresent(codingKey: .header) + footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) + columns = try typeContainer.decodeIfPresent(Int.self, forKey: .columns) + 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.encodeModelsIfPresent(molecules, forKey: .molecules) + try container.encodeModelIfPresent(header, forKey: .header) + try container.encodeModelIfPresent(footer, forKey: .footer) + try container.encodeIfPresent(columns, forKey: .columns) + } +} + diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift index 8f963f5d..96e85fad 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift @@ -51,10 +51,6 @@ import UIKit return molecule } - open override func spaceBetweenMiddleAndBottom() -> CGFloat? { - return 0 - } - open override func spaceBetweenTopAndMiddle() -> CGFloat? { return 0 } diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift new file mode 100644 index 00000000..50cece5d --- /dev/null +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -0,0 +1,77 @@ +// +// CollectionViewCell.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol { + + // Convenience helpers + open var molecule: MoleculeViewProtocol? + public let containerHelper = ContainerHelper() + open var model: CollectionItemModelProtocol? + + private var initialSetupPerformed = false + + public override init(frame: CGRect) { + super.init(frame: .zero) + initialSetup() + } + + public required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + initialSetup() + } + + private func initialSetup() { + if !initialSetupPerformed { + initialSetupPerformed = true + setupView() + } + } + + open func setupView() { + isAccessibilityElement = false + contentView.isAccessibilityElement = false + insetsLayoutMarginsFromSafeArea = false + contentView.insetsLayoutMarginsFromSafeArea = false + contentView.preservesSuperviewLayoutMargins = false + MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0) + } + + open func updateView(_ size: CGFloat) { + containerHelper.updateViewMargins(contentView, model: model, size: size) + DispatchQueue.main.async { + print("\(self.contentView.directionalLayoutMargins.leading)") + } + } + + open func reset() { + molecule?.reset() + backgroundColor = .white + } + + open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let model = model as? CollectionItemModelProtocol else { return } + self.model = model + + if let moleculeModel = model as? MoleculeModelProtocol, + let backgroundColor = moleculeModel.backgroundColor { + self.backgroundColor = backgroundColor.uiColor + } + + // align if needed. + containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) + } + + /// Convenience function. Adds the molecule to the view. + open func addMolecule(_ molecule: MoleculeViewProtocol) { + contentView.addSubview(molecule) + containerHelper.constrainView(molecule) + self.molecule = molecule + } +} diff --git a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift new file mode 100644 index 00000000..a7b39cfd --- /dev/null +++ b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift @@ -0,0 +1,289 @@ +// +// ThreeLayerCollectionViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objc open class ThreeLayerCollectionViewController: ScrollingViewController, UICollectionViewDataSource, UICollectionViewDelegate { + public var collectionView: UICollectionView? + + // The three main views + private var topView: UIView? + private var bottomView: UIView? + private var headerView: UIView? + private var footerView: UIView? + private var safeAreaView: UIView? + var useMargins: Bool = true + public var bottomViewOutsideOfScrollArea: Bool = false + private var topViewBottomConstraint: NSLayoutConstraint? + private var bottomViewTopConstraint: NSLayoutConstraint? + + //MARK: - MFViewController + open override func updateViews() { + super.updateViews() + let width = view.bounds.width + if let topView = topView as? MVMCoreViewProtocol { + topView.updateView(width) + //showHeader(width) + } + if let bottomView = bottomView as? MVMCoreViewProtocol { + bottomView.updateView(width) + //showFooter(width) + } + self.collectionView?.collectionViewLayout.invalidateLayout() + } + + open override func handleNewData() { + super.handleNewData() + //createViewForTableHeader() + //createViewForTableFooter() + collectionView?.reloadData() + } + + override open func viewDidLoad() { + let collection = createCollectionView() + collectionView = collection + view.addSubview(collection) + NSLayoutConstraint.constraintPinSubview(toSuperview: collection) + scrollView = collectionView + + registerCells() + + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + //MARK: - Spacing + // If both are subclassed to return a value, then the buttons will not be pinned towards the bottom because neither spacing would try to fill the screen. + /// Space between the top view and the table sections, nil to fill. 0 default + open func spaceBelowTopView() -> CGFloat? { + return 0 + } + + /// Space between the bottom view and the table sections, nil to fill. nil default + open func spaceAboveBottomView() -> CGFloat? { + return nil + } + + /// can override to return a minimum fill space. + open func minimumFillSpace() -> CGFloat { + return 0 + } + + /*open override func updateViewConstraints() { + super.updateViewConstraints() + + guard let tableView = collectionView else { return } + + let minimumSpace: CGFloat = minimumFillSpace() + var currentSpace: CGFloat = 0 + var totalMinimumSpace: CGFloat = 0 + + var fillTop = false + if spaceBelowTopView() == nil, headerView != nil { + fillTop = true + currentSpace += topViewBottomConstraint?.constant ?? 0 + totalMinimumSpace += minimumSpace + } + + var fillBottom = false + if spaceAboveBottomView() == nil, !bottomViewOutsideOfScrollArea, footerView != nil { + fillBottom = true + currentSpace += bottomViewTopConstraint?.constant ?? 0 + totalMinimumSpace += minimumSpace + } + + guard fillTop || fillBottom else { return } + + let newSpace = MVMCoreUIUtility.getVariableConstraintHeight(currentSpace, in: tableView, minimumHeight: totalMinimumSpace) + + // If the bottom view is outside of the scroll, then only the top view constraint is being used, so we have to double it to account for the bottom constraint not being there when we compare to the new value. + var currentSpaceForCompare: CGFloat = currentSpace + if fillTop && bottomViewOutsideOfScrollArea { + currentSpaceForCompare = currentSpace * 2; + } + + let width = view.bounds.width + if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 0.1) { + if fillTop && fillBottom { + // space both + let half = newSpace / 2 + topViewBottomConstraint?.constant = half + bottomViewTopConstraint?.constant = half + showHeader(width) + showFooter(width) + } else if fillTop { + // Only top is spaced (half the size if the bottom view is out of the scroll because it needs to be sized as if there are two spacers but there is only one. + if bottomViewOutsideOfScrollArea { + topViewBottomConstraint?.constant = newSpace / 2 + } else { + topViewBottomConstraint?.constant = newSpace + } + showHeader(width) + } else if fillBottom { + // Only bottom is spaced. + bottomViewTopConstraint?.constant = newSpace + showFooter(width) + } + } + } + + //MARK: - Header Footer + /// Gets the top view and adds it to a spacing view, headerView, and then calls showHeader. + open func createViewForTableHeader() { + let topView = viewForTop() + self.topView = topView + + let headerView = MVMCoreUICommonViewsUtility.commonView() + headerView.addSubview(topView) + topView.topAnchor.constraint(equalTo: headerView.topAnchor).isActive = true + topView.leftAnchor.constraint(equalTo: headerView.leftAnchor).isActive = true + headerView.rightAnchor.constraint(equalTo: topView.rightAnchor).isActive = true + topViewBottomConstraint = headerView.bottomAnchor.constraint(equalTo: topView.bottomAnchor, constant: spaceBelowTopView() ?? 0) + topViewBottomConstraint?.isActive = true + self.headerView = headerView + showHeader(nil) + } + + /// Gets the bottom view and adds it to a spacing view, footerView, and then calls showFooter. + open func createViewForTableFooter() { + let bottomView = viewForBottom() + self.bottomView = bottomView + + let footerView = MVMCoreUICommonViewsUtility.commonView() + footerView.addSubview(bottomView) + bottomViewTopConstraint = bottomView.topAnchor.constraint(equalTo: footerView.topAnchor, constant: spaceAboveBottomView() ?? 0) + bottomViewTopConstraint?.isActive = true + bottomView.leftAnchor.constraint(equalTo: footerView.leftAnchor).isActive = true + footerView.rightAnchor.constraint(equalTo: bottomView.rightAnchor).isActive = true + footerView.bottomAnchor.constraint(equalTo: bottomView.bottomAnchor).isActive = true + self.footerView = footerView + showFooter(nil) + } + + /// Takes the current headerView and adds it to the tableHeaderView + func showHeader(_ sizingWidth: CGFloat?) { + headerView?.removeFromSuperview() + tableView?.tableHeaderView = nil + guard let headerView = headerView else { + return + } + + // This extra view is needed because of the wonkiness of apple's table header. Things breaks if using autolayout. + headerView.setNeedsLayout() + headerView.layoutIfNeeded() + MVMCoreUIUtility.sizeView(toFit: headerView) + let tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: MVMCoreUIUtility.getWidth(), height: headerView.frame.height)) + tableHeaderView.addSubview(headerView) + NSLayoutConstraint.constraintPinSubview(toSuperview: headerView) + tableView?.tableHeaderView = tableHeaderView + } + + /// Takes the current footerView and adds it to the tableFooterView + func showFooter(_ sizingWidth: CGFloat?) { + footerView?.removeFromSuperview() + safeAreaView?.removeFromSuperview() + guard let footerView = footerView, let tableView = tableView else { + return + } + + if bottomViewOutsideOfScrollArea { + // put bottom view outside of scrolling area. + bottomConstraint?.isActive = false + view.addSubview(footerView) + footerView.topAnchor.constraint(equalTo: tableView.bottomAnchor).isActive = true + footerView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + view.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true + view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true + safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: view) + safeAreaView?.backgroundColor = bottomView?.backgroundColor + } else { + bottomConstraint?.isActive = true + var y: CGFloat? + if let tableFooterView = tableView.tableFooterView { + // if footer already exists, use the same y location to avoid strange moving animation + y = tableFooterView.frame.minY + } + + // This extra view is needed because of the wonkiness of apple's table footer. Things breaks if using autolayout. + MVMCoreUIUtility.sizeView(toFit: footerView) + let tableFooterView = UIView(frame: CGRect(x: 0, y: y ?? 0, width: MVMCoreUIUtility.getWidth(), height: footerView.frame.height)) + tableFooterView.addSubview(footerView) + NSLayoutConstraint.constraintPinSubview(toSuperview: footerView) + tableView.tableFooterView = tableFooterView + } + }*/ + + //MARK: - Functions to subclass + /// Subclass for a top view. + open func viewForTop() -> UIView { + let view = MVMCoreUICommonViewsUtility.commonView() + // Small height is needed to stop apple from adding padding for grouped tables when no header. + view.heightAnchor.constraint(equalToConstant: 1).isActive = true + return view + } + + /// Subclass for a bottom view. + open func viewForBottom() -> UIView { + // Default spacing is standard when no buttons. + let view = MVMCoreUICommonViewsUtility.commonView() + view.heightAnchor.constraint(equalToConstant: PaddingDefaultVerticalSpacing).isActive = true + return view + } + + open func createCollectionView() -> UICollectionView { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.minimumLineSpacing = 1 + layout.minimumInteritemSpacing = 0 + + let collection = UICollectionView(frame: .zero, collectionViewLayout: layout) + collection.translatesAutoresizingMaskIntoConstraints = false + collection.dataSource = self + collection.delegate = self + collection.showsHorizontalScrollIndicator = false + collection.backgroundColor = .white + collection.isAccessibilityElement = false + collection.contentInsetAdjustmentBehavior = .always + return collection + } + + deinit { + collectionView?.delegate = nil + collectionView?.dataSource = nil + } + + //MARK: - Collection + + public func registerCells() { + collectionView?.register(MoleculeCollectionViewCell.self, forCellWithReuseIdentifier: "collectionItem") + } + + public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 2 + } + + public func numberOfSections(in collectionView: UICollectionView) -> Int { + return 1 + } + + public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionItem", for: indexPath) as! MoleculeCollectionViewCell + let labelModel = LabelModel(text: "hello") + let model = MoleculeCollectionItemModel(with: labelModel) + cell.set(with: model, delegateObjectIVar, nil) + return cell + } + + open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: 200, height: 200) + } + + open func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { + (cell as? CarouselItem)?.setPeaking(false, animated: false) + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index d3db2a2d..20fb924e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -24,7 +24,8 @@ @"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], @"threeLayer" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]], @"modalStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ModalMoleculeStackTemplate class]], - @"modalList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ModalMoleculeListTemplate class]] + @"modalList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ModalMoleculeListTemplate class]], + @"collection" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[CollectionTemplate class]] } mutableCopy]; }); return viewControllerMapping; From d393098fcddc0e963a54737d63e44251d1fa9748 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 7 Apr 2020 10:08:47 -0400 Subject: [PATCH 180/244] collection changes --- .../Atomic/Molecules/Items/CarouselItem.swift | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift new file mode 100644 index 00000000..9cf2a246 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift @@ -0,0 +1,73 @@ +// +// CarouselItem.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class CarouselItem: MoleculeCollectionViewCell { + + open var allowsPeaking = false + var peakingLeftArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) + var peakingRightArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) + var peakingCover = MVMCoreUICommonViewsUtility.commonView() + + open override func setupView() { + super.setupView() + + // Covers the card when peaking. + peakingCover.backgroundColor = .white + peakingCover.alpha = 0 + contentView.addSubview(peakingCover) + NSLayoutConstraint.constraintPinSubview(toSuperview: peakingCover) + + // A small arrow on the next card for when peaking. + let ratio: CGFloat = 0.015 + peakingLeftArrow.translatesAutoresizingMaskIntoConstraints = false + peakingLeftArrow.alpha = 0 + peakingLeftArrow.tintColor = .black + contentView.addSubview(peakingLeftArrow) + peakingLeftArrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true + NSLayoutConstraint.scalingPinViewLeft(toSuper: peakingLeftArrow, ratio: ratio, anchor: contentView.widthAnchor) + + peakingRightArrow.translatesAutoresizingMaskIntoConstraints = false + peakingRightArrow.transform = CGAffineTransform(scaleX: -1, y: 1) // Flip + peakingRightArrow.alpha = 0 + peakingRightArrow.tintColor = .black + contentView.addSubview(peakingRightArrow) + peakingRightArrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true + NSLayoutConstraint.scalingPinViewRight(toSuper: peakingRightArrow, ratio: ratio, anchor: contentView.widthAnchor) + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let collectionModel = model as? CarouselItemModel else { return } + + // Handles peaking. + allowsPeaking = collectionModel.peakingUI ?? false + if let peakingArrowColor = collectionModel.peakingArrowColor { + let color = peakingArrowColor.uiColor + peakingLeftArrow.tintColor = color + peakingRightArrow.tintColor = color + } + } + + public func setPeaking(_ peaking: Bool, animated: Bool) { + guard allowsPeaking else { + return + } + let animation = {() in + self.peakingRightArrow.alpha = peaking ? 1 : 0 + self.peakingLeftArrow.alpha = peaking ? 1 : 0 + self.peakingCover.alpha = peaking ? 0.5 : 0 + } + if animated { + UIView.animate(withDuration: 0.4, animations: animation) + } else { + animation() + } + } +} From 293cb041d3702b56882a4dd6023e6337fed570a3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 7 Apr 2020 10:24:20 -0400 Subject: [PATCH 181/244] Very minor changes --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- .../ListThreeColumnBillChangesDivider.swift | 19 +++++++++++++------ ...stThreeColumnBillChangesDividerModel.swift | 3 --- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index cd15f855..7c7cfd7e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1314,8 +1314,8 @@ D22B38ED23F4E11100490EF6 /* ThreeColumn */ = { isa = PBXGroup; children = ( - BBBBC87A24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift */, BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */, + BBBBC87A24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift */, 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */, 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */, 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */, diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift index ae99001b..a8d80219 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDivider.swift @@ -9,16 +9,16 @@ import Foundation @objcMembers open class ListThreeColumnBillChangesDivider: TableViewCell { - public let leftLabel = Label(frame: .zero) - public let centerLabel = Label(frame: .zero) - public let rightLabel = Label(frame: .zero) + public let leftLabel = Label.createLabelBoldBodySmall(true) + public let centerLabel = Label.createLabelBoldBodySmall(true) + public let rightLabel = Label.createLabelBoldBodySmall(true) var stack: Stack // MARK: - Initializers public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), - (view: centerLabel, model: StackItemModel(percent: 34, horizontalAlignment: .trailing)), - (view: rightLabel, model: StackItemModel(percent: 33, horizontalAlignment: .trailing))], + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 44, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent: 23, horizontalAlignment: .leading))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -46,4 +46,11 @@ import Foundation open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { return 120 } + + open override func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + centerLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift index 202bf3f5..f70a696c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift @@ -24,9 +24,6 @@ public class ListThreeColumnBillChangesDividerModel: ListItemModel, MoleculeMode override public func setDefaults() { super.setDefaults() style = "tallDivider" - leftLabel.fontStyle = .BoldBodySmall - rightLabel.fontStyle = .BoldBodySmall - centerLabel.fontStyle = .BoldBodySmall } private enum CodingKeys: String, CodingKey { From 5443d3ae62f0957106ef286620c41466e5f1b6e0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 7 Apr 2020 10:31:32 -0400 Subject: [PATCH 182/244] organize --- 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 f824b092..9516bdd3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1309,10 +1309,10 @@ D22B38EC23F4E10700490EF6 /* SectionDividers */ = { isa = PBXGroup; children = ( - AA56A20D243C5EDA00303286 /* TwoColumn */, 525665CB24211FD5007BF25F /* OneColumn */, - 525019E3240684E500EED91C /* FourColumn */, + AA56A20D243C5EDA00303286 /* TwoColumn */, D22B38ED23F4E11100490EF6 /* ThreeColumn */, + 525019E3240684E500EED91C /* FourColumn */, ); path = SectionDividers; sourceTree = ""; From 9079d6dcae44899e35659d83fb0831007ee2e7ce Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 11:22:01 -0400 Subject: [PATCH 183/244] more chanes made for design request --- .../Atomic/Atoms/Buttons/CaretLink.swift | 6 ++--- .../Atoms/TextFields/DigitEntryField.swift | 2 +- .../Atomic/Atoms/TextFields/EntryField.swift | 18 ++++++++------- .../Atoms/TextFields/TextEntryField.swift | 21 +++++++++++++----- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 6 ++--- .../Views/EntryFieldContainer.swift | 22 +++++++++---------- 6 files changed, 43 insertions(+), 32 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift index 697f4282..2e042824 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift @@ -25,11 +25,11 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { @objc public var rightViewHeight: NSNumber? @objc public var rightViewWidth: NSNumber? - @objc public var enabledColor: UIColor = .black { + @objc public var enabledColor: UIColor = .mvmBlack { didSet { changeCaretColor() } } - @objc public var disabledColor: UIColor = .mfSilver() { + @objc public var disabledColor: UIColor = .mvmCoolGray3 { didSet { changeCaretColor() } } @@ -114,7 +114,7 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { caretView.widthAnchor.constraint(equalToConstant: width).isActive = true caretView.heightAnchor.constraint(equalToConstant: height).isActive = true - let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 4) + let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 7) caretLabelSpacing.isActive = true caretSpacingConstraint = caretLabelSpacing diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryField.swift index 091f9e51..38adee03 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/DigitEntryField.swift @@ -116,7 +116,7 @@ import UIKit for (index, field) in digitBoxes.enumerated() { if index < newValue.count { let indexChar = newValue.index(newValue.startIndex, offsetBy: index) - field.digitField.attributedPlaceholder = NSAttributedString(string: String(newValue[indexChar]), attributes: [NSAttributedString.Key.foregroundColor: UIColor.mfBattleshipGrey()]) + field.digitField.attributedPlaceholder = NSAttributedString(string: String(newValue[indexChar]), attributes: [NSAttributedString.Key.foregroundColor: UIColor.mvmCoolGray6]) } } diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift index 7fb3a458..658af357 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift @@ -20,8 +20,8 @@ import UIKit public private(set) var titleLabel: Label = { let label = Label() - label.font = MFStyler.fontB3() - label.textColor = .mvmCoolGray6 + label.font = MFStyler.fontRegularMicro() + label.textColor = .mvmBlack label.setContentCompressionResistancePriority(.required, for: .vertical) return label }() @@ -31,7 +31,7 @@ import UIKit /// Provides contextual information on the TextField. public private(set) var feedbackLabel: Label = { let label = Label() - label.font = MFStyler.fontForTextFieldUnderLabel() + label.font = MFStyler.fontRegularMicro() label.textColor = .mvmBlack label.setContentCompressionResistancePriority(.required, for: .vertical) return label @@ -65,7 +65,8 @@ import UIKit public var isEnabled: Bool { get { return entryFieldContainer.isEnabled } set (enabled) { - self.feedbackLabel.textColor = enabled ? .black : .mfSilver() + self.titleLabel.textColor = enabled ? .mvmBlack : .mvmCoolGray3 + self.feedbackLabel.textColor = enabled ? .mvmBlack : .mvmCoolGray3 self.entryFieldContainer.isEnabled = enabled } } @@ -233,15 +234,16 @@ import UIKit //-------------------------------------------------- // MARK: - MoleculeViewProtocol //-------------------------------------------------- + @objc open override func reset() { super.reset() backgroundColor = .clear isAccessibilityElement = false - titleLabel.font = MFStyler.fontB3() - titleLabel.textColor = .mfBattleshipGrey() - feedbackLabel.font = MFStyler.fontForTextFieldUnderLabel() - feedbackLabel.textColor = .black + titleLabel.font = MFStyler.fontRegularMicro() + titleLabel.textColor = .mvmBlack + feedbackLabel.font = MFStyler.fontRegularMicro() + feedbackLabel.textColor = .mvmBlack entryFieldContainer.reset() } diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift index 2e7df5ee..cf927c03 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift @@ -28,7 +28,8 @@ import UIKit let textField = TextField() textField.isAccessibilityElement = true textField.setContentCompressionResistancePriority(.required, for: .vertical) - textField.font = MFStyler.fontForTextField() + textField.font = MFStyler.fontRegularBodyLarge() + textField.textColor = .mvmBlack textField.smartQuotesType = .no textField.smartDashesType = .no textField.smartInsertDeleteType = .no @@ -40,7 +41,7 @@ import UIKit //-------------------------------------------------- /// Set enabled and disabled colors to be utilized when setting this texfield's isEnabled property. - public var textColor: (enabled: UIColor?, disabled: UIColor?) = (.black, .mfSilver()) + public var textColor: (enabled: UIColor?, disabled: UIColor?) = (.mvmBlack, .mvmCoolGray3) private var observingForChange: Bool = false @@ -78,7 +79,9 @@ import UIKit if error { textField.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "", textField.text ?? "", errorMessage ?? "") + errorIconWidthContraint?.constant = 20 } else { + errorIconWidthContraint?.constant = 0 textField.accessibilityValue = nil } @@ -140,6 +143,7 @@ import UIKit //-------------------------------------------------- public var textFieldTrailingConstraint: NSLayoutConstraint? + public var errorIconWidthContraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Initializers @@ -168,7 +172,7 @@ import UIKit @objc open override func setupFieldContainerContent(_ container: UIView) { - MFStyler.styleTextField(textField) + textField.font = MFStyler.fontRegularBodyLarge() container.addSubview(textField) NSLayoutConstraint.activate([ @@ -193,14 +197,14 @@ import UIKit @objc open override func updateView(_ size: CGFloat) { super.updateView(size) - MFStyler.styleTextField(textField) + textField.font = MFStyler.fontRegularBodyLarge() layoutIfNeeded() } open override func reset() { super.reset() - textField.font = MFStyler.fontForTextField() + textField.font = MFStyler.fontRegularBodyLarge() } @objc deinit { @@ -252,6 +256,7 @@ import UIKit observingTextFieldDelegate?.isValid?(textfield: self) } } + /// Executes on UITextField.textDidBeginEditingNotification @objc func startEditing() { isSelected = true @@ -270,7 +275,7 @@ import UIKit resignFirstResponder() if isValid { showError = false - entryFieldContainer.bottomBar?.backgroundColor = UIColor.black.cgColor + entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor } } @@ -278,6 +283,10 @@ import UIKit resignFirstResponder() } + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 1e072faf..956c2afc 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -25,13 +25,13 @@ public typealias ActionBlockConfirmation = () -> (Bool) //-------------------------------------------------- /// Holds the on and off colors for the container. - public var containerTintColor: (on: UIColor?, off: UIColor?)? = (on: .mvmGreen, off: .black) + public var containerTintColor: (on: UIColor?, off: UIColor?)? = (on: .mvmGreen, off: .mvmBlack) /// Holds the on and off colors for the knob. - public var knobTintColor: (on: UIColor?, off: UIColor?)? = (on: .white, off: .white) + public var knobTintColor: (on: UIColor?, off: UIColor?)? = (on: .mvmWhite, off: .mvmWhite) /// Holds the on and off colors for the disabled state.. - public var disabledTintColor: (container: UIColor?, knob: UIColor?)? = (container: .mvmCoolGray3, knob: .white) + public var disabledTintColor: (container: UIColor?, knob: UIColor?)? = (container: .mvmCoolGray3, knob: .mvmWhite) /// Set this flag to false if you do not want to animate state changes. public var isAnimated = true diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index cf56fb9d..3a8fac64 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -17,7 +17,7 @@ import UIKit /// The bottom border line. Height is dynamic based on scenario. public var bottomBar: CAShapeLayer? = { let layer = CAShapeLayer() - layer.backgroundColor = UIColor.black.cgColor + layer.backgroundColor = UIColor.mvmBlack.cgColor layer.drawsAsynchronously = true layer.anchorPoint = CGPoint(x: 0.5, y: 1.0); return layer @@ -46,7 +46,7 @@ import UIKit /// Determines if the top, left, and right borders should be drawn. private var hideBorders = false - public var borderStrokeColor: UIColor = .mfSilver() + public var borderStrokeColor: UIColor = .mvmCoolGray3 private var borderPath: UIBezierPath = UIBezierPath() //-------------------------------------------------- @@ -210,8 +210,8 @@ import UIKit isUserInteractionEnabled = true hideBorders = false - borderStrokeColor = .mfSilver() - bottomBar?.backgroundColor = UIColor.black.cgColor + borderStrokeColor = .mvmCoolGray3 + bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor refreshUI(bottomBarSize: 1) } @@ -219,8 +219,8 @@ import UIKit isUserInteractionEnabled = true hideBorders = false - borderStrokeColor = .mfPumpkin() - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + borderStrokeColor = .mvmOrange + bottomBar?.backgroundColor = UIColor.mvmOrange.cgColor refreshUI(bottomBarSize: 4) } @@ -228,8 +228,8 @@ import UIKit isUserInteractionEnabled = true hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor + borderStrokeColor = .mvmBlack + bottomBar?.backgroundColor = UIColor.mvmOrange.cgColor refreshUI(bottomBarSize: 4) } @@ -237,8 +237,8 @@ import UIKit isUserInteractionEnabled = true hideBorders = false - borderStrokeColor = .black - bottomBar?.backgroundColor = UIColor.black.cgColor + borderStrokeColor = .mvmBlack + bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor refreshUI(bottomBarSize: 1) } @@ -255,7 +255,7 @@ import UIKit isUserInteractionEnabled = false hideBorders = false - borderStrokeColor = .mfSilver() + borderStrokeColor = .mvmCoolGray3 bottomBar?.backgroundColor = UIColor.mvmCoolGray3.cgColor refreshUI(bottomBarSize: 1) } From 1ac94059dbcc084aa5138e81ab435f42d2e1423b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 11:27:56 -0400 Subject: [PATCH 184/244] mild updates to caret --- .../Atomic/Atoms/Buttons/CaretLink.swift | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift index 2e042824..75c44eb3 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift @@ -103,8 +103,10 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { let width = CGFloat(rightViewWidth?.floatValue ?? CARET_VIEW_WIDTH) let height = CGFloat(rightViewHeight?.floatValue ?? CARET_VIEW_HEIGHT) - let edgeInsets: UIEdgeInsets = contentEdgeInsets - contentEdgeInsets = UIEdgeInsets(top: edgeInsets.top, left: edgeInsets.left, bottom: edgeInsets.bottom, right: 4 + width) + contentEdgeInsets = UIEdgeInsets(top: contentEdgeInsets.top, + left: contentEdgeInsets.left, + bottom: contentEdgeInsets.bottom, + right: 4 + width) let caretView: UIView = rightView ?? createCaretView() rightView = caretView @@ -118,8 +120,8 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { caretLabelSpacing.isActive = true caretSpacingConstraint = caretLabelSpacing - 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.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true + trailingAnchor.constraint(greaterThanOrEqualTo: caretView.trailingAnchor).isActive = true caretView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true bottomAnchor.constraint(greaterThanOrEqualTo: caretView.bottomAnchor).isActive = true contentHorizontalAlignment = .left @@ -137,17 +139,21 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { // MARK: - Atomization //------------------------------------------------------ public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let caretLinkModel = model as? CaretLinkModel else { return } - if let color = caretLinkModel.backgroundColor { + + guard let model = model as? CaretLinkModel else { return } + + if let color = model.backgroundColor { backgroundColor = color.uiColor } - enabledColor = caretLinkModel.enabledColor.uiColor - if let color = caretLinkModel.disabledColor { + + enabledColor = model.enabledColor.uiColor + if let color = model.disabledColor { disabledColor = color.uiColor } - isEnabled = caretLinkModel.enabled - set(with: caretLinkModel.action, delegateObject: delegateObject, additionalData: additionalData) - setTitle(caretLinkModel.title, for: .normal) + + isEnabled = model.enabled + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) + setTitle(model.title, for: .normal) } public func needsToBeConstrained() -> Bool { From 2b065d1b80032653eeafd623d10116509e04998b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 11:34:12 -0400 Subject: [PATCH 185/244] improvedment --- MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift index 75c44eb3..b437a56f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift @@ -103,10 +103,7 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { let width = CGFloat(rightViewWidth?.floatValue ?? CARET_VIEW_WIDTH) let height = CGFloat(rightViewHeight?.floatValue ?? CARET_VIEW_HEIGHT) - contentEdgeInsets = UIEdgeInsets(top: contentEdgeInsets.top, - left: contentEdgeInsets.left, - bottom: contentEdgeInsets.bottom, - right: 4 + width) + contentEdgeInsets.right = 4 + width let caretView: UIView = rightView ?? createCaretView() rightView = caretView From 544a630ffb164ee59043773b2e47365e807e1520 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 11:35:33 -0400 Subject: [PATCH 186/244] readable consteaint --- MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift index b437a56f..4ba95472 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift @@ -113,7 +113,7 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { caretView.widthAnchor.constraint(equalToConstant: width).isActive = true caretView.heightAnchor.constraint(equalToConstant: height).isActive = true - let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 7) + let caretLabelSpacing = caretView.leadingAnchor.constraint(equalTo: titleLabel?.trailingAnchor, constant: 7) caretLabelSpacing.isActive = true caretSpacingConstraint = caretLabelSpacing From d96aa1c310687f34116245af8dd9e0fa47369a35 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 11:36:34 -0400 Subject: [PATCH 187/244] undo --- MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift index 4ba95472..b437a56f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift @@ -113,7 +113,7 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { caretView.widthAnchor.constraint(equalToConstant: width).isActive = true caretView.heightAnchor.constraint(equalToConstant: height).isActive = true - let caretLabelSpacing = caretView.leadingAnchor.constraint(equalTo: titleLabel?.trailingAnchor, constant: 7) + let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 7) caretLabelSpacing.isActive = true caretSpacingConstraint = caretLabelSpacing From d9337cadff6bee8405d15840fa5bee0d8eaeb51c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 13:37:12 -0400 Subject: [PATCH 188/244] cleaning and revising donut --- MVMCoreUI.xcodeproj/project.pbxproj | 8 + .../Doughnut/ColorViewWithLabel.swift | 73 +++++ .../Molecules/Doughnut/DoughnutChart.swift | 292 ++++++++++-------- .../Doughnut/DoughnutChartItemModel.swift | 44 +++ .../Doughnut/DoughnutChartModel.swift | 24 +- .../Doughnut/DoughnutChartView.swift | 76 ++--- 6 files changed, 312 insertions(+), 205 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/Doughnut/ColorViewWithLabel.swift create mode 100644 MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartItemModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c0a56ebc..67f83ce7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -91,6 +91,8 @@ 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 */; }; + 0A7ECC5D243CE85300C828E8 /* DoughnutChartItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7ECC5C243CE85300C828E8 /* DoughnutChartItemModel.swift */; }; + 0A7ECC5F243CEB1200C828E8 /* ColorViewWithLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7ECC5E243CEB1200C828E8 /* ColorViewWithLabel.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 */; }; @@ -488,6 +490,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 /* CheckboxLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxLabel.swift; sourceTree = ""; }; + 0A7ECC5C243CE85300C828E8 /* DoughnutChartItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoughnutChartItemModel.swift; sourceTree = ""; }; + 0A7ECC5E243CEB1200C828E8 /* ColorViewWithLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorViewWithLabel.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 = ""; }; @@ -1340,9 +1344,11 @@ D260105723CF9CC500764D80 /* Doughnut */ = { isa = PBXGroup; children = ( + 0A7ECC5C243CE85300C828E8 /* DoughnutChartItemModel.swift */, C695A69323C9909000BFB94E /* DoughnutChartModel.swift */, C695A69523C990BC00BFB94E /* DoughnutChart.swift */, C695A69723C990C200BFB94E /* DoughnutChartView.swift */, + 0A7ECC5E243CEB1200C828E8 /* ColorViewWithLabel.swift */, ); path = Doughnut; sourceTree = ""; @@ -2067,6 +2073,7 @@ D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, + 0A7ECC5D243CE85300C828E8 /* DoughnutChartItemModel.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, 526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */, @@ -2173,6 +2180,7 @@ C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */, + 0A7ECC5F243CEB1200C828E8 /* ColorViewWithLabel.swift in Sources */, 94C0150A24215643005811A9 /* ActionTopAlertModel.swift in Sources */, 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/ColorViewWithLabel.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/ColorViewWithLabel.swift new file mode 100644 index 00000000..f8dd4b5c --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/ColorViewWithLabel.swift @@ -0,0 +1,73 @@ +// +// ColorViewWithLabel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/7/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + + +open class ColorViewWithLabel: View { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public var label = Label.createLabelRegularBodySmall(true) + public var colorView = View() + private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 8)! + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + public var heightConstraint: NSLayoutConstraint? + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + open override func setupView() { + super.setupView() + + 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(equalTo: label.trailingAnchor).isActive = true + bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + label.updateView(size) + heightConstraint?.constant = sizeObject.getValueBased(onSize: size) + setNeedsDisplay() + } + + open override func reset() { + super.reset() + label.reset() + } + + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + + guard let chartItemModel = model as? DoughnutChartItemModel else { return } + + label.set(with: chartItemModel.label, delegateObject, additionalData) + colorView.backgroundColor = chartItemModel.color.uiColor + } +} diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index d84c7dc0..c7025b0f 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -8,23 +8,38 @@ import UIKit + open class DoughnutChart: View { - var doughnutLayer = CALayer() - var titleLabel = Label.commonLabelH3(true) - var subTitleLabel = Label.commonLabelB2(true) - var doughnutChartModel: DoughnutChartModel? { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public var doughnutLayer = CALayer() + public var titleLabel = Label.createLabelRegularTitleLarge(true) + public var subTitleLabel = Label.createLabelRegularMicro(true) + public var labelContainer = View() + public static let heightConstant: CGFloat = 136 + private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)! + + //-------------------------------------------------- + // MARK: - Constraints + //-------------------------------------------------- + + public var labelContainerLeftConstraint: NSLayoutConstraint? + public var labelContainerTopConstraint: NSLayoutConstraint? + public var labelContainerBottomConstraint: NSLayoutConstraint? + public var labelContainerRightConstraint: NSLayoutConstraint? + public var heightConstraint: NSLayoutConstraint? + + //-------------------------------------------------- + // MARK: - Computed Properties + //-------------------------------------------------- + + public var doughnutChartModel: DoughnutChartModel? { get { return model as? DoughnutChartModel } - } - var labelContainer = MVMCoreUICommonViewsUtility.commonView() - var labelContainerLeftConstraint: NSLayoutConstraint? - var labelContainerTopConstraint: NSLayoutConstraint? - var labelContainerBottomConstraint: NSLayoutConstraint? - var labelContainerRightConstraint: NSLayoutConstraint? - var heightConstraint: NSLayoutConstraint? - - static let heightConstant: CGFloat = 150 - private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)! - var height: CGFloat = heightConstant { + } + + public var height: CGFloat = heightConstant { didSet { if height != oldValue { sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)! @@ -32,69 +47,73 @@ open class DoughnutChart: View { 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() - } - - open override func setupView() { - super.setupView() - guard labelContainer.superview == nil else { - return - } - 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 - - layer.addSublayer(doughnutLayer) - heightConstraint = heightAnchor.constraint(equalToConstant: - sizeObject.getValueBasedOnApplicationWidth()) - heightConstraint?.isActive = true - widthAnchor.constraint(equalTo: heightAnchor).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 - doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0) } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + 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() + } + + open override func setupView() { + super.setupView() + + 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 + + layer.addSublayer(doughnutLayer) + heightConstraint = heightAnchor.constraint(equalToConstant: sizeObject.getValueBasedOnApplicationWidth()) + heightConstraint?.isActive = true + widthAnchor.constraint(equalTo: heightAnchor).isActive = true + + labelContainerLeftConstraint = labelContainer.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor, constant: lineWidth()) + labelContainerLeftConstraint?.isActive = true + labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: lineWidth()) + labelContainerTopConstraint?.isActive = true + labelContainerRightConstraint = trailingAnchor.constraint(greaterThanOrEqualTo: labelContainer.trailingAnchor, 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 + doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0, 0, 1) + } + + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) clearLayers() - guard let doughnutChartModel = doughnutChartModel else { - return - } + guard let doughnutChartModel = doughnutChartModel else { return } + titleLabel.setOptional(with: doughnutChartModel.title, delegateObject, additionalData) subTitleLabel.setOptional(with: doughnutChartModel.subtitle, delegateObject, additionalData) titleLabel.textAlignment = .center @@ -103,78 +122,83 @@ open class DoughnutChart: View { drawGraph() } - func drawGraph() { - clearLayers() - let widthHeight = sizeObject.getValueBasedOnApplicationWidth() - doughnutLayer.frame = CGRect(x: 0, y: 0, - width: widthHeight, - height: widthHeight) - if let doughnutChart = doughnutChartModel { - var prevPercent: CGFloat = 0.0 - for model in doughnutChart.sections { + //-------------------------------------------------- + // MARK: - Draw Graph + //-------------------------------------------------- + + private func drawGraph() { + clearLayers() + let widthHeight = sizeObject.getValueBasedOnApplicationWidth() + doughnutLayer.frame = CGRect(x: 0, y: 0, width: widthHeight, height: widthHeight) + + if let doughnutChart = doughnutChartModel { + var prevPercent: CGFloat = 0.0 + for model in doughnutChart.sections { prevPercent += drawBar(model, prevPercent) - } - } - } - - func drawBar(_ chartModel: DoughnutChartItemModel, _ prevPercent: CGFloat) -> CGFloat { - - let shapeLayer = CAShapeLayer() - shapeLayer.frame = doughnutLayer.frame - shapeLayer.lineWidth = lineWidth() - shapeLayer.fillColor = nil - shapeLayer.strokeColor = chartModel.color.uiColor.cgColor - - let arcCenter = shapeLayer.position - let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0 - - 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: true) - - shapeLayer.path = circlePath.cgPath - doughnutLayer.addSublayer(shapeLayer) - return value - } - - func clearLayers() { - doughnutLayer.sublayers?.forEach({ $0.removeFromSuperlayer() }) - } + } + } + } - func updateContainer() { - heightConstraint?.constant = sizeObject.getValueBasedOnApplicationWidth() - updateLabelContainer() - setNeedsDisplay() - } + private func drawBar(_ chartModel: DoughnutChartItemModel, _ prevPercent: CGFloat) -> CGFloat { + + let shapeLayer = CAShapeLayer() + shapeLayer.frame = doughnutLayer.frame + shapeLayer.lineWidth = lineWidth() + shapeLayer.fillColor = nil + shapeLayer.strokeColor = chartModel.color.uiColor.cgColor + + let arcCenter = shapeLayer.position + let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth() / 2.0 + + 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: true) + + shapeLayer.path = circlePath.cgPath + doughnutLayer.addSublayer(shapeLayer) + return value + } - func lineWidth() -> CGFloat { - return 30 - } + private func clearLayers() { + doughnutLayer.sublayers?.forEach{ $0.removeFromSuperlayer() } + } - func lineGap() -> CGFloat { + public func updateContainer() { + + heightConstraint?.constant = sizeObject.getValueBasedOnApplicationWidth() + updateLabelContainer() + setNeedsDisplay() + } + + public func lineWidth() -> CGFloat { + return 12 + } + + public func lineGap() -> CGFloat { //If array is having the single item then no space required return doughnutChartModel?.sections.count == 1 ? 0.0 : 0.05 - } + } - func spaceRequired() -> Bool { + public func spaceRequired() -> Bool { return doughnutChartModel?.spaceRequired ?? true - } + } - func updateLabelContainer() { + public func updateLabelContainer() { + labelContainer.setNeedsDisplay() labelContainer.layoutIfNeeded() - let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth() - let labelheight = labelContainer.frame.height/2 - let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(max(0, pow(radius, 2) - pow(labelheight, 2))) + let radius = sizeObject.getValueBasedOnApplicationWidth() / 2 - lineWidth() + let labelheight = labelContainer.frame.height / 2 + let padding = sizeObject.getValueBasedOnApplicationWidth() / 2 - sqrt(max(0, pow(radius, 2) - pow(labelheight, 2))) - labelContainerLeftConstraint?.constant = padding - labelContainerRightConstraint?.constant = padding + labelContainerLeftConstraint?.constant = round(padding) + labelContainerRightConstraint?.constant = round(padding) labelContainerTopConstraint?.constant = max(radius - labelheight, labelheight) labelContainerBottomConstraint?.constant = max(radius - labelheight, labelheight) } diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartItemModel.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartItemModel.swift new file mode 100644 index 00000000..ee4e664a --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartItemModel.swift @@ -0,0 +1,44 @@ +// +// DoughnutChartItemModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 4/7/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +@objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public var backgroundColor: Color? + public static var identifier: String = "doughnutChartItem" + public var moleculeName: String = DoughnutChartItemModel.identifier + public var label: LabelModel + @Percent public var percent: CGFloat + public var color: Color + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case backgroundColor + case label + case percent + case color + } + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(percent: CGFloat, color: Color, label: LabelModel) { + self.percent = percent + self.color = color + self.label = label + } +} diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift index ff9b1bf6..fbb034c6 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift @@ -8,7 +8,12 @@ import Foundation + @objcMembers public class DoughnutChartModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public var backgroundColor: Color? public static var identifier: String = "doughnutChart" public var moleculeName: String = DoughnutChartModel.identifier @@ -17,22 +22,11 @@ import Foundation public var sections: [DoughnutChartItemModel] public var spaceRequired: Bool? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(sections: [DoughnutChartItemModel]) { self.sections = sections } } - -@objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol { - public var backgroundColor: Color? - public static var identifier: String = "doughnutChartItem" - public var moleculeName: String = DoughnutChartItemModel.identifier - public var label: LabelModel - @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/Atomic/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift index 280385cb..e037c984 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift @@ -8,18 +8,26 @@ import Foundation + @objcMembers open class DoughnutChartView: View { - var doughnutChart = DoughnutChart(frame: CGRect.zero) + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + var doughnutChart = DoughnutChart(frame: .zero) var colorLablesStack = ColorViewLabelsStack() + var doughnutChartModel: DoughnutChartModel? { - get { return model as? DoughnutChartModel } + get { return model as? DoughnutChartModel } } + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + open override func setupView() { super.setupView() - guard doughnutChart.superview == nil else { - return - } + doughnutChart.translatesAutoresizingMaskIntoConstraints = false addSubview(doughnutChart) colorLablesStack.translatesAutoresizingMaskIntoConstraints = false @@ -65,12 +73,16 @@ import Foundation colorLablesStack.reset() } + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = doughnutChartModel else { return } doughnutChart.set(with: model, delegateObject, additionalData) - + // Create the stack model var stackItems: [MoleculeStackItemModel] = [] for item in model.sections { @@ -82,6 +94,7 @@ import Foundation } } +// MARK: - MVMCoreUIViewConstrainingProtocol extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { open func horizontalAlignment() -> UIStackView.Alignment { return .leading @@ -89,6 +102,7 @@ extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { } class ColorViewLabelsStack: MoleculeStackView { + override func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { guard let stackItemModels = stackModel?.molecules else { return } for model in stackItemModels { @@ -99,53 +113,3 @@ class ColorViewLabelsStack: MoleculeStackView { } } } - -class ColorViewWithLabel: View { - - 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(equalTo: 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() - } - - override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let chartItemModel = model as? DoughnutChartItemModel else { - return - } - label.set(with: chartItemModel.label, delegateObject, additionalData) - colorView.backgroundColor = chartItemModel.color.uiColor - } -} From f125d55962e7b8f43885429c38de7b0442c3d395 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 14:10:32 -0400 Subject: [PATCH 189/244] improved constraints to center align as requested by design --- .../Molecules/Doughnut/DoughnutChart.swift | 18 ++++++++++++++++- .../Doughnut/DoughnutChartView.swift | 20 +++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index c7025b0f..2908a90d 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -15,7 +15,7 @@ open class DoughnutChart: View { //-------------------------------------------------- public var doughnutLayer = CALayer() - public var titleLabel = Label.createLabelRegularTitleLarge(true) + public var titleLabel = Label.createLabelBoldTitleLarge(true) public var subTitleLabel = Label.createLabelRegularMicro(true) public var labelContainer = View() public static let heightConstant: CGFloat = 136 @@ -49,6 +49,22 @@ open class DoughnutChart: View { } } + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + public override init(frame: CGRect) { + super.init(frame: .zero) + } + + public convenience init() { + self.init(frame: .zero) + } + + public required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift index e037c984..2b3afdd5 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift @@ -28,35 +28,33 @@ import Foundation open override func setupView() { super.setupView() - doughnutChart.translatesAutoresizingMaskIntoConstraints = false addSubview(doughnutChart) - colorLablesStack.translatesAutoresizingMaskIntoConstraints = false addSubview(colorLablesStack) doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true - doughnutChart.topAnchor.constraint(equalTo: topAnchor).isActive = true + doughnutChart.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor) doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200) doughnutBottomAnchor.isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true + let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor) colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204) colorLablesBottomAnchor.isActive = true - let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor) + colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true + + let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: topAnchor) colorLablesTopAnchor.priority = .defaultLow colorLablesTopAnchor.isActive = true - colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).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 = UILayoutPriority(rawValue: 500) - centerY.isActive = true - + doughnutChart.centerYAnchor.constraint(equalTo: colorLablesStack.centerYAnchor).isActive = true + colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true colorLablesStack.backgroundColor = .clear } From 752ff76e79f6bac7f1a6724a0fca3a4e108ad5dc Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 14:22:06 -0400 Subject: [PATCH 190/244] access modified --- .../Atomic/Molecules/Doughnut/DoughnutChartView.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift index 2b3afdd5..1c0ea963 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartView.swift @@ -14,10 +14,10 @@ import Foundation // MARK: - Properties //-------------------------------------------------- - var doughnutChart = DoughnutChart(frame: .zero) + public var doughnutChart = DoughnutChart() var colorLablesStack = ColorViewLabelsStack() - var doughnutChartModel: DoughnutChartModel? { + public var doughnutChartModel: DoughnutChartModel? { get { return model as? DoughnutChartModel } } @@ -75,7 +75,7 @@ import Foundation // MARK: - MoleculeViewProtocol //-------------------------------------------------- - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = doughnutChartModel else { return } @@ -94,6 +94,7 @@ import Foundation // MARK: - MVMCoreUIViewConstrainingProtocol extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { + open func horizontalAlignment() -> UIStackView.Alignment { return .leading } @@ -101,7 +102,7 @@ extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol { class ColorViewLabelsStack: MoleculeStackView { - override func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ 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() From 8072d8d4aa585a19df1a7e55d5748e7d7d0cf5ba Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 14:33:57 -0400 Subject: [PATCH 191/244] organized radio --- .../Atomic/Atoms/Buttons/RadioButton.swift | 23 +++++++-------- .../Buttons/RadioButtonSelectionHelper.swift | 28 ++++++++++++++----- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift index 98532549..b73ddc8b 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift @@ -8,6 +8,7 @@ import UIKit + @objcMembers open class RadioButton: Control { //-------------------------------------------------- // MARK: - Properties @@ -18,19 +19,19 @@ import UIKit widthConstraint?.constant = diameter } } - - public var enabledColor: UIColor = .black - public var disabledColor: UIColor = .mfSilver() + + public var enabledColor: UIColor = .mvmBlack + public var disabledColor: UIColor = .mvmCoolGray6 public var delegateObject: MVMCoreUIDelegateObject? public var radioModel: RadioButtonModel? { return model as? RadioButtonModel } - + lazy public var radioGroupName: String? = { return radioModel?.fieldKey }() - + lazy public var radioButtonSelectionHelper: RadioButtonSelectionHelper? = { if let radioGroupName = radioGroupName, let radioButtonModel = delegateObject?.formHolderDelegate?.formValidator?.radioButtonsModelByGroup[radioGroupName] { @@ -100,7 +101,7 @@ import UIKit public func formFieldValue() -> AnyHashable? { return radioModel?.fieldValue } - + //-------------------------------------------------- // MARK: - MVMViewProtocol //-------------------------------------------------- @@ -108,7 +109,7 @@ import UIKit open override func setupView() { super.setupView() - backgroundColor = .white + backgroundColor = .mvmWhite clipsToBounds = true widthConstraint = widthAnchor.constraint(equalToConstant: 30) widthConstraint?.isActive = true @@ -120,7 +121,7 @@ import UIKit accessibilityTraits = .button accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") } - + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) @@ -130,9 +131,9 @@ import UIKit isSelected = model.state RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject) } - + public override func reset() { - super.reset() - backgroundColor = .white + super.reset() + backgroundColor = .white } } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index 3decadb5..c7208802 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -7,29 +7,41 @@ // import Foundation -import UIKit + @objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName private var selectedRadioButton: RadioButton? private var fieldGroupName: String? public var baseValue: AnyHashable? - + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + init(_ fieldKey: String?) { self.fieldKey = fieldKey } + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) { + guard let groupName = radioButtonModel.fieldKey, - let formValidator = delegateObject?.formHolderDelegate?.formValidator else { - return - } + let formValidator = delegateObject?.formHolderDelegate?.formValidator + else { return } let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey) radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper - + if radioButtonModel.state { radioButtonSelectionHelper.selectedRadioButton = radioButton } @@ -37,6 +49,7 @@ import UIKit } public func selected(_ radioButton: RadioButton) { + selectedRadioButton?.isSelected = false selectedRadioButton = radioButton selectedRadioButton?.isSelected = true @@ -45,8 +58,9 @@ import UIKit // MARK: - FormValidationFormFieldProtocol extension RadioButtonSelectionHelper { + public func formFieldGroupName() -> String? { - return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName + return selectedRadioButton?.formFieldGroupName() ?? fieldGroupName } public func formFieldValue() -> AnyHashable? { From 6ca54fce6a4679ddb01c31dec363297e4bc406d2 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 7 Apr 2020 15:22:33 -0400 Subject: [PATCH 192/244] settingup new accessor --- MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift index 658af357..c12b7dd3 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift @@ -57,6 +57,12 @@ import UIKit } } + public var accessoryInput: View? { + didSet { + + } + } + //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- @@ -209,6 +215,9 @@ import UIKit feedbackLabelTrailing = layoutMarginsGuide.trailingAnchor.constraint(equalTo: feedbackLabel.trailingAnchor) feedbackLabelTrailing?.isActive = true layoutMarginsGuide.bottomAnchor.constraint(equalTo: feedbackLabel.bottomAnchor).isActive = true + + container.trailingAnchor.constraint(equalTo: dropDownCaretView.trailingAnchor, constant: 16).isActive = true + dropDownCaretView.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true } @objc open override func layoutSubviews() { From d53b21224183a14fedb07a5c2debc271ce03d29e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 7 Apr 2020 15:29:23 -0400 Subject: [PATCH 193/244] fiddling with three layer --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 4 +- .../Doughnut/DoughnutChartModel.swift | 7 + .../Atomic/Templates/CollectionTemplate.swift | 162 ++++++++++ .../ContainerCollectionReusableView.swift | 25 ++ .../ThreeLayerCollectionViewController.swift | 281 +++++++++--------- MVMCoreUI/Utility/MVMCoreUIUtility.m | 2 +- 7 files changed, 348 insertions(+), 137 deletions(-) create mode 100644 MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index e1310f0d..6db35f4e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -249,6 +249,7 @@ D264FA8C243BCD8E00D98315 /* CollectionTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */; }; D264FA8E243BCD9A00D98315 /* CollectionTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */; }; D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */; }; + D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; }; @@ -654,6 +655,7 @@ D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplateModel.swift; sourceTree = ""; }; D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplate.swift; sourceTree = ""; }; D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerCollectionViewController.swift; sourceTree = ""; }; + D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerCollectionReusableView.swift; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; @@ -1477,6 +1479,7 @@ D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */, D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */, + D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */, D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */, D2C521A823EDE79E00CA2634 /* ViewController.swift */, D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */, @@ -2029,6 +2032,7 @@ D21B7F77243BB70700051ABF /* MoleculeCollectionItemModel.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, 011D9602240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift in Sources */, + D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 94bbc61f..5ef0e20e 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -112,7 +112,9 @@ import Foundation // Other Items MoleculeObjectMapping.shared()?.register(viewClass: MoleculeStackItem.self, viewModelClass: MoleculeStackItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: MoleculeCollectionViewCell.self, viewModelClass: CarouselItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: MoleculeCollectionViewCell.self, viewModelClass: MoleculeCollectionItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: CarouselItem.self, viewModelClass: CarouselItemModel.self) + // Other Container Molecules MoleculeObjectMapping.shared()?.register(viewClass: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift index ff9b1bf6..2b64d1ae 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift @@ -35,4 +35,11 @@ import Foundation self.color = color self.label = label } + + private enum CodingKeys: String, CodingKey { + case backgroundColor + case label + case percent + case color + } } diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index ce135631..11142532 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -11,5 +11,167 @@ import Foundation @objc open class CollectionTemplate: ThreeLayerCollectionViewController, TemplateProtocol { public typealias TemplateModel = CollectionTemplateModel public var templateModel: CollectionTemplateModel? + + public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (CollectionItemModelProtocol & MoleculeModelProtocol))]? + + var observer: NSKeyValueObservation? + //-------------------------------------------------- + // MARK: - Computed Properties + //-------------------------------------------------- + open override func parsePageJSON() throws { + try parseTemplate(json: loadObject?.pageJSON) + try super.parsePageJSON() + } + + open override var loadObject: MVMCoreLoadObject? { + didSet { + guard loadObject != oldValue else { return } + + updateRequiredModules() + observer?.invalidate() + if let newObject = loadObject { + observer = newObject.observe(\MVMCoreLoadObject.pageJSON, options: [.old, .new]) { [weak self] object, change in + self?.updateRequiredModules() + } + } + } + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + open override func viewForTop() -> UIView? { + guard let headerModel = templateModel?.header, + let molecule = MoleculeObjectMapping.shared()?.createMolecule(headerModel, delegateObject: delegateObjectIVar) + else { return super.viewForTop() } + + // Temporary, Default the horizontal padding + if var container = templateModel?.header as? ContainerModelProtocol, container.useHorizontalMargins == nil { + container.useHorizontalMargins = true + } + + return molecule + } + + override open func viewForBottom() -> UIView? { + guard let footerModel = templateModel?.footer, + let molecule = MoleculeObjectMapping.shared()?.createMolecule(footerModel, delegateObject: delegateObjectIVar) + else { return super.viewForBottom() } + + return molecule + } + + open override func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { + + 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, + templateModel?.footer == nil, + let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), messageToLog: "Collection 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 true + } + + + open override func handleNewData() { + super.handleNewData() + setup() + registerCells() + } + + //-------------------------------------------------- + // MARK: - Collection + //-------------------------------------------------- + + open override func registerCells() { + super.registerCells() + guard let moleculesInfo = moleculesInfo else { return } + + for moleculeInfo in moleculesInfo { + collectionView?.register(moleculeInfo.class, forCellWithReuseIdentifier: moleculeInfo.identifier) + } + } + + open override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return moleculesInfo?.count ?? 0 + } + + open override func numberOfSections(in collectionView: UICollectionView) -> Int { + return 1 + } + + open override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let moleculeInfo = moleculesInfo?[indexPath.row] + else { return UICollectionViewCell() } + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath) + (cell as? MoleculeViewProtocol)?.reset() + (cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil) + (cell as? MVMCoreViewProtocol)?.updateView(view.bounds.width) + + // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells + cell.layoutIfNeeded() + return cell + } + + //-------------------------------------------------- + // MARK: - Convenience + //-------------------------------------------------- + + /// Returns the (identifier, class) of the molecule for the given map. + func getMoleculeInfo(with item: (CollectionItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: CollectionItemModelProtocol & MoleculeModelProtocol)? { + guard let item = item, + let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(item) else { return nil } + let moleculeName = moleculeClass.nameForReuse(with: item, delegateObjectIVar) ?? item.moleculeName + return (moleculeName, moleculeClass, item) + } + + /// Sets up the molecule list and ensures no errors loading all content. + func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: (CollectionItemModelProtocol & MoleculeModelProtocol))]? { + + var moleculeList: [(identifier: String, class: AnyClass, molecule: CollectionItemModelProtocol & MoleculeModelProtocol)] = [] + + if let molecules = templateModel?.molecules { + for molecule in molecules { + if let info = getMoleculeInfo(with: molecule) { + moleculeList.append(info) + } + } + } + + return moleculeList.count > 0 ? moleculeList : nil + } + + /// Sets up the header, footer, molecule list and ensures no errors loading all content. + func setup() { + moleculesInfo = getMoleculeInfoList() + } + + /// Adds modules from requiredModules() to the MVMCoreViewControllerMapping.requiredModules map. + open func updateRequiredModules() { + if let requiredModules = requiredModules(), let pageType = pageType { + MVMCoreViewControllerMappingObject.shared()?.addRequiredModules(toMapping: requiredModules, forPageType: pageType) + } + } + + /// Gets modules required by the loadObject.pageJSON. + open func requiredModules() -> [Any]? { + var modules: [String]? = [] + var errors: [MVMCoreErrorObject]? = nil + MoleculeObjectMapping.addRequiredModules(for: templateModel?.header, delegateObjectIVar, moduleList: &modules, errorList: &errors) + MoleculeObjectMapping.addRequiredModules(for: templateModel?.footer, delegateObjectIVar, moduleList: &modules, errorList: &errors) + + if let molecules = templateModel?.molecules { + for molecule in molecules { + MoleculeObjectMapping.addRequiredModules(for: molecule, delegateObjectIVar, moduleList: &modules, errorList: &errors) + } + } + + return modules + } } diff --git a/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift b/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift new file mode 100644 index 00000000..c578c273 --- /dev/null +++ b/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift @@ -0,0 +1,25 @@ +// +// ContainerCollectionReusableView.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/7/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ContainerCollectionReusableView: UICollectionReusableView { + var view: UIView? + var topConstraint: NSLayoutConstraint? + var bottomConstraint: NSLayoutConstraint? + + public func addAndContain(view: UIView) { + self.view?.removeFromSuperview() + view.setContentCompressionResistancePriority(.required, for: .vertical) + addSubview(view) + self.view = view + let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: view) + topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint + bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint + } +} diff --git a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift index a7b39cfd..74877925 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift @@ -8,19 +8,17 @@ import Foundation -@objc open class ThreeLayerCollectionViewController: ScrollingViewController, UICollectionViewDataSource, UICollectionViewDelegate { +@objc open class ThreeLayerCollectionViewController: ScrollingViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { public var collectionView: UICollectionView? // The three main views private var topView: UIView? private var bottomView: UIView? - private var headerView: UIView? - private var footerView: UIView? - private var safeAreaView: UIView? + private var headerView: ContainerCollectionReusableView? + private var footerView: ContainerCollectionReusableView? var useMargins: Bool = true - public var bottomViewOutsideOfScrollArea: Bool = false - private var topViewBottomConstraint: NSLayoutConstraint? - private var bottomViewTopConstraint: NSLayoutConstraint? + private let headerID = "header" + private let footerID = "footer" //MARK: - MFViewController open override func updateViews() { @@ -28,7 +26,7 @@ import Foundation let width = view.bounds.width if let topView = topView as? MVMCoreViewProtocol { topView.updateView(width) - //showHeader(width) + // showHeader(width) } if let bottomView = bottomView as? MVMCoreViewProtocol { bottomView.updateView(width) @@ -39,8 +37,8 @@ import Foundation open override func handleNewData() { super.handleNewData() - //createViewForTableHeader() - //createViewForTableFooter() + createViewForTableHeader() + createViewForTableFooter() collectionView?.reloadData() } @@ -74,11 +72,11 @@ import Foundation return 0 } - /*open override func updateViewConstraints() { + open override func updateViewConstraints() { super.updateViewConstraints() - + guard let tableView = collectionView else { return } - + let minimumSpace: CGFloat = minimumFillSpace() var currentSpace: CGFloat = 0 var totalMinimumSpace: CGFloat = 0 @@ -86,48 +84,43 @@ import Foundation var fillTop = false if spaceBelowTopView() == nil, headerView != nil { fillTop = true - currentSpace += topViewBottomConstraint?.constant ?? 0 + currentSpace += headerView?.bottomConstraint?.constant ?? 0 totalMinimumSpace += minimumSpace } - + var fillBottom = false - if spaceAboveBottomView() == nil, !bottomViewOutsideOfScrollArea, footerView != nil { + if spaceAboveBottomView() == nil, footerView != nil { fillBottom = true - currentSpace += bottomViewTopConstraint?.constant ?? 0 + currentSpace += footerView?.topConstraint?.constant ?? 0 totalMinimumSpace += minimumSpace } - + guard fillTop || fillBottom else { return } - + let newSpace = MVMCoreUIUtility.getVariableConstraintHeight(currentSpace, in: tableView, minimumHeight: totalMinimumSpace) - + // If the bottom view is outside of the scroll, then only the top view constraint is being used, so we have to double it to account for the bottom constraint not being there when we compare to the new value. var currentSpaceForCompare: CGFloat = currentSpace - if fillTop && bottomViewOutsideOfScrollArea { + if fillTop { currentSpaceForCompare = currentSpace * 2; } - - let width = view.bounds.width + if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 0.1) { if fillTop && fillBottom { // space both let half = newSpace / 2 - topViewBottomConstraint?.constant = half - bottomViewTopConstraint?.constant = half - showHeader(width) - showFooter(width) + headerView?.bottomConstraint?.constant = half + footerView?.topConstraint?.constant = half + collectionView?.invalidateIntrinsicContentSize() } else if fillTop { // Only top is spaced (half the size if the bottom view is out of the scroll because it needs to be sized as if there are two spacers but there is only one. - if bottomViewOutsideOfScrollArea { - topViewBottomConstraint?.constant = newSpace / 2 - } else { - topViewBottomConstraint?.constant = newSpace - } - showHeader(width) + headerView?.bottomConstraint?.constant = newSpace + collectionView?.invalidateIntrinsicContentSize() } else if fillBottom { // Only bottom is spaced. - bottomViewTopConstraint?.constant = newSpace - showFooter(width) + print("newSpace \(newSpace)") + footerView?.topConstraint?.constant = newSpace + collectionView?.invalidateIntrinsicContentSize() } } } @@ -135,113 +128,99 @@ import Foundation //MARK: - Header Footer /// Gets the top view and adds it to a spacing view, headerView, and then calls showHeader. open func createViewForTableHeader() { - let topView = viewForTop() + guard let topView = viewForTop() else { + self.topView = nil + self.headerView = nil + return + } self.topView = topView - - let headerView = MVMCoreUICommonViewsUtility.commonView() - headerView.addSubview(topView) - topView.topAnchor.constraint(equalTo: headerView.topAnchor).isActive = true - topView.leftAnchor.constraint(equalTo: headerView.leftAnchor).isActive = true - headerView.rightAnchor.constraint(equalTo: topView.rightAnchor).isActive = true - topViewBottomConstraint = headerView.bottomAnchor.constraint(equalTo: topView.bottomAnchor, constant: spaceBelowTopView() ?? 0) - topViewBottomConstraint?.isActive = true - self.headerView = headerView - showHeader(nil) } /// Gets the bottom view and adds it to a spacing view, footerView, and then calls showFooter. open func createViewForTableFooter() { - let bottomView = viewForBottom() + guard let bottomView = viewForBottom() else { + self.bottomView = nil + self.footerView = nil + return + } self.bottomView = bottomView - - let footerView = MVMCoreUICommonViewsUtility.commonView() - footerView.addSubview(bottomView) - bottomViewTopConstraint = bottomView.topAnchor.constraint(equalTo: footerView.topAnchor, constant: spaceAboveBottomView() ?? 0) - bottomViewTopConstraint?.isActive = true - bottomView.leftAnchor.constraint(equalTo: footerView.leftAnchor).isActive = true - footerView.rightAnchor.constraint(equalTo: bottomView.rightAnchor).isActive = true - footerView.bottomAnchor.constraint(equalTo: bottomView.bottomAnchor).isActive = true - self.footerView = footerView - showFooter(nil) } - /// Takes the current headerView and adds it to the tableHeaderView - func showHeader(_ sizingWidth: CGFloat?) { - headerView?.removeFromSuperview() - tableView?.tableHeaderView = nil - guard let headerView = headerView else { - return - } - - // This extra view is needed because of the wonkiness of apple's table header. Things breaks if using autolayout. - headerView.setNeedsLayout() - headerView.layoutIfNeeded() - MVMCoreUIUtility.sizeView(toFit: headerView) - let tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: MVMCoreUIUtility.getWidth(), height: headerView.frame.height)) - tableHeaderView.addSubview(headerView) - NSLayoutConstraint.constraintPinSubview(toSuperview: headerView) - tableView?.tableHeaderView = tableHeaderView - } - - /// Takes the current footerView and adds it to the tableFooterView - func showFooter(_ sizingWidth: CGFloat?) { - footerView?.removeFromSuperview() - safeAreaView?.removeFromSuperview() - guard let footerView = footerView, let tableView = tableView else { - return - } - - if bottomViewOutsideOfScrollArea { - // put bottom view outside of scrolling area. - bottomConstraint?.isActive = false - view.addSubview(footerView) - footerView.topAnchor.constraint(equalTo: tableView.bottomAnchor).isActive = true - footerView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - view.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true - view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true - safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: view) - safeAreaView?.backgroundColor = bottomView?.backgroundColor - } else { - bottomConstraint?.isActive = true - var y: CGFloat? - if let tableFooterView = tableView.tableFooterView { - // if footer already exists, use the same y location to avoid strange moving animation - y = tableFooterView.frame.minY - } - - // This extra view is needed because of the wonkiness of apple's table footer. Things breaks if using autolayout. - MVMCoreUIUtility.sizeView(toFit: footerView) - let tableFooterView = UIView(frame: CGRect(x: 0, y: y ?? 0, width: MVMCoreUIUtility.getWidth(), height: footerView.frame.height)) - tableFooterView.addSubview(footerView) - NSLayoutConstraint.constraintPinSubview(toSuperview: footerView) - tableView.tableFooterView = tableFooterView - } - }*/ +// /// Takes the current headerView and adds it to the tableHeaderView +// func showHeader(_ sizingWidth: CGFloat?) { +// headerView?.removeFromSuperview() +// tableView?.tableHeaderView = nil +// guard let headerView = headerView else { +// return +// } +// +// // This extra view is needed because of the wonkiness of apple's table header. Things breaks if using autolayout. +// headerView.setNeedsLayout() +// headerView.layoutIfNeeded() +// MVMCoreUIUtility.sizeView(toFit: headerView) +// let tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: MVMCoreUIUtility.getWidth(), height: headerView.frame.height)) +// tableHeaderView.addSubview(headerView) +// NSLayoutConstraint.constraintPinSubview(toSuperview: headerView) +// tableView?.tableHeaderView = tableHeaderView +// } +// +// /// Takes the current footerView and adds it to the tableFooterView +// func showFooter(_ sizingWidth: CGFloat?) { +// footerView?.removeFromSuperview() +// safeAreaView?.removeFromSuperview() +// guard let footerView = footerView, let tableView = tableView else { +// return +// } +// +// if bottomViewOutsideOfScrollArea { +// // put bottom view outside of scrolling area. +// bottomConstraint?.isActive = false +// view.addSubview(footerView) +// footerView.topAnchor.constraint(equalTo: tableView.bottomAnchor).isActive = true +// footerView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true +// view.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true +// view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true +// safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: view) +// safeAreaView?.backgroundColor = bottomView?.backgroundColor +// } else { +// bottomConstraint?.isActive = true +// var y: CGFloat? +// if let tableFooterView = tableView.tableFooterView { +// // if footer already exists, use the same y location to avoid strange moving animation +// y = tableFooterView.frame.minY +// } +// +// // This extra view is needed because of the wonkiness of apple's table footer. Things breaks if using autolayout. +// MVMCoreUIUtility.sizeView(toFit: footerView) +// let tableFooterView = UIView(frame: CGRect(x: 0, y: y ?? 0, width: MVMCoreUIUtility.getWidth(), height: footerView.frame.height)) +// tableFooterView.addSubview(footerView) +// NSLayoutConstraint.constraintPinSubview(toSuperview: footerView) +// tableView.tableFooterView = tableFooterView +// } +// } //MARK: - Functions to subclass /// Subclass for a top view. - open func viewForTop() -> UIView { - let view = MVMCoreUICommonViewsUtility.commonView() - // Small height is needed to stop apple from adding padding for grouped tables when no header. - view.heightAnchor.constraint(equalToConstant: 1).isActive = true - return view + open func viewForTop() -> UIView? { + return nil } /// Subclass for a bottom view. - open func viewForBottom() -> UIView { - // Default spacing is standard when no buttons. - let view = MVMCoreUICommonViewsUtility.commonView() - view.heightAnchor.constraint(equalToConstant: PaddingDefaultVerticalSpacing).isActive = true - return view + open func viewForBottom() -> UIView? { + return nil + } + + open func createCollectionViewLayout() -> UICollectionViewLayout { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.minimumLineSpacing = 0 + layout.minimumInteritemSpacing = 0 + layout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize + return layout } open func createCollectionView() -> UICollectionView { - let layout = UICollectionViewFlowLayout() - layout.scrollDirection = .vertical - layout.minimumLineSpacing = 1 - layout.minimumInteritemSpacing = 0 - - let collection = UICollectionView(frame: .zero, collectionViewLayout: layout) + let collection = UICollectionView(frame: .zero, collectionViewLayout: createCollectionViewLayout()) collection.translatesAutoresizingMaskIntoConstraints = false collection.dataSource = self collection.delegate = self @@ -259,19 +238,20 @@ import Foundation //MARK: - Collection - public func registerCells() { - collectionView?.register(MoleculeCollectionViewCell.self, forCellWithReuseIdentifier: "collectionItem") + open func registerCells() { + collectionView?.register(ContainerCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerID) + collectionView?.register(ContainerCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: footerID) } - public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 2 + open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 0 } - public func numberOfSections(in collectionView: UICollectionView) -> Int { + open func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } - public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionItem", for: indexPath) as! MoleculeCollectionViewCell let labelModel = LabelModel(text: "hello") let model = MoleculeCollectionItemModel(with: labelModel) @@ -279,11 +259,42 @@ import Foundation return cell } - open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: 200, height: 200) + open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { + guard let view = headerView ?? topView, + section == 0 else { return .zero } + + // Use this view to calculate the optimal size based on the collection view's width + return view.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), + withHorizontalFittingPriority: .required, // Width is fixed + verticalFittingPriority: .fittingSizeLevel) // Height can be as large as needed } - open func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { - (cell as? CarouselItem)?.setPeaking(false, animated: false) + open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { + guard let view = footerView ?? bottomView, + section == numberOfSections(in: collectionView) - 1 else { return .zero } + + // Use this view to calculate the optimal size based on the collection view's width + let size = view.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), + withHorizontalFittingPriority: .required, // Width is fixed + verticalFittingPriority: .fittingSizeLevel) // Height can be as large as needed + print("SIZEEE \(size.height) \(String(describing: footerView?.topConstraint?.constant))") + return size + } + + open func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { + if (kind == UICollectionView.elementKindSectionFooter) { + let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: footerID, for: indexPath) as! ContainerCollectionReusableView + footerView.addAndContain(view: bottomView!) + footerView.topConstraint?.constant = spaceAboveBottomView() ?? 0 + self.footerView = footerView + return footerView + } else if (kind == UICollectionView.elementKindSectionHeader) { + let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerID, for: indexPath) as! ContainerCollectionReusableView + headerView.addAndContain(view: topView!) + headerView.bottomConstraint?.constant = spaceBelowTopView() ?? 0 + self.headerView = headerView + return headerView + } + fatalError() } } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index bcead7fe..59c55cc6 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -164,7 +164,7 @@ CGFloat topInset = scrollview.contentInset.top; CGFloat bottomInset = scrollview.contentInset.bottom; - if (scrollview.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic) { + if (scrollview.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic || scrollview.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAlways) { topInset = scrollview.adjustedContentInset.top; bottomInset = scrollview.adjustedContentInset.bottom; } From 646dfd6a10df871831ad0dfe2f20255bfda3c544 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 7 Apr 2020 15:49:58 -0400 Subject: [PATCH 194/244] selction fixes and reuse fixes --- MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift | 9 +++++++++ MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift | 4 +--- .../Atoms/Buttons/RadioButtonSelectionHelper.swift | 9 ++++++--- MVMCoreUI/FormUIHelpers/FormValidator.swift | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift index 98532549..3d52e63b 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift @@ -19,6 +19,12 @@ import UIKit } } + public override var isSelected: Bool { + didSet { + radioModel?.state = isSelected + } + } + public var enabledColor: UIColor = .black public var disabledColor: UIColor = .mfSilver() public var delegateObject: MVMCoreUIDelegateObject? @@ -128,6 +134,9 @@ import UIKit self.delegateObject = delegateObject isSelected = model.state + if model.state { + print("log") + } RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject) } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift index 579c0ed9..99e15280 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift @@ -47,7 +47,6 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { public init(_ state: Bool) { self.state = state - baseValue = state } //-------------------------------------------------- @@ -55,7 +54,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- public func formFieldValue() -> AnyHashable? { - return state + return fieldValue } //-------------------------------------------------- @@ -75,7 +74,6 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - baseValue = state fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index 3decadb5..dbc3f7fe 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -16,8 +16,11 @@ import UIKit private var fieldGroupName: String? public var baseValue: AnyHashable? - init(_ fieldKey: String?) { - self.fieldKey = fieldKey + init(_ radioButtonModel: RadioButtonModel?) { + self.fieldKey = radioButtonModel?.fieldKey + if radioButtonModel?.state ?? false { + self.baseValue = radioButtonModel?.formFieldValue() + } } public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) { @@ -26,7 +29,7 @@ import UIKit return } - let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey) + let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel) radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index 592132f5..661036d8 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -66,7 +66,8 @@ import MVMCore return valid } for group in formRules { - valid = valid && validateGroup(group) + let groupValid = validateGroup(group) + valid = valid && groupValid } return valid } From 76aaa8c881394f09ebee5d4cde0bf75638d2e25b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 7 Apr 2020 16:55:42 -0400 Subject: [PATCH 195/244] fix navigation bar --- .../BaseControllers/ViewController.swift | 26 +++++++------------ .../Containers/NavigationController.swift | 4 +-- .../MVMCoreUISplitViewController.m | 21 ++++++++------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 5bc66109..ab143b14 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -92,12 +92,8 @@ import UIKit MVMCoreDispatchUtility.performBlock(onMainThread: { self.handleNewDataAndUpdateUI() // If the screen is showing, can update the navigation controller. - if let navigationController = self.manager?.navigationController, - self.manager!.getCurrentViewController() == self { - self.set(navigationController: navigationController) - } else if let navigationController = self.navigationController, - self == MVMCoreUIUtility.getCurrentVisibleController() { - self.set(navigationController: navigationController) + if MVMCoreUIUtility.getCurrentVisibleController() == self.manager ?? self { + self.setNavigationController() } }) } catch { @@ -177,18 +173,19 @@ import UIKit } // MARK: - Navigation Item (Move to model base) - open func set(navigationController: UINavigationController?) { + open func setNavigationController() { guard let navigationItemModel = pageModel?.navigationItem, - let navigationController = navigationController else { + let navigationController = manager?.navigationController ?? navigationController else { MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() return } + let viewController = manager ?? self if navigationController == MVMCoreUISplitViewController.main()?.navigationController, - navigationController.topViewController == self { + navigationController.topViewController == viewController { MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels() showBottomProgressBar() } - NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: self) + NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) } // Eventually will be moved to server @@ -294,10 +291,8 @@ import UIKit open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - // Update the navigation bar ui when view is appearing unless in a manager. The manager is expected to handle. - if manager == nil { - set(navigationController: navigationController) - } + // Update the navigation bar ui when view is appearing + setNavigationController() } open override func viewDidAppear(_ animated: Bool) { @@ -330,9 +325,6 @@ import UIKit // MARK: - MVMCoreViewManagerViewControllerProtocol open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) { - if initialLoadFinished { - set(navigationController: manager.navigationController) - } // Janky way to track current page. MVMCoreUISession.sharedGlobal()?.currentPageType = pageType MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 74aadca7..eb869e89 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -40,7 +40,7 @@ import UIKit return navigationController } - public static func set(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: (UIViewController & MVMCoreViewControllerProtocol)) { + public static func set(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { viewController.navigationItem.title = navigationItemModel.title viewController.navigationItem.accessibilityLabel = navigationItemModel.title viewController.navigationItem.hidesBackButton = !navigationItemModel.systemBackButton @@ -58,7 +58,7 @@ import UIKit if navigationController == MVMCoreUISession.sharedGlobal()?.navigationController, navigationController.topViewController == viewController { // Update line. - MVMCoreUISession.sharedGlobal()?.navigationController?.separatorView?.set(with: navigationItemModel.line ?? LineModel(type: .standard), viewController.delegateObject?() as? MVMCoreUIDelegateObject, nil) + MVMCoreUISession.sharedGlobal()?.navigationController?.separatorView?.setStyle(navigationItemModel.line?.type ?? .standard) } if navigationController == MVMCoreUISplitViewController.main()?.navigationController, diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 476e7264..342d4b06 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -153,11 +153,11 @@ CGFloat const PanelAnimationDuration = 0.2; - (IBAction)leftPanelButtonPressed:(id)sender { [MVMCoreDispatchUtility performBlockOnMainThread:^{ UIViewController *viewController = self.navigationController.topViewController; - + UIViewController *detailViewController = [self getCurrentDetailViewController]; // If Viewcontroller confirms to protocol and implements the the method leftPanelButtonPressed - if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] - && [viewController respondsToSelector:@selector(isOverridingLeftButton)] - && [((UIViewController *)viewController) isOverridingLeftButton]) { + if ([detailViewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] + && [detailViewController respondsToSelector:@selector(isOverridingLeftButton)] + && [((UIViewController *)detailViewController) isOverridingLeftButton]) { return; } @@ -175,9 +175,9 @@ CGFloat const PanelAnimationDuration = 0.2; - (IBAction)backButtonPressed:(id)sender { [MVMCoreDispatchUtility performBlockOnMainThread:^{ - UIViewController *viewController = self.navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] && [viewController respondsToSelector:@selector(backButtonPressed)]) { - [((UIViewController *)viewController) backButtonPressed]; + UIViewController *detailViewController = [self getCurrentDetailViewController]; + if ([detailViewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] && [detailViewController respondsToSelector:@selector(backButtonPressed)]) { + [((UIViewController *)detailViewController) backButtonPressed]; } else { [[MVMCoreNavigationHandler sharedNavigationHandler] popTopViewControllerAnimated:YES]; } @@ -187,11 +187,12 @@ CGFloat const PanelAnimationDuration = 0.2; - (IBAction)rightPanelButtonPressed:(id)sender { [MVMCoreDispatchUtility performBlockOnMainThread:^{ UIViewController *viewController = self.navigationController.topViewController; + UIViewController *detailViewController = [self getCurrentDetailViewController]; // If Viewcontroller confirms to protocol and implements the the method rightPanelButtonPressed - if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] - && [viewController respondsToSelector:@selector(isOverridingRightButton)] - && [((UIViewController *)viewController) isOverridingRightButton]) { + if ([detailViewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] + && [detailViewController respondsToSelector:@selector(isOverridingRightButton)] + && [((UIViewController *)detailViewController) isOverridingRightButton]) { return; } From 88defbc75c32ad22eb63027860f0c547b119790d Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 8 Apr 2020 10:16:33 +0530 Subject: [PATCH 196/244] file paths added --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9516bdd3..d5abeb54 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -196,6 +196,10 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; + BBAA4F02243D8E3B005AAD5F /* RadioBoxCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4EFE243D8E3A005AAD5F /* RadioBoxCollectionViewCell.swift */; }; + BBAA4F03243D8E3B005AAD5F /* RadioBoxes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */; }; + BBAA4F04243D8E3B005AAD5F /* RadioBoxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */; }; + BBAA4F05243D8E3B005AAD5F /* RadioBoxesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */; }; BBBBC87C24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBBBC87A24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift */; }; BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; @@ -600,6 +604,10 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; + BBAA4EFE243D8E3A005AAD5F /* RadioBoxCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxCollectionViewCell.swift; sourceTree = ""; }; + BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxes.swift; sourceTree = ""; }; + BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxModel.swift; sourceTree = ""; }; + BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxesModel.swift; sourceTree = ""; }; BBBBC87A24374A4900B0F079 /* ListThreeColumnBillChangesDivider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillChangesDivider.swift; sourceTree = ""; }; BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillChangesDividerModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; @@ -1584,6 +1592,10 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( + BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */, + BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */, + BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */, + BBAA4EFE243D8E3A005AAD5F /* RadioBoxCollectionViewCell.swift */, 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, 01509D922327ECFB00EF99AA /* ProgressBar.swift */, 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, @@ -2041,6 +2053,7 @@ D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */, 014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */, 0A21DB91235E0EDB00C160A2 /* DigitBox.swift in Sources */, + BBAA4F04243D8E3B005AAD5F /* RadioBoxModel.swift in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, @@ -2058,6 +2071,7 @@ 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */, + BBAA4F02243D8E3B005AAD5F /* RadioBoxCollectionViewCell.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, @@ -2092,6 +2106,7 @@ 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, 526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */, D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */, + BBAA4F05243D8E3B005AAD5F /* RadioBoxesModel.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, @@ -2183,6 +2198,7 @@ 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */, + BBAA4F03243D8E3B005AAD5F /* RadioBoxes.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */, 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */, From 3051d38ec5d9860087671e3deb625bcdaccac2b1 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Wed, 8 Apr 2020 16:02:44 +0530 Subject: [PATCH 197/244] added files --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++--- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../ListThreeColumnDataUsageDivider.swift | 61 +++++++++++++++++++ ...ListThreeColumnDataUsageDividerModel.swift | 51 ++++++++++++++++ .../ListThreeColumnSpeedTestDivider.swift | 2 +- 5 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 17df3c34..8a1dfb23 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -128,8 +128,6 @@ 8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */; }; 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */; }; 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */; }; - 8D21E4B924247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D21E4B824247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift */; }; - 8D21E4BB2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D21E4BA2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift */; }; 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; }; 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; }; 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */; }; @@ -139,6 +137,8 @@ 8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */; }; 8DD1E36E243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1E36D243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift */; }; 8DD1E370243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1E36F243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift */; }; + 8DEFA95C243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DEFA95B243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift */; }; + 8DEFA95E243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DEFA95D243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift */; }; 942C372E241149170066E45E /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */; }; 942C372F241149170066E45E /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */; }; 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */; }; @@ -535,8 +535,6 @@ 8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTotalData.swift; sourceTree = ""; }; 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyTextModel.swift; sourceTree = ""; }; 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyText.swift; sourceTree = ""; }; - 8D21E4B824247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnDataUsageDividerModel.swift; sourceTree = ""; }; - 8D21E4BA2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnDataUsageDivider.swift; sourceTree = ""; }; 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = ""; }; 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = ""; }; 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDividerModel.swift; sourceTree = ""; }; @@ -546,6 +544,8 @@ 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItem.swift; sourceTree = ""; }; 8DD1E36D243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataModel.swift; sourceTree = ""; }; 8DD1E36F243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalData.swift; sourceTree = ""; }; + 8DEFA95B243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnDataUsageDividerModel.swift; sourceTree = ""; }; + 8DEFA95D243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnDataUsageDivider.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 942C372C241149170066E45E /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; 942C372D241149170066E45E /* NHaasGroteskDSStd-55Rg.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-55Rg.otf"; sourceTree = ""; }; @@ -1332,8 +1332,8 @@ 8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */, AA1EC59624373985003D6F50 /* ListThreeColumnSpeedTestDividerModel.swift */, AA1EC59824373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift */, - 8D21E4B824247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift */, - 8D21E4BA2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift */, + 8DEFA95B243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift */, + 8DEFA95D243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -1996,7 +1996,6 @@ D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonSelectionHelper.swift in Sources */, 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, - 8D21E4B924247D1600ACAF24 /* ListThreeColumnDataUsageDividerModel.swift in Sources */, D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, 94382086243238D100B43AF3 /* WebViewModel.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, @@ -2094,7 +2093,6 @@ EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, - 8D21E4BB2424887800ACAF24 /* ListThreeColumnDataUsageDivider.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, @@ -2106,6 +2104,7 @@ 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, 0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */, + 8DEFA95C243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift in Sources */, 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */, 0A1B4A96233BB18F005B3FB4 /* CheckboxLabel.swift in Sources */, 0A21DB8B235E06EF00C160A2 /* MFDigitTextBox.m in Sources */, @@ -2184,6 +2183,7 @@ D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */, BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, + 8DEFA95E243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index f8c81052..cccefc85 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -154,6 +154,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalDataDivider.self, viewModelClass: ListThreeColumnInternationalDataDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnSpeedTestDivider.self, viewModelClass: ListThreeColumnSpeedTestDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnBillChangesDivider.self, viewModelClass: ListThreeColumnBillChangesDividerModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsageDivider.self, viewModelClass: ListThreeColumnDataUsageDividerModel.self) // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift new file mode 100644 index 00000000..113be5f1 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift @@ -0,0 +1,61 @@ +// +// ListThreeColumnDataUsageDivider.swift +// MVMCoreUI +// +// Created by Kruthika KP on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnDataUsageDivider: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + public let leftLabel = Label.createLabelBoldBodySmall(true) + public let centerLabel = Label.createLabelBoldBodySmall(true) + public let rightLabel = Label.createLabelBoldBodySmall(true) + var stack: Stack + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 32, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center)), + (view: rightLabel, model: StackItemModel(percent: 35, horizontalAlignment: .center))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + // MARK: - ModelMoleculeViewProtocol + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnDataUsageDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + open override func reset() { + super.reset() + leftLabel.styleBoldBodySmall(true) + centerLabel.styleBoldBodySmall(true) + rightLabel.styleBoldBodySmall(true) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift new file mode 100644 index 00000000..f57bdf01 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift @@ -0,0 +1,51 @@ +// +// ListThreeColumnDataUsageDividerModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 20/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnDataUsageDividerModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list3CDataUsgDiv" + public let leftLabel: LabelModel + public let centerLabel: LabelModel + public let rightLabel: LabelModel + + public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + override public func setDefaults() { + super.setDefaults() + style = "tallDivider" + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from:decoder) + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift index aa9fbc2d..ad9f0740 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift @@ -22,7 +22,7 @@ import Foundation // MARK: - Initializers //------------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal) + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } From 870658b4c1d9ddd6512a331e96563bf52ed6a9bf Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Wed, 8 Apr 2020 17:18:05 +0530 Subject: [PATCH 198/244] subtext label implemented --- .../Views/RadioBoxCollectionViewCell.swift | 47 +++++++++++++------ .../Atomic/Atoms/Views/RadioBoxModel.swift | 5 ++ MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 12 +++-- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift index 67068c85..d959285d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift @@ -9,18 +9,20 @@ import Foundation open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtocol { - public let bodyLabel = Label.commonLabelB2(true) + public let bodyLabel = Label(frame: .zero) + public let subTextLabel = Label(frame: .zero) public let lineView = View(frame: .zero) var bottomView = MVMCoreUICommonViewsUtility.commonView() public var lineViewHeight: NSLayoutConstraint? public var fieldValue: String? + var boxModel: RadioBoxModel! open override var isSelected: Bool{ didSet{ - self.lineViewHeight?.constant = self.isSelected ? 4.0 : 0 - UIView.animate(withDuration: 0.5) { - self.layoutIfNeeded() + if let shapeLayer = self.bottomView.layer.sublayers?.filter({$0.name == "outofstock"}).first as? CAShapeLayer { + shapeLayer.strokeColor = isSelected ? UIColor.black.cgColor : UIColor.mfGet(forHex: "#747676").cgColor } + self.lineViewHeight?.constant = self.isSelected ? 4.0 : 0 self.bottomView.layer.sublayers?.filter({$0.name == "border"}).forEach({$0.removeFromSuperlayer()}) if(self.isSelected){ self.bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) @@ -28,8 +30,11 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco self.bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) } else { - self.addBordertoView() + self.addBordertoView("#747676") } + UIView.animate(withDuration: 0.5) { + self.layoutIfNeeded() + } } } @@ -77,7 +82,18 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco bottomView.addSubview(bodyLabel) NSLayoutConstraint.constraintPinSubview(bodyLabel, pinTop: false, topConstant:0 , pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 12, pinRight: true, rightConstant: 12) bodyLabel.topAnchor.constraint(equalTo: lineView.bottomAnchor, constant: 12).isActive = true - bodyLabel.bottomAnchor.constraint(lessThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true + + subTextLabel.numberOfLines = 1 + bottomView.addSubview(subTextLabel) + NSLayoutConstraint.constraintPinSubview(subTextLabel, pinTop: false, topConstant:0 , pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 12, pinRight: true, rightConstant: 12) + subTextLabel.bottomAnchor.constraint(lessThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true + subTextLabel.topAnchor.constraint(equalTo: bodyLabel.bottomAnchor, constant: 2).isActive = true + + subTextLabel.font = MFFonts.mfFontTXRegular(11.0) + bodyLabel.font = MFFonts.mfFontTXRegular(13.0) + subTextLabel.textColor = UIColor.mfGet(forHex: "#747676") + + } public func updateView(_ size: CGFloat) { @@ -85,15 +101,16 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco self.bottomView.setNeedsLayout() self.bottomView.layer.sublayers?.filter({$0.name == "border"}).forEach({$0.removeFromSuperlayer()}) DispatchQueue.main.async { [weak self] in - self?.addBordertoView() + guard let self = self else { return } + self.addBordertoView(self.boxModel.enabled ? "#747676" : "#D8DADA") } } - private func addBordertoView(){ - bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) - bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) - bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) - bottomView.layer.addBorder(edge: .top, color: UIColor.mfGet(forHex: "#747676"), thickness: 1.0) + private func addBordertoView(_ color:String){ + bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: color), thickness: 1.0) + bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: color), thickness: 1.0) + bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: color), thickness: 1.0) + bottomView.layer.addBorder(edge: .top, color: UIColor.mfGet(forHex: color), thickness: 1.0) } private func addOutOfStockLine(){ @@ -103,20 +120,22 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco let shapeLayer = CAShapeLayer() shapeLayer.name = "outofstock" shapeLayer.path = path.cgPath - shapeLayer.strokeColor = UIColor.darkGray.cgColor + shapeLayer.strokeColor = self.boxModel.enabled ? UIColor.black.cgColor : UIColor.mfGet(forHex: "#D8DADA").cgColor shapeLayer.lineWidth = 0.5 bottomView.layer.addSublayer(shapeLayer) } public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let collectionModel = model as? RadioBoxModel else { return } + boxModel = collectionModel if let backgroundColor = collectionModel.backgroundColor { bottomView.backgroundColor = backgroundColor.uiColor } self.isUserInteractionEnabled = collectionModel.enabled lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor bodyLabel.text = collectionModel.text - isSelected = collectionModel.selected + subTextLabel.text = collectionModel.subText +// isSelected = collectionModel.selected fieldValue = collectionModel.fieldValue isOutOfStock = collectionModel.strikethrough diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift index 31f58e53..4ce1e302 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -10,6 +10,7 @@ import Foundation @objcMembers public class RadioBoxModel: MoleculeModelProtocol { public static var identifier: String = "radioBox" public var text: String + public var subText: String? public var backgroundColor: Color? = Color(uiColor: .white) public var selectedAccentColor: Color? = try? Color(colorString: "#D52B1E") public var selected: Bool = false @@ -20,6 +21,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case moleculeName case text + case subText case selectedAccentColor case backgroundColor case selected @@ -31,6 +33,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) text = try typeContainer.decode(String.self, forKey: .text) + subText = try typeContainer.decodeIfPresent(String.self, forKey: .subText) if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor) { selectedAccentColor = color } @@ -52,6 +55,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.encode(text, forKey: .text) + try container.encodeIfPresent(subText, forKey: .subText) try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(selected, forKey: .selected) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift index 90a0d684..ec0689bc 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -56,9 +56,15 @@ open class RadioBoxes: View { @objc override open func updateView(_ size: CGFloat) { collectionView.collectionViewLayout.invalidateLayout() DispatchQueue.main.async { [weak self] in - self?.setNeedsDisplay() - self?.collectionView.layoutIfNeeded() - self?.collectionView.reloadData() + guard let self = self else { return } + self.setNeedsDisplay() + self.collectionView.layoutIfNeeded() + self.collectionView.reloadData() + guard let firstSelectedIndex = self.boxes?.firstIndex(where: {$0.selected == true}) else { + return + } + self.collectionView.selectItem(at: IndexPath(item: firstSelectedIndex, section: 0), animated: true, scrollPosition: .centeredHorizontally) + } } From 3e38234d123a4282cdfda1ffeae3e4f4436559ac Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Apr 2020 08:09:30 -0400 Subject: [PATCH 199/244] green --- MVMCoreUI/Categories/UIColor+MFConvenience.h | 1 + MVMCoreUI/Categories/UIColor+MFConvenience.m | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index c3c78c7a..92b28a36 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -24,6 +24,7 @@ + (nonnull UIColor *)mvmOrange; + (nonnull UIColor *)mfPumpkinColor; + (nonnull UIColor *)mfShamrock; ++ (nonnull UIColor *)mvmGreen; + (nonnull UIColor *)mfCerulean; + (nonnull UIColor *)mfWhiteTwo; diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index 6ff8f70f..33df3848 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -61,6 +61,10 @@ return [UIColor mfColor8bitsWithRed:0 green:134 blue:49 alpha:1.0]; } ++ (nonnull UIColor *)mvmGreen { + return [UIColor mfColor8bitsWithRed:0 green:134 blue:48 alpha:1.0]; +} + + (nonnull UIColor *)mfCerulean { return [UIColor mfColor8bitsWithRed:0 green:122 blue:184 alpha:1.0]; } From dcf168b53ecec3030eaddf717e8446ee400c35cc Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Apr 2020 08:19:06 -0400 Subject: [PATCH 200/244] rolaback --- MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift | 3 --- MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift | 3 --- MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift index c12b7dd3..da46c26e 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift @@ -215,9 +215,6 @@ import UIKit feedbackLabelTrailing = layoutMarginsGuide.trailingAnchor.constraint(equalTo: feedbackLabel.trailingAnchor) feedbackLabelTrailing?.isActive = true layoutMarginsGuide.bottomAnchor.constraint(equalTo: feedbackLabel.bottomAnchor).isActive = true - - container.trailingAnchor.constraint(equalTo: dropDownCaretView.trailingAnchor, constant: 16).isActive = true - dropDownCaretView.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true } @objc open override func layoutSubviews() { diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift index cf927c03..de0d1789 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/TextEntryField.swift @@ -79,9 +79,7 @@ import UIKit if error { textField.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "", textField.text ?? "", errorMessage ?? "") - errorIconWidthContraint?.constant = 20 } else { - errorIconWidthContraint?.constant = 0 textField.accessibilityValue = nil } @@ -143,7 +141,6 @@ import UIKit //-------------------------------------------------- public var textFieldTrailingConstraint: NSLayoutConstraint? - public var errorIconWidthContraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Initializers diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index 2908a90d..bad0492d 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -17,7 +17,7 @@ open class DoughnutChart: View { public var doughnutLayer = CALayer() public var titleLabel = Label.createLabelBoldTitleLarge(true) public var subTitleLabel = Label.createLabelRegularMicro(true) - public var labelContainer = View() + public var labelContainer = MVMCoreUICommonViewsUtility.commonView() public static let heightConstant: CGFloat = 136 private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)! From d755709daa37b4bd4b01ee0c125001e876a35923 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Apr 2020 08:35:21 -0400 Subject: [PATCH 201/244] remove code for later change --- MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift index da46c26e..658af357 100644 --- a/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/TextFields/EntryField.swift @@ -57,12 +57,6 @@ import UIKit } } - public var accessoryInput: View? { - didSet { - - } - } - //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- From fd31ca294bbb108f1b4b59eaf2017bb22f3b4718 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Apr 2020 09:22:32 -0400 Subject: [PATCH 202/244] update made --- MVMCoreUI/Styles/Padding.swift | 16 ++++++++-------- MVMCoreUI/Styles/Styler.swift | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift index ca99d5dc..3ed0922e 100644 --- a/MVMCoreUI/Styles/Padding.swift +++ b/MVMCoreUI/Styles/Padding.swift @@ -11,7 +11,7 @@ import Foundation public struct Padding { - public static let One: CGFloat = 6 + public static let One: CGFloat = 8 public static let Two: CGFloat = 12 public static let Three: CGFloat = 18 public static let Four: CGFloat = 24 @@ -24,24 +24,24 @@ public struct Padding { public struct Default { public static let Standard: CGFloat = 24 - public static let HorizontalSpacing: CGFloat = 32 - public static let VerticalSpacing: CGFloat = 32 - public static let VerticalSpacing3: CGFloat = 24 + public static let HorizontalMarginSpacing: CGFloat = 32 + public static let LargeVerticalMarginSpacing: CGFloat = 32 + public static let VerticalMarginSpacing: CGFloat = 24 public static var horizontalPaddingForApplicationWidth: CGFloat { - return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalSpacing + return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalMarginSpacing } public static var verticalPaddingForApplicationWidth: CGFloat { - return MFSizeObject(scalingStandardSize: VerticalSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalSpacing + return MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalMarginSpacing } public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: HorizontalSpacing)?.getValueBased(onSize: size) ?? HorizontalSpacing + return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBased(onSize: size) ?? HorizontalMarginSpacing } public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: VerticalSpacing)?.getValueBased(onSize: size) ?? VerticalSpacing + return MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBased(onSize: size) ?? VerticalMarginSpacing } } } diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 75d0b9ee..e6675b1d 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -167,10 +167,10 @@ open class Styler { } /// Styles the provided label to the declared enum Font case. - public func styleLabel(_ label: UILabel, genericScaling: Bool = true) { + public func styleLabel(_ label: UILabel, textColor: UIColor = .mvmBlack, genericScaling: Bool = true) { label.font = getFont(genericScaling) - label.textColor = .black + label.textColor = textColor } } From de084aa89987af29d5a9db2b4b0fd1170a1eb1ec Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Apr 2020 09:24:31 -0400 Subject: [PATCH 203/244] margin in styler --- MVMCoreUI/Styles/Styler.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index e6675b1d..e5ac19b7 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -197,8 +197,8 @@ open class Styler { open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat?, horizontal: Bool = true, vertical: Bool = false) { - var horizontalPadding: CGFloat = Padding.Default.HorizontalSpacing - let verticalPadding: CGFloat = vertical ? Padding.Default.VerticalSpacing3 : 0 + var horizontalPadding: CGFloat = Padding.Default.HorizontalMarginSpacing + let verticalPadding: CGFloat = vertical ? Padding.Default.VerticalMarginSpacing : 0 if let size = size { horizontalPadding = horizontal ? Padding.Default.horizontalPaddingForSize(size) : 0 From 8b957b1d4969ea0c96a600cb288aed2a966efedd Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Apr 2020 10:10:39 -0400 Subject: [PATCH 204/244] padding updates --- MVMCoreUI/Styles/Padding.swift | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift index 3ed0922e..0dd9ff6e 100644 --- a/MVMCoreUI/Styles/Padding.swift +++ b/MVMCoreUI/Styles/Padding.swift @@ -9,20 +9,21 @@ import Foundation +/// Padding is a multiple based on the number 4. public struct Padding { - public static let One: CGFloat = 8 - public static let Two: CGFloat = 12 - public static let Three: CGFloat = 18 - public static let Four: CGFloat = 24 - public static let Five: CGFloat = 30 - public static let Six: CGFloat = 36 - public static let Seven: CGFloat = 42 - public static let Eight: CGFloat = 48 - public static let Nine: CGFloat = 54 - public static let Ten: CGFloat = 60 + public static let OneHalf: CGFloat = 2 + public static let One: CGFloat = 4 + public static let Two: CGFloat = 8 + public static let Three: CGFloat = 12 + public static let Four: CGFloat = 16 + public static let Five: CGFloat = 24 + public static let Eight: CGFloat = 32 + public static let Ten: CGFloat = 40 + public static let Twelve: CGFloat = 48 + public static let Eighteen: CGFloat = 72 - public struct Default { + public struct Component { public static let Standard: CGFloat = 24 public static let HorizontalMarginSpacing: CGFloat = 32 public static let LargeVerticalMarginSpacing: CGFloat = 32 From c52337a08beb9e795b03f7f92ceaa0d34f10a1d3 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Apr 2020 10:28:14 -0400 Subject: [PATCH 205/244] name change --- MVMCoreUI/Styles/Styler.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index e5ac19b7..96bd558c 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -197,11 +197,11 @@ open class Styler { open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat?, horizontal: Bool = true, vertical: Bool = false) { - var horizontalPadding: CGFloat = Padding.Default.HorizontalMarginSpacing - let verticalPadding: CGFloat = vertical ? Padding.Default.VerticalMarginSpacing : 0 + var horizontalPadding: CGFloat = Padding.Component.HorizontalMarginSpacing + let verticalPadding: CGFloat = vertical ? Padding.Component.VerticalMarginSpacing : 0 if let size = size { - horizontalPadding = horizontal ? Padding.Default.horizontalPaddingForSize(size) : 0 + horizontalPadding = horizontal ? Padding.Component.horizontalPaddingForSize(size) : 0 } DispatchQueue.main.async { @@ -215,7 +215,7 @@ open class Styler { open class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) { - let horizontalPadding: CGFloat = horizontal ? Padding.Default.horizontalPaddingForSize(size) : 0 + let horizontalPadding: CGFloat = horizontal ? Padding.Component.horizontalPaddingForSize(size) : 0 DispatchQueue.main.async { MVMCoreUIUtility.setMarginsFor(view, From d66da2d2b831e92cc85d2e208125d3cf52a9fef5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 8 Apr 2020 11:16:41 -0400 Subject: [PATCH 206/244] fix --- MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift | 3 --- MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift index 3d52e63b..3ee1a9a2 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift @@ -134,9 +134,6 @@ import UIKit self.delegateObject = delegateObject isSelected = model.state - if model.state { - print("log") - } RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject) } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift index 99e15280..8863e9fa 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift @@ -47,6 +47,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { public init(_ state: Bool) { self.state = state + baseValue = state } //-------------------------------------------------- @@ -74,6 +75,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + baseValue = state fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName From c2e52ea31330c3c9c0921aa6440bf1773cd48731 Mon Sep 17 00:00:00 2001 From: "Pan, Xinlei (Ryan)" Date: Wed, 8 Apr 2020 11:51:14 -0400 Subject: [PATCH 207/244] Revert "Merge branch 'feature/usenewfont' into 'develop'" This reverts merge request !353 --- MVMCoreUI/Utility/MFFonts.m | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Utility/MFFonts.m b/MVMCoreUI/Utility/MFFonts.m index 24c62a9a..533b3a87 100644 --- a/MVMCoreUI/Utility/MFFonts.m +++ b/MVMCoreUI/Utility/MFFonts.m @@ -85,20 +85,14 @@ NSString * const DS55Rg = @"NHaasGroteskDSStd-55Rg"; + (nonnull UIFont *)mfFont75Bd:(CGFloat)size { [self loadMVMFonts]; - if (size >= 15) { - return [MFFonts mfFontDSBold:size]; - } else { - return [MFFonts mfFontTXBold:size]; - } + UIFont *font = [UIFont fontWithName:DS75Bd size:size]; + return font ?: [UIFont boldSystemFontOfSize:size]; } + (nonnull UIFont *)mfFont55Rg:(CGFloat)size { [self loadMVMFonts]; - if (size >= 15) { - return [MFFonts mfFontDSRegular:size]; - } else { - return [MFFonts mfFontTXRegular:size]; - } + UIFont *font = [UIFont fontWithName:DS55Rg size:size]; + return font ?: [UIFont systemFontOfSize:size]; } + (nullable UIFont *)mfFontOcratxt:(CGFloat)size { From 8c9ab45951a935c30d97bd055c8d34ed3af5116f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 16:14:40 -0400 Subject: [PATCH 208/244] Fixes for sizing and base classes --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + .../Atomic/Templates/CollectionTemplate.swift | 11 +- .../BaseClasses/CollectionViewCell.swift | 2 +- .../ContainerCollectionReusableView.swift | 10 +- ...ProgrammaticCollectionViewController.swift | 80 ++++++ .../ProgrammaticTableViewController.swift | 5 + .../ThreeLayerCollectionViewController.swift | 249 ++++++------------ .../BaseControllers/ViewController.swift | 18 +- MVMCoreUI/Utility/MVMCoreUIUtility.m | 2 +- 9 files changed, 193 insertions(+), 188 deletions(-) create mode 100644 MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6db35f4e..df6cdbf6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -250,6 +250,7 @@ D264FA8E243BCD9A00D98315 /* CollectionTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */; }; D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */; }; D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */; }; + D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; }; @@ -656,6 +657,7 @@ D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplate.swift; sourceTree = ""; }; D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerCollectionViewController.swift; sourceTree = ""; }; D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerCollectionReusableView.swift; sourceTree = ""; }; + D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticCollectionViewController.swift; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; @@ -1485,6 +1487,7 @@ D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */, D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */, D2A92885241ACD99004E01C6 /* ProgrammaticTableViewController.swift */, + D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */, ); path = BaseControllers; sourceTree = ""; @@ -2162,6 +2165,7 @@ C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */, 011D958524042432000E3791 /* RulesProtocol.swift in Sources */, 94AF4A3F23E9D13900676048 /* MFCaretButton.m in Sources */, + D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, 526A265E240D200500B0D828 /* ListTwoColumnCompareChanges.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index 11142532..d8812119 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -64,7 +64,6 @@ import Foundation } open override func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { - guard super.shouldFinishProcessingLoad(loadObject, error: error) else { return false } // This template requires atleast one of the three layers. @@ -103,8 +102,8 @@ import Foundation } open override func numberOfSections(in collectionView: UICollectionView) -> Int { - return 1 - } + return 1 + } open override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let moleculeInfo = moleculesInfo?[indexPath.row] @@ -124,7 +123,7 @@ import Foundation //-------------------------------------------------- /// Returns the (identifier, class) of the molecule for the given map. - func getMoleculeInfo(with item: (CollectionItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: CollectionItemModelProtocol & MoleculeModelProtocol)? { + open func getMoleculeInfo(with item: (CollectionItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: CollectionItemModelProtocol & MoleculeModelProtocol)? { guard let item = item, let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(item) else { return nil } let moleculeName = moleculeClass.nameForReuse(with: item, delegateObjectIVar) ?? item.moleculeName @@ -132,7 +131,7 @@ import Foundation } /// Sets up the molecule list and ensures no errors loading all content. - func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: (CollectionItemModelProtocol & MoleculeModelProtocol))]? { + open func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: (CollectionItemModelProtocol & MoleculeModelProtocol))]? { var moleculeList: [(identifier: String, class: AnyClass, molecule: CollectionItemModelProtocol & MoleculeModelProtocol)] = [] @@ -148,7 +147,7 @@ import Foundation } /// Sets up the header, footer, molecule list and ensures no errors loading all content. - func setup() { + open func setup() { moleculesInfo = getMoleculeInfoList() } diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index 50cece5d..fb5b1a5e 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -46,7 +46,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo open func updateView(_ size: CGFloat) { containerHelper.updateViewMargins(contentView, model: model, size: size) DispatchQueue.main.async { - print("\(self.contentView.directionalLayoutMargins.leading)") + print("leading \(self.contentView.directionalLayoutMargins.leading)") } } diff --git a/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift b/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift index c578c273..a0e80f21 100644 --- a/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift +++ b/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift @@ -14,12 +14,16 @@ public class ContainerCollectionReusableView: UICollectionReusableView { var bottomConstraint: NSLayoutConstraint? public func addAndContain(view: UIView) { + guard self.view != view else { return } self.view?.removeFromSuperview() view.setContentCompressionResistancePriority(.required, for: .vertical) addSubview(view) self.view = view - let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: view) - topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint - bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint + topConstraint = view.topAnchor.constraint(equalTo: topAnchor) + topConstraint?.isActive = true + bottomConstraint = bottomAnchor.constraint(equalTo: view.bottomAnchor) + bottomConstraint?.isActive = true + rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true + view.leftAnchor.constraint(equalTo: leftAnchor).isActive = true } } diff --git a/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift new file mode 100644 index 00000000..0dd473e2 --- /dev/null +++ b/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift @@ -0,0 +1,80 @@ +// +// ProgrammaticCollectionViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/8/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objc open class ProgrammaticCollectionViewController: ScrollingViewController { + + public var collectionView: UICollectionView? + + open override func loadView() { + let view = UIView() + view.backgroundColor = .white + + let collection = createCollectionView() + view.addSubview(collection) + NSLayoutConstraint.constraintPinSubview(toSuperview: collection) + + collectionView = collection + scrollView = collectionView + self.view = view + } + + /// A place to register cells with the collectionView + open func registerCells() {} + + open override func viewDidLoad() { + super.viewDidLoad() + registerCells() + } + + /// Creates the layout for the collection. + open func createCollectionViewLayout() -> UICollectionViewLayout { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.minimumLineSpacing = 0 + layout.minimumInteritemSpacing = 0 + layout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize + return layout + } + + /// Creates the collection view. + open func createCollectionView() -> UICollectionView { + let collection = UICollectionView(frame: .zero, collectionViewLayout: createCollectionViewLayout()) + collection.translatesAutoresizingMaskIntoConstraints = false + collection.dataSource = self + collection.delegate = self + collection.showsHorizontalScrollIndicator = false + collection.backgroundColor = .white + collection.isAccessibilityElement = false + collection.contentInsetAdjustmentBehavior = .always + return collection + } + + deinit { + collectionView?.delegate = nil + collectionView?.dataSource = nil + } +} + +extension ProgrammaticCollectionViewController: UICollectionViewDataSource { + open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 0 + } + + open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + return UICollectionViewCell() + } + + open func numberOfSections(in collectionView: UICollectionView) -> Int { + return 1 + } +} + +extension ProgrammaticCollectionViewController: UICollectionViewDelegate { +} diff --git a/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift index 4e262398..b27845b3 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift @@ -42,6 +42,11 @@ open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UI self.view = view } + open override func viewDidLoad() { + super.viewDidLoad() + registerWithTable() + } + /// This class should create the table view that will be used here. Subclass this for different table styles. open func createTableView() -> UITableView { let tableView = UITableView(frame: .zero, style: .grouped) diff --git a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift index 74877925..62c47d6e 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift @@ -8,73 +8,18 @@ import Foundation -@objc open class ThreeLayerCollectionViewController: ScrollingViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { - public var collectionView: UICollectionView? +@objc open class ThreeLayerCollectionViewController: ProgrammaticCollectionViewController, UICollectionViewDelegateFlowLayout { // The three main views private var topView: UIView? private var bottomView: UIView? private var headerView: ContainerCollectionReusableView? private var footerView: ContainerCollectionReusableView? - var useMargins: Bool = true private let headerID = "header" private let footerID = "footer" - //MARK: - MFViewController - open override func updateViews() { - super.updateViews() - let width = view.bounds.width - if let topView = topView as? MVMCoreViewProtocol { - topView.updateView(width) - // showHeader(width) - } - if let bottomView = bottomView as? MVMCoreViewProtocol { - bottomView.updateView(width) - //showFooter(width) - } - self.collectionView?.collectionViewLayout.invalidateLayout() - } - - open override func handleNewData() { - super.handleNewData() - createViewForTableHeader() - createViewForTableFooter() - collectionView?.reloadData() - } - - override open func viewDidLoad() { - let collection = createCollectionView() - collectionView = collection - view.addSubview(collection) - NSLayoutConstraint.constraintPinSubview(toSuperview: collection) - scrollView = collectionView - - registerCells() - - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - //MARK: - Spacing - // If both are subclassed to return a value, then the buttons will not be pinned towards the bottom because neither spacing would try to fill the screen. - /// Space between the top view and the table sections, nil to fill. 0 default - open func spaceBelowTopView() -> CGFloat? { - return 0 - } - - /// Space between the bottom view and the table sections, nil to fill. nil default - open func spaceAboveBottomView() -> CGFloat? { - return nil - } - - /// can override to return a minimum fill space. - open func minimumFillSpace() -> CGFloat { - return 0 - } - - open override func updateViewConstraints() { - super.updateViewConstraints() - + /// Updates the padding for flexible space (header or footer) + private func updateFlexibleSpace() { guard let tableView = collectionView else { return } let minimumSpace: CGFloat = minimumFillSpace() @@ -105,29 +50,70 @@ import Foundation currentSpaceForCompare = currentSpace * 2; } - if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 0.1) { + if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 2) { if fillTop && fillBottom { // space both let half = newSpace / 2 headerView?.bottomConstraint?.constant = half footerView?.topConstraint?.constant = half - collectionView?.invalidateIntrinsicContentSize() + collectionView?.collectionViewLayout.invalidateLayout() } else if fillTop { // Only top is spaced (half the size if the bottom view is out of the scroll because it needs to be sized as if there are two spacers but there is only one. headerView?.bottomConstraint?.constant = newSpace - collectionView?.invalidateIntrinsicContentSize() + collectionView?.collectionViewLayout.invalidateLayout() } else if fillBottom { // Only bottom is spaced. - print("newSpace \(newSpace)") footerView?.topConstraint?.constant = newSpace - collectionView?.invalidateIntrinsicContentSize() + collectionView?.collectionViewLayout.invalidateLayout() } } } + + //MARK: - MFViewController + open override func updateViews() { + super.updateViews() + let width = view.bounds.width + if let topView = topView as? MVMCoreViewProtocol { + topView.updateView(width) + } + if let bottomView = bottomView as? MVMCoreViewProtocol { + bottomView.updateView(width) + } + invalidateCollectionLayout() + } + + open override func handleNewData() { + super.handleNewData() + createViewForHeader() + createViewForFooter() + reloadCollectionData() + } + + override open func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + //MARK: - Spacing + // If both are subclassed to return a value, then the buttons will not be pinned towards the bottom because neither spacing would try to fill the screen. + /// Space between the top view and the collection rows, nil to fill. 0 default + open func spaceBelowTopView() -> CGFloat? { + return 0 + } + + /// Space between the bottom view and the collection rows, nil to fill. nil default + open func spaceAboveBottomView() -> CGFloat? { + return nil + } + + /// can override to return a minimum fill space. + open func minimumFillSpace() -> CGFloat { + return 0 + } //MARK: - Header Footer - /// Gets the top view and adds it to a spacing view, headerView, and then calls showHeader. - open func createViewForTableHeader() { + /// Creates the top view. + open func createViewForHeader() { guard let topView = viewForTop() else { self.topView = nil self.headerView = nil @@ -136,8 +122,8 @@ import Foundation self.topView = topView } - /// Gets the bottom view and adds it to a spacing view, footerView, and then calls showFooter. - open func createViewForTableFooter() { + /// Creates the footer + open func createViewForFooter() { guard let bottomView = viewForBottom() else { self.bottomView = nil self.footerView = nil @@ -145,60 +131,7 @@ import Foundation } self.bottomView = bottomView } - -// /// Takes the current headerView and adds it to the tableHeaderView -// func showHeader(_ sizingWidth: CGFloat?) { -// headerView?.removeFromSuperview() -// tableView?.tableHeaderView = nil -// guard let headerView = headerView else { -// return -// } -// -// // This extra view is needed because of the wonkiness of apple's table header. Things breaks if using autolayout. -// headerView.setNeedsLayout() -// headerView.layoutIfNeeded() -// MVMCoreUIUtility.sizeView(toFit: headerView) -// let tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: MVMCoreUIUtility.getWidth(), height: headerView.frame.height)) -// tableHeaderView.addSubview(headerView) -// NSLayoutConstraint.constraintPinSubview(toSuperview: headerView) -// tableView?.tableHeaderView = tableHeaderView -// } -// -// /// Takes the current footerView and adds it to the tableFooterView -// func showFooter(_ sizingWidth: CGFloat?) { -// footerView?.removeFromSuperview() -// safeAreaView?.removeFromSuperview() -// guard let footerView = footerView, let tableView = tableView else { -// return -// } -// -// if bottomViewOutsideOfScrollArea { -// // put bottom view outside of scrolling area. -// bottomConstraint?.isActive = false -// view.addSubview(footerView) -// footerView.topAnchor.constraint(equalTo: tableView.bottomAnchor).isActive = true -// footerView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true -// view.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true -// view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true -// safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: view) -// safeAreaView?.backgroundColor = bottomView?.backgroundColor -// } else { -// bottomConstraint?.isActive = true -// var y: CGFloat? -// if let tableFooterView = tableView.tableFooterView { -// // if footer already exists, use the same y location to avoid strange moving animation -// y = tableFooterView.frame.minY -// } -// -// // This extra view is needed because of the wonkiness of apple's table footer. Things breaks if using autolayout. -// MVMCoreUIUtility.sizeView(toFit: footerView) -// let tableFooterView = UIView(frame: CGRect(x: 0, y: y ?? 0, width: MVMCoreUIUtility.getWidth(), height: footerView.frame.height)) -// tableFooterView.addSubview(footerView) -// NSLayoutConstraint.constraintPinSubview(toSuperview: footerView) -// tableView.tableFooterView = tableFooterView -// } -// } - + //MARK: - Functions to subclass /// Subclass for a top view. open func viewForTop() -> UIView? { @@ -210,85 +143,65 @@ import Foundation return nil } - open func createCollectionViewLayout() -> UICollectionViewLayout { - let layout = UICollectionViewFlowLayout() - layout.scrollDirection = .vertical - layout.minimumLineSpacing = 0 - layout.minimumInteritemSpacing = 0 - layout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize - return layout - } - - open func createCollectionView() -> UICollectionView { - let collection = UICollectionView(frame: .zero, collectionViewLayout: createCollectionViewLayout()) - collection.translatesAutoresizingMaskIntoConstraints = false - collection.dataSource = self - collection.delegate = self - collection.showsHorizontalScrollIndicator = false - collection.backgroundColor = .white - collection.isAccessibilityElement = false - collection.contentInsetAdjustmentBehavior = .always - return collection - } - - deinit { - collectionView?.delegate = nil - collectionView?.dataSource = nil - } - //MARK: - Collection - open func registerCells() { + /// Should be used to refresh the layout of the collection view. Updates flexible padding. + open func invalidateCollectionLayout() { + self.collectionView?.collectionViewLayout.invalidateLayout() + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: { + self.updateFlexibleSpace() + }) + } + + /// Should be used to reload the data of the collection view. Updates flexible padding. + open func reloadCollectionData() { + collectionView?.reloadData() + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: { + self.updateFlexibleSpace() + }) + } + + open override func registerCells() { + super.registerCells() collectionView?.register(ContainerCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerID) collectionView?.register(ContainerCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: footerID) } - open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + open override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 0 } - open func numberOfSections(in collectionView: UICollectionView) -> Int { - return 1 - } - - open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionItem", for: indexPath) as! MoleculeCollectionViewCell - let labelModel = LabelModel(text: "hello") - let model = MoleculeCollectionItemModel(with: labelModel) - cell.set(with: model, delegateObjectIVar, nil) - return cell - } - open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { - guard let view = headerView ?? topView, + guard let _ = topView, section == 0 else { return .zero } + let header = headerView ?? self.collectionView(collectionView, viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionHeader, at: IndexPath(row: 0, section: section)) // Use this view to calculate the optimal size based on the collection view's width - return view.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), + return header.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), withHorizontalFittingPriority: .required, // Width is fixed verticalFittingPriority: .fittingSizeLevel) // Height can be as large as needed } open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { - guard let view = footerView ?? bottomView, + guard let _ = bottomView, section == numberOfSections(in: collectionView) - 1 else { return .zero } + let footer = footerView ?? self.collectionView(collectionView, viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionFooter, at: IndexPath(row: 0, section: section)) // Use this view to calculate the optimal size based on the collection view's width - let size = view.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), + let size = footer.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), withHorizontalFittingPriority: .required, // Width is fixed verticalFittingPriority: .fittingSizeLevel) // Height can be as large as needed - print("SIZEEE \(size.height) \(String(describing: footerView?.topConstraint?.constant))") return size } open func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { - if (kind == UICollectionView.elementKindSectionFooter) { + if kind == UICollectionView.elementKindSectionFooter { let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: footerID, for: indexPath) as! ContainerCollectionReusableView footerView.addAndContain(view: bottomView!) footerView.topConstraint?.constant = spaceAboveBottomView() ?? 0 self.footerView = footerView return footerView - } else if (kind == UICollectionView.elementKindSectionHeader) { + } else if kind == UICollectionView.elementKindSectionHeader { let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerID, for: indexPath) as! ContainerCollectionReusableView headerView.addAndContain(view: topView!) headerView.bottomConstraint?.constant = spaceBelowTopView() ?? 0 diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 5bc66109..4e4d289d 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -24,7 +24,7 @@ import UIKit public var formValidator: FormValidator? - public var needsUpdateUI = true + public var needsUpdateUI = false private var observingForResponses = false private var initialLoadFinished = false private var previousScreenSize = CGSize.zero @@ -155,8 +155,8 @@ import UIKit /// Calls processNewData and then sets the ui to update with updateView open func handleNewDataAndUpdateUI() { handleNewData() - self.needsUpdateUI = true - self.view.setNeedsLayout() + needsUpdateUI = true + view.setNeedsLayout() } /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, @@ -170,9 +170,9 @@ import UIKit navigationModel.line = LineModel(type: .none) } pageModel?.navigationItem = navigationModel - if self.formValidator == nil { + if formValidator == nil { let rules = pageModel?.formRules - self.formValidator = FormValidator(rules) + formValidator = FormValidator(rules) } } @@ -268,10 +268,10 @@ import UIKit initialLoad() } - // Handle data on load - handleNewData() - - view.setNeedsLayout() + // Handle data for first load. Dispatched to allow subclasses to finish their view did load implementations. + DispatchQueue.main.async { + self.handleNewDataAndUpdateUI() + } } open override func viewDidLayoutSubviews() { diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index 59c55cc6..b502467d 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -168,8 +168,8 @@ topInset = scrollview.adjustedContentInset.top; bottomInset = scrollview.adjustedContentInset.bottom; } - CGFloat remainingSpace = frameHeight - contentSizeHeight - topInset - bottomInset; + NSLog(@"scc SPACCEEE remaining: %f frame: %f, content: %f, insets:(%f,%f)",remainingSpace,frameHeight,contentSizeHeight,topInset,bottomInset); return remainingSpace - 1; } From 9178385e6d9ab2d85aa1bb400412efb76eb08b19 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 16:16:16 -0400 Subject: [PATCH 209/244] comments --- .../BaseControllers/ThreeLayerCollectionViewController.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift index 62c47d6e..af9fce4c 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift @@ -148,6 +148,7 @@ import Foundation /// Should be used to refresh the layout of the collection view. Updates flexible padding. open func invalidateCollectionLayout() { self.collectionView?.collectionViewLayout.invalidateLayout() + // TODO: Improve this workaround (autolayout for cells happens async so contentSize isn't accurate immediately) DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: { self.updateFlexibleSpace() }) @@ -156,6 +157,7 @@ import Foundation /// Should be used to reload the data of the collection view. Updates flexible padding. open func reloadCollectionData() { collectionView?.reloadData() + // TODO: Improve this workaround (autolayout for cells happens async so contentSize isn't accurate immediately) DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: { self.updateFlexibleSpace() }) From e4a6a1ddf0816a0f610c646a95109fb3affaa0ad Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 16:18:05 -0400 Subject: [PATCH 210/244] remove code for kevin pr --- .../Atomic/Molecules/Doughnut/DoughnutChartModel.swift | 7 ------- 1 file changed, 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift index 2b64d1ae..ff9b1bf6 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChartModel.swift @@ -35,11 +35,4 @@ import Foundation self.color = color self.label = label } - - private enum CodingKeys: String, CodingKey { - case backgroundColor - case label - case percent - case color - } } From 8a9d85a83c8523cd9df2dadcdd3dfd72e78a17fe Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 16:24:17 -0400 Subject: [PATCH 211/244] comments --- .../BaseControllers/ContainerCollectionReusableView.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift b/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift index a0e80f21..d7fb0ed4 100644 --- a/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift +++ b/MVMCoreUI/BaseControllers/ContainerCollectionReusableView.swift @@ -8,10 +8,11 @@ import Foundation +/// CollectionReusableView that can contains any other view. public class ContainerCollectionReusableView: UICollectionReusableView { - var view: UIView? - var topConstraint: NSLayoutConstraint? - var bottomConstraint: NSLayoutConstraint? + public var view: UIView? + public var topConstraint: NSLayoutConstraint? + public var bottomConstraint: NSLayoutConstraint? public func addAndContain(view: UIView) { guard self.view != view else { return } From c6b8eacff48343620b23ac6a5bc4c8b9ce24bfbd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 16:36:46 -0400 Subject: [PATCH 212/244] update fix --- MVMCoreUI/BaseClasses/CollectionViewCell.swift | 4 +--- .../ThreeLayerCollectionViewController.swift | 11 ++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index fb5b1a5e..e7bb7893 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -45,9 +45,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo open func updateView(_ size: CGFloat) { containerHelper.updateViewMargins(contentView, model: model, size: size) - DispatchQueue.main.async { - print("leading \(self.contentView.directionalLayoutMargins.leading)") - } + (molecule as? MVMCoreViewProtocol)?.updateView(size) } open func reset() { diff --git a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift index af9fce4c..bf5520b9 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift @@ -8,9 +8,9 @@ import Foundation +/// A view controller that has three main layers, a header, collection rows, and a footer. The header is added as a supplement header to the first section, and the footer is added as a supplement footer to the last section. This view controller allows for flexible space between the three layers to fit the screeen. @objc open class ThreeLayerCollectionViewController: ProgrammaticCollectionViewController, UICollectionViewDelegateFlowLayout { - // The three main views private var topView: UIView? private var bottomView: UIView? private var headerView: ContainerCollectionReusableView? @@ -69,7 +69,7 @@ import Foundation } } - //MARK: - MFViewController + //MARK: - ViewController open override func updateViews() { super.updateViews() let width = view.bounds.width @@ -79,6 +79,11 @@ import Foundation if let bottomView = bottomView as? MVMCoreViewProtocol { bottomView.updateView(width) } + if let cells = collectionView?.visibleCells { + for cell in cells { + (cell as? MVMCoreViewProtocol)?.updateView(width) + } + } invalidateCollectionLayout() } @@ -106,7 +111,7 @@ import Foundation return nil } - /// can override to return a minimum fill space. + /// can override to return a minimum fill space. 0 default open func minimumFillSpace() -> CGFloat { return 0 } From 4941c51be3627eb2f5fa8da8a2c0f36524b9efdd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 16:47:20 -0400 Subject: [PATCH 213/244] update to make collection less restrictive --- .../Items/CollectionItemModelProtocol.swift | 2 +- .../Items/MoleculeCollectionItemModel.swift | 2 +- .../BaseClasses/CollectionViewCell.swift | 9 +++++-- ...ProgrammaticCollectionViewController.swift | 1 + .../ThreeLayerCollectionViewController.swift | 25 ++++++++----------- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift index c8bfb7d7..9361ab1e 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift @@ -8,6 +8,6 @@ import Foundation -public protocol CollectionItemModelProtocol: ContainerModelProtocol { +public protocol CollectionItemModelProtocol { } diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift index 8d236f4b..b3d2aba6 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers open class MoleculeCollectionItemModel: CollectionItemModelProtocol, MoleculeModelProtocol { +@objcMembers open class MoleculeCollectionItemModel: CollectionItemModelProtocol, ContainerModelProtocol, MoleculeModelProtocol { open class var identifier: String { return "collectionItem" } diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index e7bb7893..e9857808 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -8,6 +8,7 @@ import Foundation +/// A base collection view cell with basic mvm functionality. open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol { // Convenience helpers @@ -44,7 +45,9 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo } open func updateView(_ size: CGFloat) { - containerHelper.updateViewMargins(contentView, model: model, size: size) + if let model = model as? ContainerModelProtocol { + containerHelper.updateViewMargins(contentView, model: model, size: size) + } (molecule as? MVMCoreViewProtocol)?.updateView(size) } @@ -63,7 +66,9 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo } // align if needed. - containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) + if let model = model as? ContainerModelProtocol { + containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) + } } /// Convenience function. Adds the molecule to the view. diff --git a/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift index 0dd473e2..9d279d79 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift @@ -8,6 +8,7 @@ import Foundation +/// A base view controller with a collection view. @objc open class ProgrammaticCollectionViewController: ScrollingViewController { public var collectionView: UICollectionView? diff --git a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift index bf5520b9..82dda260 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift @@ -181,35 +181,30 @@ import Foundation open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { guard let _ = topView, section == 0 else { return .zero } + + // Calculate the height of the header since apple doesn't support autolayout. Width is fixed, height is tall as content. let header = headerView ?? self.collectionView(collectionView, viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionHeader, at: IndexPath(row: 0, section: section)) - - // Use this view to calculate the optimal size based on the collection view's width - return header.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), - withHorizontalFittingPriority: .required, // Width is fixed - verticalFittingPriority: .fittingSizeLevel) // Height can be as large as needed + return header.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel) } open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { guard let _ = bottomView, section == numberOfSections(in: collectionView) - 1 else { return .zero } + + // Calculate the height of the footr since apple doesn't support autolayout. Width is fixed, height is tall as content. let footer = footerView ?? self.collectionView(collectionView, viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionFooter, at: IndexPath(row: 0, section: section)) - - // Use this view to calculate the optimal size based on the collection view's width - let size = footer.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), - withHorizontalFittingPriority: .required, // Width is fixed - verticalFittingPriority: .fittingSizeLevel) // Height can be as large as needed - return size + return footer.systemLayoutSizeFitting(CGSize(width: collectionView.frame.width, height: UIView.layoutFittingExpandedSize.height), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel) } open func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { - if kind == UICollectionView.elementKindSectionFooter { - let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: footerID, for: indexPath) as! ContainerCollectionReusableView + if kind == UICollectionView.elementKindSectionFooter, + let footerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: footerID, for: indexPath) as? ContainerCollectionReusableView { footerView.addAndContain(view: bottomView!) footerView.topConstraint?.constant = spaceAboveBottomView() ?? 0 self.footerView = footerView return footerView - } else if kind == UICollectionView.elementKindSectionHeader { - let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerID, for: indexPath) as! ContainerCollectionReusableView + } else if kind == UICollectionView.elementKindSectionHeader, + let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerID, for: indexPath) as? ContainerCollectionReusableView { headerView.addAndContain(view: topView!) headerView.bottomConstraint?.constant = spaceBelowTopView() ?? 0 self.headerView = headerView From ce8cc3d430e7ae7f0161d66fcfe9aa22ac3dcde4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 16:51:30 -0400 Subject: [PATCH 214/244] comments --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- .../Atomic/Molecules/Items/MoleculeCollectionItemModel.swift | 2 +- .../Atomic/Molecules/Items/MoleculeCollectionViewCell.swift | 1 + MVMCoreUI/BaseClasses/CollectionViewCell.swift | 5 ++++- .../Protocols}/CollectionItemModelProtocol.swift | 0 5 files changed, 7 insertions(+), 3 deletions(-) rename MVMCoreUI/{Atomic/Molecules/Items => BaseClasses/Protocols}/CollectionItemModelProtocol.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index df6cdbf6..9c49c057 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -914,6 +914,7 @@ 0A5D59C323AD488600EFD9E9 /* Protocols */ = { isa = PBXGroup; children = ( + D21B7F72243BAC6800051ABF /* CollectionItemModelProtocol.swift */, 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, ); path = Protocols; @@ -1265,7 +1266,6 @@ D260105E23D0BFFC00764D80 /* StackItem.swift */, 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */, D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */, - D21B7F72243BAC6800051ABF /* CollectionItemModelProtocol.swift */, D21B7F76243BB70700051ABF /* MoleculeCollectionItemModel.swift */, D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift index b3d2aba6..b9ac345b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift @@ -8,7 +8,7 @@ import Foundation - +/// A model for a collection item that is a container for any molecule. @objcMembers open class MoleculeCollectionItemModel: CollectionItemModelProtocol, ContainerModelProtocol, MoleculeModelProtocol { open class var identifier: String { return "collectionItem" diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift index 0ae515f5..1f615732 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift @@ -8,6 +8,7 @@ import UIKit +/// A collection item that is a container for any molecule. open class MoleculeCollectionViewCell: CollectionViewCell { open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index e9857808..a559c93e 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -18,6 +18,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo private var initialSetupPerformed = false + // MARK: - Inits public override init(frame: CGRect) { super.init(frame: .zero) initialSetup() @@ -35,6 +36,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo } } + // MARK: - MVMCoreViewProtocol open func setupView() { isAccessibilityElement = false contentView.isAccessibilityElement = false @@ -56,6 +58,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo backgroundColor = .white } + // MARK: - MoleculeViewProtocol open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? CollectionItemModelProtocol else { return } self.model = model @@ -71,7 +74,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo } } - /// Convenience function. Adds the molecule to the view. + /// Convenience function. Adds a molecule to the view. open func addMolecule(_ molecule: MoleculeViewProtocol) { contentView.addSubview(molecule) containerHelper.constrainView(molecule) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift b/MVMCoreUI/BaseClasses/Protocols/CollectionItemModelProtocol.swift similarity index 100% rename from MVMCoreUI/Atomic/Molecules/Items/CollectionItemModelProtocol.swift rename to MVMCoreUI/BaseClasses/Protocols/CollectionItemModelProtocol.swift From 40efdc4968e23493376aac7c9f0018e1a133ea3f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 8 Apr 2020 17:24:38 -0400 Subject: [PATCH 215/244] re-order --- MVMCoreUI/Atomic/Templates/CollectionTemplate.swift | 4 ++-- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index d8812119..0bbcd45f 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -79,9 +79,9 @@ import Foundation open override func handleNewData() { - super.handleNewData() setup() - registerCells() + registerCells() + super.handleNewData() } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 7575faf1..b236e332 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -81,9 +81,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } open override func handleNewData() { - super.handleNewData() setup() registerWithTable() + super.handleNewData() } //-------------------------------------------------- From 03438a116587d0ebfd7f6e7b7e269f2e4a5fccb4 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 8 Apr 2020 22:33:14 -0400 Subject: [PATCH 216/244] reuse fixes --- .../Buttons/RadioButtonSelectionHelper.swift | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index dbc3f7fe..2273785f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -13,46 +13,50 @@ import UIKit public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName private var selectedRadioButton: RadioButton? - private var fieldGroupName: String? + private var selectedRadioButtonModel: RadioButtonModel? public var baseValue: AnyHashable? - init(_ radioButtonModel: RadioButtonModel?) { - self.fieldKey = radioButtonModel?.fieldKey - if radioButtonModel?.state ?? false { - self.baseValue = radioButtonModel?.formFieldValue() + public func set(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton) { + self.fieldKey = radioButtonModel.fieldKey + if radioButtonModel.state { + if self.baseValue == nil { + self.baseValue = radioButtonModel.fieldValue + } + selectedRadioButtonModel = radioButtonModel + + // Below code is needed for cell resuse scenario. + radioButton.isSelected = true + selectedRadioButton = radioButton + } else { + radioButton.isSelected = false } } - + public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) { guard let groupName = radioButtonModel.fieldKey, - let formValidator = delegateObject?.formHolderDelegate?.formValidator else { - return + let formValidator = delegateObject?.formHolderDelegate?.formValidator else { + return } - - let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel) - radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey - formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper - if radioButtonModel.state { - radioButtonSelectionHelper.selectedRadioButton = radioButton - } + let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper() + radioButtonSelectionHelper.set(radioButtonModel, radioButton) + formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper FormValidator.setupValidation(for: radioButtonSelectionHelper, delegate: delegateObject?.formHolderDelegate) } public func selected(_ radioButton: RadioButton) { selectedRadioButton?.isSelected = false + selectedRadioButtonModel?.state = false selectedRadioButton = radioButton + selectedRadioButton?.isSelected = true + selectedRadioButtonModel = selectedRadioButton?.radioModel } } // MARK: - FormValidationFormFieldProtocol -extension RadioButtonSelectionHelper { - public func formFieldGroupName() -> String? { - return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName - } - +extension RadioButtonSelectionHelper { public func formFieldValue() -> AnyHashable? { - return selectedRadioButton?.formFieldValue() + return selectedRadioButtonModel?.fieldValue } } From eccfa4db62a2d6a8bb61afa7eaf3b47e37f2cfa5 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Thu, 9 Apr 2020 11:54:00 +0530 Subject: [PATCH 217/244] removed duplicate files --- .../ListThreeColumnDataUsageDivider.swift | 61 -------- ...ListThreeColumnDataUsageDividerModel.swift | 51 ------- .../OtherHandlers/MoleculeObjectMapping.swift | 144 ------------------ 3 files changed, 256 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift delete mode 100644 MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift delete mode 100644 MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift deleted file mode 100644 index c4944e3e..00000000 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift +++ /dev/null @@ -1,61 +0,0 @@ -// -// ListThreeColumnDataUsageDivider.swift -// MVMCoreUI -// -// Created by Kruthika KP on 20/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -@objcMembers open class ListThreeColumnDataUsageDivider: TableViewCell { - - //----------------------------------------------------- - // MARK: - Outlets - //------------------------------------------------------- - public let leftLabel = Label.createLabelBoldBodySmall(true) - public let centerLabel = Label.createLabelBoldBodySmall(true) - public let rightLabel = Label.createLabelBoldBodySmall(true) - var stack: Stack - - //------------------------------------------------------ - // MARK: - Initializers - //------------------------------------------------------ - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), - (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center)), - (view: rightLabel, model: StackItemModel(percent: 34, horizontalAlignment: .center))], - axis: .horizontal) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - open override func setupView() { - super.setupView() - addMolecule(stack) - stack.restack() - } - - // MARK: - ModelMoleculeViewProtocol - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListThreeColumnDataUsageDividerModel else { return } - leftLabel.set(with: model.leftLabel, delegateObject, additionalData) - centerLabel.set(with: model.centerLabel, delegateObject, additionalData) - rightLabel.set(with: model.rightLabel, delegateObject, additionalData) - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 121 - } - - open override func reset() { - super.reset() - leftLabel.styleBoldBodySmall(true) - centerLabel.styleBoldBodySmall(true) - rightLabel.styleBoldBodySmall(true) - } -} diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift deleted file mode 100644 index f57bdf01..00000000 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// ListThreeColumnDataUsageDividerModel.swift -// MVMCoreUI -// -// Created by Kruthika KP on 20/03/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public class ListThreeColumnDataUsageDividerModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "list3CDataUsgDiv" - public let leftLabel: LabelModel - public let centerLabel: LabelModel - public let rightLabel: LabelModel - - public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { - self.leftLabel = leftLabel - self.centerLabel = centerLabel - self.rightLabel = rightLabel - super.init() - } - - override public func setDefaults() { - super.setDefaults() - style = "tallDivider" - } - - private enum CodingKeys: String, CodingKey { - case moleculeName - case leftLabel - case centerLabel - case rightLabel - } - - required init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) - centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) - rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - try super.init(from:decoder) - } - - public override func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(leftLabel, forKey: .leftLabel) - try container.encode(centerLabel, forKey: .centerLabel) - try container.encode(rightLabel, forKey: .rightLabel) - } -} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift deleted file mode 100644 index a33e298e..00000000 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// MVMCoreUIMoleculeMappingObject+ModelMapping.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -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: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) - - // Label - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) - // need to move labelattributemodel to different method - try? ModelRegistry.register(LabelAttributeFontModel.self) - try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... - try? ModelRegistry.register(LabelAttributeUnderlineModel.self) - try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) - try? ModelRegistry.register(LabelAttributeActionModel.self) - - // Buttons - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) - - // Entry Field - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - - // Other Atoms - 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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) - - // 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: HeadlineBodyLink.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: LabelToggle.self, viewModelClass: LabelToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - - // List items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.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) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.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: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.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) - - // Designed List Items - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) - - // Designed Section Dividers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self) - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnDataUsageDivider.self, viewModelClass: ListThreeColumnDataUsageDividerModel.self) - - // Designed Headers - MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) - - // TODO: Need model - MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString) - - // TODO: Need View - try? ModelRegistry.register(TabsModel.self) - - // Helper models - try? ModelRegistry.register(RuleRequiredModel.self) - try? ModelRegistry.register(RuleAnyRequiredModel.self) - try? ModelRegistry.register(RuleAnyValueChangedModel.self) - try? ModelRegistry.register(RuleAllValueChangedModel.self) - try? ModelRegistry.register(RuleEqualsModel.self) - try? ModelRegistry.register(RuleRegexModel.self) - - // Actions - try? ModelRegistry.register(ActionTopAlertModel.self) - try? ModelRegistry.register(ActionCollapseNotificationModel.self) - try? ModelRegistry.register(ActionOpenPanelModel.self) - } -} From 7cba93e9f571672d462328cc06ead3e82caab0bd Mon Sep 17 00:00:00 2001 From: Damodaram <> Date: Thu, 9 Apr 2020 15:24:08 +0530 Subject: [PATCH 218/244] confluence changes Updated --- .../Views/RadioBoxCollectionViewCell.swift | 1 - .../Atomic/Atoms/Views/RadioBoxModel.swift | 11 ++++++++++ MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 22 +++++++++++++++---- .../Atomic/Atoms/Views/RadioBoxesModel.swift | 9 +------- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift index d959285d..419f278c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift @@ -135,7 +135,6 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor bodyLabel.text = collectionModel.text subTextLabel.text = collectionModel.subText -// isSelected = collectionModel.selected fieldValue = collectionModel.fieldValue isOutOfStock = collectionModel.strikethrough diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift index 4ce1e302..0c119ed8 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -17,6 +17,8 @@ import Foundation public var enabled: Bool = true public var strikethrough: Bool = false public var fieldValue: String? + public var fieldKey: String? + public var groupName: String? private enum CodingKeys: String, CodingKey { case moleculeName @@ -28,6 +30,9 @@ import Foundation case enabled case strikethrough case fieldValue + case fieldKey + case groupName + } required public init(from decoder: Decoder) throws { @@ -50,6 +55,9 @@ import Foundation strikethrough = isStrikeTrough } fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) + } public func encode(to encoder: Encoder) throws { @@ -63,5 +71,8 @@ import Foundation try container.encodeIfPresent(enabled, forKey: .enabled) try container.encodeIfPresent(strikethrough, forKey: .strikethrough) try container.encodeIfPresent(fieldValue, forKey: .fieldValue) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(groupName, forKey: .groupName) + } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift index ec0689bc..d0cae6b4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -14,13 +14,18 @@ open class RadioBoxes: View { /// The models for the molecules. var boxes: [RadioBoxModel]? - public var fieldKey: String? - public var groupName: String? public var collectionViewHeight: NSLayoutConstraint? private let boxWidth: Double = 151.0 private let boxHeight: Double = 64.0 private let itemSpacing: Double = 10.0 private let leadingSpacing: Double = 0 + + public var selectedBox: RadioBoxModel? { + get{ + guard let selectedItem = collectionView.indexPathsForSelectedItems?.first else {return nil} + return boxes?[selectedItem.item] + } + } // MARK: - MVMCoreViewProtocol open override func setupView() { @@ -45,8 +50,6 @@ open class RadioBoxes: View { super.set(with: model, delegateObject, additionalData) guard let radioBoxesModel = model as? RadioBoxesModel else { return } backgroundColor = radioBoxesModel.backgroundColor?.uiColor - fieldKey = radioBoxesModel.fieldKey - groupName = radioBoxesModel.groupName registerCells() setupLayout(with: radioBoxesModel) prepareMolecules(with: radioBoxesModel) @@ -119,3 +122,14 @@ extension RadioBoxes: UICollectionViewDataSource { return cell } } +extension RadioBoxes: UICollectionViewDelegate { + public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + guard let boxItem = boxes?[indexPath.row] else { return } + boxItem.selected = true + } + public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { + guard let boxItem = boxes?[indexPath.row] else { return } + boxItem.selected = false + } +} + diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift index 4e690ffa..d50978a1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift @@ -12,16 +12,13 @@ import Foundation public var backgroundColor: Color? = Color(uiColor: .white) public var selectedAccentColor: Color? = Color(uiColor: .red) public var boxes: [RadioBoxModel] - public var fieldKey: String? - public var groupName: String? private enum CodingKeys: String, CodingKey { case moleculeName case selectedAccentColor case backgroundColor case boxes - case fieldKey - case groupName + } required public init(from decoder: Decoder) throws { @@ -33,8 +30,6 @@ import Foundation backgroundColor = color } boxes = try typeContainer.decode([RadioBoxModel].self, forKey: .boxes) - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) } public func encode(to encoder: Encoder) throws { @@ -42,7 +37,5 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(groupName, forKey: .groupName) } } From 76d4a3975780b2a945502beae04a879efcfb5bb0 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 9 Apr 2020 10:25:02 -0400 Subject: [PATCH 219/244] change for git --- MVMCoreUI/Styles/Styler.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 96bd558c..b5d6627c 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -213,9 +213,9 @@ open class Styler { } } - open class func setMarginsFor(_ view: UIView?, size: CGFloat, defaultHorizontal horizontal: Bool, top: CGFloat, bottom: CGFloat) { + open class func setMarginsFor(_ view: UIView?, size: CGFloat, horizontal: CGFloat?, top: CGFloat, bottom: CGFloat) { - let horizontalPadding: CGFloat = horizontal ? Padding.Component.horizontalPaddingForSize(size) : 0 + let horizontalPadding: CGFloat = horizontal ?? Padding.Component.horizontalPaddingForSize(size) DispatchQueue.main.async { MVMCoreUIUtility.setMarginsFor(view, From db0b953bad1fc5af048cd939fb85f548e3584a54 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 9 Apr 2020 10:35:58 -0400 Subject: [PATCH 220/244] fixes --- .../Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index 2273785f..60c79465 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -19,7 +19,8 @@ import UIKit public func set(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton) { self.fieldKey = radioButtonModel.fieldKey if radioButtonModel.state { - if self.baseValue == nil { + if self.baseValue == nil, + let selected = radioButtonModel.baseValue as? Bool, selected { self.baseValue = radioButtonModel.fieldValue } selectedRadioButtonModel = radioButtonModel From b7edafc5d885a21f98754411d98f74dcf1e6746d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Apr 2020 11:17:10 -0400 Subject: [PATCH 221/244] columns --- MVMCoreUI.xcodeproj/project.pbxproj | 4 +++ .../Atomic/Templates/CollectionTemplate.swift | 25 +++++++++++++-- .../CollectionTemplateItemProtocol.swift | 29 +++++++++++++++++ .../BaseClasses/CollectionViewCell.swift | 15 ++++++++- .../ThreeLayerCollectionViewController.swift | 32 ++++++++++++------- MVMCoreUI/Utility/MVMCoreUIUtility.m | 1 - 6 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 4dd0bb20..eeb8862a 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -257,6 +257,7 @@ D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */; }; D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */; }; D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */; }; + D264FAA5243F66A500D98315 /* CollectionTemplateItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; }; @@ -670,6 +671,7 @@ D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerCollectionViewController.swift; sourceTree = ""; }; D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerCollectionReusableView.swift; sourceTree = ""; }; D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticCollectionViewController.swift; sourceTree = ""; }; + D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplateItemProtocol.swift; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; @@ -1442,6 +1444,7 @@ 942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */, 014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */, D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */, + D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */, D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */, D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */, ); @@ -2237,6 +2240,7 @@ 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, 8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */, + D264FAA5243F66A500D98315 /* CollectionTemplateItemProtocol.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, 8DD1E36E243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift in Sources */, D243859923A16B1800332775 /* Container.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index 0bbcd45f..1d2f07a6 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -83,11 +83,23 @@ import Foundation registerCells() super.handleNewData() } - + //-------------------------------------------------- // MARK: - Collection //-------------------------------------------------- + open override func update(cell: UICollectionViewCell, size: CGFloat) { + super.update(cell: cell, size: size) + + // Update the width for columns. + if let collectionView = collectionView, + let columns = templateModel?.columns, columns > 0, + let cell = cell as? CollectionTemplateItemProtocol { + let width = (size - collectionView.adjustedContentInset.left - collectionView.adjustedContentInset.right) / CGFloat(columns) + cell.set(width: width) + } + } + open override func registerCells() { super.registerCells() guard let moleculesInfo = moleculesInfo else { return } @@ -111,13 +123,20 @@ import Foundation let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath) (cell as? MoleculeViewProtocol)?.reset() (cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil) - (cell as? MVMCoreViewProtocol)?.updateView(view.bounds.width) - + update(cell: cell, size: view.frame.width) // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells cell.layoutIfNeeded() return cell } + public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + (collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol)?.didSelectCell(at: indexPath, delegateObject: delegateObjectIVar, additionalData: nil) + } + + public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { + (cell as? CollectionTemplateItemProtocol)?.willDisplay() + } + //-------------------------------------------------- // MARK: - Convenience //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift new file mode 100644 index 00000000..55db2c6d --- /dev/null +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplateItemProtocol.swift @@ -0,0 +1,29 @@ +// +// CollectionTemplateItemProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/9/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +/// A protocol that items of the CollectionTemplate must conform to. +public protocol CollectionTemplateItemProtocol: UICollectionViewCell { + + /// Set the width of the item. Used for the columns functionality + func set(width: CGFloat) + + /// Handle action when cell is pressed + func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) + + /// Called when the cell will display. + func willDisplay() +} + +// Default implementation does nothing +extension CollectionTemplateItemProtocol { + public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {} + + public func willDisplay() {} +} diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index a559c93e..58bd06ff 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -9,12 +9,13 @@ import Foundation /// A base collection view cell with basic mvm functionality. -open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol { +open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol, CollectionTemplateItemProtocol { // Convenience helpers open var molecule: MoleculeViewProtocol? public let containerHelper = ContainerHelper() open var model: CollectionItemModelProtocol? + open var widthConstraint: NSLayoutConstraint? private var initialSetupPerformed = false @@ -56,6 +57,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo open func reset() { molecule?.reset() backgroundColor = .white + widthConstraint?.isActive = false } // MARK: - MoleculeViewProtocol @@ -80,4 +82,15 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo containerHelper.constrainView(molecule) self.molecule = molecule } + + // MARK: - CollectionTemplateItemProtocol + public func set(width: CGFloat) { + if let widthConstraint = widthConstraint { + widthConstraint.constant = width + widthConstraint.isActive = true + } else { + widthConstraint = contentView.widthAnchor.constraint(equalToConstant: width) + widthConstraint?.isActive = true + } + } } diff --git a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift index 82dda260..aa34f2f2 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerCollectionViewController.swift @@ -50,7 +50,7 @@ import Foundation currentSpaceForCompare = currentSpace * 2; } - if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 2) { + if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 1) { if fillTop && fillBottom { // space both let half = newSpace / 2 @@ -72,19 +72,22 @@ import Foundation //MARK: - ViewController open override func updateViews() { super.updateViews() - let width = view.bounds.width - if let topView = topView as? MVMCoreViewProtocol { - topView.updateView(width) - } - if let bottomView = bottomView as? MVMCoreViewProtocol { - bottomView.updateView(width) - } - if let cells = collectionView?.visibleCells { - for cell in cells { - (cell as? MVMCoreViewProtocol)?.updateView(width) + // Needed due to dispatch in reloadCollectionData. + DispatchQueue.main.async { + let width = self.view.bounds.width + if let topView = self.topView as? MVMCoreViewProtocol { + topView.updateView(width) } + if let bottomView = self.bottomView as? MVMCoreViewProtocol { + bottomView.updateView(width) + } + if let cells = self.collectionView?.visibleCells { + for cell in cells { + self.update(cell: cell, size: width) + } + } + self.invalidateCollectionLayout() } - invalidateCollectionLayout() } open override func handleNewData() { @@ -168,6 +171,11 @@ import Foundation }) } + /// Called in updateView, updates the cell. + open func update(cell: UICollectionViewCell, size: CGFloat) { + (cell as? MVMCoreViewProtocol)?.updateView(size) + } + open override func registerCells() { super.registerCells() collectionView?.register(ContainerCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerID) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index b502467d..0841e248 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -169,7 +169,6 @@ bottomInset = scrollview.adjustedContentInset.bottom; } CGFloat remainingSpace = frameHeight - contentSizeHeight - topInset - bottomInset; - NSLog(@"scc SPACCEEE remaining: %f frame: %f, content: %f, insets:(%f,%f)",remainingSpace,frameHeight,contentSizeHeight,topInset,bottomInset); return remainingSpace - 1; } From 4cac288e5ba420b71524db3d47cc17eaa34174d9 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Apr 2020 11:29:05 -0400 Subject: [PATCH 222/244] carousel loop fix --- MVMCoreUI/Atomic/Organisms/Carousel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 05a28a51..18c2978a 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -294,7 +294,7 @@ extension Carousel: UIScrollViewDelegate { return } - let lastPageIndex = numberOfPages + 1 + let lastPageIndex = numberOfPages + 2 let goToIndex = {(index: Int) in self.goTo(index, animated: false) self.collectionView.layoutIfNeeded() From 4eb4cf97417d2ba2cb590afbe3000d74f483ee47 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Apr 2020 11:37:22 -0400 Subject: [PATCH 223/244] temporary fix loop --- MVMCoreUI/Atomic/Organisms/Carousel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 18c2978a..54dc37e7 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -294,7 +294,7 @@ extension Carousel: UIScrollViewDelegate { return } - let lastPageIndex = numberOfPages + 2 + let lastPageIndex = numberOfPages + 1 let goToIndex = {(index: Int) in self.goTo(index, animated: false) self.collectionView.layoutIfNeeded() @@ -332,7 +332,7 @@ extension Carousel: UIScrollViewDelegate { open func scrollViewDidScroll(_ scrollView: UIScrollView) { // Check if the user is dragging the card even further past the next card. - checkForDraggingOutOfBounds(scrollView) + //checkForDraggingOutOfBounds(scrollView) // Let the pager know our progress if needed. pagingView?.scrollViewDidScroll?(collectionView) From 7a1c0dd0fd9f411e063676305abdebf17e81e6ae Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 9 Apr 2020 12:49:20 -0400 Subject: [PATCH 224/244] mild changes --- .../Atomic/Atoms/Buttons/RadioButton.swift | 8 ++++---- .../Buttons/RadioButtonSelectionHelper.swift | 20 +++++++++++++++---- .../Molecules/Items/ListItemModel.swift | 1 + MVMCoreUI/FormUIHelpers/FormValidator.swift | 1 + .../Rules/RuleAnyValueChangedModel.swift | 17 ++++++++++++---- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift index 98532549..fa17d85c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift @@ -19,8 +19,8 @@ import UIKit } } - public var enabledColor: UIColor = .black - public var disabledColor: UIColor = .mfSilver() + public var enabledColor: UIColor = .mvmBlack + public var disabledColor: UIColor = .mvmCoolGray3 public var delegateObject: MVMCoreUIDelegateObject? public var radioModel: RadioButtonModel? { @@ -108,7 +108,7 @@ import UIKit open override func setupView() { super.setupView() - backgroundColor = .white + backgroundColor = .mvmWhite clipsToBounds = true widthConstraint = widthAnchor.constraint(equalToConstant: 30) widthConstraint?.isActive = true @@ -133,6 +133,6 @@ import UIKit public override func reset() { super.reset() - backgroundColor = .white + backgroundColor = .mvmWhite } } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index 3decadb5..76a58db8 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -7,24 +7,35 @@ // import Foundation -import UIKit + @objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName private var selectedRadioButton: RadioButton? private var fieldGroupName: String? public var baseValue: AnyHashable? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + init(_ fieldKey: String?) { self.fieldKey = fieldKey } + //-------------------------------------------------- + // MARK: - FUnctions + //-------------------------------------------------- + public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) { guard let groupName = radioButtonModel.fieldKey, - let formValidator = delegateObject?.formHolderDelegate?.formValidator else { - return - } + let formValidator = delegateObject?.formHolderDelegate?.formValidator + else { return } let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey) radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey @@ -45,6 +56,7 @@ import UIKit // MARK: - FormValidationFormFieldProtocol extension RadioButtonSelectionHelper { + public func formFieldGroupName() -> String? { return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName } diff --git a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift index 9365125a..9a00a94d 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift @@ -9,6 +9,7 @@ import Foundation + @objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol { //-------------------------------------------------- // MARK: - Properties diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index 592132f5..f1d0855e 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -9,6 +9,7 @@ import UIKit import MVMCore + @objcMembers public class FormValidator: NSObject { static var defaultGroupName: String = "default" diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift index 042243db..7cf24cd5 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift @@ -8,25 +8,34 @@ import Foundation -public class RuleAnyValueChangedModel: RulesProtocol { +public class RuleAnyValueChangedModel: RulesProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "anyValueChanged" public var type: String = RuleAnyValueChangedModel.identifier public var fields: [String] + //-------------------------------------------------- + // MARK: - Validation + //-------------------------------------------------- + public func isValid(_ formField: FormFieldProtocol) -> Bool { return formField.baseValue != formField.formFieldValue() } public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { + for formKey in fields { - guard let formField = fieldMolecules[formKey] else { - continue - } + guard let formField = fieldMolecules[formKey] else { continue } + if isValid(formField) { return true } } + return false } } From 020030e669b9bc0caec7576bd830431065934655 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 9 Apr 2020 12:53:37 -0400 Subject: [PATCH 225/244] comments --- MVMCoreUI/FormUIHelpers/FormValidator.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index f1d0855e..06c8cdf1 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -11,7 +11,10 @@ import MVMCore @objcMembers public class FormValidator: NSObject { - + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + static var defaultGroupName: String = "default" var formRules: [FormGroupRule]? weak var delegate: FormHolderProtocol? @@ -19,10 +22,18 @@ import MVMCore var groupWatchers: [FormGroupWatcherFieldProtocol] = [] var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:] + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(_ formRules: [FormGroupRule]?) { self.formRules = formRules } + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + /// Adds the form field to the validator. public func add(_ field: FormFieldProtocol) { if let fieldKey = field.fieldKey { From f3224b371ed2a2b0528c59b69b915fa128d299fc Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Apr 2020 12:54:17 -0400 Subject: [PATCH 226/244] comment fix --- .../Items/MoleculeCollectionItemModel.swift | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift index b9ac345b..ed9467fd 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionItemModel.swift @@ -9,22 +9,14 @@ import Foundation /// A model for a collection item that is a container for any molecule. -@objcMembers open class MoleculeCollectionItemModel: CollectionItemModelProtocol, ContainerModelProtocol, MoleculeModelProtocol { +@objcMembers public class MoleculeCollectionItemModel: MoleculeContainerModel, CollectionItemModelProtocol, MoleculeModelProtocol { open class var identifier: String { return "collectionItem" } - open var molecule: MoleculeModelProtocol public var backgroundColor: Color? - - 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? - + /// Defaults to set - open func setDefaults() { + public func setDefaults() { if useHorizontalMargins == nil { useHorizontalMargins = true } @@ -41,26 +33,25 @@ import Foundation private enum CodingKeys: String, CodingKey { case moleculeName - case molecule case backgroundColor } - public init(with moleculeModel: MoleculeModelProtocol) { - molecule = moleculeModel + public override init(with moleculeModel: MoleculeModelProtocol) { + super.init(with: moleculeModel) setDefaults() } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecule = try typeContainer.decodeModel(codingKey: .molecule) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + try super.init(from: decoder) setDefaults() } - open func encode(to encoder: Encoder) throws { + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeModel(molecule, forKey: .molecule) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } From 57a5dbb064b1f8c10eac1baf4ebf8ff87ba6fec0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Apr 2020 12:58:26 -0400 Subject: [PATCH 227/244] dress feedback --- MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift | 5 +++++ .../Atomic/Molecules/Items/MoleculeCollectionViewCell.swift | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift index 9cf2a246..3089596a 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift @@ -15,6 +15,11 @@ open class CarouselItem: MoleculeCollectionViewCell { var peakingRightArrow = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) var peakingCover = MVMCoreUICommonViewsUtility.commonView() + open override func addMolecule(_ molecule: MoleculeViewProtocol) { + super.addMolecule(molecule) + contentView.sendSubviewToBack(molecule) + } + open override func setupView() { super.setupView() diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift index 1f615732..42af1a53 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeCollectionViewCell.swift @@ -17,7 +17,6 @@ open class MoleculeCollectionViewCell: CollectionViewCell { if molecule == nil { if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(collectionModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { addMolecule(moleculeView) - contentView.sendSubviewToBack(moleculeView) } } else { molecule?.set(with: collectionModel.molecule, delegateObject, additionalData) From 5f000598a69abc800adbddae79f95233b516503f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Apr 2020 14:19:47 -0400 Subject: [PATCH 228/244] layout fix --- .../ThreeColumn/ListThreeColumnDataUsageDivider.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift index 113be5f1..eab5e8be 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDivider.swift @@ -22,10 +22,10 @@ import Foundation // MARK: - Initializers //------------------------------------------------------ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 32, horizontalAlignment: .leading)), - (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center)), - (view: rightLabel, model: StackItemModel(percent: 35, horizontalAlignment: .center))], - axis: .horizontal) + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 40, horizontalAlignment: .leading)), + (view: centerLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(percent: 23, horizontalAlignment: .leading))], + axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } From 0c7b7a2e8b98999c778220bd68d645238b5dc4c1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 9 Apr 2020 14:22:20 -0400 Subject: [PATCH 229/244] undo change --- .../ThreeColumn/ListThreeColumnSpeedTestDivider.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift index ad9f0740..aa9fbc2d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDivider.swift @@ -22,7 +22,7 @@ import Foundation // MARK: - Initializers //------------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .center)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal) + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } From 97b1ac48ddfbc5a342f99389a39db37adf2d8ab0 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 9 Apr 2020 15:46:01 -0400 Subject: [PATCH 230/244] latest --- MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift | 14 +++++++++++--- .../Atomic/Atoms/Buttons/RadioButtonModel.swift | 2 +- ...stLeftVariableRadioButtonAndPaymentMethod.swift | 12 ++++++++---- MVMCoreUI/BaseClasses/Control.swift | 1 + 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift index fa17d85c..6eb00959 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift @@ -40,6 +40,13 @@ import UIKit } }() + public override var isEnabled: Bool { + didSet { + isUserInteractionEnabled = isEnabled + setNeedsDisplay() + } + } + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -71,7 +78,7 @@ import UIKit } //-------------------------------------------------- - // MARK: - Methods + // MARK: - Validation //-------------------------------------------------- /// The action performed when tapped. @@ -128,11 +135,12 @@ import UIKit self.delegateObject = delegateObject isSelected = model.state + isEnabled = model.enabled RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject) } public override func reset() { - super.reset() - backgroundColor = .mvmWhite + super.reset() + backgroundColor = .mvmWhite } } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift index 579c0ed9..ee408bb4 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift @@ -51,7 +51,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol { } //-------------------------------------------------- - // MARK: - Method + // MARK: - Validation //-------------------------------------------------- public func formFieldValue() -> AnyHashable? { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift index 9517acf0..4597a0b9 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift @@ -8,12 +8,13 @@ import UIKit + @objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell { //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - let radioButton = RadioButton(frame: .zero) + let radioButton = RadioButton() let leftImage = MFLoadImageView(pinnedEdges: .all) let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() var stack: Stack @@ -57,7 +58,7 @@ import UIKit // MARK: - Molecule //---------------------------------------------------- - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return} radioButton.set(with: model.radioButton, delegateObject, additionalData) @@ -69,7 +70,10 @@ import UIKit return 90 } - public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - radioButton.tapAction() + public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + + if radioButton.isEnabled { + radioButton.tapAction() + } } } diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index ebb88977..d8acb6f6 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -8,6 +8,7 @@ import UIKit + @objcMembers open class Control: UIControl, MoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties From 5715d7eb237ab818980a7b96a327131be5b2bde8 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 9 Apr 2020 15:56:00 -0400 Subject: [PATCH 231/244] need groupName --- .../Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index 60c79465..09936d87 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -18,6 +18,8 @@ import UIKit public func set(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton) { self.fieldKey = radioButtonModel.fieldKey + self.groupName = radioButtonModel.groupName + if radioButtonModel.state { if self.baseValue == nil, let selected = radioButtonModel.baseValue as? Bool, selected { @@ -56,7 +58,7 @@ import UIKit } // MARK: - FormValidationFormFieldProtocol -extension RadioButtonSelectionHelper { +extension RadioButtonSelectionHelper { public func formFieldValue() -> AnyHashable? { return selectedRadioButtonModel?.fieldValue } From 072951f91269c6c1bb74f8086058de537db37b06 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 9 Apr 2020 17:22:43 -0400 Subject: [PATCH 232/244] fixes --- .../Atoms/Buttons/RadioButtonSelectionHelper.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift index 09936d87..6c1da830 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift @@ -19,7 +19,7 @@ import UIKit public func set(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton) { self.fieldKey = radioButtonModel.fieldKey self.groupName = radioButtonModel.groupName - + if radioButtonModel.state { if self.baseValue == nil, let selected = radioButtonModel.baseValue as? Bool, selected { @@ -46,12 +46,16 @@ import UIKit formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper FormValidator.setupValidation(for: radioButtonSelectionHelper, delegate: delegateObject?.formHolderDelegate) } - + public func selected(_ radioButton: RadioButton) { - selectedRadioButton?.isSelected = false - selectedRadioButtonModel?.state = false + // Checks because the view could be reused + if selectedRadioButton?.radioModel === selectedRadioButtonModel { + selectedRadioButton?.isSelected = false + } else { + selectedRadioButtonModel?.state = false + } + selectedRadioButton = radioButton - selectedRadioButton?.isSelected = true selectedRadioButtonModel = selectedRadioButton?.radioModel } From 185efa547e98df67bd8fab1c1a07e09d3f7bbc9f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Apr 2020 09:38:00 -0400 Subject: [PATCH 233/244] Feedback push --- .../BaseClasses/CollectionViewCell.swift | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index 58bd06ff..e11b350c 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -15,7 +15,9 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo open var molecule: MoleculeViewProtocol? public let containerHelper = ContainerHelper() open var model: CollectionItemModelProtocol? - open var widthConstraint: NSLayoutConstraint? + + /// The width, used for establishing columns + open var width: CGFloat? private var initialSetupPerformed = false @@ -57,7 +59,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo open func reset() { molecule?.reset() backgroundColor = .white - widthConstraint?.isActive = false + width = nil } // MARK: - MoleculeViewProtocol @@ -85,12 +87,18 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo // MARK: - CollectionTemplateItemProtocol public func set(width: CGFloat) { - if let widthConstraint = widthConstraint { - widthConstraint.constant = width - widthConstraint.isActive = true - } else { - widthConstraint = contentView.widthAnchor.constraint(equalToConstant: width) - widthConstraint?.isActive = true - } + self.width = width } + + // Column logic, set width. + override open func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes { + let autoLayoutAttributes = super.preferredLayoutAttributesFitting(layoutAttributes) + guard let width = width else { return autoLayoutAttributes } + + let targetSize = CGSize(width: width, height: 0) + let newSize = contentView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: UILayoutPriority.required, verticalFittingPriority: UILayoutPriority.defaultLow) + let newFrame = CGRect(origin: autoLayoutAttributes.frame.origin, size: newSize) + autoLayoutAttributes.frame = newFrame + return autoLayoutAttributes + } } From 8da03356e416acad252fa685ced0e920ddfcff8c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Apr 2020 11:15:55 -0400 Subject: [PATCH 234/244] Fixing reuse and sizing issues. --- MVMCoreUI/Atomic/Organisms/Carousel.swift | 70 +++++++++++++------ .../Atomic/Organisms/CarouselModel.swift | 22 +++--- .../ThreeLayerTableViewController.swift | 2 +- .../BaseControllers/ViewController.swift | 3 +- 4 files changed, 63 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 54dc37e7..1ed2ecd2 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -54,6 +54,32 @@ open class Carousel: View { private var size: CGFloat? + // Updates the model and index. + public func updateModelIndex() { + (model as? CarouselModel)?.index = pageIndex + } + + open override func layoutSubviews() { + super.layoutSubviews() + // Accounts for any collection size changes + DispatchQueue.main.async { + self.layoutCollection() + } + } + + /// Invalidates the layout and ensures we are paged to the correct cell. + open func layoutCollection() { + collectionView.collectionViewLayout.invalidateLayout() + showPeaking(false) + + // Go to current cell. layoutIfNeeded is needed otherwise cellForItem returns nil for peaking logic. The dispatch is a sad way to ensure the collection view is ready to be scrolled. + DispatchQueue.main.async { + self.collectionView.scrollToItem(at: IndexPath(row: self.currentIndex, section: 0), at: self.itemAlignment, animated: false) + self.collectionView.layoutIfNeeded() + self.showPeaking(true) + } + } + // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() @@ -73,15 +99,12 @@ open class Carousel: View { open override func updateView(_ size: CGFloat) { super.updateView(size) self.size = size - collectionView.collectionViewLayout.invalidateLayout() - showPeaking(false) - - // Go to current cell. layoutIfNeeded is needed otherwise cellForItem returns nil for peaking logic. The dispatch is a sad way to ensure the collection view is ready to be scrolled. - DispatchQueue.main.async { - self.collectionView.scrollToItem(at: IndexPath(row: self.currentIndex, section: 0), at: self.itemAlignment, animated: false) - self.collectionView.layoutIfNeeded() - self.showPeaking(true) + + // Update cells and re-layout. + for cell in collectionView.visibleCells { + (cell as? MVMCoreViewProtocol)?.updateView(size) } + layoutCollection() } // MARK: - MoleculeViewProtocol @@ -108,6 +131,9 @@ open class Carousel: View { } setupPagingMolecule(carouselModel.pagingMolecule, delegateObject: delegateObject) + + pageIndex = carouselModel.index + pagingView?.setPage(carouselModel.index) collectionView.reloadData() } @@ -197,6 +223,7 @@ open class Carousel: View { } let currentPage = pager.currentPage() localSelf.pageIndex = currentPage + localSelf.updateModelIndex() localSelf.goTo(localSelf.currentIndex, animated: !UIAccessibility.isVoiceOverRunning) }) } @@ -246,7 +273,7 @@ open class Carousel: View { extension Carousel: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let itemWidth = (size ?? collectionView.bounds.width) * CGFloat(itemWidthPercent) + let itemWidth = collectionView.bounds.width * CGFloat(itemWidthPercent) return CGSize(width: itemWidth, height: collectionView.bounds.height) } @@ -280,19 +307,18 @@ extension Carousel: UIScrollViewDelegate { func goTo(_ index: Int, animated: Bool) { showPeaking(false) - setAccessiblity(collectionView.cellForItem(at: IndexPath(row: self.currentIndex, section: 0)), index: index) - self.currentIndex = index - self.collectionView.scrollToItem(at: IndexPath(row: self.currentIndex, section: 0), at: self.itemAlignment, animated: animated) - if let cell = collectionView.cellForItem(at: IndexPath(row: self.currentIndex, section: 0)) { - setAccessiblity(collectionView.cellForItem(at: IndexPath(row: self.currentIndex, section: 0)), index: index) + setAccessiblity(collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)), index: index) + currentIndex = index + updateModelIndex() + collectionView.scrollToItem(at: IndexPath(row: currentIndex, section: 0), at: itemAlignment, animated: animated) + if let cell = collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)) { + setAccessiblity(collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)), index: index) UIAccessibility.post(notification: .layoutChanged, argument: cell) } } func handleUserOnBufferCell() { - guard loop else { - return - } + guard loop else { return } let lastPageIndex = numberOfPages + 1 let goToIndex = {(index: Int) in @@ -320,9 +346,11 @@ extension Carousel: UIScrollViewDelegate { let index = scrollView.contentOffset.x / (itemWidth + separatorWidth) let lastCellIndex = collectionView(collectionView, numberOfItemsInSection: 0) - 1 if index < 1 { - self.currentIndex = 0 + currentIndex = 0 + updateModelIndex() } else if index > CGFloat(lastCellIndex - 1) { - self.currentIndex = lastCellIndex + currentIndex = lastCellIndex + updateModelIndex() } } @@ -348,9 +376,7 @@ extension Carousel: UIScrollViewDelegate { targetContentOffset.pointee = scrollView.contentOffset // This is for setting up smooth custom paging. (Since UICollectionView only handles paging based on collection view size and not cell size). - guard let separatorWidth = (collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumLineSpacing else { - return - } + guard let separatorWidth = (collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumLineSpacing else { return } // We switch cards if we pass the velocity threshold or position threshold (currently 50%). let itemWidth = collectionView.bounds.width * CGFloat(itemWidthPercent) diff --git a/MVMCoreUI/Atomic/Organisms/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/CarouselModel.swift index 9fb4fe3b..c5f73a01 100644 --- a/MVMCoreUI/Atomic/Organisms/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/CarouselModel.swift @@ -12,7 +12,7 @@ import UIKit public static var identifier: String = "carousel" public var backgroundColor: Color? public var molecules: [CarouselItemModel] - + public var index: Int = 0 public var spacing: Float? public var border: Bool? public var loop: Bool? @@ -29,6 +29,7 @@ import UIKit case moleculeName case backgroundColor case molecules + case index case spacing case border case loop @@ -40,15 +41,16 @@ 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(Color.self, forKey: .backgroundColor) - self.spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) - self.border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) - self.loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop) - self.height = try typeContainer.decodeIfPresent(Float.self, forKey: .height) - self.itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent) - self.itemAlignment = try typeContainer.decodeIfPresent(UICollectionView.ScrollPosition.self, forKey: .itemAlignment) - self.pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule) + molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) + index = try typeContainer.decodeIfPresent(Int.self, forKey: .index) ?? 0 + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + 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(UICollectionView.ScrollPosition.self, forKey: .itemAlignment) + pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule) } public func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index c0f267fc..000f2e7f 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -33,7 +33,7 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { bottomView.updateView(width) showFooter(width) } - self.tableView?.reloadData() + tableView?.reloadData() } open override func handleNewData() { diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index d19ebdaf..eb4be908 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -278,7 +278,8 @@ import UIKit return } - if needsUpdateUI || screenSizeChanged() { + // First update should be explicit (hence the zero check) + if needsUpdateUI || (previousScreenSize != .zero && screenSizeChanged()) { updateViews() needsUpdateUI = false } From 15911265a7d7b25fb4a498cb0568309fe60a4dbd Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 10 Apr 2020 14:29:40 -0400 Subject: [PATCH 235/244] comments and formatting --- MVMCoreUI/FormUIHelpers/FormValidator.swift | 9 ++++++--- .../Rules/Rules/FormGroupRule.swift | 16 ++++++++++++++++ .../Rules/Rules/RuleAllValueChangedModel.swift | 11 +++++++++-- .../Rules/Rules/RuleEqualsModel.swift | 18 ++++++++++++++---- .../Rules/Rules/RuleRegexModel.swift | 11 +++++++++++ .../Rules/Rules/RuleRequiredModel.swift | 17 +++++++++++++---- 6 files changed, 69 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index e4c20365..29690ae5 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -74,13 +74,13 @@ import MVMCore /// Validates all rule groups. Returns if valid public func validate() -> Bool { var valid = true - guard let formRules = formRules else { - return valid - } + guard let formRules = formRules else { return valid } + for group in formRules { let groupValid = validateGroup(group) valid = valid && groupValid } + return valid } @@ -138,13 +138,16 @@ import MVMCore // TODO: Temporary hacks, rewrite architecture to support this. public extension FormValidator { + func getGroupName(forPageType pageType: String?) -> String? { + for actionItem in groupWatchers { if let buttonModel = actionItem as? ButtonModel, pageType == (buttonModel.action as? ActionOpenPageModel)?.pageType { return buttonModel.groupName } } + return nil } } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift index b40d0460..56a5a2cf 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift @@ -11,19 +11,35 @@ import Foundation open class FormGroupRule: Codable { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + var groupName: String var rules: [RulesProtocol] + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + init(_ groupName: String, _ rules: [RulesProtocol]) { self.groupName = groupName self.rules = rules } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case groupName case rules } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.groupName = try typeContainer.decode(String.self, forKey: .groupName) diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift index 7535c6dd..1f50bcc7 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift @@ -9,11 +9,18 @@ import Foundation public class RuleAllValueChangedModel: RulesProtocol { - + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "allValueChanged" public var type: String = RuleAllValueChangedModel.identifier public var fields: [String] - + + //-------------------------------------------------- + // MARK: - Validation + //-------------------------------------------------- + public func isValid(_ formField: FormFieldProtocol) -> Bool { return formField.baseValue != formField.formFieldValue() } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift index e6b338a4..05e7ad32 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift @@ -10,31 +10,41 @@ import Foundation public class RuleEqualsModel: RulesProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "equals" public var type: String = RuleEqualsModel.identifier public var fields: [String] + + //-------------------------------------------------- + // MARK: - Validation + //-------------------------------------------------- public func isValid(_ formField: FormFieldProtocol) -> Bool { return false } public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { + var valid = true var compareValue: AnyHashable? + for formKey in fields { - guard let formField = fieldMolecules[formKey] else { - continue - } + guard let formField = fieldMolecules[formKey] else { continue } if compareValue == nil { compareValue = formField.formFieldValue() continue } - if compareValue != formField.formFieldValue(){ + + if compareValue != formField.formFieldValue() { valid = false break } } + return valid } } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift index db1c4859..68eea7e5 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift @@ -8,16 +8,27 @@ import Foundation + public class RuleRegexModel: RulesProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "regex" public var type: String = RuleRegexModel.identifier public var fields: [String] public var regex: String + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public func isValid(_ formField: FormFieldProtocol) -> Bool { + if let stringToValidate = formField.formFieldValue() as? String { return MVMCoreUIUtility.validate(stringToValidate, withRegularExpression: regex) } + return false } } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift index cfff35eb..b34a24df 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift @@ -10,21 +10,30 @@ import Foundation public class RuleRequiredModel: RulesProtocol { - + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "allRequired" public var type: String = RuleRequiredModel.identifier public var fields: [String] + //-------------------------------------------------- + // MARK: - Validation + //-------------------------------------------------- + public func isValid(_ formField: FormFieldProtocol) -> Bool { - guard let value = formField.formFieldValue() else { - return false - } + guard let value = formField.formFieldValue() else { return false } + var valid = true + if let valueString = value as? String { valid = valueString.count > 0 + } else if let valueBool = value as? Bool { valid = valueBool } + return valid } } From 5ce98da559b77bf2b8c422b19f24a0eb7c5bf67d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Apr 2020 16:59:40 -0400 Subject: [PATCH 236/244] improvements --- MVMCoreUI.xcodeproj/project.pbxproj | 24 ++- MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift | 159 +++++++++++++++++ .../Views/RadioBoxCollectionViewCell.swift | 165 +----------------- .../Atomic/Atoms/Views/RadioBoxModel.swift | 13 +- MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 11 +- .../Atomic/Atoms/Views/RadioBoxesModel.swift | 22 ++- MVMCoreUI/Atomic/Organisms/Carousel.swift | 4 - MVMCoreUI/BaseClasses/CollectionView.swift | 46 +++++ ...ProgrammaticCollectionViewController.swift | 7 +- 9 files changed, 255 insertions(+), 196 deletions(-) create mode 100644 MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift create mode 100644 MVMCoreUI/BaseClasses/CollectionView.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0cd70ea2..0af01831 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -202,7 +202,6 @@ BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */; }; BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */; }; BB6C6AC924225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */; }; - BBAA4F02243D8E3B005AAD5F /* RadioBoxCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4EFE243D8E3A005AAD5F /* RadioBoxCollectionViewCell.swift */; }; BBAA4F03243D8E3B005AAD5F /* RadioBoxes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */; }; BBAA4F04243D8E3B005AAD5F /* RadioBoxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */; }; BBAA4F05243D8E3B005AAD5F /* RadioBoxesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */; }; @@ -268,6 +267,9 @@ D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */; }; D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */; }; D264FAA5243F66A500D98315 /* CollectionTemplateItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */; }; + D264FAA7243FE13B00D98315 /* RadioBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA6243FE13B00D98315 /* RadioBox.swift */; }; + D264FAAA2440F97600D98315 /* CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA92440F97600D98315 /* CollectionView.swift */; }; + D264FAAC2441009400D98315 /* RadioBoxCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAAB2441009400D98315 /* RadioBoxCollectionViewCell.swift */; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; }; @@ -626,7 +628,6 @@ BB6C6ABF242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerTall.swift; sourceTree = ""; }; BB6C6AC62422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShort.swift; sourceTree = ""; }; BB6C6AC72422528F005F7224 /* ListOneColumnTextWithWhitespaceDividerShortModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOneColumnTextWithWhitespaceDividerShortModel.swift; sourceTree = ""; }; - BBAA4EFE243D8E3A005AAD5F /* RadioBoxCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxCollectionViewCell.swift; sourceTree = ""; }; BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxes.swift; sourceTree = ""; }; BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxModel.swift; sourceTree = ""; }; BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxesModel.swift; sourceTree = ""; }; @@ -692,6 +693,9 @@ D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerCollectionReusableView.swift; sourceTree = ""; }; D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticCollectionViewController.swift; sourceTree = ""; }; D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplateItemProtocol.swift; sourceTree = ""; }; + D264FAA6243FE13B00D98315 /* RadioBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBox.swift; sourceTree = ""; }; + D264FAA92440F97600D98315 /* CollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionView.swift; sourceTree = ""; }; + D264FAAB2441009400D98315 /* RadioBoxCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioBoxCollectionViewCell.swift; sourceTree = ""; }; D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; @@ -1412,6 +1416,13 @@ path = Doughnut; sourceTree = ""; }; + D264FAA8243FE17A00D98315 /* Selectors */ = { + isa = PBXGroup; + children = ( + ); + path = Selectors; + sourceTree = ""; + }; D29DF0C221E404D4003B2FB9 = { isa = PBXGroup; children = ( @@ -1487,6 +1498,7 @@ D29DF10D21E67A70003B2FB9 /* Atoms */ = { isa = PBXGroup; children = ( + D264FAA8243FE17A00D98315 /* Selectors */, D29DF22B21E6A0FA003B2FB9 /* TextFields */, D29DF17D21E69E26003B2FB9 /* Views */, D29DF16821E69E1F003B2FB9 /* Buttons */, @@ -1639,10 +1651,11 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( + D264FAAB2441009400D98315 /* RadioBoxCollectionViewCell.swift */, BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */, BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */, BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */, - BBAA4EFE243D8E3A005AAD5F /* RadioBoxCollectionViewCell.swift */, + D264FAA6243FE13B00D98315 /* RadioBox.swift */, 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, 01509D922327ECFB00EF99AA /* ProgressBar.swift */, 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, @@ -1835,6 +1848,7 @@ 0AE14F63238315D2005417F8 /* TextField.swift */, D2755D7A23689C7500485468 /* TableViewCell.swift */, D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */, + D264FAA92440F97600D98315 /* CollectionView.swift */, 0A5D59C323AD488600EFD9E9 /* Protocols */, ); path = BaseClasses; @@ -2044,6 +2058,7 @@ AA56A20F243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift in Sources */, 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, + D264FAAA2440F97600D98315 /* CollectionView.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */, AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */, @@ -2122,7 +2137,6 @@ 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */, - BBAA4F02243D8E3B005AAD5F /* RadioBoxCollectionViewCell.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, @@ -2232,6 +2246,7 @@ 526A265E240D200500B0D828 /* ListTwoColumnCompareChanges.swift in Sources */, 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, + D264FAAC2441009400D98315 /* RadioBoxCollectionViewCell.swift in Sources */, BB2C969224330F73006FF80C /* ListRightVariableTextLinkAllTextAndLinks.swift in Sources */, D2D90B42240463E100DD6EC9 /* MoleculeHeaderModel.swift in Sources */, 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, @@ -2375,6 +2390,7 @@ D260106523D0CEA700764D80 /* StackModel.swift in Sources */, 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, + D264FAA7243FE13B00D98315 /* RadioBox.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift new file mode 100644 index 00000000..616c7fd6 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift @@ -0,0 +1,159 @@ +// +// RadioBox.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/9/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class RadioBox: Control { + public let label = Label.createLabelRegularBodySmall(true) + public let subTextLabel = Label.createLabelRegularMicro(true) + public var isOutOfStock = false + public var accentColor = UIColor.mvmRed + + public let innerPadding: CGFloat = 12.0 + + private var borderLayer: CALayer? + private var strikeLayer: CALayer? + private var maskLayer: CALayer? + + public var radioBoxModel: RadioBoxModel? { + return model as? RadioBoxModel + } + + open override func draw(_ layer: CALayer, in ctx: CGContext) { + // Draw the strikethrough + strikeLayer?.removeFromSuperlayer() + if isOutOfStock { + let line = getStrikeThrough(color: .black, thickness: 1) + layer.addSublayer(line) + strikeLayer = line + } + + // Draw the border + borderLayer?.removeFromSuperlayer() + if isSelected { + layer.borderWidth = 0 + let border = getSelectedBorder() + layer.addSublayer(border) + borderLayer = border + } else { + layer.borderWidth = 1 + } + + // Handle Mask + maskLayer?.removeFromSuperlayer() + if !isEnabled { + let mask = getMaskLayer() + layer.mask = mask + } + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + label.updateView(size) + subTextLabel.updateView(size) + layer.setNeedsDisplay() + } + + open override func setupView() { + super.setupView() + + layer.delegate = self + layer.borderColor = UIColor.black.cgColor + layer.borderWidth = 1 + + label.numberOfLines = 1 + addSubview(label) + NSLayoutConstraint.constraintPinSubview(label, pinTop: true, topConstant: innerPadding, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: innerPadding, pinRight: true, rightConstant: innerPadding) + + subTextLabel.textColor = .mvmCoolGray6 + subTextLabel.numberOfLines = 1 + addSubview(subTextLabel) + NSLayoutConstraint.constraintPinSubview(subTextLabel, pinTop: false, topConstant:0, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: innerPadding, pinRight: true, rightConstant: innerPadding) + bottomAnchor.constraint(lessThanOrEqualTo: subTextLabel.bottomAnchor, constant: innerPadding).isActive = true + subTextLabel.topAnchor.constraint(equalTo: label.bottomAnchor, constant: 2).isActive = true + + addTarget(self, action: #selector(touched), for: .touchUpInside) + } + + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? RadioBoxModel else { return } + isSelected = model.selected + isEnabled = model.enabled + label.text = model.text + subTextLabel.text = model.subText + isOutOfStock = model.strikethrough + } + + @objc open func touched() { + isSelected = !isSelected + layer.setNeedsDisplay() + } + + /// Gets the selected state border + func getSelectedBorder() -> CAShapeLayer { + let layer = CAShapeLayer() + + let topLineWidth: CGFloat = 4 + let topLinePath = UIBezierPath() + topLinePath.lineWidth = topLineWidth + topLinePath.move(to: CGPoint(x: 0, y: topLineWidth / 2.0)) + topLinePath.addLine(to: CGPoint(x: bounds.width, y: topLineWidth / 2.0)) + + let topLineLayer = CAShapeLayer() + topLineLayer.fillColor = nil + topLineLayer.strokeColor = UIColor.mvmRed.cgColor + topLineLayer.lineWidth = 4 + topLineLayer.path = topLinePath.cgPath + layer.addSublayer(topLineLayer) + + let lineWidth: CGFloat = 1 + let halfLineWidth: CGFloat = 0.5 + let linePath = UIBezierPath() + linePath.move(to: CGPoint(x: halfLineWidth, y: topLineWidth)) + linePath.addLine(to: CGPoint(x: halfLineWidth, y: bounds.height)) + linePath.move(to: CGPoint(x: 0, y: bounds.height - halfLineWidth)) + linePath.addLine(to: CGPoint(x: bounds.width, y: bounds.height - halfLineWidth)) + linePath.move(to: CGPoint(x: bounds.width - halfLineWidth, y: bounds.height)) + linePath.addLine(to: CGPoint(x: bounds.width - halfLineWidth, y: topLineWidth)) + + let borderLayer = CAShapeLayer() + borderLayer.fillColor = nil + borderLayer.strokeColor = UIColor.black.cgColor + borderLayer.lineWidth = lineWidth + borderLayer.path = linePath.cgPath + layer.addSublayer(borderLayer) + + return layer + } + + /// Adds a border to edge + func getStrikeThrough(color: UIColor, thickness: CGFloat) -> CAShapeLayer { + let border = CAShapeLayer() + border.name = "strikethrough" + border.fillColor = nil + border.opacity = 1.0 + border.lineWidth = thickness + border.strokeColor = color.cgColor + + let linePath = UIBezierPath() + linePath.move(to: CGPoint(x: 0, y: bounds.height)) + linePath.addLine(to: CGPoint(x: bounds.width, y: 0)) + border.path = linePath.cgPath + return border + } + + func getMaskLayer() -> CALayer { + let mask = CALayer() + mask.backgroundColor = UIColor.white.cgColor + mask.opacity = 0.3 + mask.frame = bounds + return mask + } +} + diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift index 419f278c..c90b5e92 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift @@ -7,164 +7,17 @@ // import Foundation -open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtocol { +open class RadioBoxCollectionViewCell: CollectionViewCell { + let radioBox = RadioBox() - public let bodyLabel = Label(frame: .zero) - public let subTextLabel = Label(frame: .zero) - public let lineView = View(frame: .zero) - var bottomView = MVMCoreUICommonViewsUtility.commonView() - public var lineViewHeight: NSLayoutConstraint? - public var fieldValue: String? - var boxModel: RadioBoxModel! - - open override var isSelected: Bool{ - didSet{ - if let shapeLayer = self.bottomView.layer.sublayers?.filter({$0.name == "outofstock"}).first as? CAShapeLayer { - shapeLayer.strokeColor = isSelected ? UIColor.black.cgColor : UIColor.mfGet(forHex: "#747676").cgColor - } - self.lineViewHeight?.constant = self.isSelected ? 4.0 : 0 - self.bottomView.layer.sublayers?.filter({$0.name == "border"}).forEach({$0.removeFromSuperlayer()}) - if(self.isSelected){ - self.bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) - self.bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) - self.bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: "#0000"), thickness: 1.0) - } - else { - self.addBordertoView("#747676") - } - UIView.animate(withDuration: 0.5) { - self.layoutIfNeeded() - } - } + open override func setupView() { + super.setupView() + addMolecule(radioBox) + MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0) } - var isOutOfStock: Bool = false { - didSet{ - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - self.bottomView.layer.sublayers?.filter({$0.name == "outofstock"}).forEach({$0.removeFromSuperlayer()}) - if(self.isOutOfStock) { - self.addOutOfStockLine() - } - } - } - } - - public override init(frame: CGRect) { - super.init(frame: .zero) - setupView() - } - - public required init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - setupView() - } - - public func setupView() { - guard bottomView.superview == nil else { - return - } - isAccessibilityElement = false - contentView.isAccessibilityElement = false - insetsLayoutMarginsFromSafeArea = false - contentView.insetsLayoutMarginsFromSafeArea = false - contentView.preservesSuperviewLayoutMargins = false - bottomView.translatesAutoresizingMaskIntoConstraints = false - contentView.addSubview(bottomView) - NSLayoutConstraint.constraintPinSubview(toSuperview: bottomView) - - bottomView.addSubview(lineView) - NSLayoutConstraint.constraintPinSubview(lineView, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true) - lineViewHeight = lineView.heightAnchor.constraint(equalToConstant: 0) - lineViewHeight?.isActive = true - - bodyLabel.numberOfLines = 1 - bottomView.addSubview(bodyLabel) - NSLayoutConstraint.constraintPinSubview(bodyLabel, pinTop: false, topConstant:0 , pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 12, pinRight: true, rightConstant: 12) - bodyLabel.topAnchor.constraint(equalTo: lineView.bottomAnchor, constant: 12).isActive = true - - subTextLabel.numberOfLines = 1 - bottomView.addSubview(subTextLabel) - NSLayoutConstraint.constraintPinSubview(subTextLabel, pinTop: false, topConstant:0 , pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: 12, pinRight: true, rightConstant: 12) - subTextLabel.bottomAnchor.constraint(lessThanOrEqualTo: bottomView.bottomAnchor, constant: -12.0).isActive = true - subTextLabel.topAnchor.constraint(equalTo: bodyLabel.bottomAnchor, constant: 2).isActive = true - - subTextLabel.font = MFFonts.mfFontTXRegular(11.0) - bodyLabel.font = MFFonts.mfFontTXRegular(13.0) - subTextLabel.textColor = UIColor.mfGet(forHex: "#747676") - - - } - - public func updateView(_ size: CGFloat) { - self.setNeedsLayout() - self.bottomView.setNeedsLayout() - self.bottomView.layer.sublayers?.filter({$0.name == "border"}).forEach({$0.removeFromSuperlayer()}) - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - self.addBordertoView(self.boxModel.enabled ? "#747676" : "#D8DADA") - } - } - - private func addBordertoView(_ color:String){ - bottomView.layer.addBorder(edge: .bottom, color: UIColor.mfGet(forHex: color), thickness: 1.0) - bottomView.layer.addBorder(edge: .left, color: UIColor.mfGet(forHex: color), thickness: 1.0) - bottomView.layer.addBorder(edge: .right, color: UIColor.mfGet(forHex: color), thickness: 1.0) - bottomView.layer.addBorder(edge: .top, color: UIColor.mfGet(forHex: color), thickness: 1.0) - } - - private func addOutOfStockLine(){ - let path = UIBezierPath() - path.move(to: CGPoint(x: 0, y: bottomView.bounds.height)) - path.addLine(to: CGPoint(x: bottomView.bounds.width, y: 0)) - let shapeLayer = CAShapeLayer() - shapeLayer.name = "outofstock" - shapeLayer.path = path.cgPath - shapeLayer.strokeColor = self.boxModel.enabled ? UIColor.black.cgColor : UIColor.mfGet(forHex: "#D8DADA").cgColor - shapeLayer.lineWidth = 0.5 - bottomView.layer.addSublayer(shapeLayer) - } - - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let collectionModel = model as? RadioBoxModel else { return } - boxModel = collectionModel - if let backgroundColor = collectionModel.backgroundColor { - bottomView.backgroundColor = backgroundColor.uiColor - } - self.isUserInteractionEnabled = collectionModel.enabled - lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor - bodyLabel.text = collectionModel.text - subTextLabel.text = collectionModel.subText - fieldValue = collectionModel.fieldValue - isOutOfStock = collectionModel.strikethrough - - } -} - -extension CALayer { - - func addBorder(edge: UIRectEdge, color: UIColor, thickness: CGFloat) { - - let border = CALayer() - border.name = "border" - switch edge { - case UIRectEdge.top: - border.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: thickness) - break - case UIRectEdge.bottom: - border.frame = CGRect(x: 0, y: self.frame.height - thickness, width: self.frame.width, height: thickness) - break - case UIRectEdge.left: - border.frame = CGRect(x: 0, y: 0, width: thickness, height: self.frame.height) - break - case UIRectEdge.right: - border.frame = CGRect(x: self.frame.width - thickness, y: 0, width: thickness, height: self.frame.height) - break - default: - break - } - - border.backgroundColor = color.cgColor; - self.addSublayer(border) + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let model = model as? RadioBoxModel else { return } + radioBox.set(with: model, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift index 0c119ed8..89bdc842 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -12,7 +12,7 @@ import Foundation public var text: String public var subText: String? public var backgroundColor: Color? = Color(uiColor: .white) - public var selectedAccentColor: Color? = try? Color(colorString: "#D52B1E") + public var selectedAccentColor = Color(uiColor: .mvmRed) public var selected: Bool = false public var enabled: Bool = true public var strikethrough: Bool = false @@ -32,7 +32,6 @@ import Foundation case fieldValue case fieldKey case groupName - } required public init(from decoder: Decoder) throws { @@ -57,7 +56,6 @@ import Foundation fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) - } public func encode(to encoder: Encoder) throws { @@ -65,14 +63,13 @@ import Foundation try container.encode(moleculeName, forKey: .moleculeName) try container.encode(text, forKey: .text) try container.encodeIfPresent(subText, forKey: .subText) - try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor) + try container.encode(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(selected, forKey: .selected) - try container.encodeIfPresent(enabled, forKey: .enabled) - try container.encodeIfPresent(strikethrough, forKey: .strikethrough) + try container.encode(selected, forKey: .selected) + try container.encode(enabled, forKey: .enabled) + try container.encode(strikethrough, forKey: .strikethrough) try container.encodeIfPresent(fieldValue, forKey: .fieldValue) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) - } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift index d0cae6b4..58090598 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -10,10 +10,10 @@ import Foundation open class RadioBoxes: View { - public let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + public let collectionView = CollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) /// The models for the molecules. - var boxes: [RadioBoxModel]? + public var boxes: [RadioBoxModel]? public var collectionViewHeight: NSLayoutConstraint? private let boxWidth: Double = 151.0 private let boxHeight: Double = 64.0 @@ -30,15 +30,8 @@ open class RadioBoxes: View { // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() - guard collectionView.superview == nil else { - return - } - collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.dataSource = self collectionView.delegate = self - collectionView.showsHorizontalScrollIndicator = false - collectionView.backgroundColor = .clear - collectionView.isAccessibilityElement = false addSubview(collectionView) NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView) collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift index d50978a1..653eae13 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift @@ -9,33 +9,37 @@ import Foundation @objcMembers public class RadioBoxesModel: MoleculeModelProtocol { public static var identifier: String = "radioBoxes" - public var backgroundColor: Color? = Color(uiColor: .white) - public var selectedAccentColor: Color? = Color(uiColor: .red) + public var backgroundColor: Color? + public var selectedAccentColor: Color? public var boxes: [RadioBoxModel] + public var fieldKey: String? + public var groupName: String? private enum CodingKeys: String, CodingKey { case moleculeName case selectedAccentColor case backgroundColor case boxes - + case fieldKey + case groupName } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor) { - selectedAccentColor = color - } - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { - backgroundColor = color - } + selectedAccentColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) boxes = try typeContainer.decode([RadioBoxModel].self, forKey: .boxes) + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(boxes, forKey: .boxes) try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(groupName, forKey: .groupName) } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index 1ed2ecd2..e900dda8 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -83,12 +83,8 @@ open class Carousel: View { // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() - collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.dataSource = self collectionView.delegate = self - collectionView.showsHorizontalScrollIndicator = false - collectionView.backgroundColor = .clear - collectionView.isAccessibilityElement = false addSubview(collectionView) bottomPin = NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView)?[ConstraintBot] as? NSLayoutConstraint diff --git a/MVMCoreUI/BaseClasses/CollectionView.swift b/MVMCoreUI/BaseClasses/CollectionView.swift new file mode 100644 index 00000000..ff572a2e --- /dev/null +++ b/MVMCoreUI/BaseClasses/CollectionView.swift @@ -0,0 +1,46 @@ +// +// CollectionView.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class CollectionView: UICollectionView, MVMCoreViewProtocol { + + private var initialSetupPerformed = false + + private func initialSetup() { + if !initialSetupPerformed { + initialSetupPerformed = true + setupView() + } + } + + public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { + super.init(frame: frame, collectionViewLayout: layout) + initialSetup() + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + initialSetup() + } + + public func updateView(_ size: CGFloat) { + for cell in visibleCells { + (cell as? MVMCoreViewProtocol)?.updateView(size) + } + collectionViewLayout.invalidateLayout() + } + + public func setupView() { + translatesAutoresizingMaskIntoConstraints = false + showsHorizontalScrollIndicator = false + backgroundColor = .clear + isAccessibilityElement = false + contentInsetAdjustmentBehavior = .always + } +} diff --git a/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift index 9d279d79..5e7b87b0 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift +++ b/MVMCoreUI/BaseControllers/ProgrammaticCollectionViewController.swift @@ -46,14 +46,9 @@ import Foundation /// Creates the collection view. open func createCollectionView() -> UICollectionView { - let collection = UICollectionView(frame: .zero, collectionViewLayout: createCollectionViewLayout()) - collection.translatesAutoresizingMaskIntoConstraints = false + let collection = CollectionView(frame: .zero, collectionViewLayout: createCollectionViewLayout()) collection.dataSource = self collection.delegate = self - collection.showsHorizontalScrollIndicator = false - collection.backgroundColor = .white - collection.isAccessibilityElement = false - collection.contentInsetAdjustmentBehavior = .always return collection } From c665f547a6f4fc852e3add7c6c2282092898c9f2 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 10 Apr 2020 17:35:46 -0400 Subject: [PATCH 237/244] any required fixes --- MVMCoreUI/FormUIHelpers/FormValidator.swift | 15 +-------------- .../Rules/Rules/RuleAnyRequiredModel.swift | 2 +- .../Rules/Rules/RuleEqualsModel.swift | 2 +- .../FormUIHelpers/Rules/Rules/RulesProtocol.swift | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index 06c8cdf1..1f0253de 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -88,7 +88,7 @@ import MVMCore // Validate each rule. var valid = true for rule in group.rules { - valid = valid && validateRule(rule) + valid = valid && rule.validate(fields) } // Notify the group watchers of validity. @@ -97,19 +97,6 @@ import MVMCore watcher.setValidity(valid, group: group) } } - - return valid - } - - /// Validates a given rule. Returns if valid. - public func validateRule(_ rule: RulesProtocol) -> Bool { - var valid = true - for formKey in rule.fields { - guard let formField = fields[formKey] else { continue } - let fieldValidity = rule.isValid(formField) - (formField as? FormRuleWatcherFieldProtocol)?.setValidity(fieldValidity, rule: rule) - valid = valid && fieldValidity - } return valid } } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift index d41c0b0c..6ca905bf 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift @@ -35,7 +35,7 @@ public class RuleAnyRequiredModel: RulesProtocol { return false } - public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { + public func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { for formKey in fields { guard let formField = fieldMolecules[formKey] else { continue } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift index e6b338a4..4dd6e2a0 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift @@ -18,7 +18,7 @@ public class RuleEqualsModel: RulesProtocol { return false } - public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { + public func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { var valid = true var compareValue: AnyHashable? for formKey in fields { diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift index 6afe5b17..70d30506 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift @@ -22,6 +22,9 @@ public protocol RulesProtocol: ModelProtocol { // Returns if a given field is valid according to the rule func isValid(_ formField: FormFieldProtocol) -> Bool + + // Returns if a the rule is valid + func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool } public extension RulesProtocol { @@ -37,4 +40,15 @@ public extension RulesProtocol { static var categoryName: String { return "\(RulesProtocol.self)" } + + func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { + var valid = true + for formKey in fields { + guard let formField = fieldMolecules[formKey] else { continue } + let fieldValidity = isValid(formField) + (formField as? FormRuleWatcherFieldProtocol)?.setValidity(fieldValidity, rule: self) + valid = valid && fieldValidity + } + return valid + } } From 4c96cdda15e9e344e2d453462efc441edb1d6eeb Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 10 Apr 2020 17:56:08 -0400 Subject: [PATCH 238/244] more fixes --- .../Rules/Rules/RuleAnyValueChangedModel.swift | 7 ++----- MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift index 7cf24cd5..450fdb2a 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift @@ -26,16 +26,13 @@ public class RuleAnyValueChangedModel: RulesProtocol { return formField.baseValue != formField.formFieldValue() } - public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { - + public func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { for formKey in fields { guard let formField = fieldMolecules[formKey] else { continue } - if isValid(formField) { return true } - } - + } return false } } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift index 70d30506..ee768a70 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift @@ -23,7 +23,7 @@ public protocol RulesProtocol: ModelProtocol { // Returns if a given field is valid according to the rule func isValid(_ formField: FormFieldProtocol) -> Bool - // Returns if a the rule is valid + // Validates the rule and returns the result. func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool } @@ -41,6 +41,7 @@ public extension RulesProtocol { return "\(RulesProtocol.self)" } + // Indiviidual rule can override the function to validate based on the rule type. func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { var valid = true for formKey in fields { From b7b65e9d167ac7e4df587b3f8ba681b9363cb2f1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Apr 2020 20:25:57 -0400 Subject: [PATCH 239/244] Form Validation layout fixing --- MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift | 94 +++++++----- .../Atomic/Atoms/Views/RadioBoxModel.swift | 19 ++- MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift | 135 ++++++++++-------- .../Atomic/Atoms/Views/RadioBoxesModel.swift | 20 ++- MVMCoreUI/Atomic/Organisms/Carousel.swift | 2 +- MVMCoreUI/BaseClasses/CollectionView.swift | 1 + 6 files changed, 166 insertions(+), 105 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift index 616c7fd6..da762dbb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift @@ -20,10 +20,59 @@ open class RadioBox: Control { private var strikeLayer: CALayer? private var maskLayer: CALayer? + public var subTextLabelHeightConstraint: NSLayoutConstraint? + public var radioBoxModel: RadioBoxModel? { return model as? RadioBoxModel } + // MARK: - MVMCoreViewProtocol + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + label.updateView(size) + subTextLabel.updateView(size) + layer.setNeedsDisplay() + } + + open override func setupView() { + super.setupView() + + layer.delegate = self + layer.borderColor = UIColor.black.cgColor + layer.borderWidth = 1 + + label.numberOfLines = 1 + addSubview(label) + NSLayoutConstraint.constraintPinSubview(label, pinTop: true, topConstant: innerPadding, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: innerPadding, pinRight: true, rightConstant: innerPadding) + + subTextLabel.textColor = .mvmCoolGray6 + subTextLabel.numberOfLines = 1 + addSubview(subTextLabel) + NSLayoutConstraint.constraintPinSubview(subTextLabel, pinTop: false, topConstant:0, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: innerPadding, pinRight: true, rightConstant: innerPadding) + bottomAnchor.constraint(greaterThanOrEqualTo: subTextLabel.bottomAnchor, constant: innerPadding).isActive = true + subTextLabel.topAnchor.constraint(equalTo: label.bottomAnchor, constant: 2).isActive = true + subTextLabelHeightConstraint = subTextLabel.heightAnchor.constraint(equalToConstant: 0) + subTextLabelHeightConstraint?.isActive = true + + addTarget(self, action: #selector(selectBox), for: .touchUpInside) + } + + // MARK: - MoleculeViewProtocol + + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? RadioBoxModel else { return } + isSelected = model.selected + isEnabled = model.enabled + label.text = model.text + subTextLabel.text = model.subText + isOutOfStock = model.strikethrough + subTextLabelHeightConstraint?.isActive = (subTextLabel.text?.count ?? 0) == 0 + } + + // MARK: - State Handling + open override func draw(_ layer: CALayer, in ctx: CGContext) { // Draw the strikethrough strikeLayer?.removeFromSuperlayer() @@ -52,46 +101,21 @@ open class RadioBox: Control { } } - open override func updateView(_ size: CGFloat) { - super.updateView(size) - label.updateView(size) - subTextLabel.updateView(size) + open override func layoutSubviews() { + super.layoutSubviews() + // Accounts for any size changes layer.setNeedsDisplay() } - open override func setupView() { - super.setupView() - - layer.delegate = self - layer.borderColor = UIColor.black.cgColor - layer.borderWidth = 1 - - label.numberOfLines = 1 - addSubview(label) - NSLayoutConstraint.constraintPinSubview(label, pinTop: true, topConstant: innerPadding, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: innerPadding, pinRight: true, rightConstant: innerPadding) - - subTextLabel.textColor = .mvmCoolGray6 - subTextLabel.numberOfLines = 1 - addSubview(subTextLabel) - NSLayoutConstraint.constraintPinSubview(subTextLabel, pinTop: false, topConstant:0, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: innerPadding, pinRight: true, rightConstant: innerPadding) - bottomAnchor.constraint(lessThanOrEqualTo: subTextLabel.bottomAnchor, constant: innerPadding).isActive = true - subTextLabel.topAnchor.constraint(equalTo: label.bottomAnchor, constant: 2).isActive = true - - addTarget(self, action: #selector(touched), for: .touchUpInside) + @objc open func selectBox() { + isSelected = true + radioBoxModel?.selected = isSelected + layer.setNeedsDisplay() } - public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? RadioBoxModel else { return } - isSelected = model.selected - isEnabled = model.enabled - label.text = model.text - subTextLabel.text = model.subText - isOutOfStock = model.strikethrough - } - - @objc open func touched() { - isSelected = !isSelected + @objc open func deselectBox() { + isSelected = false + radioBoxModel?.selected = isSelected layer.setNeedsDisplay() } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift index 89bdc842..caf26800 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -7,7 +7,7 @@ // import Foundation -@objcMembers public class RadioBoxModel: MoleculeModelProtocol { +@objcMembers public class RadioBoxModel: MoleculeModelProtocol, FormFieldProtocol { public static var identifier: String = "radioBox" public var text: String public var subText: String? @@ -18,8 +18,9 @@ import Foundation public var strikethrough: Bool = false public var fieldValue: String? public var fieldKey: String? - public var groupName: String? - + public var groupName: String = FormValidator.defaultGroupName + public var baseValue: AnyHashable? + private enum CodingKeys: String, CodingKey { case moleculeName case text @@ -34,6 +35,10 @@ import Foundation case groupName } + public func formFieldValue() -> AnyHashable? { + return selected + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) text = try typeContainer.decode(String.self, forKey: .text) @@ -53,9 +58,13 @@ import Foundation if let isStrikeTrough = try typeContainer.decodeIfPresent(Bool.self, forKey: .strikethrough) { strikethrough = isStrikeTrough } + fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } + baseValue = selected } public func encode(to encoder: Encoder) throws { @@ -70,6 +79,6 @@ import Foundation try container.encode(strikethrough, forKey: .strikethrough) try container.encodeIfPresent(fieldValue, forKey: .fieldValue) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encode(groupName, forKey: .groupName) } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift index 58090598..6fe66bc2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift @@ -10,28 +10,31 @@ import Foundation open class RadioBoxes: View { - public let collectionView = CollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + public var collectionView: CollectionView! + public var collectionViewHeight: NSLayoutConstraint! + private let boxWidth: CGFloat = 151.0 + private let boxHeight: CGFloat = 64.0 + private let itemSpacing: CGFloat = 8.0 + + private var delegateObject: MVMCoreUIDelegateObject? /// The models for the molecules. public var boxes: [RadioBoxModel]? - public var collectionViewHeight: NSLayoutConstraint? - private let boxWidth: Double = 151.0 - private let boxHeight: Double = 64.0 - private let itemSpacing: Double = 10.0 - private let leadingSpacing: Double = 0 - - public var selectedBox: RadioBoxModel? { - get{ - guard let selectedItem = collectionView.indexPathsForSelectedItems?.first else {return nil} - return boxes?[selectedItem.item] + + private var size: CGFloat? + + open override func layoutSubviews() { + super.layoutSubviews() + // Accounts for any collection size changes + DispatchQueue.main.async { + self.collectionView.collectionViewLayout.invalidateLayout() } } - + // MARK: - MVMCoreViewProtocol open override func setupView() { super.setupView() - collectionView.dataSource = self - collectionView.delegate = self + collectionView = createCollectionView() addSubview(collectionView) NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView) collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) @@ -41,62 +44,66 @@ open class RadioBoxes: View { // MARK: - MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) + self.delegateObject = delegateObject + guard let radioBoxesModel = model as? RadioBoxesModel else { return } + boxes = radioBoxesModel.boxes + FormValidator.setupValidation(for: radioBoxesModel, delegate: delegateObject?.formHolderDelegate) + backgroundColor = radioBoxesModel.backgroundColor?.uiColor registerCells() - setupLayout(with: radioBoxesModel) - prepareMolecules(with: radioBoxesModel) + setHeight() collectionView.reloadData() } @objc override open func updateView(_ size: CGFloat) { - collectionView.collectionViewLayout.invalidateLayout() - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - self.setNeedsDisplay() - self.collectionView.layoutIfNeeded() - self.collectionView.reloadData() - guard let firstSelectedIndex = self.boxes?.firstIndex(where: {$0.selected == true}) else { - return - } - self.collectionView.selectItem(at: IndexPath(item: firstSelectedIndex, section: 0), animated: true, scrollPosition: .centeredHorizontally) - - } - } - - // MARK: - JSON Setters - /// Updates the layout being used - - func setupLayout(with radioBoxesModel: RadioBoxesModel?) { - let layout = UICollectionViewFlowLayout() - layout.scrollDirection = .vertical - layout.sectionInset = UIEdgeInsets.init(top: CGFloat(leadingSpacing), left: CGFloat(leadingSpacing), bottom: CGFloat(leadingSpacing), right: CGFloat(leadingSpacing)) - layout.minimumLineSpacing = 10 - layout.minimumInteritemSpacing = 10 - collectionView.collectionViewLayout = layout + super.updateView(size) + self.size = size + collectionView.updateView(size) } - func prepareMolecules(with radioBoxesModel: RadioBoxesModel?) { - guard let newMolecules = radioBoxesModel?.boxes else { - boxes = nil - return - } - boxes = newMolecules - let height = Double(round(Double((boxes?.count ?? Int(0.0)))/2.0))*(boxHeight+10.0) - collectionViewHeight?.constant = CGFloat(height) - collectionViewHeight?.isActive = true + // MARK: - Creation + + /// Creates the layout for the collection. + open func createCollectionViewLayout() -> UICollectionViewLayout { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + layout.minimumLineSpacing = itemSpacing + layout.minimumInteritemSpacing = itemSpacing + return layout + } + + /// Creates the collection view. + open func createCollectionView() -> CollectionView { + let collection = CollectionView(frame: .zero, collectionViewLayout: createCollectionViewLayout()) + collection.dataSource = self + collection.delegate = self + return collection } /// Registers the cells with the collection view - func registerCells() { + open func registerCells() { collectionView.register(RadioBoxCollectionViewCell.self, forCellWithReuseIdentifier: "RadioBoxCollectionViewCell") } + + // MARK: - JSON Setters + open func setHeight() { + guard let boxes = boxes, boxes.count > 0 else { + collectionViewHeight.constant = 0 + return + } + + // Calculate the height + let rows = ceil(CGFloat(boxes.count) / 2.0) + let height = (rows * boxHeight) + ((rows - 1) * itemSpacing) + collectionViewHeight?.constant = height + } } extension RadioBoxes: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let itemWidth = (Double(collectionView.bounds.width) - itemSpacing)/2 - return CGSize(width: CGFloat(itemWidth), height: CGFloat(boxHeight)) + let itemWidth: CGFloat = (collectionView.bounds.width - itemSpacing) / 2 + return CGSize(width: itemWidth, height: boxHeight) } } @@ -106,23 +113,31 @@ extension RadioBoxes: UICollectionViewDataSource { } open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let molecule = boxes?[indexPath.row], let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RadioBoxCollectionViewCell", for: indexPath) as? RadioBoxCollectionViewCell else { - return UICollectionViewCell() + guard let molecule = boxes?[indexPath.row], + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RadioBoxCollectionViewCell", for: indexPath) as? RadioBoxCollectionViewCell else { + fatalError() + } + cell.radioBox.isUserInteractionEnabled = false + cell.set(with: molecule, delegateObject, nil) + cell.updateView(size ?? collectionView.bounds.width) + if molecule.selected { + collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredVertically) } - cell.set(with: molecule, nil, nil) - cell.updateView(collectionView.bounds.width) cell.layoutIfNeeded() return cell } } + extension RadioBoxes: UICollectionViewDelegate { public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - guard let boxItem = boxes?[indexPath.row] else { return } - boxItem.selected = true + guard let cell = collectionView.cellForItem(at: indexPath) as? RadioBoxCollectionViewCell else { return } + cell.radioBox.selectBox() + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) } + public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { - guard let boxItem = boxes?[indexPath.row] else { return } - boxItem.selected = false + guard let cell = collectionView.cellForItem(at: indexPath) as? RadioBoxCollectionViewCell else { return } + cell.radioBox.deselectBox() } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift index 653eae13..28c4fab5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift @@ -7,13 +7,22 @@ // import Foundation -@objcMembers public class RadioBoxesModel: MoleculeModelProtocol { +@objcMembers public class RadioBoxesModel: MoleculeModelProtocol, FormFieldProtocol { public static var identifier: String = "radioBoxes" public var backgroundColor: Color? public var selectedAccentColor: Color? public var boxes: [RadioBoxModel] public var fieldKey: String? - public var groupName: String? + public var groupName: String = FormValidator.defaultGroupName + public var baseValue: AnyHashable? + + /// Returns the fieldValue of the selected box, otherwise the text of the selected box. + public func formFieldValue() -> AnyHashable? { + let selectedBox = boxes.first { (box) -> Bool in + return box.selected + } + return selectedBox?.fieldValue ?? selectedBox?.text + } private enum CodingKeys: String, CodingKey { case moleculeName @@ -30,7 +39,10 @@ import Foundation backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) boxes = try typeContainer.decode([RadioBoxModel].self, forKey: .boxes) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } + baseValue = formFieldValue() } public func encode(to encoder: Encoder) throws { @@ -40,6 +52,6 @@ import Foundation try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encode(groupName, forKey: .groupName) } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index e900dda8..820c5a5d 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -10,7 +10,7 @@ import UIKit open class Carousel: View { - public let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + public let collectionView = CollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) /// The current index of the collection view. Includes dummy cells when looping. public var currentIndex = 0 diff --git a/MVMCoreUI/BaseClasses/CollectionView.swift b/MVMCoreUI/BaseClasses/CollectionView.swift index ff572a2e..a1a57376 100644 --- a/MVMCoreUI/BaseClasses/CollectionView.swift +++ b/MVMCoreUI/BaseClasses/CollectionView.swift @@ -39,6 +39,7 @@ open class CollectionView: UICollectionView, MVMCoreViewProtocol { public func setupView() { translatesAutoresizingMaskIntoConstraints = false showsHorizontalScrollIndicator = false + showsVerticalScrollIndicator = false backgroundColor = .clear isAccessibilityElement = false contentInsetAdjustmentBehavior = .always From e8b8d8132cc0447bcc066939e5ffded9d11d75d3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Apr 2020 20:32:12 -0400 Subject: [PATCH 240/244] remove form validator from radio box for now --- .../Atomic/Atoms/Views/RadioBoxModel.swift | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift index caf26800..b2a23c6a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift @@ -7,7 +7,7 @@ // import Foundation -@objcMembers public class RadioBoxModel: MoleculeModelProtocol, FormFieldProtocol { +@objcMembers public class RadioBoxModel: MoleculeModelProtocol { public static var identifier: String = "radioBox" public var text: String public var subText: String? @@ -17,9 +17,6 @@ import Foundation public var enabled: Bool = true public var strikethrough: Bool = false public var fieldValue: String? - public var fieldKey: String? - public var groupName: String = FormValidator.defaultGroupName - public var baseValue: AnyHashable? private enum CodingKeys: String, CodingKey { case moleculeName @@ -31,12 +28,6 @@ import Foundation case enabled case strikethrough case fieldValue - case fieldKey - case groupName - } - - public func formFieldValue() -> AnyHashable? { - return selected } required public init(from decoder: Decoder) throws { @@ -60,11 +51,6 @@ import Foundation } fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue) - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - self.groupName = groupName - } - baseValue = selected } public func encode(to encoder: Encoder) throws { @@ -78,7 +64,5 @@ import Foundation try container.encode(enabled, forKey: .enabled) try container.encode(strikethrough, forKey: .strikethrough) try container.encodeIfPresent(fieldValue, forKey: .fieldValue) - try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encode(groupName, forKey: .groupName) } } From c718cfa92af82796b1c1de273987f00eef3c1c00 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Apr 2020 20:34:06 -0400 Subject: [PATCH 241/244] selectors folder --- MVMCoreUI.xcodeproj/project.pbxproj | 20 +++++++++---------- .../Atoms/{Views => Selectors}/Checkbox.swift | 0 .../{Views => Selectors}/CheckboxModel.swift | 0 .../Atoms/{Views => Selectors}/RadioBox.swift | 0 .../RadioBoxCollectionViewCell.swift | 0 .../{Views => Selectors}/RadioBoxModel.swift | 0 .../{Views => Selectors}/RadioBoxes.swift | 0 .../RadioBoxesModel.swift | 0 .../{Buttons => Selectors}/RadioButton.swift | 0 .../RadioButtonModel.swift | 0 .../RadioButtonSelectionHelper.swift | 0 11 files changed, 10 insertions(+), 10 deletions(-) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/Checkbox.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/CheckboxModel.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/RadioBox.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/RadioBoxCollectionViewCell.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/RadioBoxModel.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/RadioBoxes.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/RadioBoxesModel.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Buttons => Selectors}/RadioButton.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Buttons => Selectors}/RadioButtonModel.swift (100%) rename MVMCoreUI/Atomic/Atoms/{Buttons => Selectors}/RadioButtonSelectionHelper.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0af01831..294f6188 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1419,6 +1419,16 @@ D264FAA8243FE17A00D98315 /* Selectors */ = { isa = PBXGroup; children = ( + D264FAAB2441009400D98315 /* RadioBoxCollectionViewCell.swift */, + BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */, + BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */, + BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */, + D264FAA6243FE13B00D98315 /* RadioBox.swift */, + 0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */, + 011D95AE2407266E000E3791 /* RadioButtonModel.swift */, + 01004F2F22721C3800991ECC /* RadioButton.swift */, + 31BE15CA23D8924C00452370 /* CheckboxModel.swift */, + 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, ); path = Selectors; sourceTree = ""; @@ -1641,9 +1651,6 @@ DBC4391A224421A0001AB423 /* CaretLink.swift */, D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */, D2E2A99E23E07F8A000B42E6 /* PillButton.swift */, - 0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */, - 011D95AE2407266E000E3791 /* RadioButtonModel.swift */, - 01004F2F22721C3800991ECC /* RadioButton.swift */, ); path = Buttons; sourceTree = ""; @@ -1651,11 +1658,6 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( - D264FAAB2441009400D98315 /* RadioBoxCollectionViewCell.swift */, - BBAA4F01243D8E3B005AAD5F /* RadioBoxesModel.swift */, - BBAA4EFF243D8E3B005AAD5F /* RadioBoxes.swift */, - BBAA4F00243D8E3B005AAD5F /* RadioBoxModel.swift */, - D264FAA6243FE13B00D98315 /* RadioBox.swift */, 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */, 01509D922327ECFB00EF99AA /* ProgressBar.swift */, 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */, @@ -1672,8 +1674,6 @@ 017BEB7A236763000024EF95 /* LineModel.swift */, D213347623843825008E41B3 /* Line.swift */, 94C2D9822386F3E30006CF46 /* Label */, - 31BE15CA23D8924C00452370 /* CheckboxModel.swift */, - 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */, D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Views/Checkbox.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Views/CheckboxModel.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/CheckboxModel.swift diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Views/RadioBox.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxCollectionViewCell.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Views/RadioBoxCollectionViewCell.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxCollectionViewCell.swift diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Views/RadioBoxModel.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Views/RadioBoxes.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift diff --git a/MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Views/RadioBoxesModel.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Buttons/RadioButton.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonModel.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonModel.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonModel.swift diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonSelectionHelper.swift similarity index 100% rename from MVMCoreUI/Atomic/Atoms/Buttons/RadioButtonSelectionHelper.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/RadioButtonSelectionHelper.swift From cf5b554b851f23ea0e1572ca5838072ad1fdd216 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 10 Apr 2020 20:36:42 -0400 Subject: [PATCH 242/244] remove old comment no longer applicable --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 0f0baac6..ab0d5b43 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -47,7 +47,7 @@ import Foundation // need to move labelattributemodel to different method try? ModelRegistry.register(LabelAttributeFontModel.self) try? ModelRegistry.register(LabelAttributeColorModel.self) - try? ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions... + try? ModelRegistry.register(LabelAttributeImageModel.self) try? ModelRegistry.register(LabelAttributeUnderlineModel.self) try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) try? ModelRegistry.register(LabelAttributeActionModel.self) @@ -66,9 +66,12 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ItemDropdownEntryField.self, viewModelClass: ItemDropdownEntryFieldModel.self) MoleculeObjectMapping.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - // Other Atoms + // Selectors + MoleculeObjectMapping.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: RadioBoxes.self, viewModelClass: RadioBoxesModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) + // Other Atoms MoleculeObjectMapping.shared()?.register(viewClass: ProgressBar.self, viewModelClass: ProgressBarModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MultiProgress.self, viewModelClass: MultiProgressBarModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CaretView.self, viewModelClass: CaretViewModel.self) @@ -77,10 +80,8 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: Line.self, viewModelClass: LineModel.self) MoleculeObjectMapping.shared()?.register(viewClass: GraphView.self, viewModelClass: CircleProgressModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: WebView.self, viewModelClass: WebViewModel.self) From 3024b457f43c21faa03be2c7b2c8cbee3f4c040f Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Sun, 12 Apr 2020 19:25:20 -0400 Subject: [PATCH 243/244] bugfix for load gif file form different bundle --- MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift index b8b5321d..826759a7 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MFLoadImageView.swift @@ -276,7 +276,7 @@ import UIKit let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback") if let format = format, format.lowercased().contains("gif") { // Gifs aren't supported by default and need special handling - MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, completionHandler: finishedLoadingBlock) + MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock) } else { MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock) } From 3df9b65098ac243c609c22824f4d29a41f1ff053 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 13 Apr 2020 12:39:33 -0400 Subject: [PATCH 244/244] spelling --- MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift index ee768a70..305b4c35 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift @@ -41,7 +41,7 @@ public extension RulesProtocol { return "\(RulesProtocol.self)" } - // Indiviidual rule can override the function to validate based on the rule type. + // Individual rule can override the function to validate based on the rule type. func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { var valid = true for formKey in fields {