// // 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 public var location: Int public var length: Int public var tintColor: UIColor public var lineHeight: CGFloat public var size: Tooltip.Size public func setAttribute(on attributedString: NSMutableAttributedString) { var size = size.dimensions.height var yPos = (lineHeight - size) / 2 print("tooltip yPos: \(yPos)") if yPos < 0 { yPos = 0 size = lineHeight } let image = ImageLabelAttribute(location: location, length: length, imageName: "info", frame: .init(x: 0, y: yPos, width: size, height: size), tintColor: tintColor) image.setAttribute(on: attributedString) } public init(action: PassthroughSubject = .init(), location: Int, length: Int, tintColor: UIColor = .black, accessibleText: String? = nil, size: Tooltip.Size = .medium, lineHeight: CGFloat = 0.0){ self.action = action self.location = location self.length = length self.tintColor = tintColor self.accessibleText = accessibleText self.lineHeight = lineHeight self.size = size } public static func == (lhs: ToolTipLabelAttribute, rhs: ToolTipLabelAttribute) -> Bool { lhs.isEqual(rhs) } public func isEqual(_ equatable: ToolTipLabelAttribute) -> Bool { return id == equatable.id && range == equatable.range } }