From 0f4c11e2f2b7e9cd906c66eb537d9296b6fe5aef Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Fri, 24 Apr 2020 12:40:11 +0530 Subject: [PATCH] Code cleanup and realigned file structure. --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ++--------- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 3 +-- .../ListDeviceComplexLinkMedium.swift | 21 ++++++++----------- .../ListDeviceComplexLinkMediumModel.swift | 18 ++++------------ 4 files changed, 16 insertions(+), 38 deletions(-) rename MVMCoreUI/Atomic/Molecules/DesignedComponents/List/{DeviceItems => Device}/ListDeviceComplexLinkMedium.swift (65%) rename MVMCoreUI/Atomic/Molecules/DesignedComponents/List/{DeviceItems => Device}/ListDeviceComplexLinkMediumModel.swift (78%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2b5f17be..6511b1d2 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1122,15 +1122,6 @@ name = "Recovered References"; sourceTree = ""; }; - AA2AD114244EE43900BBFFE3 /* DeviceItems */ = { - isa = PBXGroup; - children = ( - AA2AD115244EE46800BBFFE3 /* ListDeviceComplexLinkMedium.swift */, - AA2AD117244EE48C00BBFFE3 /* ListDeviceComplexLinkMediumModel.swift */, - ); - path = DeviceItems; - sourceTree = ""; - }; AA4FC2A323F4F69600E251DB /* RightVariable */ = { isa = PBXGroup; children = ( @@ -1190,6 +1181,8 @@ children = ( BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */, BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */, + AA2AD117244EE48C00BBFFE3 /* ListDeviceComplexLinkMediumModel.swift */, + AA2AD115244EE46800BBFFE3 /* ListDeviceComplexLinkMedium.swift */, ); path = Device; sourceTree = ""; @@ -1393,7 +1386,6 @@ isa = PBXGroup; children = ( D20FFFB42451E32100A31DA2 /* Device */, - AA2AD114244EE43900BBFFE3 /* DeviceItems */, 52267A0523FFE0A900906CBA /* OneColumn */, D22D8396241FDE4700D3DF69 /* TwoColumn */, 8DD1E36C243B3CD900D8F2DF /* ThreeColumn */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 3ea55ae6..55aa6e9a 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -152,7 +152,6 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsage.self, viewModelClass: ListThreeColumnDataUsageModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexLinkMedium.self, viewModelClass: ListDeviceComplexLinkMediumModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) @@ -169,9 +168,9 @@ import Foundation // Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) - // Device Items MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexButtonMedium.self, viewModelClass: ListDeviceComplexButtonMediumModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexLinkMedium.self, viewModelClass: ListDeviceComplexLinkMediumModel.self) // TODO: Need View try? ModelRegistry.register(TabsModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/DeviceItems/ListDeviceComplexLinkMedium.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexLinkMedium.swift similarity index 65% rename from MVMCoreUI/Atomic/Molecules/DesignedComponents/List/DeviceItems/ListDeviceComplexLinkMedium.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexLinkMedium.swift index 53c957b4..e829554a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/DeviceItems/ListDeviceComplexLinkMedium.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexLinkMedium.swift @@ -12,23 +12,23 @@ import Foundation //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - private let stack: Stack public let eyebrow = Label.createLabelRegularMicro(true) public let headline = Label.createLabelBoldTitleMedium(true) public let body = Label.createLabelRegularBodySmall(true) public let body2 = Label.createLabelRegularBodySmall(true) public let link = Link() - public let rightImage = MFLoadImageView(pinnedEdges: .all) - let leftStack: Stack + public let rightImage = MFLoadImageView() + let verticalStack: Stack + public let stack: Stack //------------------------------------------------------ // MARK: - Initializers //------------------------------------------------------ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - leftStack = Stack.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 - stack = Stack.createStack(with: [(view: leftStack, model: StackItemModel(horizontalAlignment: .leading)), (view: rightImage, model: StackItemModel(verticalAlignment: .center))], axis: .horizontal) + verticalStack = Stack.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.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading)), (view: rightImage, model: StackItemModel(verticalAlignment: .center))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -43,7 +43,7 @@ import Foundation super.setupView() addMolecule(stack) stack.restack() - leftStack.restack() + verticalStack.restack() } //------------------------------------------------------ @@ -52,11 +52,7 @@ import Foundation open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListDeviceComplexLinkMediumModel else { return } - eyebrow.setOptional(with: model.eyebrow, 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) + verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.link], delegateObject, additionalData) rightImage.set(with: model.image, delegateObject, additionalData) } @@ -70,6 +66,7 @@ import Foundation headline.styleBoldTitleMedium(true) body.styleRegularBodySmall(true) body2.styleRegularBodySmall(true) + eyebrow.textColor = .mvmCoolGray6 } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/DeviceItems/ListDeviceComplexLinkMediumModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexLinkMediumModel.swift similarity index 78% rename from MVMCoreUI/Atomic/Molecules/DesignedComponents/List/DeviceItems/ListDeviceComplexLinkMediumModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexLinkMediumModel.swift index 683a7d52..66c88183 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/DeviceItems/ListDeviceComplexLinkMediumModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexLinkMediumModel.swift @@ -8,7 +8,6 @@ import Foundation public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProtocol { - public static var identifier: String = "listDvcLnkM" public var eyebrow: LabelModel? public var headline: LabelModel? @@ -30,7 +29,6 @@ public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProto /// Defaults to set override public func setDefaults() { super.setDefaults() - eyebrow?.textColor = Color(uiColor: .mvmCoolGray6) if image.width == nil, image.height == nil { image.width = 116 image.height = 116 @@ -49,18 +47,10 @@ public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProto required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - if let eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) { - self.eyebrow = eyebrow - } - if let headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) { - 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 - } + eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) + headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) + body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) + body2 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body2) link = try typeContainer.decode(LinkModel.self, forKey: .link) image = try typeContainer.decode(ImageViewModel.self, forKey: .image) try super.init(from: decoder)