This commit is contained in:
Suresh, Kamlesh 2020-01-14 19:29:37 -05:00
commit c3433c2f80
33 changed files with 2519 additions and 131 deletions

View File

@ -93,7 +93,7 @@
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; };
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; };
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; };
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */; };
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; };
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */; };
@ -153,6 +153,7 @@
D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */; };
D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */; };
D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */; };
D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */; };
D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -367,7 +368,7 @@
944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = "<group>"; };
944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = "<group>"; };
9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = "<group>"; };
946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = "<group>"; };
946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = "<group>"; };
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = "<group>"; };
94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = "<group>"; };
@ -424,6 +425,7 @@
D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimaryButton+MoleculeProtocolExtension.swift"; sourceTree = "<group>"; };
D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonViewModel.swift; sourceTree = "<group>"; };
D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerLabelsModel.swift; sourceTree = "<group>"; };
D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyCaretLinkImageModel.swift; sourceTree = "<group>"; };
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = "<group>"; };
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = "<group>"; };
@ -694,7 +696,7 @@
946EE1B5237B663A0036751F /* Extensions */ = {
isa = PBXGroup;
children = (
946EE1B9237B66D80036751F /* ModelHelper.swift */,
946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -770,6 +772,7 @@
01EB368D23609801006832FA /* HeadlineBodyModel.swift */,
D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */,
D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */,
D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */,
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */,
);
path = VerticalCombinationViews;
@ -1549,6 +1552,7 @@
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */,
D243859923A16B1800332775 /* Container.swift in Sources */,
D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */,
D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */,
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
01EB369323609801006832FA /* HeaderModel.swift in Sources */,
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */,
@ -1574,7 +1578,6 @@
012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */,
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
C003506123AA94CD00B6AC29 /* Button.swift in Sources */,
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */,
@ -1603,7 +1606,7 @@
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */,
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
);

File diff suppressed because it is too large Load Diff

View File

@ -13,12 +13,18 @@ public enum ButtonStyle: String, Codable {
case secondary
}
public enum ButtonSize: String, Codable {
case standard
case tiny
}
public class ButtonModel: MoleculeProtocol {
public static var identifier: String = "button"
public var backgroundColor: Color?
public var title: String
public var action: ActionProtocol
public var style: ButtonStyle?
public var style: ButtonStyle? = .primary
public var size: ButtonSize? = .standard
init(with title: String, action: ActionProtocol) {
self.title = title
@ -30,6 +36,7 @@ public class ButtonModel: MoleculeProtocol {
case title
case action
case style
case size
}
required public init(from decoder: Decoder) throws {
@ -37,7 +44,12 @@ public class ButtonModel: MoleculeProtocol {
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
title = try typeContainer.decode(String.self, forKey: .title)
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style)
if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) {
self.style = style
}
if let size = try typeContainer.decodeIfPresent(ButtonSize.self, forKey: .size) {
self.size = size
}
}
public func encode(to encoder: Encoder) throws {
@ -46,5 +58,6 @@ public class ButtonModel: MoleculeProtocol {
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeModel(action, forKey: .action)
try container.encodeIfPresent(style, forKey: .style)
try container.encodeIfPresent(size, forKey: .size)
}
}

View File

@ -16,9 +16,6 @@ extension MFTextButton: ModelMoleculeViewProtocol {
setTitleColor(model.textColor.uiColor, for: .normal)
isEnabled = model.enabled
backgroundColor = model.backgroundColor?.uiColor
//TODO: Use object when handleAction is rewrote to handle action model
if let actionMap = model.action.toJSON() {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
}
}

View File

@ -22,9 +22,14 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
setAsSecondaryCustom()
}
}
//TODO: Use object when handleAction is rewrote to handle action model
if let actionMap = model.action.toJSON() {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
if let size = model.size {
switch size {
case .standard:
setAsTiny(false)
case .tiny:
setAsTiny(true)
}
}
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
}
}

View File

@ -352,6 +352,45 @@
}
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
// Only treated as a container if we are constraining a molecule.
if (!self.constrainedView) {
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
}
if (self.shouldSetupMoleculeFromJSON) {
NSDictionary *moleculeJSON = [json dict:KeyMolecule];
if (self.molecule) {
[self.molecule setWithJSON:moleculeJSON delegateObject:delegateObject additionalData:additionalData];
} else if (moleculeJSON) {
UIView <MVMCoreUIMoleculeViewProtocol>*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;
}

View File

@ -40,16 +40,24 @@ import UIKit
}
}
public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.model = model
if let backgroundColor = model?.backgroundColor {
self.backgroundColor = backgroundColor.uiColor
}
}
public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
}
public class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
}
// MARK:- MVMCoreViewProtocol
@ -61,6 +69,7 @@ extension View: MVMCoreViewProtocol {
open func setupView() {
translatesAutoresizingMaskIntoConstraints = false
insetsLayoutMarginsFromSafeArea = false
MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0)
}
}

