From 921df032b29ae0649c3c6ecb831d5824aef343ec Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 9 Jun 2021 23:12:45 +0530 Subject: [PATCH] Changes as per review comments --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 5 +++-- .../Atomic/Atoms/Views/Label/LabelModel.swift | 15 ++------------- ...stLeftVariableIconWithRightCaretBodyText.swift | 4 ---- ...tVariableIconWithRightCaretBodyTextModel.swift | 3 +++ 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 09ed3386..395ab923 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -316,8 +316,8 @@ public typealias ActionBlock = () -> () textColor = color.uiColor } - if let numberofLines = labelModel.numberOfLines { - numberOfLines = numberofLines + if let lines = labelModel.numberOfLines { + numberOfLines = lines } if let attributes = labelModel.attributes, let labelText = text { @@ -794,6 +794,7 @@ extension Label { accessibilityCustomActions = [] clauses = [] accessibilityTraits = .staticText + numberOfLines = 0 } public func needsToBeConstrained() -> Bool { true } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 8aa4c0d6..5cc07fed 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -25,7 +25,7 @@ public var html: String? public var hero: Int? public var makeWholeViewClickable: Bool? - public var numberOfLines:Int? + public var numberOfLines: Int? //-------------------------------------------------- // MARK: - Keys @@ -51,24 +51,13 @@ enum AttributeTypeKey: String, CodingKey { case type } - - //----------------------------------------------------- - // MARK: - Methods - //----------------------------------------------------- - - internal func setDefaults() { - if numberOfLines == nil { - numberOfLines = 1 - } - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(text: String) { self.text = text - setDefaults() } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index feb8694d..6174fc4b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -55,7 +55,6 @@ leftImage.contentMode = .scaleAspectFit rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } @@ -73,9 +72,6 @@ headlineBody.set(with: model.headlineBody, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) updateAccessibilityLabel() - if let numberOfLines = model.rightLabel.numberOfLines{ - rightLabel.numberOfLines = numberOfLines - } } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 891f37f5..5076eb9e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -29,6 +29,9 @@ public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, Mol } headlineBody.style = .item headlineBody.headline?.hero = 0 + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //-----------------------------------------------------