From 740545e9c30fcbc8eada62fba137727eb1d0e126 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 22 May 2020 15:30:02 -0400 Subject: [PATCH 1/3] Try again --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 15 +++++++-------- ...tLeftVariableNumberedListAllTextAndLinks.swift | 3 ++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 598f3f4e..35d45ac6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -674,12 +674,15 @@ public typealias ActionBlock = () -> () setScale(scale) } + open override func layoutSubviews() { + super.layoutSubviews() + + // This fixes a defect for when there are multiple labels stacked in a list item. Sometime some labels will not fill their available space. + preferredMaxLayoutWidth = frame.width + } + @objc public func updateView(_ size: CGFloat) { scaleSize = size as NSNumber - - // This fixes a defect for when there are multiple labels stacked in a list item. Sometime some labels will not fill their available space. - preferredMaxLayoutWidth = size - if let originalAttributedString = originalAttributedString { let attributedString = NSMutableAttributedString(attributedString: originalAttributedString) attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length)) @@ -878,10 +881,6 @@ extension Label { return true } - public func horizontalAlignment() -> UIStackView.Alignment { - return .leading - } - public func copyBackgroundColor() -> Bool { return true } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift index e7a35cc6..9f2d62c9 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift @@ -21,7 +21,7 @@ import Foundation //-------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(horizontalAlignment: .fill)), - (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))], + (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .fill))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -35,6 +35,7 @@ import Foundation //-------------------------------------------------- override open func setupView() { super.setupView() + leftLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) addMolecule(stack) stack.restack() } From 528ae8a6854e1f137d804f6017a1e4f39bc32ecb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 22 May 2020 16:25:12 -0400 Subject: [PATCH 2/3] Fix for specific molecule --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 12 +++++------- ...ListLeftVariableNumberedListAllTextAndLinks.swift | 5 +++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 35d45ac6..087e893c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -674,15 +674,9 @@ public typealias ActionBlock = () -> () setScale(scale) } - open override func layoutSubviews() { - super.layoutSubviews() - - // This fixes a defect for when there are multiple labels stacked in a list item. Sometime some labels will not fill their available space. - preferredMaxLayoutWidth = frame.width - } - @objc public func updateView(_ size: CGFloat) { scaleSize = size as NSNumber + if let originalAttributedString = originalAttributedString { let attributedString = NSMutableAttributedString(attributedString: originalAttributedString) attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length)) @@ -881,6 +875,10 @@ extension Label { return true } + public func horizontalAlignment() -> UIStackView.Alignment { + return .leading + } + public func copyBackgroundColor() -> Bool { return true } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift index 9f2d62c9..f00e7ff1 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift @@ -58,4 +58,9 @@ import Foundation super.reset() leftLabel.styleTitle2XLarge(true) } + + open override func layoutSubviews() { + super.layoutSubviews() + eyebrowHeadlineBodyLink.body.preferredMaxLayoutWidth = eyebrowHeadlineBodyLink.frame.width + } } From 1588644577ab84502f869dc16fe25c0aa090403f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 22 May 2020 16:28:05 -0400 Subject: [PATCH 3/3] comment --- .../ListLeftVariableNumberedListAllTextAndLinks.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift index f00e7ff1..d623311b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift @@ -61,6 +61,7 @@ import Foundation open override func layoutSubviews() { super.layoutSubviews() + // This fixes a defect body text where it doesn't layout correctly. eyebrowHeadlineBodyLink.body.preferredMaxLayoutWidth = eyebrowHeadlineBodyLink.frame.width } }