View File

@ -0,0 +1,265 @@
//
// Container.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 12/11/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
public protocol ContainerModelProtocol: Model {
var horizontalAlignment: UIStackView.Alignment? { get set }
var verticalAlignment: UIStackView.Alignment? { get set }
var useHorizontalMargins: Bool? { get set }
var useVerticalMargins: Bool? { get set }
}
public class ContainerHelper: NSObject {
var leftConstraint: NSLayoutConstraint?
var topConstraint: NSLayoutConstraint?
var bottomConstraint: NSLayoutConstraint?
var rightConstraint: NSLayoutConstraint?
var alignCenterHorizontalConstraint: NSLayoutConstraint?
var alignCenterLeftConstraint: NSLayoutConstraint?
var alignCenterRightConstraint: NSLayoutConstraint?
var alignCenterVerticalConstraint: NSLayoutConstraint?
var alignCenterTopConstraint: NSLayoutConstraint?
var alignCenterBottomConstraint: NSLayoutConstraint?
var leftLowConstraint: NSLayoutConstraint?
var topLowConstraint: NSLayoutConstraint?
var bottomLowConstraint: NSLayoutConstraint?
var rightLowConstraint: NSLayoutConstraint?
func constrainView(_ view: UIView) {
guard let margins = view.superview?.layoutMarginsGuide else { return }
leftConstraint = view.leftAnchor.constraint(equalTo: margins.leftAnchor)
leftConstraint?.isActive = true
topConstraint = view.topAnchor.constraint(equalTo: margins.topAnchor)
topConstraint?.isActive = true
rightConstraint = margins.rightAnchor.constraint(equalTo: view.rightAnchor)
rightConstraint?.isActive = true
bottomConstraint = margins.bottomAnchor.constraint(equalTo: view.bottomAnchor)
bottomConstraint?.isActive = true
alignCenterHorizontalConstraint = view.centerXAnchor.constraint(equalTo: margins.centerXAnchor)
alignCenterLeftConstraint = view.leftAnchor.constraint(greaterThanOrEqualTo: margins.leftAnchor)
alignCenterRightConstraint = margins.rightAnchor.constraint(greaterThanOrEqualTo: view.rightAnchor)
alignCenterVerticalConstraint = view.centerYAnchor.constraint(equalTo: margins.centerYAnchor)
alignCenterTopConstraint = view.topAnchor.constraint(greaterThanOrEqualTo: margins.topAnchor)
alignCenterBottomConstraint = margins.bottomAnchor.constraint(greaterThanOrEqualTo: view.bottomAnchor)
leftLowConstraint = view.leftAnchor.constraint(equalTo: margins.leftAnchor)
leftLowConstraint?.priority = UILayoutPriority(rawValue: 200)
leftLowConstraint?.isActive = true
topLowConstraint = view.topAnchor.constraint(equalTo: margins.topAnchor)
topLowConstraint?.priority = UILayoutPriority(rawValue: 200)
topLowConstraint?.isActive = true
rightLowConstraint = margins.rightAnchor.constraint(equalTo: view.rightAnchor)
rightLowConstraint?.priority = UILayoutPriority(rawValue: 200)
rightLowConstraint?.isActive = true
bottomLowConstraint = margins.bottomAnchor.constraint(equalTo: view.bottomAnchor)
bottomLowConstraint?.priority = UILayoutPriority(rawValue: 200)
bottomLowConstraint?.isActive = true
setAccessibility(view)
}
func setAccessibility(_ view: UIView) {
guard let superView = view.superview else { return }
superView.isAccessibilityElement = false
if let elements = view.accessibilityElements {
superView.accessibilityElements = elements
} else {
superView.accessibilityElements = [view]
}
}
func alignHorizontal(_ alignment: UIStackView.Alignment) {
switch alignment {
case .center:
alignCenterHorizontalConstraint?.isActive = true
alignCenterLeftConstraint?.isActive = true
alignCenterRightConstraint?.isActive = true
leftConstraint?.isActive = false
rightConstraint?.isActive = false
case .leading:
alignCenterHorizontalConstraint?.isActive = false
alignCenterLeftConstraint?.isActive = false
alignCenterRightConstraint?.isActive = true
leftConstraint?.isActive = true
rightConstraint?.isActive = false
case .trailing:
alignCenterHorizontalConstraint?.isActive = false
alignCenterLeftConstraint?.isActive = true
alignCenterRightConstraint?.isActive = false
leftConstraint?.isActive = false
rightConstraint?.isActive = true
case .fill:
alignCenterHorizontalConstraint?.isActive = false
alignCenterLeftConstraint?.isActive = false
alignCenterRightConstraint?.isActive = false
leftConstraint?.isActive = true
rightConstraint?.isActive = true
default: break
}
}
func alignVertical(_ alignment: UIStackView.Alignment) {
switch alignment {
case .center:
alignCenterVerticalConstraint?.isActive = true
alignCenterTopConstraint?.isActive = true
alignCenterBottomConstraint?.isActive = true
topConstraint?.isActive = false
bottomConstraint?.isActive = false
case .leading:
alignCenterVerticalConstraint?.isActive = false
alignCenterTopConstraint?.isActive = false
alignCenterBottomConstraint?.isActive = true
topConstraint?.isActive = true
bottomConstraint?.isActive = false
case .trailing:
alignCenterVerticalConstraint?.isActive = false
alignCenterTopConstraint?.isActive = true
alignCenterBottomConstraint?.isActive = false
topConstraint?.isActive = false
bottomConstraint?.isActive = true
case .fill:
alignCenterVerticalConstraint?.isActive = false
alignCenterTopConstraint?.isActive = false
alignCenterBottomConstraint?.isActive = false
topConstraint?.isActive = true
bottomConstraint?.isActive = true
default: break
}
}
func set(with model: ContainerModelProtocol) {
if let horizontalAlignment = model.horizontalAlignment {
alignHorizontal(horizontalAlignment)
}
if let verticalAlignment = model.verticalAlignment {
alignVertical(verticalAlignment)
}
}
static func getAlignment(for string: String) -> UIStackView.Alignment? {
switch string {
case "leading":
return .leading
case "trailing":
return .trailing
case "center":
return .center
case "fill":
return .fill
default:
return nil
}
}
static func getAlignmentString(for alignment: UIStackView.Alignment?) -> String? {
switch alignment {
case .leading:
return "leading"
case .trailing:
return "trailing"
case .center:
return "center"
case .fill:
return "fill"
default:
return nil
}
}
func set(with JSON: [AnyHashable: Any]?, for contained: UIView) {
if let horizontalAlignmentString = JSON?.optionalStringForKey("horizontalAlignment"), let alignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
alignHorizontal(alignment)
} else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
alignHorizontal(alignment)
}
if let verticalAlignmentString = JSON?.optionalStringForKey("verticalAlignment"), let alignment = ContainerHelper.getAlignment(for: verticalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
alignVertical(alignment)
} else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
alignVertical(alignment)
}
}
}
open class Container: View {
<<<<<<< HEAD
=======
var containerModel: ContainerModelProtocol?
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
var view: UIView?
let containerHelper = ContainerHelper()
var containerModel: ContainerModelProtocol? {
get { return model as? ContainerModelProtocol }
}
var topMarginPadding: CGFloat = 0
var bottomMarginPadding: CGFloat = 0
override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let containerModel = model as? ContainerModelProtocol else { return }
containerHelper.set(with: containerModel)
}
}
// MARK: - MVMCoreViewProtocol
public extension Container {
override func updateView(_ size: CGFloat) {
super.updateView(size)
(view as? MVMCoreViewProtocol)?.updateView(size)
MFStyler.setMarginsFor(self, size: size, defaultHorizontal: containerModel?.useHorizontalMargins ?? true, top: containerModel?.useHorizontalMargins ?? true ? topMarginPadding : 0, bottom: containerModel?.useHorizontalMargins ?? true ? bottomMarginPadding : 0)
}
/// Will be called only once.
override func setupView() {
super.setupView()
backgroundColor = .clear
}
func addAndContain(_ view: UIView) {
view.translatesAutoresizingMaskIntoConstraints = false
addSubview(view)
containerHelper.constrainView(view)
self.view = view
}
convenience init(andContain view: UIView) {
self.init()
addAndContain(view)
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol
public extension Container {
override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
guard let view = view else { return }
containerHelper.set(with: json, for: view)
}
override func reset() {
super.reset()
(view as? MVMCoreUIMoleculeViewProtocol)?.reset?()
}
func setAsMolecule() {
(view as? MVMCoreUIMoleculeViewProtocol)?.setAsMolecule?()
}
}

View File

@ -1,5 +1,5 @@
//
// ModelHelper.swift
// MoleculeModelHelper.swift
// MVMCoreUI
//
// Created by Ryan on 11/12/19.

View File

@ -16,11 +16,33 @@ import Foundation
enum FooterCodingKeys: String, CodingKey {
case backgroundColor
}
/// Defaults to set
func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
if topMarginPadding == nil {
topMarginPadding = PaddingDefaultVerticalSpacing
}
if bottomMarginPadding == nil {
bottomMarginPadding = PaddingDefaultVerticalSpacing
}
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
setDefaults()
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
try super.init(from: decoder)
setDefaults()
}
public override func encode(to encoder: Encoder) throws {

View File

@ -0,0 +1,37 @@
//
// FooterModel.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 11/27/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class FooterModel: MoleculeContainerModel, MoleculeProtocol {
public static var identifier: String = "footer"
public var backgroundColor: Color?
enum FooterCodingKeys: String, CodingKey {
case backgroundColor
}
required public init(from decoder: Decoder) throws {
<<<<<<< HEAD
let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
try super.init(from: decoder)
=======
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
>>>>>>> 83b0a554049f764888ce9db27dbd7fa503fddf01
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: FooterCodingKeys.self)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
}
}

