refactored action

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-05-08 10:45:42 -05:00
parent 66f7b7d87f
commit 2bbe71e106

View File

@ -14,6 +14,12 @@ public protocol ActionLabelAttributeModel: LabelAttributeModel {
var action: PassthroughSubject<Void, Never> { 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)
}
}