51 lines
1.4 KiB
Swift
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 isEqualSelf(_ 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)
|
|
}
|
|
}
|