View File

@ -18,19 +18,34 @@ import Foundation
case line
case backgroundColor
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
// Default Values
/// Defaults to set
func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
if topMarginPadding == nil {
topMarginPadding = PaddingDefaultVerticalSpacing
}
if bottomMarginPadding == nil {
bottomMarginPadding = PaddingDefaultVerticalSpacing
}
line?.type = .heavy
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
setDefaults()
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
setDefaults()
}
public override func encode(to encoder: Encoder) throws {

View File

@ -15,7 +15,7 @@ import MVMCore
public var action: ActionProtocol?
public var hideArrow: Bool?
public var line: LineModel?
public var style: String?
public var style: String? = "standard"
enum ListItemCodingKeys: String, CodingKey {
case backgroundColor
@ -24,6 +24,27 @@ import MVMCore
case line
case style
}
/// Defaults to set
func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
if topMarginPadding == nil {
topMarginPadding = 24
}
if bottomMarginPadding == nil {
bottomMarginPadding = 24
}
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
setDefaults()
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self)
@ -31,10 +52,13 @@ import MVMCore
action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
style = try typeContainer.decodeIfPresent(String.self, forKey: .style)
if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) {
self.style = style
}
try super.init(from: decoder)
setDefaults()
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: ListItemCodingKeys.self)
@ -43,5 +67,6 @@ import MVMCore
try container.encodeIfPresent(hideArrow, forKey: .hideArrow)
try container.encodeIfPresent(line, forKey: .line)
try container.encodeIfPresent(style, forKey: .style)
}
}
}

