updated vars and split up action

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-04-17 13:11:06 -05:00
parent c3f6fc1d10
commit 4642a65977

View File

@ -15,7 +15,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
private let toolTipAction = PassthroughSubject<Void, Never>() private let tooltipAction = PassthroughSubject<Void, Never>()
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Public Properties // MARK: - Public Properties
@ -24,21 +24,23 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
open var labelText: String? { didSet { didChange() }} open var labelText: String? { didSet { didChange() }}
open var labelAttributes: [any LabelAttributeModel]? { didSet { didChange() }} open var labelAttributes: [any LabelAttributeModel]? { didSet { didChange() } }
open var labelTextStyle: TextStyle = .defaultStyle { didSet { didChange() }} open var labelTextStyle: TextStyle = .defaultStyle { didSet { didChange() } }
open var labelTextPosition: TextPosition = .left { didSet { didChange() } }
public lazy var textColorConfiguration: AnyColorable = { public lazy var textColorConfiguration: AnyColorable = {
label.textColorConfiguration label.textColorConfiguration
}() { didSet { didChange() }} }() { didSet { didChange() }}
open var tooltipCloseButtonText: String = "Close" { didSet { didChange() }} open var tooltipCloseButtonText: String = "Close" { didSet { didChange() } }
open var tooltipSize: Tooltip.Size = .medium { didSet { didChange() }} open var tooltipSize: Tooltip.Size = .medium { didSet { didChange() } }
open var tooltipTitle: String = "" { didSet { didChange() }} open var tooltipTitle: String = "" { didSet { didChange() } }
open var tooltipContent: String = "" { didSet { didChange() }} open var tooltipContent: String = "" { didSet { didChange() } }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Overrides // MARK: - Overrides
@ -50,7 +52,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
label.pinToSuperView() label.pinToSuperView()
//create the tooltip click event //create the tooltip click event
toolTipAction.sink { [weak self] in tooltipAction.sink { [weak self] in
guard let self else { return } guard let self else { return }
self.presentTooltip(surface: self.surface, self.presentTooltip(surface: self.surface,
title: self.tooltipTitle, title: self.tooltipTitle,
@ -71,21 +73,20 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
//add the tool tip //add the tool tip
if let oldText = updatedLabelText, !tooltipTitle.isEmpty, !tooltipContent.isEmpty { if let oldText = updatedLabelText, !tooltipTitle.isEmpty, !tooltipContent.isEmpty {
let toolTipUpdateText = "\(oldText) " //create a little space between the final character and tooltip image let tooltipUpdateText = "\(oldText) " //create a little space between the final character and tooltip image
let toolTipAttribute = ToolTipLabelAttribute(action: toolTipAction, let frame = CGRect(x: 0, y: 0, width: tooltipSize.dimensions.width, height: tooltipSize.dimensions.width)
location: toolTipUpdateText.count - 1, let color = textColorConfiguration.getColor(self)
length: 1, let tooltipAttribute = ImageLabelAttribute(location: tooltipUpdateText.count - 2, imageName: "info", frame: frame, tintColor: color)
tintColor: textColorConfiguration.getColor(self), let tooltipAction = ActionLabelAttribute(location: tooltipUpdateText.count - 3, length: 3, shouldUnderline: false, action: tooltipAction)
size: tooltipSize, updatedLabelText = tooltipUpdateText
lineHeight: labelTextStyle.lineHeight) attributes.append(tooltipAttribute)
updatedLabelText = toolTipUpdateText attributes.append(tooltipAction)
attributes.append(toolTipAttribute)
} }
label.debugBorder()
//set the titleLabel //set the titleLabel
label.text = updatedLabelText label.text = updatedLabelText
label.attributes = attributes label.attributes = attributes
label.textStyle = labelTextStyle label.textStyle = labelTextStyle
label.textPosition = labelTextPosition
label.surface = surface label.surface = surface
label.disabled = disabled label.disabled = disabled
} }