unordered list added
numbered list added
This commit is contained in:
parent
99b97fd934
commit
30d864749a
@ -67,6 +67,11 @@
|
|||||||
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */; };
|
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */; };
|
||||||
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */; };
|
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */; };
|
||||||
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; };
|
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; };
|
||||||
|
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; };
|
||||||
|
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; };
|
||||||
|
C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */; };
|
||||||
|
C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */; };
|
||||||
|
C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5123C77A4900A3614A /* NumberedList.swift */; };
|
||||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
||||||
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.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 */; };
|
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; };
|
||||||
@ -307,6 +312,11 @@
|
|||||||
94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = "<group>"; };
|
94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = "<group>"; };
|
||||||
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = "<group>"; };
|
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>"; };
|
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.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>"; };
|
||||||
|
C6FA7D5123C77A4900A3614A /* NumberedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedList.swift; sourceTree = "<group>"; };
|
||||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.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>"; };
|
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>"; };
|
D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = "<group>"; };
|
||||||
@ -538,10 +548,20 @@
|
|||||||
017BEB3F23620A230024EF95 /* TextFieldModel.swift */,
|
017BEB3F23620A230024EF95 /* TextFieldModel.swift */,
|
||||||
017BEB4123620AD20024EF95 /* FormModelProtocol.swift */,
|
017BEB4123620AD20024EF95 /* FormModelProtocol.swift */,
|
||||||
017BEB7A236763000024EF95 /* LineModel.swift */,
|
017BEB7A236763000024EF95 /* LineModel.swift */,
|
||||||
|
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */,
|
||||||
|
C695A68023C9830D00BFB94E /* NumberedListModel.swift */,
|
||||||
);
|
);
|
||||||
path = Molecules;
|
path = Molecules;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
0A5D59C323AD488600EFD9E9 /* Protocols */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */,
|
||||||
|
);
|
||||||
|
path = Protocols;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
0AA33B322398134B0067DD0F /* Primitive Models */ = {
|
0AA33B322398134B0067DD0F /* Primitive Models */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -580,14 +600,6 @@
|
|||||||
name = "Recovered References";
|
name = "Recovered References";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
0A5D59C323AD488600EFD9E9 /* Protocols */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */,
|
|
||||||
);
|
|
||||||
path = Protocols;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
D213347423842FE3008E41B3 /* Controllers */ = {
|
D213347423842FE3008E41B3 /* Controllers */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -785,6 +797,9 @@
|
|||||||
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */,
|
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */,
|
||||||
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
|
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
|
||||||
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */,
|
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */,
|
||||||
|
C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */,
|
||||||
|
C6FA7D5123C77A4900A3614A /* NumberedList.swift */,
|
||||||
|
C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */,
|
||||||
);
|
);
|
||||||
path = Molecules;
|
path = Molecules;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1318,6 +1333,7 @@
|
|||||||
0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */,
|
0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */,
|
||||||
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */,
|
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */,
|
||||||
D2B18B812360945C00A9AEDC /* View.swift in Sources */,
|
D2B18B812360945C00A9AEDC /* View.swift in Sources */,
|
||||||
|
C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */,
|
||||||
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
|
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
|
||||||
D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */,
|
D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */,
|
||||||
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */,
|
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */,
|
||||||
@ -1343,6 +1359,7 @@
|
|||||||
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
|
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
|
||||||
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */,
|
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */,
|
||||||
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */,
|
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */,
|
||||||
|
C6FA7D5323C77A4A00A3614A /* LabelRightMoleculesStack.swift in Sources */,
|
||||||
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
||||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
||||||
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
||||||
@ -1358,10 +1375,12 @@
|
|||||||
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */,
|
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */,
|
||||||
D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */,
|
D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */,
|
||||||
D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */,
|
D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */,
|
||||||
|
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */,
|
||||||
017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */,
|
017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */,
|
||||||
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
|
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
|
||||||
D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */,
|
D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */,
|
||||||
017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */,
|
017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */,
|
||||||
|
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */,
|
||||||
012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */,
|
012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */,
|
||||||
01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */,
|
01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */,
|
||||||
D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */,
|
D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */,
|
||||||
@ -1400,6 +1419,7 @@
|
|||||||
D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */,
|
D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */,
|
||||||
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */,
|
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */,
|
||||||
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */,
|
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */,
|
||||||
|
C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */,
|
||||||
01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */,
|
01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */,
|
||||||
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */,
|
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */,
|
||||||
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
|
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
|
||||||
|
|||||||
33
MVMCoreUI/Models/Molecules/NumberedListModel.swift
Normal file
33
MVMCoreUI/Models/Molecules/NumberedListModel.swift
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// NumberedListModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Murugan, Vimal on 10/01/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers public class NumberedListModel: OrderListProtocol {
|
||||||
|
public var backgroundColor: String?
|
||||||
|
public static var identifier: String = "numberedList"
|
||||||
|
public var list: [LabelModel]
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case list
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.list = try typeContainer.decodeMolecules(codingKey: .list) as! [LabelModel]
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encodeModels(list, forKey: .list)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public protocol OrderListProtocol: MoleculeProtocol {
|
||||||
|
var list: [LabelModel] {get}
|
||||||
|
}
|
||||||
34
MVMCoreUI/Models/Molecules/UnOrderedListModel.swift
Normal file
34
MVMCoreUI/Models/Molecules/UnOrderedListModel.swift
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// UnOrderedListModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Murugan, Vimal on 10/01/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers public class UnOrderedListModel: OrderListProtocol {
|
||||||
|
|
||||||
|
public var backgroundColor: String?
|
||||||
|
public static var identifier: String = "unOrderedList"
|
||||||
|
public var bulletChar: String?
|
||||||
|
public var list: [LabelModel]
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case list
|
||||||
|
case bulletChar
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar)
|
||||||
|
self.list = try typeContainer.decodeMolecules(codingKey: .list) as! [LabelModel]
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encodeIfPresent(bulletChar, forKey: .bulletChar)
|
||||||
|
try container.encodeModels(list, forKey: .list)
|
||||||
|
}
|
||||||
|
}
|
||||||
199
MVMCoreUI/Molecules/LabelRightMoleculesStack.swift
Normal file
199
MVMCoreUI/Molecules/LabelRightMoleculesStack.swift
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
//
|
||||||
|
// ListMoleculeContainer.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Murugan, Vimal on 03/01/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
open class LabelRightMoleculesStack: MoleculeStackView {
|
||||||
|
|
||||||
|
var orderedListModel: OrderListProtocol?
|
||||||
|
|
||||||
|
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
|
let previousModel = self.orderedListModel
|
||||||
|
//Remove previously drawn views
|
||||||
|
removeAllItemViews()
|
||||||
|
guard let orderedListModel = model as? OrderListProtocol else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var items: [StackItem]?
|
||||||
|
if previousModel?.list.count == orderedListModel.list.count {
|
||||||
|
items = stackItems
|
||||||
|
}
|
||||||
|
stackItems = []
|
||||||
|
self.model = MoleculeStackModel(molecules: [])
|
||||||
|
for (index, labelModel) in orderedListModel.list.enumerated() {
|
||||||
|
let labelContainer = items?[index].view as? LeftLabelRightMoleculeContainer ?? LeftLabelRightMoleculeContainer()
|
||||||
|
labelContainer.leftText = leftTextForIndex(index)
|
||||||
|
labelContainer.setWithModel(labelModel, delegateObject, additionalData)
|
||||||
|
addView(labelContainer, lastItem: index == orderedListModel.list.count - 1)
|
||||||
|
}
|
||||||
|
self.orderedListModel = orderedListModel
|
||||||
|
restack()
|
||||||
|
}
|
||||||
|
|
||||||
|
//MARK: - Subclass should overirde this
|
||||||
|
func leftTextForIndex(_ index: Int) -> String {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LeftLabelRightMoleculeContainer: View {
|
||||||
|
|
||||||
|
var label = Label.commonLabelB2(true)
|
||||||
|
var rightContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||||
|
var leftContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||||
|
var rightMoleculeName: String?
|
||||||
|
var rightMolecule: View?
|
||||||
|
var leftText: String?
|
||||||
|
var leftWidthConstraint: NSLayoutConstraint?
|
||||||
|
var percentage: CGFloat = 5
|
||||||
|
|
||||||
|
var constraintBtwViews: NSLayoutConstraint?
|
||||||
|
var spaceBtwViews: CGFloat = 0 {
|
||||||
|
didSet {
|
||||||
|
if spaceBtwViews != oldValue {
|
||||||
|
constraintBtwViews?.constant = spaceBtwViews
|
||||||
|
setNeedsDisplay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Inits
|
||||||
|
public override init() {
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
|
super.init(frame: CGRect.zero)
|
||||||
|
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
|
||||||
|
guard rightContainer.superview == nil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
addSubview(rightContainer)
|
||||||
|
addSubview(leftContainer)
|
||||||
|
leftContainer.addSubview(label)
|
||||||
|
|
||||||
|
NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||||
|
leftContainer.rightAnchor.constraint(greaterThanOrEqualTo: label.rightAnchor).isActive = true
|
||||||
|
leftContainer.bottomAnchor.constraint(greaterThanOrEqualTo: label.bottomAnchor).isActive = true
|
||||||
|
|
||||||
|
let lowRightConstraint = leftContainer.rightAnchor.constraint(equalTo: label.rightAnchor)
|
||||||
|
lowRightConstraint.priority = UILayoutPriority(rawValue: 200)
|
||||||
|
lowRightConstraint.isActive = true
|
||||||
|
|
||||||
|
let lowBottomConstraint = leftContainer.bottomAnchor.constraint(equalTo: label.bottomAnchor)
|
||||||
|
lowBottomConstraint.priority = UILayoutPriority(rawValue: 200)
|
||||||
|
lowBottomConstraint.isActive = true
|
||||||
|
|
||||||
|
NSLayoutConstraint.constraintPinSubview(leftContainer, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||||
|
bottomAnchor.constraint(greaterThanOrEqualTo: leftContainer.bottomAnchor).isActive = true
|
||||||
|
|
||||||
|
NSLayoutConstraint.constraintPinSubview(rightContainer, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true)
|
||||||
|
constraintBtwViews = rightContainer.leftAnchor.constraint(equalTo: leftContainer.rightAnchor, constant: spaceBtwViews)
|
||||||
|
constraintBtwViews?.priority = .required
|
||||||
|
constraintBtwViews?.isActive = true
|
||||||
|
|
||||||
|
setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||||
|
setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||||
|
rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
|
||||||
|
rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
|
||||||
|
leftContainer.setContentHuggingPriority(.required, for: .horizontal)
|
||||||
|
leftContainer.setContentHuggingPriority(.required, for: .vertical)
|
||||||
|
updateLeftViewWidthConstraint(percentage)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
rightMolecule?.updateView(size)
|
||||||
|
label.updateView(size)
|
||||||
|
updateLeftViewWidthConstraint(percentage)
|
||||||
|
setNeedsDisplay()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func reset() {
|
||||||
|
super.reset()
|
||||||
|
rightMolecule?.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
|
let previousMoleculeName = model?.moleculeName
|
||||||
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
|
removeSubviewsInRightContainer()
|
||||||
|
guard let labelModel = model as? LabelModel else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
label.text = leftText
|
||||||
|
rightMoleculeName = labelModel.moleculeName
|
||||||
|
//For reuse purpose check that allready added molecule is same
|
||||||
|
if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName {
|
||||||
|
rightMolecule.setWithModel(labelModel, delegateObject, additionalData)
|
||||||
|
addView(rightMolecule)
|
||||||
|
} else {
|
||||||
|
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(labelModel, delegateObject, false) {
|
||||||
|
addView(molecule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
let previousMoleculeName = rightMoleculeName
|
||||||
|
removeSubviewsInRightContainer()
|
||||||
|
guard let moleculeJSON = json, let _ = moleculeJSON.optionalStringForKey(KeyMoleculeName) else {
|
||||||
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
label.text = leftText
|
||||||
|
rightMoleculeName = moleculeJSON.optionalStringForKey(KeyMoleculeName)
|
||||||
|
//For reuse purpose check that allready added molecule is same
|
||||||
|
if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName {
|
||||||
|
rightMolecule.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
addView(rightMolecule)
|
||||||
|
} else {
|
||||||
|
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: false) {
|
||||||
|
addView(molecule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateLeftViewWidthConstraint(_ percent: CGFloat) {
|
||||||
|
percentage = percent
|
||||||
|
leftWidthConstraint?.isActive = false
|
||||||
|
leftWidthConstraint = leftContainer.widthAnchor.constraint(equalTo: widthAnchor, multiplier: CGFloat(percent/100), constant: 0)
|
||||||
|
leftWidthConstraint?.isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeSubviewsInRightContainer() {
|
||||||
|
rightContainer.subviews.forEach({ $0.removeFromSuperview() })
|
||||||
|
}
|
||||||
|
|
||||||
|
func addView(_ view: UIView) {
|
||||||
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
rightContainer.addSubview(view)
|
||||||
|
NSLayoutConstraint.constraintPinSubview(view, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true)
|
||||||
|
rightMolecule = view as? View
|
||||||
|
}
|
||||||
|
}
|
||||||
18
MVMCoreUI/Molecules/NumberedList.swift
Normal file
18
MVMCoreUI/Molecules/NumberedList.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// NumberedList.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Murugan, Vimal on 03/01/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
open class NumberedList: LabelRightMoleculesStack {
|
||||||
|
|
||||||
|
//MARK:- Super class override methods
|
||||||
|
override func leftTextForIndex(_ index: Int) -> String {
|
||||||
|
return String(index+1) + "."
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
MVMCoreUI/Molecules/UnOrderedList.swift
Normal file
18
MVMCoreUI/Molecules/UnOrderedList.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// UnOrderedList.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Murugan, Vimal on 03/01/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
open class UnOrderedList: LabelRightMoleculesStack {
|
||||||
|
|
||||||
|
//MARK:- Super class override methods
|
||||||
|
override func leftTextForIndex(_ index: Int) -> String {
|
||||||
|
return (orderedListModel as? UnOrderedListModel)?.bulletChar ?? "•"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -68,7 +68,9 @@
|
|||||||
@"dropDownListItem": DropDownFilterTableViewCell.class,
|
@"dropDownListItem": DropDownFilterTableViewCell.class,
|
||||||
@"headlineBodyButton": HeadlineBodyButton.class,
|
@"headlineBodyButton": HeadlineBodyButton.class,
|
||||||
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class,
|
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class,
|
||||||
@"stackItem": StackItem.class
|
@"stackItem": StackItem.class,
|
||||||
|
@"unOrderedList": UnOrderedList.class,
|
||||||
|
@"numberedList": NumberedList.class
|
||||||
} mutableCopy];
|
} mutableCopy];
|
||||||
});
|
});
|
||||||
return mapping;
|
return mapping;
|
||||||
|
|||||||
@ -29,5 +29,7 @@ import Foundation
|
|||||||
ModelRegistry.register(LabelAttributeUnderlineModel.self)
|
ModelRegistry.register(LabelAttributeUnderlineModel.self)
|
||||||
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
|
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
|
||||||
ModelRegistry.register(LabelAttributeActionModel.self)
|
ModelRegistry.register(LabelAttributeActionModel.self)
|
||||||
|
ModelRegistry.register(NumberedListModel.self)
|
||||||
|
ModelRegistry.register(UnOrderedListModel.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user