From d0b390291580ad43d701b00e37c19e4d70bba372 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 4 Aug 2020 17:27:17 +0530 Subject: [PATCH] 22008(iOS - List - Three Column - Speed Test) initial commit. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 + MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../ListThreeColumnSpeedTest.swift | 139 ++++++++++++++++++ .../ListThreeColumnSpeedTestModel.swift | 79 ++++++++++ 4 files changed, 227 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTest.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTestModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 97f48227..454ef7e7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -242,6 +242,8 @@ AAB7EDF1246ADA2A00E54929 /* ListProgressBarThin.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB7EDF0246ADA2A00E54929 /* ListProgressBarThin.swift */; }; AAB9C10824346F4B00151545 /* RadioSwatches.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C10724346F4B00151545 /* RadioSwatches.swift */; }; AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C109243496DD00151545 /* RadioSwatch.swift */; }; + AAC23FAD24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC23FAC24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift */; }; + AAC23FAF24D92A1E009208DF /* ListThreeColumnSpeedTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC23FAE24D92A1E009208DF /* ListThreeColumnSpeedTest.swift */; }; AAC6F167243332E400F295C1 /* RadioSwatchesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */; }; AAE7270C24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270B24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift */; }; AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; @@ -719,6 +721,8 @@ AAB7EDF0246ADA2A00E54929 /* ListProgressBarThin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListProgressBarThin.swift; sourceTree = ""; }; AAB9C10724346F4B00151545 /* RadioSwatches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatches.swift; sourceTree = ""; }; AAB9C109243496DD00151545 /* RadioSwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = ""; }; + AAC23FAC24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestModel.swift; sourceTree = ""; }; + AAC23FAE24D92A1E009208DF /* ListThreeColumnSpeedTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTest.swift; sourceTree = ""; }; AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchesModel.swift; sourceTree = ""; }; AAE7270B24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLinkModel.swift; sourceTree = ""; }; AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; @@ -1160,6 +1164,8 @@ 323AC96B24C837FF00F8E4C4 /* ListThreeColumnBillChanges.swift */, AAA905DE24D1758700D1EFAB /* ListThreeColumnBillHistoryModel.swift */, AAA905E024D1759A00D1EFAB /* ListThreeColumnBillHistory.swift */, + AAC23FAC24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift */, + AAC23FAE24D92A1E009208DF /* ListThreeColumnSpeedTest.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -2189,6 +2195,7 @@ 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D264FAAA2440F97600D98315 /* CollectionView.swift in Sources */, + AAC23FAD24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift in Sources */, BBC0C4FF24811DCA0087C44F /* TagModel.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, 3265B30424BCA749000D154B /* HeadersH1NoButtonsBodyText.swift in Sources */, @@ -2288,6 +2295,7 @@ 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, + AAC23FAF24D92A1E009208DF /* ListThreeColumnSpeedTest.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index ef8e4573..27123d63 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -194,6 +194,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsage.self, viewModelClass: ListThreeColumnDataUsageModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnBillChanges.self, viewModelClass: ListThreeColumnBillChangesModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnBillHistory.self, viewModelClass: ListThreeColumnBillHistoryModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnSpeedTest.self, viewModelClass: ListThreeColumnSpeedTestModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListProgressBarThin.self, viewModelClass: ListProgressBarThinModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTest.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTest.swift new file mode 100644 index 00000000..9c1b342f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTest.swift @@ -0,0 +1,139 @@ +// +// ListThreeColumnSpeedTest.swift +// MVMCoreUI +// +// Created by Lekshmi S on 04/08/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListThreeColumnSpeedTest: TableViewCell { + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + public var title = Label(fontStyle: .RegularMicro) + public var topLeftHeadlineBody = HeadlineBody() + public var bottomLeftHeadlineBody = HeadlineBody() + public var verticalStack1: Stack + public var topCenterHeadlineBody = HeadlineBody() + public var bottomCenterHeadlineBody = HeadlineBody() + public var verticalStack2: Stack + public var topRightHeadlineBody = HeadlineBody() + public var bottomRightHeadlineBody = HeadlineBody() + public var verticalStack3: Stack + public var horizontalStack: Stack + public var stack: Stack + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + + verticalStack1 = Stack.createStack(with: [(view: topLeftHeadlineBody, model: StackItemModel(horizontalAlignment: .leading)), (view: bottomLeftHeadlineBody, model: StackItemModel(horizontalAlignment: .leading))], axis: .vertical) + verticalStack2 = Stack.createStack(with: [(view: topCenterHeadlineBody, model: StackItemModel(horizontalAlignment: .leading)), (view: bottomCenterHeadlineBody, model: StackItemModel(horizontalAlignment: .leading))], axis: .vertical) + verticalStack3 = Stack.createStack(with: [(view: topRightHeadlineBody, model: StackItemModel(horizontalAlignment: .leading)), (view: bottomRightHeadlineBody, model: StackItemModel(horizontalAlignment: .leading))], axis: .vertical) + horizontalStack = Stack.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 36, horizontalAlignment: .leading)), + (view: verticalStack2, model: StackItemModel(percent: 34, horizontalAlignment: .leading)), + (view: verticalStack3, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], + axis: .horizontal) + stack = Stack.createStack(with: [(view: title, model: StackItemModel(horizontalAlignment: .leading)), (view: horizontalStack, model: StackItemModel(horizontalAlignment: .leading))], axis: .vertical, spacing: 0) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------ + // MARK: - Lifecycle + //------------------------------------------------------ + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + verticalStack1.restack() + verticalStack2.restack() + verticalStack3.restack() + horizontalStack.restack() + } + + //-------------------------------------------------- + // MARK: - ModelMoleculeViewProtocol + //-------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnSpeedTestModel else { return } + title.set(with: model.title, delegateObject, additionalData) + verticalStack1.updateContainedMolecules(with: [model.topLeftHeadlineBody, model.bottomLeftHeadlineBody], delegateObject, additionalData) + verticalStack2.updateContainedMolecules(with: [model.topCenterHeadlineBody, model.bottomCenterHeadlineBody], delegateObject, additionalData) + verticalStack3.updateContainedMolecules(with: [model.topRightHeadlineBody, model.bottomRightHeadlineBody], delegateObject, additionalData) + updateAccessibilityLabel() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + open override func reset() { + super.reset() + title.setFontStyle(.BoldBodySmall) + styleHeadlineBody(topLeftHeadlineBody, true) + styleHeadlineBody(bottomLeftHeadlineBody, false) + styleHeadlineBody(topCenterHeadlineBody, false) + styleHeadlineBody(bottomCenterHeadlineBody, false) + styleHeadlineBody(topRightHeadlineBody, false) + styleHeadlineBody(bottomRightHeadlineBody, false) + } + + func styleHeadlineBody(_ headlineBody: HeadlineBody, _ isBodyMicro: Bool) { + headlineBody.headlineLabel.setFontStyle(.RegularMicro) + headlineBody.headlineLabel.textColor = .mvmCoolGray6 + headlineBody.messageLabel.setFontStyle(.RegularBodySmall) + if isBodyMicro { + headlineBody.messageLabel.setFontStyle(.RegularMicro) + headlineBody.messageLabel.textColor = .mvmCoolGray6 + } + } + + //-------------------------------------------------- + // MARK: - Accessibility + //-------------------------------------------------- + func updateAccessibilityLabel() { + isAccessibilityElement = true + var message = "" + if let title = title.text, !title.isEmpty { + message += title + ", " + } + if let topLeftHeadlineBodyText = accessibilityTextOfHeadlineBody(topLeftHeadlineBody), !topLeftHeadlineBodyText.isEmpty { + message += topLeftHeadlineBodyText + ", " + } + if let topCenterHeadlineBodyText = accessibilityTextOfHeadlineBody(topCenterHeadlineBody), !topCenterHeadlineBodyText.isEmpty { + message += topCenterHeadlineBodyText + ", " + } + if let topRightHeadlineBodyText = accessibilityTextOfHeadlineBody(topRightHeadlineBody), !topRightHeadlineBodyText.isEmpty { + message += topRightHeadlineBodyText + ", " + } + if let bottomLeftHeadlineBodyText = accessibilityTextOfHeadlineBody(bottomLeftHeadlineBody), !bottomLeftHeadlineBodyText.isEmpty { + message += bottomLeftHeadlineBodyText + ", " + } + if let bottomCenterHeadlineBodyText = accessibilityTextOfHeadlineBody(bottomCenterHeadlineBody), !bottomCenterHeadlineBodyText.isEmpty { + message += bottomCenterHeadlineBodyText + ", " + } + if let bottomRightHeadlineBodyText = accessibilityTextOfHeadlineBody(bottomRightHeadlineBody), !bottomRightHeadlineBodyText.isEmpty { + message += bottomRightHeadlineBodyText + } + accessibilityLabel = message + } + + func accessibilityTextOfHeadlineBody(_ headlineBody: HeadlineBody) -> String? { + var message = "" + if let headlineLabel = headlineBody.headlineLabel.text { + message += headlineLabel + ", " + } + if let messageLabel = headlineBody.messageLabel.text { + message += messageLabel + } + return message + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTestModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTestModel.swift new file mode 100644 index 00000000..1ba62c2f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnSpeedTestModel.swift @@ -0,0 +1,79 @@ +// +// ListThreeColumnSpeedTestModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 04/08/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListThreeColumnSpeedTestModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "list3CSpdTst" + public var title: LabelModel + public var topLeftHeadlineBody: HeadlineBodyModel + public var topCenterHeadlineBody: HeadlineBodyModel + public var topRightHeadlineBody: HeadlineBodyModel + public var bottomLeftHeadlineBody: HeadlineBodyModel + public var bottomCenterHeadlineBody: HeadlineBodyModel + public var bottomRightHeadlineBody: HeadlineBodyModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(title: LabelModel, topLeftHeadlineBody: HeadlineBodyModel, topCenterHeadlineBody: HeadlineBodyModel, topRightHeadlineBody: HeadlineBodyModel, bottomLeftHeadlineBody: HeadlineBodyModel, bottomCenterHeadlineBody: HeadlineBodyModel, bottomRightHeadlineBody: HeadlineBodyModel) { + self.title = title + self.topLeftHeadlineBody = topLeftHeadlineBody + self.topCenterHeadlineBody = topCenterHeadlineBody + self.topRightHeadlineBody = topRightHeadlineBody + self.bottomLeftHeadlineBody = bottomLeftHeadlineBody + self.bottomCenterHeadlineBody = bottomCenterHeadlineBody + self.bottomRightHeadlineBody = bottomRightHeadlineBody + super.init() + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName + case title + case topLeftHeadlineBody + case topCenterHeadlineBody + case topRightHeadlineBody + case bottomLeftHeadlineBody + case bottomCenterHeadlineBody + case bottomRightHeadlineBody + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + title = try typeContainer.decode(LabelModel.self, forKey: .title) + topLeftHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .topLeftHeadlineBody) + topCenterHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .topCenterHeadlineBody) + topRightHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .topRightHeadlineBody) + bottomLeftHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .bottomLeftHeadlineBody) + bottomCenterHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .bottomCenterHeadlineBody) + bottomRightHeadlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .bottomRightHeadlineBody) + 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(title, forKey: .title) + try container.encode(topLeftHeadlineBody, forKey: .topLeftHeadlineBody) + try container.encode(topCenterHeadlineBody, forKey: .topCenterHeadlineBody) + try container.encode(topRightHeadlineBody, forKey: .topRightHeadlineBody) + try container.encode(bottomLeftHeadlineBody, forKey: .bottomLeftHeadlineBody) + try container.encode(bottomCenterHeadlineBody, forKey: .bottomCenterHeadlineBody) + try container.encode(bottomRightHeadlineBody, forKey: .bottomRightHeadlineBody) + } +}