From 2f69b07bf56e24aafac38228a20575404f33da28 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Fri, 3 May 2019 14:20:23 -0400 Subject: [PATCH] Removed unneeded parameter. --- MVMCoreUI/Atoms/Views/Label.swift | 20 +++++++------------ .../Atoms/Views/LabelWithInternalButton.swift | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 255fa342..54788654 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -50,7 +50,6 @@ public typealias ActionBlock = () -> Void // Used for tappable links in the text. private struct ActionableClause { - var labelView: Label? var location: Int? var length: Int? var actionText: String? @@ -173,8 +172,7 @@ public typealias ActionBlock = () -> Void let subStringRange = Range(range, in: text) else { return } - clauses.append(ActionableClause(labelView: self, - location: range.location, + clauses.append(ActionableClause(location: range.location, length: range.length, actionText: String(text[subStringRange]), actionBlock: actionBlock)) @@ -198,8 +196,7 @@ public typealias ActionBlock = () -> Void let subStringRange = Range(range, in: text) else { return } - clauses.append(ActionableClause(labelView: self, - location: range.location, + clauses.append(ActionableClause(location: range.location, length: range.length, actionText: String(text[subStringRange]), actionBlock: { [weak self, weak delegate] in @@ -233,8 +230,7 @@ public typealias ActionBlock = () -> Void let string = text as NSString let range = string.range(of: actionText) - clauses.append(ActionableClause(labelView: self, - location: range.location, + clauses.append(ActionableClause(location: range.location, length: range.length, actionText: actionText, actionBlock: actionBlock)) @@ -258,7 +254,7 @@ public typealias ActionBlock = () -> Void let string = text as NSString let range = string.range(of: actionText) - clauses.append(ActionableClause(labelView: self, location: range.location, length: range.length, actionText: actionText, + clauses.append(ActionableClause(location: range.location, length: range.length, actionText: actionText, actionBlock: { [weak self, weak delegate] in var willPerform = true @@ -400,8 +396,7 @@ public typealias ActionBlock = () -> Void let subStringRange = Range(NSRange(location: actionLocation, length: actionLength), in: text) else { continue } - label.clauses.append(ActionableClause(labelView: label, - location: actionLocation, + label.clauses.append(ActionableClause(location: actionLocation, length: actionLength, actionText: String(text[subStringRange]), actionBlock: { [weak delegate] in @@ -563,7 +558,7 @@ extension Label { return true } } - + return false } @@ -603,7 +598,6 @@ extension Label { // MARK: - UITapGestureRecognizer Override extension UITapGestureRecognizer { - func didTapAttributedTextInLabel(_ label: Label, inRange targetRange: NSRange) -> Bool { guard let attributedText = label.attributedText else { return false } @@ -620,7 +614,7 @@ extension UITapGestureRecognizer { textContainer.maximumNumberOfLines = label.numberOfLines let labelSize = label.bounds.size textContainer.size = labelSize - + let j = layoutManager.boundingRect(forGlyphRange: targetRange, in: textContainer) let indexOfCharacter = layoutManager.characterIndex(for: location(in: label), in: textContainer, fractionOfDistanceBetweenInsertionPoints: nil) return NSLocationInRange(indexOfCharacter, targetRange) diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index e2db0fdb..2bdab94a 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -210,7 +210,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt setAlternateActionTextAttributes([NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)]) self.label?.attributedText = attributedText - self.label?.accessibilityTraits = .button + self.label?.accessibilityTraits = actionText?.isEmpty ?? false ? .staticText : .button } @objc public func setActionMap(_ actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {