From 2bbe71e1060329e0bd57348607ae123a09a5f0ae Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 8 May 2023 10:45:42 -0500 Subject: [PATCH] refactored action Signed-off-by: Matt Bruce --- .../Label/Attributes/ActionLabelAttribute.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Label/Attributes/ActionLabelAttribute.swift b/VDS/Components/Label/Attributes/ActionLabelAttribute.swift index 1b9ce53a..4a29f613 100644 --- a/VDS/Components/Label/Attributes/ActionLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/ActionLabelAttribute.swift @@ -14,6 +14,12 @@ public protocol ActionLabelAttributeModel: LabelAttributeModel { var action: PassthroughSubject { get set } } +extension ActionLabelAttributeModel { + public func addHandler(on attributedString: NSMutableAttributedString){ + attributedString.addAttribute(NSAttributedString.Key.action, value: "handler", range: range) + } +} + public struct ActionLabelAttribute: ActionLabelAttributeModel { public static func == (lhs: ActionLabelAttribute, rhs: ActionLabelAttribute) -> Bool { @@ -54,7 +60,7 @@ public struct ActionLabelAttribute: ActionLabelAttributeModel { if(shouldUnderline){ UnderlineLabelAttribute(location: location, length: length).setAttribute(on: attributedString) } - attributedString.addAttribute(NSAttributedString.Key.action, value: "handler", range: range) + addHandler(on: attributedString) } }