vds_ios/VDS/Components/Label/Attributes/LabelAttributeAction.swift
Matt Bruce 5a22e6ecd0 first cut
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-08-03 17:03:59 -05:00

42 lines
1.1 KiB
Swift

//
// LabelAttributeAction.swift
// VDS
//
// Created by Matt Bruce on 8/3/22.
//
import Foundation
import UIKit
public protocol LabelAttributeActionable: LabelAttributeModel {
var action: Blocks.ActionBlock { get set }
}
public struct LabelAttributeActionModel: LabelAttributeActionable {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var location: Int
public var length: Int
public var action: Blocks.ActionBlock = {}
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(location: Int, length: Int, action: @escaping Blocks.ActionBlock) {
self.location = location
self.length = length
self.action = action
}
private enum CodingKeys: String, CodingKey {
case location, length
}
public func setAttribute(on attributedString: NSMutableAttributedString) {
attributedString.addAttribute(.underlineStyle, value: UnderlineStyle.single.value(), range: range)
}
}