View File

@ -114,11 +114,13 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
backgroundColor = .white
}
public class func name(forReuse molecule: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let molecule = molecule?.optionalDictionaryForKey(KeyMolecule) else {
public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let molecule = (model as? CarouselItemModel)?.molecule,
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type,
let name = moleculeClass.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else {
return nil
}
return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName)
return name
}
public func updateView(_ size: CGFloat) {

View File

@ -13,24 +13,23 @@ import UIKit
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model,
let moleculeModel = (model as? ListItemModel)?.molecule,
let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) else {
return
guard let moleculeModel = (model as? ListItemModel)?.molecule else { return }
if molecule != nil {
(molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData)
} else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) {
addMolecule(moleculeView)
}
addMolecule(moleculeView)
}
public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moleculeModel = (molecule as? ListItemModel)?.molecule else {
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moleculeModel = (model as? ListItemModel)?.molecule else {
return "\(self)<>"
}
let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol
let moleculeName = className?.nameForReuse(molecule, delegateObject) ?? moleculeModel.moleculeName ?? ""
let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type
let moleculeName = className?.nameForReuse(moleculeModel, delegateObject) ?? moleculeModel.moleculeName ?? ""
return "\(self)<\(moleculeName)>"
}
public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule),
let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON) else {
@ -39,7 +38,7 @@ import UIKit
return theClass.requiredModules?(moleculeJSON, delegateObject: delegateObject, error: error)
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
guard let moleculeModel = (molecule as? MoleculeContainerModel)?.molecule,
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type,
let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else {

View File

@ -0,0 +1,100 @@
//
// StackItem.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 12/13/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
open class StackItemModel: ContainerModelProtocol, MoleculeProtocol {
public static var identifier: String = "stackItem"
public var backgroundColor: String?
public var view: StackItem?
public var molecule: MoleculeProtocol
public var spacing: CGFloat? = 16
public var percentage: Int? = 0
public var verticalAlignment: UIStackView.Alignment?
public var horizontalAlignment: UIStackView.Alignment?
public var useHorizontalMargins: Bool? = false
public var useVerticalMargins: Bool? = false
public var gone: Bool? = false
<<<<<<< HEAD
enum CodingKeys: String, CodingKey {
case molecule
case spacing
case percentage
case verticalAlignment
case horizontalAlignment
case useHorizontalMargins
case useVerticalMargins
case gone
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)
percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage)
if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) {
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
}
if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) {
horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString)
}
useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins)
useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins)
gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeModel(molecule, forKey: .molecule)
try container.encodeIfPresent(spacing, forKey: .spacing)
try container.encodeIfPresent(percentage, forKey: .percentage)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment)
try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins)
try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins)
try container.encodeIfPresent(gone, forKey: .gone)
=======
init(with view: StackItem) {
self.view = view
view.containerModel = self
}
init(with view: StackItem, json: [AnyHashable: Any]?) {
self.view = view
view.containerModel = self
update(with: json)
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
}
func update(with json: [AnyHashable: Any]?) {
gone = json?.boolForKey("gone") ?? (json == nil)
spacing = json?.optionalCGFloatForKey("spacing")
percentage = json?["percent"] as? Int
if let horizontalAlignmentString = json?.optionalStringForKey("horizontalAlignment") {
horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString)
} else {
horizontalAlignment = nil
}
if let verticalAlignmentString = json?.optionalStringForKey("verticalAlignment") {
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
} else {
verticalAlignment = nil
}
useHorizontalMargins = json?.optionalBoolForKey("useHorizontalMargins") ?? false
useVerticalMargins = json?.optionalBoolForKey("useVerticalMargins") ?? false
}
}
open class StackItem: MoleculeContainer {
}

