refactored tooltip to use icon

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-17 14:16:50 -05:00
parent d5489dc9af
commit e186b77763
2 changed files with 11 additions and 25 deletions

View File

@ -38,10 +38,10 @@ open class Tooltip: Control, TooltipLaunchable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Public Properties // MARK: - Public Properties
//-------------------------------------------------- //--------------------------------------------------
open var imageView = UIImageView().with { open var icon = Icon().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.name = .info
$0.contentMode = .scaleAspectFill $0.size = .small
$0.clipsToBounds = true $0.isUserInteractionEnabled = false
} }
open var closeButtonText: String = "Close" { didSet { setNeedsUpdate() }} open var closeButtonText: String = "Close" { didSet { setNeedsUpdate() }}
@ -111,18 +111,8 @@ open class Tooltip: Control, TooltipLaunchable {
open override func setup() { open override func setup() {
super.setup() super.setup()
if let image = BundleManager.shared.image(for: "info") { addSubview(icon)
infoImage = image icon.pinToSuperView()
}
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
backgroundColor = .clear backgroundColor = .clear
isAccessibilityElement = true isAccessibilityElement = true
@ -149,7 +139,6 @@ open class Tooltip: Control, TooltipLaunchable {
content = "" content = ""
fillColor = .primary fillColor = .primary
closeButtonText = "Close" closeButtonText = "Close"
imageView.image = nil
shouldUpdateView = true shouldUpdateView = true
setNeedsUpdate() setNeedsUpdate()
} }
@ -158,14 +147,11 @@ open class Tooltip: Control, TooltipLaunchable {
open override func updateView() { open override func updateView() {
super.updateView() super.updateView()
//set the dimensions //get the size
let dimensions = size.value.dimensions icon.size = size.value
heightConstraint?.constant = dimensions.height
widthConstraint?.constant = dimensions.width
//get the color for the image //get the color for the image
let imageColor = iconColorConfiguration.getColor(self) icon.color = iconColorConfiguration.getColor(self)
imageView.image = infoImage.withTintColor(imageColor)
} }
open override func updateAccessibility() { open override func updateAccessibility() {