From e186b77763598fcadd65f5964cc9c8d09e94e700 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 17 Aug 2023 14:16:50 -0500 Subject: [PATCH] refactored tooltip to use icon Signed-off-by: Matt Bruce --- VDS/Components/Tabs/Tabs.swift | 2 +- VDS/Components/Tooltip/Tooltip.swift | 34 ++++++++-------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/VDS/Components/Tabs/Tabs.swift b/VDS/Components/Tabs/Tabs.swift index 548178e5..928daa8d 100644 --- a/VDS/Components/Tabs/Tabs.swift +++ b/VDS/Components/Tabs/Tabs.swift @@ -200,7 +200,7 @@ open class Tabs: View { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() - + updateStackView() updateTabs() updateContentView() diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index c522137f..d3adc11d 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -38,10 +38,10 @@ open class Tooltip: Control, TooltipLaunchable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - open var imageView = UIImageView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.contentMode = .scaleAspectFill - $0.clipsToBounds = true + open var icon = Icon().with { + $0.name = .info + $0.size = .small + $0.isUserInteractionEnabled = false } open var closeButtonText: String = "Close" { didSet { setNeedsUpdate() }} @@ -111,18 +111,8 @@ open class Tooltip: Control, TooltipLaunchable { open override func setup() { super.setup() - if let image = BundleManager.shared.image(for: "info") { - infoImage = image - } - - addSubview(imageView) - - imageView.pinToSuperView() - heightConstraint = imageView.heightAnchor.constraint(equalToConstant: size.value.dimensions.height) - heightConstraint?.isActive = true - widthConstraint = imageView.widthAnchor.constraint(equalToConstant: size.value.dimensions.width) - widthConstraint?.isActive = true - + addSubview(icon) + icon.pinToSuperView() backgroundColor = .clear isAccessibilityElement = true @@ -149,7 +139,6 @@ open class Tooltip: Control, TooltipLaunchable { content = "" fillColor = .primary closeButtonText = "Close" - imageView.image = nil shouldUpdateView = true setNeedsUpdate() } @@ -157,15 +146,12 @@ open class Tooltip: Control, TooltipLaunchable { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() - - //set the dimensions - let dimensions = size.value.dimensions - heightConstraint?.constant = dimensions.height - widthConstraint?.constant = dimensions.width + + //get the size + icon.size = size.value //get the color for the image - let imageColor = iconColorConfiguration.getColor(self) - imageView.image = infoImage.withTintColor(imageColor) + icon.color = iconColorConfiguration.getColor(self) } open override func updateAccessibility() {