View File

@ -12,12 +12,12 @@ import Foundation
public static var identifier: String = "stackItem"
public var backgroundColor: Color?
public var spacing: CGFloat?
public var percentage: Int? = 0
public var percent: Int?
public var gone: Bool = false
enum MoleculeStackItemCodingKeys: String, CodingKey {
case spacing
case percentage
case percent
case gone
}
@ -28,7 +28,7 @@ import Foundation
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)
percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage)
percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent)
if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) {
self.gone = gone
}
@ -39,7 +39,7 @@ import Foundation
try super.encode(to: encoder)
var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
try container.encodeIfPresent(spacing, forKey: .spacing)
try container.encodeIfPresent(percentage, forKey: .percentage)
try container.encodeIfPresent(percent, forKey: .percent)
try container.encode(gone, forKey: .gone)
}
}

View File

@ -179,9 +179,13 @@ import UIKit
backgroundColor = .white
}
public class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
return molecule?.moleculeName ?? ""
public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
}
// MARK: - Arrow
/// Adds the standard mvm style caret to the accessory view

View File

@ -8,8 +8,8 @@
import UIKit
@objcMembers public class CornerLabels: ViewConstrainingView {
@objcMembers public class CornerLabels: View {
var middleView: UIView?
let topLeftLabel = Label.commonLabelB1(true)
let topRightLabel = Label.commonLabelB1(true)
let bottomLeftLabel = Label.commonLabelB3(true)
@ -38,18 +38,19 @@ import UIKit
var topLabelToMoleculeConstraint: NSLayoutConstraint?
var bottomLabelToMoleculeConstraint: NSLayoutConstraint?
public override func addMolecule(_ molecule: UIView) {
insertSubview(molecule, at: 0)
public func addMiddleView(_ view: UIView) {
insertSubview(view, at: 0)
topLabelToMoleculeConstraint?.isActive = false
bottomLabelToMoleculeConstraint?.isActive = false
molecule.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
layoutMarginsGuide.rightAnchor.constraint(equalTo: molecule.rightAnchor).isActive = true
view.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
layoutMarginsGuide.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
topLabelToMoleculeConstraint = molecule.topAnchor.constraint(equalTo: topLabelsView.bottomAnchor, constant: spaceAboveMolecule)
topLabelToMoleculeConstraint = view.topAnchor.constraint(equalTo: topLabelsView.bottomAnchor, constant: spaceAboveMolecule)
topLabelToMoleculeConstraint?.isActive = true
bottomLabelToMoleculeConstraint = bottomLabelsView.topAnchor.constraint(equalTo: molecule.bottomAnchor, constant: spaceBelowMolecule)
bottomLabelToMoleculeConstraint = bottomLabelsView.topAnchor.constraint(equalTo: view.bottomAnchor, constant: spaceBelowMolecule)
bottomLabelToMoleculeConstraint?.isActive = true
self.middleView = view
}
// MARK: - MVMCoreViewProtocol
@ -59,12 +60,11 @@ import UIKit
topRightLabel.updateView(size)
bottomLeftLabel.updateView(size)
bottomRightLabel.updateView(size)
(middleView as? MVMCoreViewProtocol)?.updateView(size)
}
public override func setupView() {
super.setupView()
shouldSetupMoleculeFromJSON = true
guard topLeftLabel.superview == nil else {
return
}
@ -141,17 +141,6 @@ import UIKit
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
topLeftLabel.setWithJSON(json?.optionalDictionaryForKey("topLeftLabel"), delegateObject: delegateObject, additionalData: additionalData)
topRightLabel.setWithJSON(json?.optionalDictionaryForKey("topRightLabel"), delegateObject: delegateObject, additionalData: additionalData)
bottomLeftLabel.setWithJSON(json?.optionalDictionaryForKey("bottomLeftLabel"), delegateObject: delegateObject, additionalData: additionalData)
bottomRightLabel.setWithJSON(json?.optionalDictionaryForKey("bottomRightLabel"), delegateObject: delegateObject, additionalData: additionalData)
topLabelToMoleculeConstraint?.constant = (molecule != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0
bottomLabelToMoleculeConstraint?.constant = (molecule != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0
}
public override func setAsMolecule() {
super.setAsMolecule()
styleDefault()
@ -163,8 +152,7 @@ import UIKit
styleDefault()
spaceAboveMolecule = 6.0
spaceBelowMolecule = 6.0
molecule?.reset?()
(middleView as? MoleculeViewProtocol)?.reset?()
}
func styleDefault() {
@ -174,25 +162,27 @@ import UIKit
bottomRightLabel.styleB3(true)
}
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return 34
}
}
extension CornerLabels: MoleculeViewProtocol {
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? CornerLabelsModel,
let data = try? model.encode(using: JSONEncoder()),
let json = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] else {
return
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model as? CornerLabelsModel else { return }
if middleView != nil {
(middleView as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData)
} else {
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model.molecule, delegateObject) {
addMiddleView(molecule)
}
}
self.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
// topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData)
// topRightLabel.setWithModel(model.topRightLabel, delegateObject, additionalData)
// bottomLeftLabel.setWithModel(model.bottomLeftLabel, delegateObject, additionalData)
// bottomRightLabel.setWithModel(model.bottomRightLabel, delegateObject, additionalData)
//
// topLabelToMoleculeConstraint?.constant = (molecule != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0
// bottomLabelToMoleculeConstraint?.constant = (molecule != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0
topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData)
topRightLabel.setWithModel(model.topRightLabel, delegateObject, additionalData)
bottomLeftLabel.setWithModel(model.bottomLeftLabel, delegateObject, additionalData)
bottomRightLabel.setWithModel(model.bottomRightLabel, delegateObject, additionalData)
topLabelToMoleculeConstraint?.constant = (middleView != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0
bottomLabelToMoleculeConstraint?.constant = (middleView != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0
}
}

View File

@ -41,7 +41,7 @@ import UIKit
super.setWithModel(model, delegateObject, additionalData)
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
public class override func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 30
}

