From 384681982e99104e7573f4234a78eb2e5f561ab8 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Mon, 12 Oct 2020 18:13:25 +0530 Subject: [PATCH 1/7] 22353(iOS - List store locator) initial commit. --- MVMCoreUI.xcodeproj/project.pbxproj | 16 +++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../List/Miscellaneous/ListStoreLocator.swift | 132 ++++++++++++++++++ .../Miscellaneous/ListStoreLocatorModel.swift | 82 +++++++++++ 4 files changed, 231 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b25857e7..8f20b793 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -251,6 +251,8 @@ 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 */; }; + AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; + AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -757,6 +759,8 @@ 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 = ""; }; + AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; + AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -1285,6 +1289,15 @@ path = TwoColumn; sourceTree = ""; }; + AAE96FA025341F410037A989 /* Miscellaneous */ = { + isa = PBXGroup; + children = ( + AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */, + AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */, + ); + path = Miscellaneous; + sourceTree = ""; + }; D202AFE2242A5F1400E5BEDF /* Extensions */ = { isa = PBXGroup; children = ( @@ -1454,6 +1467,7 @@ D22B38EA23F4E08B00490EF6 /* List */ = { isa = PBXGroup; children = ( + AAE96FA025341F410037A989 /* Miscellaneous */, D20FFFB42451E32100A31DA2 /* Device */, 52267A0523FFE0A900906CBA /* OneColumn */, D22D8396241FDE4700D3DF69 /* TwoColumn */, @@ -2288,6 +2302,7 @@ C07065C42395677300FBF997 /* Link.swift in Sources */, 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, + AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */, D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */, AA56A20F243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift in Sources */, AAB9C10824346F4B00151545 /* RadioSwatches.swift in Sources */, @@ -2417,6 +2432,7 @@ 0A849EFE246F1775009F277F /* RuleEqualsIgnoreCaseModel.swift in Sources */, D28764FB245A33A500CB882D /* TwoLinkViewModel.swift in Sources */, AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */, + AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, D213347723843825008E41B3 /* Line.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index e11c782a..6bbb22bd 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -199,6 +199,7 @@ import Foundation 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) + MoleculeObjectMapping.shared()?.register(viewClass: ListStoreLocator.self, viewModelClass: ListStoreLocatorModel.self) // MARK:- Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift new file mode 100644 index 00000000..6f94dd13 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -0,0 +1,132 @@ +// +// ListStoreLocator.swift +// MVMCoreUI +// +// Created by Lekshmi S on 12/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListStoreLocator: TableViewCell { + + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + public let heart = Heart() + public let leftHeadline = Label(fontStyle: .BoldBodySmall) + public let leftBody = Label(fontStyle: .RegularBodySmall) + public let leftSubBody = Label(fontStyle: .RegularBodySmall) + public let rightLabel = Label(fontStyle: .BoldBodySmall) + public var horizontalStack: Stack + public var stack: Stack + + public var sizeObject: MFSizeObject? = MFSizeObject(standardSize: 12, standardiPadPortraitSize: 18) + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + + //horizontal stack with leftHeadline, heart, rightLabel + horizontalStack = Stack.createStack(with: [(view: leftHeadline, model: StackItemModel(horizontalAlignment: .fill)), (view: heart, model: StackItemModel(horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(horizontalAlignment: .trailing))], axis: .horizontal, spacing: 8) + + //stack with all components + stack = Stack.createStack(with: [horizontalStack, leftBody, leftSubBody], 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() + + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.numberOfLines = 1 + addMolecule(stack) + stack.restack() + horizontalStack.restack() + accessibilityHint = heart.accessibilityHint + accessibilityTraits = heart.accessibilityTraits + } + + public override func updateView(_ size: CGFloat) { + super.updateView(size) + if let dimension = sizeObject?.getValueBased(onSize: size) { + heart.widthConstraint?.constant = dimension + } + } + + //------------------------------------------------------ + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + + guard let model = model as? ListStoreLocatorModel else { return } + horizontalStack.updateContainedMolecules(with: [model.leftHeadline, model.heart, model.rightLabel], delegateObject, additionalData) + leftBody.set(with: model.leftBody, delegateObject, additionalData) + leftSubBody.set(with: model.leftSubBody, delegateObject, additionalData) + updateAccessibilityLabel() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 120 + } + + open override func reset() { + super.reset() + leftHeadline.setFontStyle(.BoldBodySmall) + leftBody.setFontStyle(.RegularBodySmall) + leftSubBody.setFontStyle(.RegularBodySmall) + rightLabel.setFontStyle(.RegularBodySmall) + } + + //-------------------------------------------------- + // MARK: - Accessibility + //-------------------------------------------------- + func getAccessibilityMessage() -> String? { + var message = "" + heart.updateAccessibilityLabel() + + if let leftHeadlineText = leftHeadline.text, !leftHeadlineText.isEmpty { + message += leftHeadlineText + ", " + } + + if let leftBodyText = leftBody.text, !leftBodyText.isEmpty { + message += leftBodyText + ", " + } + + if let leftSubBodyText = leftSubBody.text, !leftSubBodyText.isEmpty { + message += leftSubBodyText + ", " + } + + if let heartLabel = heart.accessibilityLabel { + message += heartLabel + ", " + } + + if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty { + message += rightLabelText + } + return message + } + + func updateAccessibilityLabel() { + if let accessoryView = accessoryView { + // Both caret and heart. + isAccessibilityElement = false + accessoryView.accessibilityLabel = getAccessibilityMessage() + accessibilityElements = [accessoryView, heart] + } else { + // Make whole cell focusable if no action. + isAccessibilityElement = true + accessibilityLabel = getAccessibilityMessage() + } + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift new file mode 100644 index 00000000..0fed6749 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -0,0 +1,82 @@ +// +// ListStoreLocatorModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 12/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier = "listStrLctr" + public var heart: HeartModel + public var leftHeadline: LabelModel + public var leftBody: LabelModel + public var leftSubBody: LabelModel + public var rightLabel: LabelModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(heart: HeartModel, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) { + self.heart = heart + self.leftHeadline = leftHeadline + self.leftBody = leftBody + self.leftSubBody = leftSubBody + self.rightLabel = rightLabel + super.init() + } + + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + leftHeadline.hero = 0 + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case heart + case leftHeadline + case leftBody + case leftSubBody + case rightLabel + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + heart = try typeContainer.decode(HeartModel.self, forKey:.heart) + leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) + leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody) + leftSubBody = try typeContainer.decode(LabelModel.self, forKey: .leftSubBody) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + 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(heart, forKey: .heart) + try container.encode(leftHeadline, forKey: .leftHeadline) + try container.encode(leftBody, forKey: .leftBody) + try container.encode(leftSubBody, forKey: .leftSubBody) + try container.encode(rightLabel, forKey: .rightLabel) + } +} From 400563bcdd139d29ef88008f5f6c0997398c6411 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 13 Oct 2020 18:35:23 +0530 Subject: [PATCH 2/7] Changes to align accessoryview. --- .../List/Miscellaneous/ListStoreLocator.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index 6f94dd13..6c1e65e5 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -19,6 +19,7 @@ import Foundation public let leftSubBody = Label(fontStyle: .RegularBodySmall) public let rightLabel = Label(fontStyle: .BoldBodySmall) public var horizontalStack: Stack + private let rightLabelStackItem: StackItem public var stack: Stack public var sizeObject: MFSizeObject? = MFSizeObject(standardSize: 12, standardiPadPortraitSize: 18) @@ -28,8 +29,14 @@ import Foundation //------------------------------------------------------ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + let horizontalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .trailing)], + axis: .horizontal, spacing: 8) + rightLabelStackItem = StackItem(andContain: rightLabel) + let horizontalStackItems = [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem] //horizontal stack with leftHeadline, heart, rightLabel - horizontalStack = Stack.createStack(with: [(view: leftHeadline, model: StackItemModel(horizontalAlignment: .fill)), (view: heart, model: StackItemModel(horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(horizontalAlignment: .trailing))], axis: .horizontal, spacing: 8) + horizontalStack = Stack(with: horizontalStackModel, stackItems: horizontalStackItems) //stack with all components stack = Stack.createStack(with: [horizontalStack, leftBody, leftSubBody], axis: .vertical, spacing: 0) @@ -76,6 +83,16 @@ import Foundation updateAccessibilityLabel() } + open override func alignAccessoryToHero() -> CGPoint? { + let heroCenter = super.alignAccessoryToHero() + + if let heroCenter = heroCenter { + let convertedPoint = horizontalStack.convert(heroCenter, from: self) + rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - horizontalStack.bounds.midY + } + return heroCenter + } + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 120 } From 10b153489d6087310b42b91732aa8a0184f0664d Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Mon, 26 Oct 2020 17:52:17 +0530 Subject: [PATCH 3/7] Accessibility label changes --- .../List/Miscellaneous/ListStoreLocator.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index 6c1e65e5..177f4b1a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -124,10 +124,6 @@ import Foundation message += leftSubBodyText + ", " } - if let heartLabel = heart.accessibilityLabel { - message += heartLabel + ", " - } - if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty { message += rightLabelText } @@ -143,7 +139,12 @@ import Foundation } else { // Make whole cell focusable if no action. isAccessibilityElement = true - accessibilityLabel = getAccessibilityMessage() + if let message = getAccessibilityMessage(), + let heartLabel = heart.accessibilityLabel { + accessibilityLabel = message + ", " + heartLabel + } else { + accessibilityLabel = getAccessibilityMessage() + } } } } From 77b62f0213b7b12e70a98e463a4565b2655a43a3 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Tue, 27 Oct 2020 11:31:14 +0530 Subject: [PATCH 4/7] Code changes after review. --- .../List/Miscellaneous/ListStoreLocator.swift | 51 ++++++++----------- .../Miscellaneous/ListStoreLocatorModel.swift | 4 +- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index 177f4b1a..362a823f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -6,8 +6,6 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -import Foundation - @objcMembers open class ListStoreLocator: TableViewCell { //-------------------------------------------------- @@ -17,36 +15,27 @@ import Foundation public let leftHeadline = Label(fontStyle: .BoldBodySmall) public let leftBody = Label(fontStyle: .RegularBodySmall) public let leftSubBody = Label(fontStyle: .RegularBodySmall) - public let rightLabel = Label(fontStyle: .BoldBodySmall) - public var horizontalStack: Stack - private let rightLabelStackItem: StackItem - public var stack: Stack - + public let rightLabel = Label(fontStyle: .RegularBodySmall) + private lazy var rightLabelStackItem: StackItem = { + return StackItem(andContain: rightLabel) + }() + private lazy var horizontalStackItems: [StackItem] = { + return [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem] + }() + private lazy var horizontalStackModel: StackModel = { + return StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .trailing)], + axis: .horizontal, spacing: Padding.Two) + }() + public lazy var horizontalStack: Stack = { + return Stack(with: horizontalStackModel, stackItems: horizontalStackItems) + }() + public lazy var stack: Stack = { + return Stack.createStack(with: [horizontalStack, leftBody, leftSubBody], axis: .vertical, spacing: 0) + }() public var sizeObject: MFSizeObject? = MFSizeObject(standardSize: 12, standardiPadPortraitSize: 18) - //------------------------------------------------------ - // MARK: - Initializers - //------------------------------------------------------ - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - - let horizontalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .trailing)], - axis: .horizontal, spacing: 8) - rightLabelStackItem = StackItem(andContain: rightLabel) - let horizontalStackItems = [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem] - //horizontal stack with leftHeadline, heart, rightLabel - horizontalStack = Stack(with: horizontalStackModel, stackItems: horizontalStackItems) - - //stack with all components - stack = Stack.createStack(with: [horizontalStack, leftBody, leftSubBody], 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 //------------------------------------------------------- @@ -127,7 +116,7 @@ import Foundation if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty { message += rightLabelText } - return message + return message.count > 0 ? message : nil } func updateAccessibilityLabel() { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index 0fed6749..52f9f9fc 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -6,14 +6,12 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -import Foundation - public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public static var identifier = "listStrLctr" + public static var identifier = "listStoreLoctr" public var heart: HeartModel public var leftHeadline: LabelModel public var leftBody: LabelModel From a9eae29e1aa58f816c1b55a1fe952ebe6582b4c4 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 28 Oct 2020 17:03:59 +0530 Subject: [PATCH 5/7] Identifier name changed. --- .../List/Miscellaneous/ListStoreLocatorModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index 52f9f9fc..32392b50 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -11,7 +11,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { // MARK: - Properties //-------------------------------------------------- - public static var identifier = "listStoreLoctr" + public static var identifier = "listStoreLocator" public var heart: HeartModel public var leftHeadline: LabelModel public var leftBody: LabelModel From 94deaeff60e01ab1db8a7caf8c21d6480dfcb4db Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Mon, 2 Nov 2020 18:24:40 +0530 Subject: [PATCH 6/7] Removed variables to optimize code. --- .../List/Miscellaneous/ListStoreLocator.swift | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index 362a823f..24c7770a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -19,17 +19,11 @@ private lazy var rightLabelStackItem: StackItem = { return StackItem(andContain: rightLabel) }() - private lazy var horizontalStackItems: [StackItem] = { - return [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem] - }() - private lazy var horizontalStackModel: StackModel = { - return StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .trailing)], - axis: .horizontal, spacing: Padding.Two) - }() public lazy var horizontalStack: Stack = { - return Stack(with: horizontalStackModel, stackItems: horizontalStackItems) + return Stack(with: StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .fill), + StackItemModel(horizontalAlignment: .trailing)], + axis: .horizontal, spacing: Padding.Two), stackItems: [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem]) }() public lazy var stack: Stack = { return Stack.createStack(with: [horizontalStack, leftBody, leftSubBody], axis: .vertical, spacing: 0) From 7728afb122ce0ff7c52879932f5c7ef46831b027 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 2 Nov 2020 10:19:31 -0500 Subject: [PATCH 7/7] accessibility fix --- .../List/Miscellaneous/ListStoreLocator.swift | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index 24c7770a..6a1f0dc5 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -18,16 +18,16 @@ public let rightLabel = Label(fontStyle: .RegularBodySmall) private lazy var rightLabelStackItem: StackItem = { return StackItem(andContain: rightLabel) - }() + }() public lazy var horizontalStack: Stack = { return Stack(with: StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .trailing)], axis: .horizontal, spacing: Padding.Two), stackItems: [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem]) - }() + }() public lazy var stack: Stack = { return Stack.createStack(with: [horizontalStack, leftBody, leftSubBody], axis: .vertical, spacing: 0) - }() + }() public var sizeObject: MFSizeObject? = MFSizeObject(standardSize: 12, standardiPadPortraitSize: 18) //------------------------------------------------------- @@ -76,6 +76,15 @@ return heroCenter } + public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + if listItemModel?.action != nil { + super.didSelectCell(at: index, delegateObject: delegateObject, additionalData: additionalData) + } else { + heart.tapAction() + updateAccessibilityLabel() + } + } + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 120 }