From a2696ece91c5c06dee794f5b727fe0c9dfd50862 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 8 May 2023 10:46:42 -0500 Subject: [PATCH] updated trailing tooltip label Signed-off-by: Matt Bruce --- .../Tooltip/TrailingTooltipLabel.swift | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index 0d0f8e19..5441d6eb 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -16,16 +16,16 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { // MARK: - Private Properties //-------------------------------------------------- private let tooltipAction = PassthroughSubject() - + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- open var label = Label() open var labelText: String? { didSet { didChange() }} - + open var labelAttributes: [any LabelAttributeModel]? { didSet { didChange() } } - + open var labelTextStyle: TextStyle = .defaultStyle { didSet { didChange() } } open var labelTextPosition: TextPosition = .left { didSet { didChange() } } @@ -36,8 +36,6 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { open var tooltipCloseButtonText: String = "Close" { didSet { didChange() } } - open var tooltipSize: Tooltip.Size = .medium { didSet { didChange() } } - open var tooltipTitle: String = "" { didSet { didChange() } } open var tooltipContent: String = "" { didSet { didChange() } } @@ -68,43 +66,35 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { label.text = labelText label.textStyle = labelTextStyle label.textPosition = labelTextPosition + label.attributes = labelAttributes label.surface = surface label.disabled = disabled //add tooltip if let labelText, !labelText.isEmpty, !tooltipTitle.isEmpty, !tooltipContent.isEmpty { - //create the model - let model = Label.TooltipModel(surface: surface, - closeButtonText: tooltipCloseButtonText, - size: tooltipSize, - title: tooltipTitle, - content: tooltipContent) - - //add the model - label.addTooltip(model: model) + label.addTooltip(model: .init(surface: surface, closeButtonText: tooltipCloseButtonText, title: tooltipTitle, content: tooltipContent)) } } } + extension Label { public struct TooltipModel { public var surface: Surface public var closeButtonText: String - public var size: Tooltip.Size public var title: String public var content: String - public init(surface: Surface = .light, closeButtonText: String = "Close", size: Tooltip.Size = .medium, title: String, content: String) { + public init(surface: Surface = .light, closeButtonText: String = "Close", title: String, content: String) { self.surface = surface self.closeButtonText = closeButtonText - self.size = size self.title = title self.content = content } } public func addTooltip(model: TooltipModel) { - + var newAttributes: [any LabelAttributeModel] = [] if let attributes { attributes.forEach { attribute in @@ -113,11 +103,10 @@ extension Label { } } } - + if let text = text, !text.isEmpty { let tooltip = TooltipLabelAttribute(surface: surface, closeButtonText: model.closeButtonText, - size: model.size, title: model.title, content: model.content) newAttributes.append(tooltip)