View File

@ -10,14 +10,14 @@ import Foundation
public protocol ModelMoleculeViewProtocol {
func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?)
func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?
static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]?
}
extension ModelMoleculeViewProtocol {
public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return nil
public static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
@ -25,7 +25,6 @@ extension ModelMoleculeViewProtocol {
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
// Temporary
public static func decodeJSONToModel<T>(json: [AnyHashable: Any], type: T.Type) throws -> T where T : Decodable {
let data = try JSONSerialization.data(withJSONObject: json)

View File

@ -46,7 +46,7 @@ open class ModuleMolecule: Container {
}
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
guard let moduleMolecule = molecule as? ModuleMoleculeModel,
let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName),
@ -58,10 +58,10 @@ open class ModuleMolecule: Container {
return height
}
public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moduleMolecule = model as? ModuleMoleculeModel,
let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName),
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol,
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type,
let name = classType.nameForReuse(moduleModel, delegateObject) else {
// Critical error
return "moduleMolecule<>"
@ -69,7 +69,7 @@ open class ModuleMolecule: Container {
return name
}
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName,
let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {

View File

@ -0,0 +1,116 @@
//
// ModuleMolecule.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 6/25/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
open class ModuleMoleculeModel: ContainerModelProtocol {
public static var identifier: String = "moduleMolecule"
public var molecule: MoleculeProtocol?
public var moduleName: String
public var horizontalAlignment: UIStackView.Alignment? = .fill
public var verticalAlignment: UIStackView.Alignment? = .fill
public var useHorizontalMargins: Bool? = false
public var useVerticalMargins: Bool? = false
enum CodingKeys: String, CodingKey {
case molecule
case moduleName
case horizontalAlignment
case verticalAlignment
case useHorizontalMargins
case useVerticalMargins
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
moduleName = try typeContainer.decode(String.self, forKey:.moduleName)
if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) {
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
}
if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) {
horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString)
}
useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins)
useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moduleName, forKey: .moduleName)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment)
try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins)
try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins)
}
}
open class ModuleMolecule: Container {
<<<<<<< HEAD
var moduleMoleculeModel: ModuleMoleculeModel? {
get { return model as? ModuleMoleculeModel }
=======
public override func setupView() {
super.setupView()
containerModel = ModuleMoleculeModel()
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
}
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
#warning("need to change getter to get moduleModel instead to use.")
super.setWithModel(model, delegateObject, additionalData)
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
// Critical error
return
}
if view == nil {
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: false) {
addAndContain(moleculeView)
}
} else {
(view as? MVMCoreUIMoleculeViewProtocol)?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData)
}
}
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
// Critical error
return 0
}
return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.estimatedHeight?(forRow: module, delegateObject: delegateObject) ?? 0
}
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moduleName = molecule?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
// Critical error
return "moduleMolecule<>"
}
return "moduleMolecule<" + (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.name?(forReuse: module, delegateObject: delegateObject) ?? module.stringForkey(KeyMoleculeName)) + ">"
}
public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
let moduleName = json?.optionalStringForKey("moduleName")
if moduleName == nil || delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) == nil {
if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) {
error?.pointee = errorObject
MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject)
}
}
if let moduleName = moduleName {
return [moduleName]
}
return nil
}
}

