vds_ios/VDS/Components/Label/Attributes/LabelAttributeAction.swift
Matt Bruce 48797d2003 updated to have a casted isEqual
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-09-15 16:58:54 -05:00

51 lines
1.4 KiB
Swift

//
// LabelAttributeAction.swift
// VDS
//
// Created by Matt Bruce on 8/3/22.
//
import Foundation
import UIKit
import Combine
public protocol LabelAttributeActionable: LabelAttributeModel {
var action: PassthroughSubject<Void, Never> { get set }
}
public struct LabelAttributeActionModel: LabelAttributeActionable {
public static func == (lhs: LabelAttributeActionModel, rhs: LabelAttributeActionModel) -> Bool {
lhs.isEqual(rhs)
}
public func isEqual(_ equatable: LabelAttributeActionModel) -> Bool {
return id == equatable.id && range == equatable.range
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var id = UUID()
public var location: Int
public var length: Int
public var action = PassthroughSubject<Void, Never>()
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(location: Int, length: Int) {
self.location = location
self.length = length
}
private enum CodingKeys: String, CodingKey {
case location, length
}
public func setAttribute(on attributedString: NSMutableAttributedString) {
attributedString.addAttribute(.underlineStyle, value: UnderlineStyle.single.value(), range: range)
}
}