stack flexibility update
molecule container protocol fix missing functions update numbered and unordered list to more model approach
This commit is contained in:
parent
d26d3b1e40
commit
9847ef5302
@ -107,15 +107,15 @@
|
||||
94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; };
|
||||
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; };
|
||||
C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; };
|
||||
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; };
|
||||
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; };
|
||||
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; };
|
||||
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; };
|
||||
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; };
|
||||
C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; };
|
||||
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; };
|
||||
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; };
|
||||
C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */; };
|
||||
C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */; };
|
||||
C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */; };
|
||||
C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5123C77A4900A3614A /* NumberedList.swift */; };
|
||||
C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; };
|
||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
||||
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
|
||||
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; };
|
||||
@ -272,6 +272,8 @@
|
||||
D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32821EE8736003B2FB9 /* Localizable.strings */; };
|
||||
D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */; };
|
||||
D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */; };
|
||||
D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */; };
|
||||
D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */; };
|
||||
D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -370,9 +372,9 @@
|
||||
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = "<group>"; };
|
||||
0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; };
|
||||
0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = "<group>"; };
|
||||
0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = "<group>"; };
|
||||
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = "<group>"; };
|
||||
0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = "<group>"; };
|
||||
0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = "<group>"; };
|
||||
0ABD136A237B193A0081388D /* EntryFieldContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = "<group>"; };
|
||||
0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = "<group>"; };
|
||||
0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = "<group>"; };
|
||||
@ -396,15 +398,15 @@
|
||||
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = "<group>"; };
|
||||
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = "<group>"; };
|
||||
C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
|
||||
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = "<group>"; };
|
||||
C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = "<group>"; };
|
||||
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = "<group>"; };
|
||||
C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = "<group>"; };
|
||||
C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = "<group>"; };
|
||||
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; };
|
||||
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = "<group>"; };
|
||||
C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = "<group>"; };
|
||||
C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedList.swift; sourceTree = "<group>"; };
|
||||
C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelRightMoleculesStack.swift; sourceTree = "<group>"; };
|
||||
C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeStack.swift; sourceTree = "<group>"; };
|
||||
C6FA7D5123C77A4900A3614A /* NumberedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedList.swift; sourceTree = "<group>"; };
|
||||
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; };
|
||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
||||
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
|
||||
D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = "<group>"; };
|
||||
@ -575,6 +577,8 @@
|
||||
D29DF32A21EE8736003B2FB9 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
D29DF32B21EE8736003B2FB9 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||
D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
|
||||
D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeView.swift; sourceTree = "<group>"; };
|
||||
D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeModel.swift; sourceTree = "<group>"; };
|
||||
D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeMappingObject.h; sourceTree = "<group>"; };
|
||||
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIMoleculeMappingObject.m; sourceTree = "<group>"; };
|
||||
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeViewProtocol.h; sourceTree = "<group>"; };
|
||||
@ -701,8 +705,6 @@
|
||||
012A88AE238C626E00FE3DA1 /* CarouselModel.swift */,
|
||||
012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */,
|
||||
012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */,
|
||||
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */,
|
||||
C695A68023C9830D00BFB94E /* NumberedListModel.swift */,
|
||||
);
|
||||
path = Molecules;
|
||||
sourceTree = "<group>";
|
||||
@ -715,7 +717,7 @@
|
||||
path = Protocols;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0ABD1369237B18EE0081388D /* views */ = {
|
||||
0ABD1369237B18EE0081388D /* views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0ABD136A237B193A0081388D /* EntryFieldContainer.swift */,
|
||||
@ -723,14 +725,6 @@
|
||||
path = views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0AA33B322398134B0067DD0F /* Primitive Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0AA33B35239813EE0067DD0F /* Color.swift */,
|
||||
);
|
||||
path = "Primitive Models";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
946EE1B5237B663A0036751F /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -807,6 +801,7 @@
|
||||
D224798D2316A988003FCCF9 /* VerticalCombinationViews */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D29E28D423D1FFFA00ACEA85 /* Lists */,
|
||||
D2A638FC22CA98280052ED1F /* HeadlineBody.swift */,
|
||||
01EB368D23609801006832FA /* HeadlineBodyModel.swift */,
|
||||
D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */,
|
||||
@ -988,9 +983,6 @@
|
||||
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */,
|
||||
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
|
||||
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */,
|
||||
C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */,
|
||||
C6FA7D5123C77A4900A3614A /* NumberedList.swift */,
|
||||
C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */,
|
||||
D260105723CF9CC500764D80 /* Doughnut */,
|
||||
);
|
||||
path = Molecules;
|
||||
@ -1299,6 +1291,28 @@
|
||||
path = Strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D29E28D423D1FFFA00ACEA85 /* Lists */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D29E28DB23D21B0A00ACEA85 /* StringAndMoleculeStack */,
|
||||
C695A68023C9830D00BFB94E /* NumberedListModel.swift */,
|
||||
C6FA7D5123C77A4900A3614A /* NumberedList.swift */,
|
||||
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */,
|
||||
C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */,
|
||||
);
|
||||
path = Lists;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D29E28DB23D21B0A00ACEA85 /* StringAndMoleculeStack */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D29E28D923D21AFA00ACEA85 /* StringAndMoleculeModel.swift */,
|
||||
D29E28D723D21AB800ACEA85 /* StringAndMoleculeView.swift */,
|
||||
C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */,
|
||||
);
|
||||
path = StringAndMoleculeStack;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D2B18B7D236090D500A9AEDC /* BaseClasses */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -1543,6 +1557,7 @@
|
||||
D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */,
|
||||
012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */,
|
||||
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
||||
D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */,
|
||||
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
||||
D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */,
|
||||
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */,
|
||||
@ -1563,6 +1578,7 @@
|
||||
D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */,
|
||||
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */,
|
||||
D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */,
|
||||
D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */,
|
||||
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */,
|
||||
D260105D23D0BCD400764D80 /* Stack.swift in Sources */,
|
||||
D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */,
|
||||
@ -1589,7 +1605,7 @@
|
||||
011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */,
|
||||
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */,
|
||||
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */,
|
||||
C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */,
|
||||
C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */,
|
||||
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
||||
D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -203,6 +203,7 @@ open class Container: View, ContainerProtocol {
|
||||
get { return model as? ContainerModelProtocol }
|
||||
}
|
||||
|
||||
// MARK:- ModelMoleculeViewProtocol
|
||||
override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithModel(model, delegateObject, additionalData)
|
||||
guard let containerModel = model as? ContainerModelProtocol else { return }
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
//
|
||||
// NumberedListModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 10/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class NumberedListModel: OrderListProtocol {
|
||||
public var backgroundColor: Color?
|
||||
public static var identifier: String = "numberedList"
|
||||
public var list: [MoleculeProtocol]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case list
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
list = try typeContainer.decodeMolecules(codingKey: .list)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeModels(list, forKey: .list)
|
||||
}
|
||||
}
|
||||
|
||||
public protocol OrderListProtocol: MoleculeProtocol {
|
||||
var list: [MoleculeProtocol] {get}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
//
|
||||
// UnOrderedListModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 10/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class UnOrderedListModel: OrderListProtocol {
|
||||
public var backgroundColor: Color?
|
||||
public static var identifier: String = "unOrderedList"
|
||||
public var bulletChar: String?
|
||||
public var list: [MoleculeProtocol]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case bulletChar
|
||||
case list
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar)
|
||||
list = try typeContainer.decodeMolecules(codingKey: .list)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(bulletChar, forKey: .bulletChar)
|
||||
try container.encodeModels(list, forKey: .list)
|
||||
}
|
||||
}
|
||||
@ -94,12 +94,12 @@ extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol {
|
||||
}
|
||||
|
||||
class ColorViewLabelsStack: MoleculeStackView {
|
||||
override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
|
||||
override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
guard let stackItemModels = stackModel?.molecules else { return }
|
||||
for model in stackItemModels {
|
||||
let view = ColorViewWithLabel()
|
||||
let stackItem = MoleculeStackItem(andContain: view)
|
||||
stackItem.setWithModel(model, delegate, nil)
|
||||
stackItem.setWithModel(model, delegateObject, additionalData)
|
||||
stackItems.append(stackItem)
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class StackItemModel: StackItemModelProtocol, Codable {
|
||||
@objcMembers public class StackItemModel: StackItemModelProtocol, MoleculeProtocol {
|
||||
public static var identifier: String = "simpleStackItem"
|
||||
public var backgroundColor: Color?
|
||||
public var spacing: CGFloat?
|
||||
public var percent: Int?
|
||||
public var gone: Bool = false
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol StackItemModelProtocol {
|
||||
public protocol StackItemModelProtocol: MoleculeProtocol {
|
||||
var spacing: CGFloat? { get set }
|
||||
var percent: Int? { get set }
|
||||
var gone: Bool { get set }
|
||||
|
||||
@ -1,167 +0,0 @@
|
||||
//
|
||||
// ListMoleculeContainer.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 03/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class LabelRightMoleculesStack: MoleculeStackView {
|
||||
|
||||
var orderedListModel: OrderListProtocol?
|
||||
|
||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
let previousModel = self.orderedListModel
|
||||
//Remove previously drawn views
|
||||
removeAllItemViews()
|
||||
guard let orderedListModel = model as? OrderListProtocol else {
|
||||
return
|
||||
}
|
||||
|
||||
var items: [StackItem]?
|
||||
if previousModel?.list.count == orderedListModel.list.count {
|
||||
items = stackItems
|
||||
}
|
||||
stackItems = []
|
||||
self.model = MoleculeStackModel(molecules: [])
|
||||
for (index, labelModel) in orderedListModel.list.enumerated() {
|
||||
let labelContainer = items?[index].view as? LeftLabelRightMoleculeContainer ?? LeftLabelRightMoleculeContainer()
|
||||
labelContainer.leftText = leftTextForIndex(index)
|
||||
labelContainer.setWithModel(labelModel, delegateObject, additionalData)
|
||||
addView(labelContainer, lastItem: index == orderedListModel.list.count - 1)
|
||||
}
|
||||
self.orderedListModel = orderedListModel
|
||||
restack()
|
||||
}
|
||||
|
||||
//MARK: - Subclass should overirde this
|
||||
func leftTextForIndex(_ index: Int) -> String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
class LeftLabelRightMoleculeContainer: View {
|
||||
|
||||
var label = Label.commonLabelB2(true)
|
||||
var rightContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||
var leftContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||
var rightMoleculeName: String?
|
||||
var rightMolecule: View?
|
||||
var leftText: String?
|
||||
var leftWidthConstraint: NSLayoutConstraint?
|
||||
var percentage: CGFloat = 5
|
||||
|
||||
var constraintBtwViews: NSLayoutConstraint?
|
||||
var spaceBtwViews: CGFloat = 0 {
|
||||
didSet {
|
||||
if spaceBtwViews != oldValue {
|
||||
constraintBtwViews?.constant = spaceBtwViews
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Inits
|
||||
public convenience init() {
|
||||
self.init(frame:.zero)
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
}
|
||||
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func setupView() {
|
||||
super.setupView()
|
||||
|
||||
guard rightContainer.superview == nil else {
|
||||
return
|
||||
}
|
||||
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(rightContainer)
|
||||
addSubview(leftContainer)
|
||||
leftContainer.addSubview(label)
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||
leftContainer.rightAnchor.constraint(greaterThanOrEqualTo: label.rightAnchor).isActive = true
|
||||
leftContainer.bottomAnchor.constraint(greaterThanOrEqualTo: label.bottomAnchor).isActive = true
|
||||
|
||||
let lowRightConstraint = leftContainer.rightAnchor.constraint(equalTo: label.rightAnchor)
|
||||
lowRightConstraint.priority = UILayoutPriority(rawValue: 200)
|
||||
lowRightConstraint.isActive = true
|
||||
|
||||
let lowBottomConstraint = leftContainer.bottomAnchor.constraint(equalTo: label.bottomAnchor)
|
||||
lowBottomConstraint.priority = UILayoutPriority(rawValue: 200)
|
||||
lowBottomConstraint.isActive = true
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(leftContainer, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: leftContainer.bottomAnchor).isActive = true
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(rightContainer, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true)
|
||||
constraintBtwViews = rightContainer.leftAnchor.constraint(equalTo: leftContainer.rightAnchor, constant: spaceBtwViews)
|
||||
constraintBtwViews?.priority = .required
|
||||
constraintBtwViews?.isActive = true
|
||||
|
||||
setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
updateLeftViewWidthConstraint(percentage)
|
||||
|
||||
}
|
||||
|
||||
override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
rightMolecule?.updateView(size)
|
||||
label.updateView(size)
|
||||
updateLeftViewWidthConstraint(percentage)
|
||||
setNeedsDisplay()
|
||||
}
|
||||
|
||||
override func reset() {
|
||||
super.reset()
|
||||
rightMolecule?.reset()
|
||||
}
|
||||
|
||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
let previousMoleculeName = self.rightMoleculeName
|
||||
super.setWithModel(model, delegateObject, additionalData)
|
||||
removeSubviewsInRightContainer()
|
||||
label.text = leftText
|
||||
rightMoleculeName = model?.moleculeName
|
||||
guard let validModel = model else {
|
||||
return
|
||||
}
|
||||
//For reuse purpose check that allready added molecule is same
|
||||
if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName {
|
||||
rightMolecule.setWithModel(validModel, delegateObject, additionalData)
|
||||
addView(rightMolecule)
|
||||
} else {
|
||||
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(validModel, delegateObject, false) {
|
||||
addView(molecule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateLeftViewWidthConstraint(_ percent: CGFloat) {
|
||||
percentage = percent
|
||||
leftWidthConstraint?.isActive = false
|
||||
leftWidthConstraint = leftContainer.widthAnchor.constraint(equalTo: widthAnchor, multiplier: CGFloat(percent/100), constant: 0)
|
||||
leftWidthConstraint?.isActive = true
|
||||
}
|
||||
|
||||
func removeSubviewsInRightContainer() {
|
||||
rightContainer.subviews.forEach({ $0.removeFromSuperview() })
|
||||
}
|
||||
|
||||
func addView(_ view: UIView) {
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
rightContainer.addSubview(view)
|
||||
NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true)
|
||||
rightMolecule = view as? View
|
||||
}
|
||||
}
|
||||
@ -42,4 +42,28 @@ open class MoleculeContainer: Container {
|
||||
}
|
||||
super.setWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
public override static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||
guard let containerModel = model as? MoleculeContainerModel,
|
||||
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type,
|
||||
let moleculeName = moleculeClass.nameForReuse(containerModel.molecule, delegateObject) else {
|
||||
return "\(model?.moleculeName ?? "moleculeContainer")<>"
|
||||
}
|
||||
return "\(model?.moleculeName ?? "moleculeContainer")<\(moleculeName)>"
|
||||
}
|
||||
|
||||
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
guard let containerModel = molecule as? MoleculeContainerModel else { return 0 }
|
||||
guard let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type,
|
||||
let moleculeHeight = moleculeClass.estimatedHeight(forRow: containerModel.molecule, delegateObject: delegateObject) else {
|
||||
return (containerModel.topMarginPadding ?? 0) + (containerModel.bottomMarginPadding ?? 0)
|
||||
}
|
||||
return moleculeHeight + (containerModel.topMarginPadding ?? 0) + (containerModel.bottomMarginPadding ?? 0)
|
||||
}
|
||||
|
||||
public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||
guard let containerModel = molecule as? MoleculeContainerModel,
|
||||
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(containerModel.molecule) as? ModelMoleculeViewProtocol.Type else { return nil }
|
||||
return moleculeClass.requiredModules(containerModel.molecule, delegateObject: delegateObject, error: error)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
//
|
||||
// NumberedList.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 03/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class NumberedList: LabelRightMoleculesStack {
|
||||
|
||||
//MARK:- Super class override methods
|
||||
override func leftTextForIndex(_ index: Int) -> String {
|
||||
return String(index+1) + "."
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
//
|
||||
// UnOrderedList.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 03/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class UnOrderedList: LabelRightMoleculesStack {
|
||||
|
||||
//MARK:- Super class override methods
|
||||
override func leftTextForIndex(_ index: Int) -> String {
|
||||
return (orderedListModel as? UnOrderedListModel)?.bulletChar ?? "•"
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
//
|
||||
// NumberedList.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 03/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class NumberedList: StringAndMoleculeStack {
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
//
|
||||
// NumberedListModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 10/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class NumberedListModel: MoleculeStackModel {
|
||||
public override class var identifier: String {
|
||||
return "numberedList"
|
||||
}
|
||||
|
||||
private enum NumberedListCodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case backgroundColor
|
||||
case list
|
||||
}
|
||||
|
||||
// Numbered list model comes in the from of list = [MoleculeProtocol]
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: NumberedListCodingKeys.self)
|
||||
|
||||
let list = try typeContainer.decodeMolecules(codingKey: .list)
|
||||
var models: [MoleculeStackItemModel] = []
|
||||
for (index, molecule) in list.enumerated() {
|
||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index).", molecule: molecule)))
|
||||
}
|
||||
super.init(molecules: models)
|
||||
spacing = 0
|
||||
}
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: NumberedListCodingKeys.self)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
|
||||
var models: [MoleculeProtocol] = []
|
||||
for molecule in molecules {
|
||||
models.append(molecule.molecule)
|
||||
}
|
||||
try container.encodeModels(models, forKey: .list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
//
|
||||
// StringAndMoleculeModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 1/17/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class StringAndMoleculeModel: MoleculeProtocol {
|
||||
public static var identifier: String = "stringAndMoleculeModel"
|
||||
public var backgroundColor: Color?
|
||||
public var string: String
|
||||
public var molecule: MoleculeProtocol
|
||||
|
||||
public init(string: String, molecule: MoleculeProtocol) {
|
||||
self.string = string
|
||||
self.molecule = molecule
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case backgroundColor
|
||||
case string
|
||||
case molecule
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
string = try typeContainer.decode(String.self, forKey: .string)
|
||||
molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
try container.encode(string, forKey: .string)
|
||||
try container.encodeModel(molecule, forKey: .molecule)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
//
|
||||
// ListMoleculeContainer.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 03/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
// This class is only temporarily necessary. Eventually we will have initWithModel instad of just init for moleculeviews, which will remove this need.
|
||||
open class StringAndMoleculeStack: MoleculeStackView {
|
||||
override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
guard let model = stackModel else { return }
|
||||
for stackItemModel in model.molecules {
|
||||
guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel,
|
||||
let moleculeName = stringAndMoleculeModel.molecule.moleculeName,
|
||||
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: moleculeName) as? (UIView & ModelMoleculeViewProtocol) else {
|
||||
// Throw error
|
||||
return
|
||||
}
|
||||
let view = StringAndMoleculeView(string: stringAndMoleculeModel.string, molecule: molecule)
|
||||
let stackItem = MoleculeStackItem(andContain: view)
|
||||
stackItem.setWithModel(stackItemModel, delegateObject, nil)
|
||||
stackItems.append(stackItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
//
|
||||
// StringAndMoleculeView.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 1/17/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class StringAndMoleculeView: View {
|
||||
var label = Label.commonLabelB2(true)
|
||||
var string: String
|
||||
var molecule: UIView & ModelMoleculeViewProtocol
|
||||
|
||||
var leftWidthConstraint: NSLayoutConstraint?
|
||||
@Percent var percentage: CGFloat = 5
|
||||
|
||||
var constraintBetweenViews: NSLayoutConstraint?
|
||||
var spaceBetweenViews: CGFloat = 0 {
|
||||
didSet {
|
||||
if spaceBetweenViews != oldValue {
|
||||
constraintBetweenViews?.constant = spaceBetweenViews
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Inits
|
||||
public init(string: String, molecule: UIView & ModelMoleculeViewProtocol) {
|
||||
self.string = string
|
||||
self.molecule = molecule
|
||||
super.init(frame: .zero)
|
||||
}
|
||||
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override public func setupView() {
|
||||
super.setupView()
|
||||
guard subviews.count == 0 else {
|
||||
return
|
||||
}
|
||||
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(label)
|
||||
addSubview(molecule)
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: label.bottomAnchor).isActive = true
|
||||
|
||||
let lowBottomConstraint = bottomAnchor.constraint(equalTo: label.bottomAnchor)
|
||||
lowBottomConstraint.priority = UILayoutPriority(rawValue: 200)
|
||||
lowBottomConstraint.isActive = true
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(molecule, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true)
|
||||
constraintBetweenViews = molecule.leftAnchor.constraint(equalTo: label.rightAnchor, constant: spaceBetweenViews)
|
||||
constraintBetweenViews?.priority = .required
|
||||
constraintBetweenViews?.isActive = true
|
||||
|
||||
setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
updateLeftViewWidthConstraint(percentage)
|
||||
}
|
||||
|
||||
override open func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
(molecule as? MVMCoreViewProtocol)?.updateView(size)
|
||||
label.updateView(size)
|
||||
}
|
||||
|
||||
override open func reset() {
|
||||
super.reset()
|
||||
label.reset()
|
||||
(molecule as? MoleculeViewProtocol)?.reset?()
|
||||
}
|
||||
|
||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithModel(model, delegateObject, additionalData)
|
||||
guard let model = model as? StringAndMoleculeModel else { return }
|
||||
label.text = model.string
|
||||
molecule.setWithModel(model.molecule, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
func updateLeftViewWidthConstraint(_ percent: CGFloat) {
|
||||
percentage = percent
|
||||
leftWidthConstraint?.isActive = false
|
||||
leftWidthConstraint = label.widthAnchor.constraint(equalTo: widthAnchor, multiplier: CGFloat(percent/100), constant: 0)
|
||||
leftWidthConstraint?.isActive = true
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
//
|
||||
// UnOrderedList.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 03/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class UnOrderedList: StringAndMoleculeStack {
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
//
|
||||
// UnOrderedListModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 10/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class UnOrderedListModel: MoleculeStackModel {
|
||||
public override class var identifier: String {
|
||||
return "unOrderedList"
|
||||
}
|
||||
public var bulletChar = "•"
|
||||
|
||||
private enum NumberedListCodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case backgroundColor
|
||||
case list
|
||||
case bulletChar
|
||||
}
|
||||
|
||||
// Numbered list model comes in the from of list = [MoleculeProtocol]
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: NumberedListCodingKeys.self)
|
||||
if let bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar) {
|
||||
self.bulletChar = bulletChar
|
||||
}
|
||||
|
||||
let list = try typeContainer.decodeMolecules(codingKey: .list)
|
||||
var models: [MoleculeStackItemModel] = []
|
||||
for molecule in list {
|
||||
models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule)))
|
||||
}
|
||||
super.init(molecules: models)
|
||||
spacing = 0
|
||||
}
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: NumberedListCodingKeys.self)
|
||||
try container.encode(bulletChar, forKey: .bulletChar)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
|
||||
var models: [MoleculeProtocol] = []
|
||||
for molecule in molecules {
|
||||
models.append(molecule.molecule)
|
||||
}
|
||||
try container.encodeModels(models, forKey: .list)
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,9 @@
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol, StackModelProtocol {
|
||||
public static var identifier: String = "stack"
|
||||
public class var identifier: String {
|
||||
return "stack"
|
||||
}
|
||||
public var backgroundColor: Color?
|
||||
public var molecules: [MoleculeStackItemModel]
|
||||
public var axis: NSLayoutConstraint.Axis = .vertical
|
||||
|
||||
@ -23,10 +23,10 @@ open class MoleculeStackView: Stack<MoleculeStackModel> {
|
||||
|
||||
// MARK: - Adding to stack
|
||||
/// Creates all of the stackItems for the stackItemModels
|
||||
override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
|
||||
override func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
guard let stackItemModels = stackModel?.molecules else { return }
|
||||
for model in stackItemModels {
|
||||
if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? MoleculeStackItem {
|
||||
if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegateObject) as? MoleculeStackItem {
|
||||
stackItems.append(stackItem)
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,38 +94,26 @@ open class Stack<T>: Container where T: StackModelProtocol {
|
||||
removeAllItemViews()
|
||||
|
||||
// If the items in the stack are different, clear them, create new ones.
|
||||
if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) {
|
||||
if (previousModel == nil) || Self.nameForReuse(previousModel, delegateObject) != Self.nameForReuse(model, delegateObject) {
|
||||
stackItems = []
|
||||
createStackItemsFromModel(with: delegateObject)
|
||||
} else if let models = stackModel?.molecules {
|
||||
for (index, element) in models.enumerated() {
|
||||
(stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element as? MoleculeProtocol, delegateObject, additionalData)
|
||||
}
|
||||
createStackItemsFromModel(model, delegateObject, additionalData)
|
||||
} else {
|
||||
setStackItemsFromModel(model, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
restack()
|
||||
}
|
||||
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
if let model = model {
|
||||
setWithModel(model, delegateObject, additionalData)
|
||||
} else if let json = json,
|
||||
let data = try? JSONSerialization.data(withJSONObject: json),
|
||||
let model = try? JSONDecoder().decode(MoleculeStackModel.self, from: data) {
|
||||
setWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||
// This will aggregate names of molecules to make an id.
|
||||
guard let model = model as? MoleculeStackModel else {
|
||||
guard let model = model as? T else {
|
||||
return "stack<>"
|
||||
}
|
||||
var name = "stack<"
|
||||
for case let item in model.molecules {
|
||||
if let moleculeName = item.molecule.moleculeName {
|
||||
if let moleculeName = item.moleculeName {
|
||||
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type,
|
||||
let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) {
|
||||
let nameForReuse = moleculeClass.nameForReuse(item, delegateObject) {
|
||||
name.append(nameForReuse + ",")
|
||||
} else {
|
||||
name.append(moleculeName + ",")
|
||||
@ -138,7 +126,7 @@ open class Stack<T>: Container where T: StackModelProtocol {
|
||||
|
||||
// Need to update to take into account first spacing flag
|
||||
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
guard let model = molecule as? MoleculeStackModel else { return 0 }
|
||||
guard let model = molecule as? T else { return 0 }
|
||||
let horizontal = model.axis == .horizontal
|
||||
var estimatedHeight: CGFloat = 0
|
||||
for case let item in model.molecules {
|
||||
@ -157,7 +145,7 @@ open class Stack<T>: Container where T: StackModelProtocol {
|
||||
}
|
||||
|
||||
public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||
guard let model = molecule as? MoleculeStackModel else { return nil }
|
||||
guard let model = molecule as? T else { return nil }
|
||||
var modules: [String] = []
|
||||
for case let item in model.molecules {
|
||||
if let modulesForMolecule = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.requiredModules(item, delegateObject: delegateObject, error: error) {
|
||||
@ -167,11 +155,21 @@ open class Stack<T>: Container where T: StackModelProtocol {
|
||||
return modules.count > 0 ? modules : nil
|
||||
}
|
||||
|
||||
// MARK: - Adding to stack
|
||||
// MARK: - Subclassables
|
||||
|
||||
/// Can be subclassed to create views when we get stack item models and have no views yet
|
||||
func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
|
||||
func createStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
}
|
||||
|
||||
/// Can be subclassed to set stack items with model when we already have views
|
||||
func setStackItemsFromModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
guard let models = stackModel?.molecules else { return }
|
||||
for (index, element) in models.enumerated() {
|
||||
(stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element, delegateObject, additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Adding to stack
|
||||
/// Convenience function, adds a view to a StackItem to the Stack
|
||||
func addViewToItemToStack(_ view: UIView, lastItem: Bool) {
|
||||
let stackItemModel = StackItemModel()
|
||||
|
||||
@ -72,8 +72,6 @@
|
||||
@"headlineBodyButton": HeadlineBodyButton.class,
|
||||
@"stackItem": MoleculeStackItem.class,
|
||||
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class,
|
||||
@"unOrderedList": UnOrderedList.class,
|
||||
@"numberedList": NumberedList.class,
|
||||
@"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class,
|
||||
@"doughnutChart": DoughnutChartView.class,
|
||||
@"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class
|
||||
|
||||
@ -11,13 +11,23 @@ import Foundation
|
||||
@objcMembers public class MoleculeObjectMapping: NSObject {
|
||||
public static func registerObjects() {
|
||||
let mapping = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping
|
||||
mapping?.setObject(MoleculeStackView.self, forKey: "stack" as NSString)
|
||||
|
||||
ModelRegistry.register(MoleculeStackModel.self)
|
||||
mapping?.setObject(MoleculeStackView.self, forKey: MoleculeStackModel.identifier as NSString)
|
||||
ModelRegistry.register(StackModel.self)
|
||||
mapping?.setObject(Stack<StackModel>.self, forKey: StackModel.identifier as NSString)
|
||||
ModelRegistry.register(StackItemModel.self)
|
||||
mapping?.setObject(StackItem.self, forKey: StackItemModel.identifier as NSString)
|
||||
ModelRegistry.register(StringAndMoleculeModel.self)
|
||||
mapping?.setObject(StringAndMoleculeView.self, forKey: StringAndMoleculeModel.identifier as NSString)
|
||||
ModelRegistry.register(UnOrderedListModel.self)
|
||||
mapping?.setObject(UnOrderedList.self, forKey: UnOrderedListModel.identifier as NSString)
|
||||
ModelRegistry.register(NumberedListModel.self)
|
||||
mapping?.setObject(NumberedList.self, forKey: NumberedListModel.identifier as NSString)
|
||||
|
||||
ModelRegistry.register(LabelModel.self)
|
||||
ModelRegistry.register(HeaderModel.self)
|
||||
ModelRegistry.register(FooterModel.self)
|
||||
ModelRegistry.register(HeadlineBodyModel.self)
|
||||
ModelRegistry.register(MoleculeStackModel.self)
|
||||
ModelRegistry.register(MoleculeStackItemModel.self)
|
||||
ModelRegistry.register(TextFieldModel.self)
|
||||
ModelRegistry.register(ProgressBarModel.self)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user