View File

@ -9,6 +9,11 @@
import UIKit
open class MoleculeContainer: Container {
/// Can be overriden to change how the molecule is added to the hierarchy.
public func addMolecule(_ molecule: UIView) {
addAndContain(molecule)
}
override public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule) else {
@ -31,7 +36,7 @@ open class MoleculeContainer: Container {
(view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData)
} else {
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(casteModel.molecule, delegateObject) {
addAndContain(molecule)
addMolecule(molecule)
}
}
}

View File

@ -0,0 +1,90 @@
//
// StandardHeaderView.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 2/12/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
public class StandardHeaderView: MoleculeContainer {
var line: Line?
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
line?.updateView(size)
}
public override func setupView() {
super.setupView()
topMarginPadding = PaddingDefaultVerticalSpacing
bottomMarginPadding = PaddingDefaultVerticalSpacing
guard line == nil else { return }
let line = Line()
line.style = .heavy
addSubview(line)
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true
self.line = line
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
if let separatorJSON = json?.optionalDictionaryForKey("separator") {
line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
}
}
<<<<<<< HEAD
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let headerModel = model as? HeaderModel else {
return
}
if let seperatorModel = headerModel.seperator as? LineModel {
line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
}
}
=======
// open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
// //TODO: Need to create setWithModel in ViewConstraining View
//
// #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.")
// //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.
// setUpWithModel(model, delegateObject, additionalData)
//
// // This molecule will by default handle margins.
// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false)
// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false)
//
// guard let headerModel = model as? HeaderModel else {
// return
// }
//
// if let seperatorModel = headerModel.seperator as? LineModel {
// line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
// }
// }
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
open override func reset() {
super.reset()
line?.style = .heavy
topMarginPadding = PaddingDefaultVerticalSpacing
bottomMarginPadding = PaddingDefaultVerticalSpacing
}
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
if let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) {
return height + PaddingDefaultVerticalSpacing + PaddingDefaultVerticalSpacing
}
return 121
}
}

View File

@ -85,7 +85,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
body.styleB2(true)
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 65
}
}

View File

@ -7,7 +7,7 @@
//
import Foundation
@objcMembers public class HeadLineBodyCaretLinkImage: ViewConstrainingView {
@objcMembers public class HeadLineBodyCaretLinkImage: View {
let headlineBody = HeadlineBody(frame: .zero)
let caretButton = CaretButton(frame: .zero)
@ -34,7 +34,7 @@ import Foundation
}
let view = MVMCoreUICommonViewsUtility.commonView()
addSubview(view)
pinView(toSuperView: view)
NSLayoutConstraint.constraintPinSubview(toSuperview: view)
view.addSubview(headlineBody)
view.addSubview(caretButton)
@ -78,7 +78,16 @@ import Foundation
backgroundImageView.reset()
}
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 320
}
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model as? HeadlineBodyCaretLinkImageModel else { return }
headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData)
caretButton.setWithModel(model.caretLink, delegateObject, additionalData)
backgroundImageView.setWithModel(model.image, delegateObject, additionalData)
}
}

View File

@ -0,0 +1,17 @@
//
// headlineBodyCaretLinkImageModel.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/14/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
public class HeadlineBodyCaretLinkImageModel: MoleculeProtocol {
public static var identifier: String = "headlineBodyCaretLinkImage"
public var backgroundColor: Color?
public var caretLink: LinkModel?
public var headlineBody: HeadlineBodyModel
public var image: ImageViewModel
}

