vds_ios/VDS/Components/Label/Attributes/ToolTipLabelAttribute.swift
Matt Bruce eacee20fe9 added init
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-01-25 18:20:11 -06:00

48 lines
1.5 KiB
Swift

//
// ToolTipLabelAttribute.swift
// VDS
//
// Created by Matt Bruce on 10/4/22.
//
import Foundation
import UIKit
import Combine
public struct ToolTipLabelAttribute: ActionLabelAttributeModel {
public var id = UUID()
public var accessibleText: String? = "Tool Tip"
public var action: PassthroughSubject<Void, Never>
public var location: Int
public var length: Int
public var tintColor: UIColor
public func setAttribute(on attributedString: NSMutableAttributedString) {
let image = ImageLabelAttribute(location: location,
length: length,
imageName: "info",
frame: .init(x: 0, y: -2, width: 13.3, height: 13.3),
tintColor: tintColor)
image.setAttribute(on: attributedString)
}
public init(action: PassthroughSubject<Void, Never> = .init(), location: Int, length: Int, tintColor: UIColor = .black, accessibleText: String? = nil){
self.action = action
self.location = location
self.length = length
self.tintColor = tintColor
self.accessibleText = accessibleText
}
public static func == (lhs: ToolTipLabelAttribute, rhs: ToolTipLabelAttribute) -> Bool {
lhs.isEqual(rhs)
}
public func isEqual(_ equatable: ToolTipLabelAttribute) -> Bool {
return id == equatable.id && range == equatable.range
}
}