From 3fda7db3201fc6a01b8b1112b624d0e9bdc27baa Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 31 Mar 2020 15:14:15 -0400 Subject: [PATCH] Move Legacy Files --- .../Atomic/Atoms/Views/Label/Label.swift | 26 ++++++++++--------- MVMCoreUI/Styles/MFStyler.h | 1 - 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 7fec5960..31cd5eba 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -52,10 +52,7 @@ public typealias ActionBlock = () -> () isUserInteractionEnabled = !clauses.isEmpty if clauses.count > 1 { clauses.sort { first, second in - guard let firstLocation = first.range?.location, - let secondLocation = second.range?.location - else { return false } - return firstLocation < secondLocation + return first.range.location < second.range.location } } } @@ -63,12 +60,18 @@ public typealias ActionBlock = () -> () /// Used for tappable links in the text. public struct ActionableClause { - var range: NSRange? - var actionBlock: ActionBlock? - var accessibilityID: Int = 0 + public var range: NSRange + public var actionBlock: ActionBlock + public var accessibilityID: Int = 0 - func performAction() { - actionBlock?() + public func performAction() { + actionBlock() + } + + public init(range: NSRange, actionBlock: @escaping ActionBlock, accessibilityID: Int = 0) { + self.range = range + self.actionBlock = actionBlock + self.accessibilityID = accessibilityID } } @@ -897,8 +900,7 @@ extension Label { let mutableAttributedString = NSMutableAttributedString(attributedString: attributedText) clauses.forEach { clause in - guard let range = clause.range else { return } - mutableAttributedString.removeAttribute(NSAttributedString.Key.underlineStyle, range: range) + mutableAttributedString.removeAttribute(NSAttributedString.Key.underlineStyle, range: clause.range) } self.attributedText = mutableAttributedString @@ -981,7 +983,7 @@ extension Label { for clause in clauses { // This determines if we tapped on the desired range of text. - if let range = clause.range, gesture.didTapAttributedTextInLabel(self, inRange: range) { + if gesture.didTapAttributedTextInLabel(self, inRange: clause.range) { clause.performAction() return } diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 6accea28..a3827044 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -9,7 +9,6 @@ #import #import -@class LabelWithInternalButton; @class MFSizeObject; //enum for border