Code cleanup and realigned file structure.

This commit is contained in:
Lekshmi S 2020-04-24 12:40:11 +05:30
parent e34e859aa1
commit 0f4c11e2f2
4 changed files with 16 additions and 38 deletions

View File

@ -1122,15 +1122,6 @@
name = "Recovered References"; name = "Recovered References";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
AA2AD114244EE43900BBFFE3 /* DeviceItems */ = {
isa = PBXGroup;
children = (
AA2AD115244EE46800BBFFE3 /* ListDeviceComplexLinkMedium.swift */,
AA2AD117244EE48C00BBFFE3 /* ListDeviceComplexLinkMediumModel.swift */,
);
path = DeviceItems;
sourceTree = "<group>";
};
AA4FC2A323F4F69600E251DB /* RightVariable */ = { AA4FC2A323F4F69600E251DB /* RightVariable */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -1190,6 +1181,8 @@
children = ( children = (
BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */, BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */,
BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */, BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */,
AA2AD117244EE48C00BBFFE3 /* ListDeviceComplexLinkMediumModel.swift */,
AA2AD115244EE46800BBFFE3 /* ListDeviceComplexLinkMedium.swift */,
); );
path = Device; path = Device;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1393,7 +1386,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D20FFFB42451E32100A31DA2 /* Device */, D20FFFB42451E32100A31DA2 /* Device */,
AA2AD114244EE43900BBFFE3 /* DeviceItems */,
52267A0523FFE0A900906CBA /* OneColumn */, 52267A0523FFE0A900906CBA /* OneColumn */,
D22D8396241FDE4700D3DF69 /* TwoColumn */, D22D8396241FDE4700D3DF69 /* TwoColumn */,
8DD1E36C243B3CD900D8F2DF /* ThreeColumn */, 8DD1E36C243B3CD900D8F2DF /* ThreeColumn */,

View File

@ -152,7 +152,6 @@ import Foundation
MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsage.self, viewModelClass: ListThreeColumnDataUsageModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsage.self, viewModelClass: ListThreeColumnDataUsageModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexLinkMedium.self, viewModelClass: ListDeviceComplexLinkMediumModel.self)
// Designed Section Dividers // Designed Section Dividers
MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self)
@ -169,9 +168,9 @@ import Foundation
// Designed Headers // Designed Headers
MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self)
// Device Items // Device Items
MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexButtonMedium.self, viewModelClass: ListDeviceComplexButtonMediumModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexButtonMedium.self, viewModelClass: ListDeviceComplexButtonMediumModel.self)
MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexLinkMedium.self, viewModelClass: ListDeviceComplexLinkMediumModel.self)
// TODO: Need View // TODO: Need View
try? ModelRegistry.register(TabsModel.self) try? ModelRegistry.register(TabsModel.self)

View File

@ -12,23 +12,23 @@ import Foundation
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//----------------------------------------------------- //-----------------------------------------------------
private let stack: Stack<StackModel>
public let eyebrow = Label.createLabelRegularMicro(true) public let eyebrow = Label.createLabelRegularMicro(true)
public let headline = Label.createLabelBoldTitleMedium(true) public let headline = Label.createLabelBoldTitleMedium(true)
public let body = Label.createLabelRegularBodySmall(true) public let body = Label.createLabelRegularBodySmall(true)
public let body2 = Label.createLabelRegularBodySmall(true) public let body2 = Label.createLabelRegularBodySmall(true)
public let link = Link() public let link = Link()
public let rightImage = MFLoadImageView(pinnedEdges: .all) public let rightImage = MFLoadImageView()
let leftStack: Stack<StackModel> let verticalStack: Stack<StackModel>
public let stack: Stack<StackModel>
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//------------------------------------------------------ //------------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
leftStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)), (view: headline, model: StackItemModel(horizontalAlignment: .leading)), (view: body, model: StackItemModel(horizontalAlignment: .leading)), (view: body2, model: StackItemModel(horizontalAlignment: .leading)), (view: link, model: StackItemModel(horizontalAlignment: .leading))], axis: .vertical, spacing: 0)
leftStack.stackModel?.molecules[4].spacing = 16
rightImage.addSizeConstraintsForAspectRatio = true rightImage.addSizeConstraintsForAspectRatio = true
stack = Stack<StackModel>.createStack(with: [(view: leftStack, model: StackItemModel(horizontalAlignment: .leading)), (view: rightImage, model: StackItemModel(verticalAlignment: .center))], axis: .horizontal) verticalStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)), (view: headline, model: StackItemModel(horizontalAlignment: .leading)), (view: body, model: StackItemModel(horizontalAlignment: .leading)), (view: body2, model: StackItemModel(horizontalAlignment: .leading)), (view: link, model: StackItemModel(spacing: 16, horizontalAlignment: .leading))], axis: .vertical, spacing: 0)
stack = Stack<StackModel>.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading)), (view: rightImage, model: StackItemModel(verticalAlignment: .center))], axis: .horizontal)
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
} }
@ -43,7 +43,7 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
leftStack.restack() verticalStack.restack()
} }
//------------------------------------------------------ //------------------------------------------------------
@ -52,11 +52,7 @@ import Foundation
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.set(with: model, delegateObject, additionalData) super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListDeviceComplexLinkMediumModel else { return } guard let model = model as? ListDeviceComplexLinkMediumModel else { return }
eyebrow.setOptional(with: model.eyebrow, delegateObject, additionalData) verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.link], delegateObject, additionalData)
headline.setOptional(with: model.headline, delegateObject, additionalData)
body.setOptional(with: model.body, delegateObject, additionalData)
body2.setOptional(with: model.body2, delegateObject, additionalData)
link.set(with: model.link, delegateObject, additionalData)
rightImage.set(with: model.image, delegateObject, additionalData) rightImage.set(with: model.image, delegateObject, additionalData)
} }
@ -70,6 +66,7 @@ import Foundation
headline.styleBoldTitleMedium(true) headline.styleBoldTitleMedium(true)
body.styleRegularBodySmall(true) body.styleRegularBodySmall(true)
body2.styleRegularBodySmall(true) body2.styleRegularBodySmall(true)
eyebrow.textColor = .mvmCoolGray6
} }
} }

View File

@ -8,7 +8,6 @@
import Foundation import Foundation
public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProtocol { public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProtocol {
public static var identifier: String = "listDvcLnkM" public static var identifier: String = "listDvcLnkM"
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var headline: LabelModel? public var headline: LabelModel?
@ -30,7 +29,6 @@ public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProto
/// Defaults to set /// Defaults to set
override public func setDefaults() { override public func setDefaults() {
super.setDefaults() super.setDefaults()
eyebrow?.textColor = Color(uiColor: .mvmCoolGray6)
if image.width == nil, image.height == nil { if image.width == nil, image.height == nil {
image.width = 116 image.width = 116
image.height = 116 image.height = 116
@ -49,18 +47,10 @@ public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProto
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
if let eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) { eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
self.eyebrow = eyebrow headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline)
} body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
if let headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) { body2 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body2)
self.headline = headline
}
if let body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) {
self.body = body
}
if let body2 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body2) {
self.body2 = body2
}
link = try typeContainer.decode(LinkModel.self, forKey: .link) link = try typeContainer.decode(LinkModel.self, forKey: .link)
image = try typeContainer.decode(ImageViewModel.self, forKey: .image) image = try typeContainer.decode(ImageViewModel.self, forKey: .image)
try super.init(from: decoder) try super.init(from: decoder)