From 4a0064b43239267ca08f9d4c0906c34c2406f059 Mon Sep 17 00:00:00 2001 From: Damodaram Date: Mon, 26 Oct 2020 16:49:45 +0530 Subject: [PATCH 1/7] new molecule changes --- MVMCoreUI.xcodeproj/project.pbxproj | 8 + MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + ...riableIconWithRightCaretAllTextLinks.swift | 137 ++++++++++++++++++ ...eIconWithRightCaretAllTextLinksModel.swift | 74 ++++++++++ 4 files changed, 220 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 4b0faceb..67b98b6b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -282,6 +282,8 @@ BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */; }; BBC0C4FD24811DBC0087C44F /* Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC0C4FC24811DBC0087C44F /* Tag.swift */; }; BBC0C4FF24811DCA0087C44F /* TagModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC0C4FE24811DCA0087C44F /* TagModel.swift */; }; + BBF2CDB4254697C00024472A /* ListLeftVariableIconWithRightCaretAllTextLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF2CDB3254697C00024472A /* ListLeftVariableIconWithRightCaretAllTextLinksModel.swift */; }; + BBF2CDB7254697CF0024472A /* ListLeftVariableIconWithRightCaretAllTextLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF2CDB6254697CF0024472A /* ListLeftVariableIconWithRightCaretAllTextLinks.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; @@ -794,6 +796,8 @@ BBBBC87B24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillChangesDividerModel.swift; sourceTree = ""; }; BBC0C4FC24811DBC0087C44F /* Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tag.swift; sourceTree = ""; }; BBC0C4FE24811DCA0087C44F /* TagModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagModel.swift; sourceTree = ""; }; + BBF2CDB3254697C00024472A /* ListLeftVariableIconWithRightCaretAllTextLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretAllTextLinksModel.swift; sourceTree = ""; }; + BBF2CDB6254697CF0024472A /* ListLeftVariableIconWithRightCaretAllTextLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretAllTextLinks.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; @@ -1491,6 +1495,8 @@ 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, AA0A257724766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift */, AA0A257924766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift */, + BBF2CDB3254697C00024472A /* ListLeftVariableIconWithRightCaretAllTextLinksModel.swift */, + BBF2CDB6254697CF0024472A /* ListLeftVariableIconWithRightCaretAllTextLinks.swift */, 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */, 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */, AA7F32AA246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift */, @@ -2389,6 +2395,7 @@ D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D28764AC245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift in Sources */, BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */, + BBF2CDB7254697CF0024472A /* ListLeftVariableIconWithRightCaretAllTextLinks.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */, @@ -2401,6 +2408,7 @@ D2CAC7D3251105A700C75681 /* MVMCoreUITopAlertExpandableView+Extension.swift in Sources */, AA07EA932510A451009A2AE3 /* Star.swift in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, + BBF2CDB4254697C00024472A /* ListLeftVariableIconWithRightCaretAllTextLinksModel.swift in Sources */, D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */, D28BA74D248589C800B75CB8 /* TabPageModelProtocol.swift in Sources */, 014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 8a5b737a..036d4070 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -171,6 +171,7 @@ import Foundation // MARK:- Designed List Items MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaretBodyText.self, viewModelClass: ListLeftVariableIconWithRightCaretBodyTextModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaretAllTextLinks.self, viewModelClass: ListLeftVariableIconWithRightCaretAllTextLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift new file mode 100644 index 00000000..29159ddc --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -0,0 +1,137 @@ +// +// ListLeftVariableIconWithRightCaretAllTextLinks.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 26/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +@objcMembers open class ListLeftVariableIconWithRightCaretAllTextLinks: TableViewCell { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + + public let leftImage = LoadImageView() + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() + public let rightLabel = Label(fontStyle: .RegularBodySmall) + public let rightLabelStackItem: StackItem + public var stack: Stack + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + rightLabelStackItem = StackItem(andContain: rightLabel) + let stackItems = [StackItem(andContain: leftImage), StackItem(andContain: eyebrowHeadlineBodyLink), rightLabelStackItem] + let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill)], axis: .horizontal) + stack = Stack(with: stackModel, stackItems: stackItems) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + open override func alignAccessoryToHero() -> CGPoint? { + // Ensures that the right label is centered vertically with headline. + let heroCenter = super.alignAccessoryToHero() + if let heroCenter = heroCenter { + let convertedPoint = stack.convert(heroCenter, from: self) + rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY + } + return heroCenter + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //-------------------------------------------------- + + override open func setupView() { + super.setupView() + + leftImage.addSizeConstraintsForAspectRatio = true + leftImage.contentMode = .scaleAspectFit + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.numberOfLines = 1 + addMolecule(stack) + stack.restack() + } + + //-------------------------------------------------- + // 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? ListLeftVariableIconWithRightCaretAllTextLinksModel else { return } + + leftImage.set(with: model.image, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + updateAccessibilityLabel() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + rightLabel.setFontStyle(.RegularBodySmall) + } + + //-------------------------------------------------- + // MARK: - Accessibility + //-------------------------------------------------- + + + func getAccessibilityMessage() -> String? { + var message: String = "" + + if let leftImageLabel = leftImage.imageView.accessibilityLabel { + message += leftImageLabel + ", " + } + if let rightLabel = rightLabel.text { + message += rightLabel + } + if let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() { + message += label + } + + return message + } + + func updateAccessibilityLabel() { + + let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 + accessibilityTraits = .button + + if !linkShowing && accessoryView == nil { + // Make whole cell focusable if one action + isAccessibilityElement = true + accessibilityLabel = getAccessibilityMessage() + } else { + // Make buttons focusable. + isAccessibilityElement = false + var elements: [Any] = [] + + if let accessoryView = accessoryView { + accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage() + elements.append(accessoryView) + } else { + eyebrowHeadlineBodyLink.link.accessibilityLabel = eyebrowHeadlineBodyLink.link.titleLabel?.text + } + + elements.append(link) + + if linkShowing { + elements.append(eyebrowHeadlineBodyLink.link) + } + + accessibilityElements = elements + } + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift new file mode 100644 index 00000000..f83d0c6f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift @@ -0,0 +1,74 @@ +// +// ListLeftVariableIconWithRightCaretAllTextLinksModel.swift +// MVMCoreUI +// +// Created by Dhamodaram Nandi on 26/10/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, MoleculeModelProtocol { + //----------------------------------------------------- + // MARK: - Properties + //----------------------------------------------------- + + public static var identifier: String = "listLVImgRCAll" + public var image: ImageViewModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + public var rightLabel: LabelModel + + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if image.width == nil, image.height == nil { + image.width = 30 + image.height = 30 + } + eyebrowHeadlineBodyLink.headline?.hero = 0 + } + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + + public init(image: ImageViewModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel, rightLabel: LabelModel) { + self.image = image + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + self.rightLabel = rightLabel + super.init() + } + + //----------------------------------------------------- + // MARK: - Keys + //----------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case image + case eyebrowHeadlineBodyLink + case rightLabel + } + + //----------------------------------------------------- + // MARK: - Codec + //----------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + image = try typeContainer.decode(ImageViewModel.self, forKey: .image) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + 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(image, forKey: .image) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + try container.encode(rightLabel, forKey: .rightLabel) + } +} From dceb0e6c8fac6a7547fe676a558844396be9e13f Mon Sep 17 00:00:00 2001 From: Damodaram Date: Thu, 29 Oct 2020 09:51:14 +0530 Subject: [PATCH 2/7] accessibility changes --- ...riableIconWithRightCaretAllTextLinks.swift | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index 29159ddc..0bafed66 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -87,27 +87,22 @@ // MARK: - Accessibility //-------------------------------------------------- - func getAccessibilityMessage() -> String? { - var message: String = "" - if let leftImageLabel = leftImage.imageView.accessibilityLabel { - message += leftImageLabel + ", " - } - if let rightLabel = rightLabel.text { - message += rightLabel - } - if let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() { - message += label + guard let rightLabel = rightLabel.text else { + return eyebrowHeadlineBodyLink.getAccessibilityMessage() } - return message + guard let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() else { + return rightLabel + } + + return rightLabel + ", " + label } func updateAccessibilityLabel() { - + let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 - accessibilityTraits = .button if !linkShowing && accessoryView == nil { // Make whole cell focusable if one action @@ -122,10 +117,10 @@ accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage() elements.append(accessoryView) } else { - eyebrowHeadlineBodyLink.link.accessibilityLabel = eyebrowHeadlineBodyLink.link.titleLabel?.text + rightLabel.accessibilityLabel = getAccessibilityMessage() } - elements.append(link) + elements.append(rightLabel) if linkShowing { elements.append(eyebrowHeadlineBodyLink.link) @@ -134,4 +129,5 @@ accessibilityElements = elements } } + } From dde32fd6a4fdd7cfae3f0f04d90c80184b4a63ac Mon Sep 17 00:00:00 2001 From: Damodaram Date: Thu, 29 Oct 2020 14:37:18 +0530 Subject: [PATCH 3/7] accessibility updated --- ...riableIconWithRightCaretAllTextLinks.swift | 53 +++++++++---------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index 0bafed66..2031cdd3 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -16,7 +16,7 @@ public let rightLabel = Label(fontStyle: .RegularBodySmall) public let rightLabelStackItem: StackItem public var stack: Stack - + //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -86,48 +86,43 @@ //-------------------------------------------------- // MARK: - Accessibility //-------------------------------------------------- - + func getAccessibilityMessage() -> String? { - - guard let rightLabel = rightLabel.text else { - return eyebrowHeadlineBodyLink.getAccessibilityMessage() + var message = "" + if let leftImageLabel = leftImage.imageView.accessibilityLabel { + message += leftImageLabel + ", " } - - guard let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() else { - return rightLabel + if let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() { + message += label + ", " } - - return rightLabel + ", " + label + if let rightLabel = rightLabel.text { + message += rightLabel + } + return message } func updateAccessibilityLabel() { - let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 + isAccessibilityElement = !linkShowing + accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none - if !linkShowing && accessoryView == nil { - // Make whole cell focusable if one action - isAccessibilityElement = true + if !linkShowing { + // Make whole cell focusable if no link. accessibilityLabel = getAccessibilityMessage() + } else if let accessoryView = accessoryView { + // Both caret and link. Read all content on caret. + accessoryView.accessibilityLabel = getAccessibilityMessage() + accessibilityElements = [accessoryView, eyebrowHeadlineBodyLink.link] } else { - // Make buttons focusable. - isAccessibilityElement = false + // Only link. Manually add accessibility elements to ensure they are read in the right order. var elements: [Any] = [] - - if let accessoryView = accessoryView { - accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage() - elements.append(accessoryView) - } else { - rightLabel.accessibilityLabel = getAccessibilityMessage() + if let otherElements = eyebrowHeadlineBodyLink.getAccessibilityElements() { + elements.append(otherElements) } - - elements.append(rightLabel) - - if linkShowing { - elements.append(eyebrowHeadlineBodyLink.link) + if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty { + elements.append(rightLabel) } - accessibilityElements = elements } } - } From f3370d6ec6d6384e4426ea710365603cb31d5a31 Mon Sep 17 00:00:00 2001 From: Damodaram Date: Fri, 30 Oct 2020 19:35:33 +0530 Subject: [PATCH 4/7] initialisation changes --- ...riableIconWithRightCaretAllTextLinks.swift | 26 +++++++------------ ...eIconWithRightCaretAllTextLinksModel.swift | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index 2031cdd3..75e8d299 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -14,24 +14,18 @@ public let leftImage = LoadImageView() public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() public let rightLabel = Label(fontStyle: .RegularBodySmall) - public let rightLabelStackItem: StackItem - public var stack: Stack - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- + public lazy var rightLabelStackItem: StackItem = { + return StackItem(andContain: rightLabel) + }() - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - rightLabelStackItem = StackItem(andContain: rightLabel) - let stackItems = [StackItem(andContain: leftImage), StackItem(andContain: eyebrowHeadlineBodyLink), rightLabelStackItem] - let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill)], axis: .horizontal) - stack = Stack(with: stackModel, stackItems: stackItems) - super.init(style: style, reuseIdentifier: reuseIdentifier) - } - - public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } + public lazy var stack: Stack = { + return Stack.createStack(with: [ + (view: leftImage, model: StackItemModel(horizontalAlignment: .fill)), + (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .fill)), + (view: rightLabelStackItem, model: StackItemModel(horizontalAlignment: .fill,verticalAlignment: .top))], + axis: .horizontal) + }() open override func alignAccessoryToHero() -> CGPoint? { // Ensures that the right label is centered vertically with headline. diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift index f83d0c6f..c9138a84 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift @@ -26,7 +26,7 @@ public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, image.width = 30 image.height = 30 } - eyebrowHeadlineBodyLink.headline?.hero = 0 + rightLabel.hero = 0 } //----------------------------------------------------- From 3149d0e1455c486884b4ec98272c7f5ac45599ce Mon Sep 17 00:00:00 2001 From: Damodaram Date: Mon, 2 Nov 2020 19:47:17 +0530 Subject: [PATCH 5/7] updated as per review comments --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- ...eftVariableIconWithRightCaretAllTextLinks.swift | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 88f04260..3c270af0 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1546,8 +1546,8 @@ AA69AAF52445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift */, 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */, 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */, - BB3BC12D2550094500297977 /* ListLeftVariableIconWithRightCaretAllTextLinks.swift */, BB3BC12E2550094500297977 /* ListLeftVariableIconWithRightCaretAllTextLinksModel.swift */, + BB3BC12D2550094500297977 /* ListLeftVariableIconWithRightCaretAllTextLinks.swift */, 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, AA0A257724766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift */, diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index 75e8d299..e78d993f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -20,11 +20,13 @@ }() public lazy var stack: Stack = { - return Stack.createStack(with: [ - (view: leftImage, model: StackItemModel(horizontalAlignment: .fill)), - (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .fill)), - (view: rightLabelStackItem, model: StackItemModel(horizontalAlignment: .fill,verticalAlignment: .top))], - axis: .horizontal) + return Stack(with: StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), + + StackItemModel(horizontalAlignment: .fill), + + StackItemModel(horizontalAlignment: .fill,verticalAlignment: .top)], + axis: .horizontal), stackItems: [StackItem(andContain: leftImage), StackItem(andContain: eyebrowHeadlineBodyLink), rightLabelStackItem]) + }() open override func alignAccessoryToHero() -> CGPoint? { @@ -110,6 +112,7 @@ } else { // Only link. Manually add accessibility elements to ensure they are read in the right order. var elements: [Any] = [] + elements.append(leftImage) if let otherElements = eyebrowHeadlineBodyLink.getAccessibilityElements() { elements.append(otherElements) } @@ -120,3 +123,4 @@ } } } + From 7b9fa2a7a8253068ca0b497f8a081884a9aee423 Mon Sep 17 00:00:00 2001 From: Damodaram Date: Wed, 4 Nov 2020 18:58:00 +0530 Subject: [PATCH 6/7] updated as per review comments --- .../ListLeftVariableIconWithRightCaretAllTextLinks.swift | 2 +- .../ListLeftVariableIconWithRightCaretAllTextLinksModel.swift | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index e78d993f..7b5c015d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -24,7 +24,7 @@ StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .fill,verticalAlignment: .top)], + StackItemModel(horizontalAlignment: .fill)], axis: .horizontal), stackItems: [StackItem(andContain: leftImage), StackItem(andContain: eyebrowHeadlineBodyLink), rightLabelStackItem]) }() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift index c9138a84..9d9291e8 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift @@ -26,7 +26,6 @@ public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, image.width = 30 image.height = 30 } - rightLabel.hero = 0 } //----------------------------------------------------- From b6282d4bfddc82cead3bc6373456a2aa48403170 Mon Sep 17 00:00:00 2001 From: Damodaram Date: Wed, 4 Nov 2020 19:32:05 +0530 Subject: [PATCH 7/7] accessibility changes --- .../ListLeftVariableIconWithRightCaretAllTextLinks.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index 7b5c015d..d6175136 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -112,7 +112,7 @@ } else { // Only link. Manually add accessibility elements to ensure they are read in the right order. var elements: [Any] = [] - elements.append(leftImage) + elements.append(leftImage.imageView) if let otherElements = eyebrowHeadlineBodyLink.getAccessibilityElements() { elements.append(otherElements) }