Code improvement.

This commit is contained in:
Subhankar Acharya 2020-02-26 19:03:42 +05:30
parent e31918c051
commit 224148d36f
4 changed files with 136 additions and 0 deletions

View File

@ -101,6 +101,8 @@
52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; };
5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */; };
5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */; };
525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525019E42406852100EED91C /* ListFourColumnDataUsageDividerModel.swift */; };
525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */; };
8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; };
8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; };
8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; };
@ -435,6 +437,8 @@
52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = "<group>"; };
5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnPlanDataDivider.swift; sourceTree = "<group>"; };
5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnPlanDataDividerModel.swift; sourceTree = "<group>"; };
525019E42406852100EED91C /* ListFourColumnDataUsageDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageDividerModel.swift; sourceTree = "<group>"; };
525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageDivider.swift; sourceTree = "<group>"; };
8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = "<group>"; };
8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = "<group>"; };
8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = "<group>"; };
@ -781,6 +785,15 @@
path = OneColumn;
sourceTree = "<group>";
};
525019E3240684E500EED91C /* FourColumn */ = {
isa = PBXGroup;
children = (
525019E42406852100EED91C /* ListFourColumnDataUsageDividerModel.swift */,
525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */,
);
path = FourColumn;
sourceTree = "<group>";
};
946EE1B5237B663A0036751F /* Extensions */ = {
isa = PBXGroup;
children = (
@ -1024,6 +1037,7 @@
D22B38EC23F4E10700490EF6 /* SectionDividers */ = {
isa = PBXGroup;
children = (
525019E3240684E500EED91C /* FourColumn */,
52267A0523FFE0A900906CBA /* OneColumn */,
D22B38ED23F4E11100490EF6 /* ThreeColumn */,
);
@ -1758,6 +1772,7 @@
D2B18B812360945C00A9AEDC /* View.swift in Sources */,
C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */,
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */,
0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */,
94FB966323D797DA003D482B /* MFTextButton.m in Sources */,
D260105323CEA61600764D80 /* ToggleModel.swift in Sources */,
@ -1818,6 +1833,7 @@
0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */,
8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */,
D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */,
525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */,
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */,
0A21DB89235E06EF00C160A2 /* MFMdnTextField.m in Sources */,
D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */,

View File

@ -0,0 +1,60 @@
//
// ListFourColumnDataUsageDivider.swift
// MVMCoreUI
//
// Created by Lekshmi S on 18/02/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class ListFourColumnDataUsageDivider: TableViewCell {
// MARK: - MFViewProtocol
let label1 = Label.commonLabelB1(true)
let label2 = Label.commonLabelB1(true)
let label3 = Label.commonLabelB1(true)
let label4 = Label.commonLabelB1(true)
let stack = Stack<StackModel>(frame: .zero)
// MARK: - MFViewProtocol
open override func setupView() {
super.setupView()
stack.stackItems = [StackItem(andContain: label1),
StackItem(andContain: label2),
StackItem(andContain: label3),
StackItem(andContain: label4)]
addMolecule(stack)
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model as? ListFourColumnDataUsageDividerModel else { return }
label1.setWithModel(model.label1, delegateObject, additionalData)
label2.setWithModel(model.label2, delegateObject, additionalData)
label3.setWithModel(model.label3, delegateObject, additionalData)
label4.setWithModel(model.label4, delegateObject, additionalData)
//Create a stack model to use for the internal stack and set the alignment of labels
let stackModel = StackModel(molecules: [StackItemModel(percent: 15, horizontalAlignment: .leading),
StackItemModel(percent: 35, horizontalAlignment: .leading),
StackItemModel(percent: 30, horizontalAlignment: .trailing),
StackItemModel(percent: 20, horizontalAlignment: .trailing)],
axis: .horizontal)
stack.model = stackModel
stack.restack()
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func reset() {
super.reset()
label1.styleB1(true)
label2.styleB1(true)
label3.styleB1(true)
label4.styleB1(true)
}
open override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return 121
}
}

View File

@ -0,0 +1,59 @@
//
// ListFourColumnDataUsageDividerModel.swift
// MVMCoreUI
//
// Created by Lekshmi S on 18/02/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public class ListFourColumnDataUsageDividerModel: ListItemModel, MoleculeModelProtocol {
public static var identifier: String = "list4CDiv"
public var label1: LabelModel
public var label2: LabelModel
public var label3: LabelModel
public var label4: LabelModel
public init(label1: LabelModel, label2: LabelModel, label3: LabelModel, label4: LabelModel) {
self.label1 = label1
self.label2 = label2
self.label3 = label3
self.label4 = label4
super.init()
setDefaults()
}
// Defaults to set
override public func setDefaults() {
super.setDefaults()
style = "tallDivider"
}
private enum CodingKeys: String, CodingKey {
case moleculeName
case label1
case label2
case label3
case label4
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
label1 = try typeContainer.decode(LabelModel.self, forKey: .label1)
label2 = try typeContainer.decode(LabelModel.self, forKey: .label2)
label3 = try typeContainer.decode(LabelModel.self, forKey: .label3)
label4 = try typeContainer.decode(LabelModel.self, forKey: .label4)
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(label1, forKey: .label1)
try container.encode(label2, forKey: .label2)
try container.encode(label3, forKey: .label3)
try container.encode(label4, forKey: .label4)
}
}

View File

@ -56,6 +56,7 @@ import Foundation
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ImageHeadlineBody.self, viewModelClass: ImageHeadlineBodyModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self)