From fe959f09e5d4c2a24943ece195a312a050084099 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Thu, 5 Mar 2020 11:24:05 +0530 Subject: [PATCH 01/17] Code commit for List- OneColumn- Full Width Text - BodyText --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ .../ListOneColumnFullWidthTextBodyText.swift | 53 +++++++++++++++++++ ...tOneColumnFullWidthTextBodyTextModel.swift | 39 ++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 4 files changed, 101 insertions(+) create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift create mode 100644 MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 339735f3..9bb11fa8 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -110,6 +110,8 @@ 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */; }; 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B201D024081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift */; }; 52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B201D124081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift */; }; + 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */; }; + 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 */; }; 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; }; @@ -456,6 +458,8 @@ 525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageDivider.swift; sourceTree = ""; }; 52B201D024081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonAndPaymentMethod.swift; sourceTree = ""; }; 52B201D124081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonAndPaymentMethodModel.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 = ""; }; 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 = ""; }; @@ -812,6 +816,8 @@ children = ( 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */, 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */, + 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */, + 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */, ); path = OneColumn; sourceTree = ""; @@ -1774,6 +1780,7 @@ 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, + 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, @@ -1874,6 +1881,7 @@ D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, + 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, 8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift new file mode 100644 index 00000000..8afc80d6 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift @@ -0,0 +1,53 @@ +// +// ListOneColumnFullWidthTextBodyText.swift +// MVMCoreUI +// +// Created by Kruthika KP on 05/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListOneColumnFullWidthTextBodyText: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + var stack: Stack + let headlineBody = HeadlineBody() + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [headlineBody]) + 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) + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListOneColumnFullWidthTextBodyTextModel else { return } + headlineBody.set(with: model.headlineBody, delegateObject, additionalData) + stack.restack() + +} + 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/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift new file mode 100644 index 00000000..6051b340 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift @@ -0,0 +1,39 @@ +// +// ListOneColumnFullWidthTextBodyTextModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 05/03/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list1CFWBdy" + public var headlineBody: HeadlineBodyModel + + public init(headlineBody: HeadlineBodyModel) { + self.headlineBody = headlineBody + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case headlineBody + + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + 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(headlineBody, forKey: .headlineBody) + + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 34da2080..4c963401 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -103,6 +103,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: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) // Designed Section Dividers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) From edc362526ce0528999b9d00f3b7d9b9f026b740f Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Thu, 5 Mar 2020 12:22:26 +0530 Subject: [PATCH 02/17] code cleanup --- .../List/OneColumn/ListOneColumnFullWidthTextBodyText.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift index 8afc80d6..d43bf876 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift @@ -45,9 +45,5 @@ import Foundation } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 90 - } - - open override func reset() { - super.reset() - } + } } From 0a6b316198e4263daa3bdd0a7b6e1e42175f7ebc Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 5 Mar 2020 13:57:45 -0500 Subject: [PATCH 03/17] the latest --- .../Atoms/Views/LabelWithInternalButton.swift | 2 +- .../Atoms/Views/LeftRightLabelModel.swift | 12 +++++++++-- MVMCoreUI/BaseClasses/TableViewCell.swift | 8 ++++---- .../Views/Container/Container.swift | 6 +++--- .../Views/Container/ContainerHelper.swift | 20 +++++++++---------- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index c8484829..251f5b45 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -81,7 +81,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt return NSRange(location: 0, length: frontText?.count ?? 0) } - private var actionRange: NSRange { + public var actionRange: NSRange { return NSRange(location: frontText?.count ?? 0, length: actionText?.count ?? 0) } diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift index d7ee1553..44564c93 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelModel.swift @@ -8,14 +8,22 @@ import UIKit -@objcMembers public class LeftRightLabelModel: MoleculeModelProtocol { +@objcMembers open class LeftRightLabelModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "leftRightLabelView" public var moleculeName: String? = LeftRightLabelModel.identifier public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel? - init(_ leftText: LabelModel) { + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(_ leftText: LabelModel) { self.leftText = leftText } } diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 3154bbb9..63824c04 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -120,7 +120,7 @@ import UIKit } // MARK: - MFViewProtocol - public func updateView(_ size: CGFloat) { + open func updateView(_ size: CGFloat) { containerHelper.updateViewMargins(self, model: listItemModel, size: size) if accessoryView != nil { @@ -151,7 +151,7 @@ import UIKit } //TODO: ModelProtocol, Change to model - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? ListItemModelProtocol else { return } self.listItemModel = model @@ -183,11 +183,11 @@ import UIKit backgroundColor = .white } - public class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { return model.moleculeName } - public class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return nil } diff --git a/MVMCoreUI/Containers/Views/Container/Container.swift b/MVMCoreUI/Containers/Views/Container/Container.swift index 96e6c3e8..a08cd651 100644 --- a/MVMCoreUI/Containers/Views/Container/Container.swift +++ b/MVMCoreUI/Containers/Views/Container/Container.swift @@ -23,15 +23,15 @@ open class Container: View, ContainerProtocol { } // MARK:- ContainerProtocol - public func alignHorizontal(_ alignment: UIStackView.Alignment) { + open func alignHorizontal(_ alignment: UIStackView.Alignment) { containerHelper.alignHorizontal(alignment) } - public func alignVertical(_ alignment: UIStackView.Alignment) { + open func alignVertical(_ alignment: UIStackView.Alignment) { containerHelper.alignVertical(alignment) } - public func constrainView(_ view: UIView) { + open func constrainView(_ view: UIView) { containerHelper.constrainView(view) } } diff --git a/MVMCoreUI/Containers/Views/Container/ContainerHelper.swift b/MVMCoreUI/Containers/Views/Container/ContainerHelper.swift index 77226341..223589fe 100644 --- a/MVMCoreUI/Containers/Views/Container/ContainerHelper.swift +++ b/MVMCoreUI/Containers/Views/Container/ContainerHelper.swift @@ -9,7 +9,7 @@ import Foundation -public class ContainerHelper: NSObject { +open class ContainerHelper: NSObject { var leftConstraint: NSLayoutConstraint? var topConstraint: NSLayoutConstraint? var bottomConstraint: NSLayoutConstraint? @@ -28,7 +28,7 @@ public class ContainerHelper: NSObject { var bottomLowConstraint: NSLayoutConstraint? var rightLowConstraint: NSLayoutConstraint? - func constrainView(_ view: UIView) { + open func constrainView(_ view: UIView) { guard let margins = view.superview?.layoutMarginsGuide else { return } leftConstraint = view.leftAnchor.constraint(equalTo: margins.leftAnchor) leftConstraint?.isActive = true @@ -69,7 +69,7 @@ public class ContainerHelper: NSObject { setAccessibility(view) } - func setAccessibility(_ view: UIView) { + open func setAccessibility(_ view: UIView) { guard let superView = view.superview else { return } superView.isAccessibilityElement = false if let elements = view.accessibilityElements { @@ -79,7 +79,7 @@ public class ContainerHelper: NSObject { } } - func alignHorizontal(_ alignment: UIStackView.Alignment) { + open func alignHorizontal(_ alignment: UIStackView.Alignment) { switch alignment { case .center: alignCenterHorizontalConstraint?.isActive = true @@ -109,7 +109,7 @@ public class ContainerHelper: NSObject { } } - func alignVertical(_ alignment: UIStackView.Alignment) { + open func alignVertical(_ alignment: UIStackView.Alignment) { switch alignment { case .center: alignCenterVerticalConstraint?.isActive = true @@ -139,7 +139,7 @@ public class ContainerHelper: NSObject { } } - static func getAlignment(for string: String) -> UIStackView.Alignment? { + public static func getAlignment(for string: String) -> UIStackView.Alignment? { switch string { case "leading": return .leading @@ -154,7 +154,7 @@ public class ContainerHelper: NSObject { } } - static func getAlignmentString(for alignment: UIStackView.Alignment?) -> String? { + public static func getAlignmentString(for alignment: UIStackView.Alignment?) -> String? { switch alignment { case .leading: return "leading" @@ -169,11 +169,11 @@ public class ContainerHelper: NSObject { } } - func updateViewMargins(_ view: UIView, model: ContainerModelProtocol?, size: CGFloat) { + open func updateViewMargins(_ view: UIView, model: ContainerModelProtocol?, size: CGFloat) { MFStyler.setMarginsFor(view, size: size, defaultHorizontal: model?.useHorizontalMargins ?? false, top: (model?.useVerticalMargins ?? false) ? (model?.topMarginPadding ?? 0) : 0, bottom: (model?.useVerticalMargins ?? false) ? (model?.bottomMarginPadding ?? 0) : 0) } - func set(with model: ContainerModelProtocol, for contained: MVMCoreUIViewConstrainingProtocol?) { + open func set(with model: ContainerModelProtocol, for contained: MVMCoreUIViewConstrainingProtocol?) { if let horizontalAlignment = model.horizontalAlignment ?? contained?.horizontalAlignment?() { alignHorizontal(horizontalAlignment) } @@ -182,7 +182,7 @@ public class ContainerHelper: NSObject { } } - func set(with JSON: [AnyHashable: Any]?, for contained: UIView) { + open func set(with JSON: [AnyHashable: Any]?, for contained: UIView) { if let horizontalAlignmentString = JSON?.optionalStringForKey("horizontalAlignment"), let alignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() { alignHorizontal(alignment) } else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() { From c891b6763ed2db8a1dd0ebfd1f0f356c4d0b4185 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Fri, 6 Mar 2020 16:19:54 +0530 Subject: [PATCH 04/17] code cleanup and identation --- .../ListOneColumnFullWidthTextBodyText.swift | 44 +++++++++---------- ...tOneColumnFullWidthTextBodyTextModel.swift | 11 +++-- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift index d43bf876..f32e0797 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift @@ -14,36 +14,36 @@ import Foundation // MARK: - Outlets //----------------------------------------------------- var stack: Stack - let headlineBody = HeadlineBody() + let headlineBody = HeadlineBody(frame: .zero) //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [headlineBody]) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [headlineBody]) + 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) - } - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ - super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListOneColumnFullWidthTextBodyTextModel else { return } - headlineBody.set(with: model.headlineBody, delegateObject, additionalData) + override open func setupView() { + super.setupView() + addMolecule(stack) + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListOneColumnFullWidthTextBodyTextModel else { return } + headlineBody.set(with: model.headlineBody, delegateObject, additionalData) stack.restack() - -} + } + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 90 - } + return 90 + } } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift index 6051b340..5109316a 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift @@ -11,16 +11,22 @@ import Foundation public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeModelProtocol { public static var identifier: String = "list1CFWBdy" public var headlineBody: HeadlineBodyModel - + public init(headlineBody: HeadlineBodyModel) { self.headlineBody = headlineBody super.init() + setDefaults() + } + + // Defaults to set + override public func setDefaults() { + super.setDefaults() + headlineBody.style = "item" } private enum CodingKeys: String, CodingKey { case moleculeName case headlineBody - } required public init(from decoder: Decoder) throws { @@ -34,6 +40,5 @@ public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeMod var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(headlineBody, forKey: .headlineBody) - } } From 9bce3f02a1aa94ddef1a7c873e529651d92aa4cb Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 6 Mar 2020 17:06:20 -0500 Subject: [PATCH 05/17] shifting and improving --- MVMCoreUI/BaseClasses/TableViewCell.swift | 3 +++ .../ImageHeadlineBodyModel.swift | 5 +++++ .../TwoButtonView.swift | 2 ++ .../Items/MoleculeTableViewCell.swift | 18 +++++++++--------- .../HeadlineBodyModel.swift | 6 +++++- MVMCoreUI/Templates/MoleculeListTemplate.swift | 8 ++++---- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 63824c04..ebf25a3c 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -176,6 +176,9 @@ import UIKit let backgroundColor = moleculeModel.backgroundColor { self.backgroundColor = backgroundColor.uiColor } + + // align if needed. + containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) } open func reset() { diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift index 7f3d52dc..f34e7b94 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/ImageHeadlineBodyModel.swift @@ -14,4 +14,9 @@ public struct ImageHeadlineBodyModel: MoleculeModelProtocol { public var backgroundColor: Color? public var image: ImageViewModel public var headlineBody: HeadlineBodyModel + + public init(image: ImageViewModel, headlineBody: HeadlineBodyModel) { + self.image = image + self.headlineBody = headlineBody + } } diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 50288c58..98160441 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -109,7 +109,9 @@ import UIKit public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) + guard let model = model as? TwoButtonViewModel else { return } + if let secondaryModel = model.secondaryButton { showSecondaryButton() secondaryButton.set(with: secondaryModel, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index f1d3794b..33229092 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -14,18 +14,18 @@ import UIKit // MARK: - MVMCoreUIMoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? MoleculeListItemModel else { return } - - if molecule != nil { - (molecule as? ModelMoleculeViewProtocol)?.set(with: model.molecule, delegateObject, additionalData) - - } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model.molecule, delegateObject, false) { - addMolecule(moleculeView) + guard let castModel = model as? MoleculeListItemModel else { + super.set(with: model, delegateObject, additionalData) + return } - containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) + if molecule != nil { + (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) + } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { + addMolecule(moleculeView) + } + super.set(with: model, delegateObject, additionalData) } public override class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index d7a08091..0ec98c65 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class HeadlineBodyModel: MoleculeModelProtocol { +@objcMembers open class HeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "headlineBody" public var moleculeName: String? = HeadlineBodyModel.identifier public var headline: LabelModel? @@ -19,4 +19,8 @@ import Foundation public init(headline: LabelModel) { self.headline = headline } + + public init(body: LabelModel) { + self.body = body + } } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 33d6beb0..a4078f17 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -178,7 +178,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() @@ -207,7 +207,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() @@ -235,7 +235,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol view.layoutIfNeeded() } - public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open 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 { @@ -257,7 +257,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality From f3314af68f9074d9a378241825c3b68cc99dea7f Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Mon, 9 Mar 2020 10:18:20 +0530 Subject: [PATCH 06/17] Removed stack --- .../OneColumn/ListOneColumnFullWidthTextBodyText.swift | 7 ++----- .../ListOneColumnFullWidthTextBodyTextModel.swift | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift index f32e0797..da415a10 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift @@ -13,14 +13,12 @@ import Foundation //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - var stack: Stack - let headlineBody = HeadlineBody(frame: .zero) + public var headlineBody = HeadlineBody(frame: .zero) //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - stack = Stack.createStack(with: [headlineBody]) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -33,14 +31,13 @@ import Foundation //----------------------------------------------------- override open func setupView() { super.setupView() - addMolecule(stack) + addMolecule(headlineBody) } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ super.set(with: model, delegateObject, additionalData) guard let model = model as? ListOneColumnFullWidthTextBodyTextModel else { return } headlineBody.set(with: model.headlineBody, delegateObject, additionalData) - stack.restack() } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift index 5109316a..138cc69a 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift @@ -15,7 +15,6 @@ public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeMod public init(headlineBody: HeadlineBodyModel) { self.headlineBody = headlineBody super.init() - setDefaults() } // Defaults to set @@ -35,7 +34,7 @@ public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeMod 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 c96e2fa3c22a0fece536c655dfe4d1b334d296c3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 9 Mar 2020 11:29:35 -0400 Subject: [PATCH 07/17] index path update --- .../BaseControllers/MFViewController+Model.swift | 9 +++++---- .../ModelMoleculeDelegateProtocol.swift | 6 ++++++ MVMCoreUI/Templates/MoleculeListTemplate.swift | 14 +++++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index e70e68f6..05e506eb 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -31,9 +31,10 @@ extension MFViewController: MoleculeDelegateProtocol { return nil } - @objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { } + // These are required because swift will call the extension function otherwise. + @objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {} - @objc public func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { } - - @objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { } + @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/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index d3a2fe80..eb175c3a 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -20,6 +20,8 @@ public protocol MoleculeDelegateProtocol { /// 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 @@ -36,6 +38,10 @@ extension MoleculeDelegateProtocol { // Do nothing } + 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 } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index a4078f17..1dfb0938 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -178,8 +178,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - open override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { - + open override func addMolecules(_ molecules: [[AnyHashable : Any]], indexPath: IndexPath, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() molecules.forEach { molecule in @@ -189,7 +188,6 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } DispatchQueue.main.async { - guard let indexPath = self.tableView?.indexPath(for: sender) else { return } var indexPaths: [IndexPath] = [] for molecule in tmpMolecules { @@ -207,6 +205,16 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } + 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]() From 3970b34719cb4b082446cfd9f86684586a00df34 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 10 Mar 2020 01:15:37 +0530 Subject: [PATCH 08/17] Making few properties public. Constraint fixes. --- MVMCoreUI/Organisms/Carousel.swift | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 9e2422e6..f8e2f37f 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -10,7 +10,7 @@ import UIKit open class Carousel: View { - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + public let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: MVMCoreUISplitViewController.getDetailViewWidth(), height: 300), collectionViewLayout: UICollectionViewFlowLayout()) /// The current index of the collection view. Includes dummy cells when looping. var currentIndex = 0 @@ -26,7 +26,7 @@ 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. - var numberOfPages = 0 + open var numberOfPages = 0 /// The json for the molecules. var molecules: [MoleculeModelProtocol]? @@ -35,10 +35,10 @@ open class Carousel: View { var itemAlignment = UICollectionView.ScrollPosition.left /// From 0-1. The item width as a percent of the carousel width. - var itemWidthPercent: Float = 1 + public var itemWidthPercent: Float = 1 /// The height of the carousel. Default is 300. - var collectionViewHeight: NSLayoutConstraint? + public var collectionViewHeight: NSLayoutConstraint? /// The view that we use for paging var pagingView: (UIView & MVMCoreUIPagingProtocol)? @@ -65,7 +65,7 @@ open class Carousel: View { addSubview(collectionView) bottomPin = NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView)?[ConstraintBot] as? NSLayoutConstraint - collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) + collectionViewHeight = collectionView.heightAnchor.constraint(greaterThanOrEqualToConstant: 300) collectionViewHeight?.isActive = false } @@ -114,6 +114,7 @@ open class Carousel: View { layout.scrollDirection = .horizontal layout.minimumLineSpacing = CGFloat(carouselModel?.spacing ?? 1) layout.minimumInteritemSpacing = 0 + layout.itemSize = CGSize(width: MVMCoreUISplitViewController.getDetailViewWidth(), height: 300) collectionView.collectionViewLayout = layout } @@ -190,12 +191,12 @@ open class Carousel: View { pagingView.translatesAutoresizingMaskIntoConstraints = false addSubview(pagingView) pagingView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true - collectionView.bottomAnchor.constraint(equalTo: pagingView.centerYAnchor, constant: position).isActive = true + collectionView.bottomAnchor.constraint(equalTo: pagingView.topAnchor, constant: position).isActive = true bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor).isActive = true bottomPin?.isActive = false bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) bottomPin?.priority = .defaultLow - bottomPin?.isActive = true + bottomPin?.isActive = false pagingView.setNumberOfPages(numberOfPages) (pagingView as? MVMCoreUIViewConstrainingProtocol)?.alignHorizontal?(.fill) @@ -230,7 +231,7 @@ open class Carousel: View { } } - func setAccessiblity(_ cell: UICollectionViewCell?, index: Int) { + public func setAccessiblity(_ cell: UICollectionViewCell?, index: Int) { guard let cell = cell else { return } @@ -252,7 +253,7 @@ open class Carousel: View { } extension Carousel: UICollectionViewDelegateFlowLayout { - public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let itemWidth = collectionView.bounds.width * CGFloat(itemWidthPercent) return CGSize(width: itemWidth, height: collectionView.bounds.height) } @@ -263,11 +264,11 @@ extension Carousel: UICollectionViewDelegateFlowLayout { } extension Carousel: UICollectionViewDataSource { - public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return molecules?.count ?? 0 } - public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let molecule = molecules?[indexPath.row], let moleculeInfo = getMoleculeInfo(with: molecule, delegateObject: nil) else { return UICollectionViewCell() @@ -343,6 +344,8 @@ extension Carousel: UIScrollViewDelegate { // Let the pager know our progress if needed. pagingView?.scrollViewDidScroll?(collectionView) + + collectionView.collectionViewLayout.invalidateLayout() } public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { From b67263205705ce84125074188096061c03137d23 Mon Sep 17 00:00:00 2001 From: Kruthika KP <> Date: Tue, 10 Mar 2020 08:09:33 +0530 Subject: [PATCH 09/17] Removed initializers --- .../ListOneColumnFullWidthTextBodyText.swift | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift index da415a10..99bc1a16 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyText.swift @@ -15,17 +15,6 @@ import Foundation //----------------------------------------------------- public var headlineBody = HeadlineBody(frame: .zero) - //----------------------------------------------------- - // MARK: - Initializers - //----------------------------------------------------- - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - //----------------------------------------------------- // MARK: - View Lifecycle //----------------------------------------------------- From 955d398262e4aa925f1a2ddb4f415eea47ff3bcc Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 10 Mar 2020 20:11:25 +0530 Subject: [PATCH 10/17] making properties and function public --- MVMCoreUI/Organisms/Carousel.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index f8e2f37f..6fab0f68 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -41,14 +41,14 @@ open class Carousel: View { public var collectionViewHeight: NSLayoutConstraint? /// The view that we use for paging - var pagingView: (UIView & MVMCoreUIPagingProtocol)? + public var pagingView: (UIView & MVMCoreUIPagingProtocol)? /// If the carousel should loop after scrolling past the first and final cells. var loop = false private var dragging = false // For adding pager - private var bottomPin: NSLayoutConstraint? + public var bottomPin: NSLayoutConstraint? // MARK: - MVMCoreViewProtocol open override func setupView() { @@ -258,7 +258,7 @@ extension Carousel: UICollectionViewDelegateFlowLayout { return CGSize(width: itemWidth, height: collectionView.bounds.height) } - public func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { + open func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { (cell as? MoleculeCollectionViewCell)?.setPeaking(false, animated: false) } } From bd4450a7fc856d439e7af4a78e3af1ee8ec2a830 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Wed, 11 Mar 2020 22:42:08 +0530 Subject: [PATCH 11/17] making pageIndex public --- MVMCoreUI/Organisms/Carousel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 6fab0f68..b9847487 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -16,7 +16,7 @@ open class Carousel: View { var currentIndex = 0 /// The index of the page, does not include dummy cells. - var pageIndex: Int { + public var pageIndex: Int { get { return loop ? currentIndex - 2 : currentIndex } From 73230fa3411d0a4315cc4fdde49b0bf055277a46 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 13 Mar 2020 01:55:58 +0530 Subject: [PATCH 12/17] implemented feedback --- MVMCoreUI/Organisms/Carousel.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index b9847487..94c47f4b 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -13,7 +13,7 @@ open class Carousel: View { public let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: MVMCoreUISplitViewController.getDetailViewWidth(), height: 300), collectionViewLayout: UICollectionViewFlowLayout()) /// The current index of the collection view. Includes dummy cells when looping. - var currentIndex = 0 + public var currentIndex = 0 /// The index of the page, does not include dummy cells. public var pageIndex: Int { @@ -114,7 +114,6 @@ open class Carousel: View { layout.scrollDirection = .horizontal layout.minimumLineSpacing = CGFloat(carouselModel?.spacing ?? 1) layout.minimumInteritemSpacing = 0 - layout.itemSize = CGSize(width: MVMCoreUISplitViewController.getDetailViewWidth(), height: 300) collectionView.collectionViewLayout = layout } @@ -184,19 +183,19 @@ open class Carousel: View { pagingView?.removeFromSuperview() guard let pagingView = view else { bottomPin?.isActive = false - bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) + bottomPin = safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) bottomPin?.isActive = true return } pagingView.translatesAutoresizingMaskIntoConstraints = false addSubview(pagingView) pagingView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true - collectionView.bottomAnchor.constraint(equalTo: pagingView.topAnchor, constant: position).isActive = true - bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor).isActive = true + collectionView.bottomAnchor.constraint(equalTo: pagingView.bottomAnchor, constant: position).isActive = true + safeAreaLayoutGuide.bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor).isActive = true bottomPin?.isActive = false - bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) + bottomPin = safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) bottomPin?.priority = .defaultLow - bottomPin?.isActive = false + bottomPin?.isActive = true pagingView.setNumberOfPages(numberOfPages) (pagingView as? MVMCoreUIViewConstrainingProtocol)?.alignHorizontal?(.fill) From 022f76b8b218c230c5d7cb3ce0ad0e9dddd59ea7 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 13 Mar 2020 19:28:55 +0530 Subject: [PATCH 13/17] Removing hard coded width. --- MVMCoreUI/Organisms/Carousel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 94c47f4b..8ddeca5f 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -10,7 +10,7 @@ import UIKit open class Carousel: View { - public let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: MVMCoreUISplitViewController.getDetailViewWidth(), height: 300), collectionViewLayout: UICollectionViewFlowLayout()) + public let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) /// The current index of the collection view. Includes dummy cells when looping. public var currentIndex = 0 From 9b8046009af7c5efdb0908cc4e2a481024572f89 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 13 Mar 2020 20:23:20 +0530 Subject: [PATCH 14/17] Removed un-necessary code. --- MVMCoreUI/Organisms/Carousel.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 8ddeca5f..b1cd0f37 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -183,7 +183,7 @@ open class Carousel: View { pagingView?.removeFromSuperview() guard let pagingView = view else { bottomPin?.isActive = false - bottomPin = safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) + bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) bottomPin?.isActive = true return } @@ -191,9 +191,9 @@ open class Carousel: View { addSubview(pagingView) pagingView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true collectionView.bottomAnchor.constraint(equalTo: pagingView.bottomAnchor, constant: position).isActive = true - safeAreaLayoutGuide.bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor).isActive = true bottomPin?.isActive = false - bottomPin = safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) + bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) bottomPin?.priority = .defaultLow bottomPin?.isActive = true @@ -336,15 +336,13 @@ extension Carousel: UIScrollViewDelegate { handleUserOnBufferCell() } - public func scrollViewDidScroll(_ scrollView: UIScrollView) { + open func scrollViewDidScroll(_ scrollView: UIScrollView) { // Check if the user is dragging the card even further past the next card. checkForDraggingOutOfBounds(scrollView) // Let the pager know our progress if needed. pagingView?.scrollViewDidScroll?(collectionView) - - collectionView.collectionViewLayout.invalidateLayout() } public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { From d99090bc4425f93d592a70358a0667aa88bdd1f2 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 13 Mar 2020 20:29:02 +0530 Subject: [PATCH 15/17] Reverted back centerYAnchor --- MVMCoreUI/Organisms/Carousel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index b1cd0f37..64284cbd 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -190,7 +190,7 @@ open class Carousel: View { pagingView.translatesAutoresizingMaskIntoConstraints = false addSubview(pagingView) pagingView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true - collectionView.bottomAnchor.constraint(equalTo: pagingView.bottomAnchor, constant: position).isActive = true + collectionView.bottomAnchor.constraint(equalTo: pagingView.centerYAnchor, constant: position).isActive = true bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor).isActive = true bottomPin?.isActive = false bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor) From 09be34e4f8f218800a5f2d7ac1134f997c2b2824 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Fri, 13 Mar 2020 20:39:36 +0530 Subject: [PATCH 16/17] Reverted collectioViewHeight constraint. --- MVMCoreUI/Organisms/Carousel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 64284cbd..ba675adf 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -65,7 +65,7 @@ open class Carousel: View { addSubview(collectionView) bottomPin = NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView)?[ConstraintBot] as? NSLayoutConstraint - collectionViewHeight = collectionView.heightAnchor.constraint(greaterThanOrEqualToConstant: 300) + collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300) collectionViewHeight?.isActive = false } From 6d3946f0e7541b328130211fe37d942fc34da400 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 13 Mar 2020 11:52:09 -0400 Subject: [PATCH 17/17] anyrequiredmodel --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ .../New/Rules/RuleAnyRequiredModel.swift | 23 +++++++++++++++++++ .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 3 files changed, 28 insertions(+) create mode 100644 MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyRequiredModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8ece6dd9..aeaac929 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -91,6 +91,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 */; }; + 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 */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; @@ -452,6 +453,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 = ""; }; + 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 = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; @@ -807,6 +809,7 @@ 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */, 011D95A2240453F8000E3791 /* RuleRegexModel.swift */, 011D95A4240455DC000E3791 /* FormGroupRule.swift */, + 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */, ); path = Rules; sourceTree = ""; @@ -1781,6 +1784,7 @@ D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, + 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */, diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyRequiredModel.swift b/MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyRequiredModel.swift new file mode 100644 index 00000000..0eab62a7 --- /dev/null +++ b/MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyRequiredModel.swift @@ -0,0 +1,23 @@ +// +// RuleAnyRequiredModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 3/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + + +public class RuleAnyRequiredModel: RulesProtocol { + + public static var identifier: String = "anyRequired" + public var type: String = RuleRequiredModel.identifier + public var fields: [String] + + public func isValid(_ formField: FormFieldProtocol) -> Bool { + guard let value = formField.formFieldValue() else { return false } + + return true + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 17a9972c..640dbebe 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -124,6 +124,7 @@ import Foundation // 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)