updated vars and split up action
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c3f6fc1d10
commit
4642a65977
@ -15,7 +15,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
private let toolTipAction = PassthroughSubject<Void, Never>()
|
||||
private let tooltipAction = PassthroughSubject<Void, Never>()
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
@ -24,21 +24,23 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
||||
|
||||
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 = {
|
||||
label.textColorConfiguration
|
||||
}() { 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
|
||||
@ -50,7 +52,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
||||
label.pinToSuperView()
|
||||
|
||||
//create the tooltip click event
|
||||
toolTipAction.sink { [weak self] in
|
||||
tooltipAction.sink { [weak self] in
|
||||
guard let self else { return }
|
||||
self.presentTooltip(surface: self.surface,
|
||||
title: self.tooltipTitle,
|
||||
@ -71,21 +73,20 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
||||
|
||||
//add the tool tip
|
||||
if let oldText = updatedLabelText, !tooltipTitle.isEmpty, !tooltipContent.isEmpty {
|
||||
let toolTipUpdateText = "\(oldText) " //create a little space between the final character and tooltip image
|
||||
let toolTipAttribute = ToolTipLabelAttribute(action: toolTipAction,
|
||||
location: toolTipUpdateText.count - 1,
|
||||
length: 1,
|
||||
tintColor: textColorConfiguration.getColor(self),
|
||||
size: tooltipSize,
|
||||
lineHeight: labelTextStyle.lineHeight)
|
||||
updatedLabelText = toolTipUpdateText
|
||||
attributes.append(toolTipAttribute)
|
||||
let tooltipUpdateText = "\(oldText) " //create a little space between the final character and tooltip image
|
||||
let frame = CGRect(x: 0, y: 0, width: tooltipSize.dimensions.width, height: tooltipSize.dimensions.width)
|
||||
let color = textColorConfiguration.getColor(self)
|
||||
let tooltipAttribute = ImageLabelAttribute(location: tooltipUpdateText.count - 2, imageName: "info", frame: frame, tintColor: color)
|
||||
let tooltipAction = ActionLabelAttribute(location: tooltipUpdateText.count - 3, length: 3, shouldUnderline: false, action: tooltipAction)
|
||||
updatedLabelText = tooltipUpdateText
|
||||
attributes.append(tooltipAttribute)
|
||||
attributes.append(tooltipAction)
|
||||
}
|
||||
label.debugBorder()
|
||||
//set the titleLabel
|
||||
label.text = updatedLabelText
|
||||
label.attributes = attributes
|
||||
label.textStyle = labelTextStyle
|
||||
label.textPosition = labelTextPosition
|
||||
label.surface = surface
|
||||
label.disabled = disabled
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user