View File

@ -169,7 +169,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
/// Returns the (identifier, class) of the molecule for the given map.
func getMoleculeInfo(with molecule: MoleculeProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? {
guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) ,
let moleculeName = (className as? ModelMoleculeViewProtocol)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else {
let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else {
return nil
}
return (moleculeName, className, molecule)

View File

@ -97,7 +97,7 @@ open class MoleculeStackView: Container {
removeAllItemViews()
// If the items in the stack are different, clear them, create new ones.
if (previousModel == nil) || nameForReuse(previousModel, delegateObject) != nameForReuse(model, delegateObject) {
if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) {
stackItems = []
createStackItemsFromModel(with: delegateObject)
} else if let models = stackModel?.molecules {
@ -111,25 +111,6 @@ open class MoleculeStackView: Container {
stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins
}
public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
// This will aggregate names of molecules to make an id.
guard let model = model as? MoleculeStackModel else {
return "stack<>"
}
var name = "stack<"
for case let item in model.molecules {
if let moleculeName = item.molecule.moleculeName {
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol, let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) {
name.append(nameForReuse + ",")
} else {
name.append(moleculeName + ",")
}
}
}
name.append(">")
return name
}
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
if model == nil {
let data = try! JSONSerialization.data(withJSONObject: json!)
@ -141,6 +122,26 @@ open class MoleculeStackView: Container {
}
}
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
// This will aggregate names of molecules to make an id.
guard let model = model as? MoleculeStackModel else {
return "stack<>"
}
var name = "stack<"
for case let item in model.molecules {
if let moleculeName = item.molecule.moleculeName {
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type,
let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) {
name.append(nameForReuse + ",")
} else {
name.append(moleculeName + ",")
}
}
}
name.append(">")
return name
}
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
// This will aggregate names of molecules to make an id.
guard let molecules = molecule?.optionalArrayForKey(KeyMolecules) else {
@ -222,8 +223,8 @@ open class MoleculeStackView: Container {
stackItem.translatesAutoresizingMaskIntoConstraints = false
let spacing = model.spacing ?? stackModel.spacing
let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percentage == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center))
let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percentage == nil ? .fill : .leading)
let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center))
let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading)
stackItem.containerHelper.alignHorizontal(horizontalAlignment)
stackItem.containerHelper.alignVertical(verticalAlignment)
@ -238,7 +239,7 @@ open class MoleculeStackView: Container {
}
pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0)
pinView(contentView, toView: stackItem, attribute: .trailing, relation: .equal, priority: .required, constant: 0)
if let percent = model.percentage {
if let percent = model.percent {
stackItem.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
}
if lastItem {
@ -255,7 +256,7 @@ open class MoleculeStackView: Container {
}
pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0)
pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
if let percent = model.percentage {
if let percent = model.percent {
stackItem.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
}
if lastItem {

View File

@ -73,6 +73,7 @@
@"headlineBodyButton": HeadlineBodyButton.class,
@"stackItem": StackItem.class,
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class,
@"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class,
@"stackItem": StackItem.class,
@"doughnutChart": DoughnutChartView.class,
@"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class

View File

@ -25,10 +25,13 @@ import Foundation
ModelRegistry.register(ScrollerModel.self)
ModelRegistry.register(CornerLabelsModel.self)
ModelRegistry.register(LineModel.self)
ModelRegistry.register(CircleProgressModel.self)
ModelRegistry.register(HeadlineBodyCaretLinkImageModel.self)
// buttons
ModelRegistry.register(ButtonModel.self)
ModelRegistry.register(TwoButtonViewModel.self)
ModelRegistry.register(LinkModel.self)
ModelRegistry.register(CaretLinkModel.self)
// list items
ModelRegistry.register(ListItemModel.self)
ModelRegistry.register(DropDownListItemModel.self)
@ -38,7 +41,7 @@ import Foundation
//need to move labelattributemodel to different method
ModelRegistry.register(LabelAttributeFontModel.self)
ModelRegistry.register(LabelAttributeColorModel.self)
ModelRegistry.register(LabelAttributeImageModel.self)
//ModelRegistry.register(LabelAttributeImageModel.self) // We need to separate the registry by types due to collisions...
ModelRegistry.register(LabelAttributeUnderlineModel.self)
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
ModelRegistry.register(LabelAttributeActionModel.self)

View File

@ -167,7 +167,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? {
guard let listItem = listItem,
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem),
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else {
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else {
return nil
}
return (moleculeName, moleculeClass, listItem)