From be71919ccf956b49005d5613516a4c417c73e2ef Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 4 Oct 2022 11:38:20 -0500 Subject: [PATCH] added new properties for accessible and for actions that aren't text Signed-off-by: Matt Bruce --- .../Label/Attributes/LabelAttributeAction.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/VDS/Components/Label/Attributes/LabelAttributeAction.swift b/VDS/Components/Label/Attributes/LabelAttributeAction.swift index f2a5fe49..7e280a42 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeAction.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeAction.swift @@ -10,6 +10,7 @@ import UIKit import Combine public protocol LabelAttributeActionable: LabelAttributeModel { + var accessibleText: String? { get set } var action: PassthroughSubject { get set } } @@ -29,15 +30,19 @@ public struct LabelAttributeActionModel: LabelAttributeActionable { public var id = UUID() public var location: Int public var length: Int + public var shouldUnderline: Bool + public var accessibleText: String? public var action = PassthroughSubject() //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int) { + public init(location: Int, length: Int, shouldUnderline: Bool = true, accessibleText: String? = nil) { self.location = location self.length = length + self.shouldUnderline = shouldUnderline + self.accessibleText = accessibleText } private enum CodingKeys: String, CodingKey { @@ -45,6 +50,8 @@ public struct LabelAttributeActionModel: LabelAttributeActionable { } public func setAttribute(on attributedString: NSMutableAttributedString) { - attributedString.addAttribute(.underlineStyle, value: UnderlineStyle.single.value(), range: range) + if(shouldUnderline){ + attributedString.addAttribute(.underlineStyle, value: UnderlineStyle.single.value(), range: range) + } } }