diff --git a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift index 067d70ed..2ea9f227 100644 --- a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift @@ -23,6 +23,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable public var title: String? public var content: String? public var contentView: UIView? + public var presenter: UIView? public func setAttribute(on attributedString: NSMutableAttributedString) { //update the location @@ -66,7 +67,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable addHandler(on: attributedString) } - public init(id: UUID = UUID(), action: PassthroughSubject = PassthroughSubject(), subscriber: AnyCancellable? = nil, surface: Surface, accessibleText: String? = nil, closeButtonText: String = "Close", title: String? = nil, content: String? = nil, contentView: UIView? = nil) { + public init(id: UUID = UUID(), action: PassthroughSubject = PassthroughSubject(), subscriber: AnyCancellable? = nil, surface: Surface, accessibleText: String? = nil, closeButtonText: String = "Close", title: String? = nil, content: String? = nil, contentView: UIView? = nil, presenter: UIView? = nil) { self.id = id self.action = action self.subscriber = subscriber @@ -76,6 +77,8 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable self.title = title self.content = content self.contentView = contentView + self.presenter = presenter + //create the tooltip click event self.subscriber = action.sink { [weak self] in guard let self else { return } @@ -83,7 +86,8 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable title: self.title, content: self.content, contentView: contentView, - closeButtonText: self.closeButtonText) + closeButtonText: self.closeButtonText, + presenter: self.presenter) } } diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index eb43ba49..d485c007 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -295,7 +295,7 @@ open class EntryField: Control, Changeable { } if let tooltipTitle, let tooltipContent { - attributes.append(TooltipLabelAttribute(surface: surface, title: tooltipTitle, content: tooltipContent, contentView: tooltipContentView)) + attributes.append(TooltipLabelAttribute(surface: surface, title: tooltipTitle, content: tooltipContent, contentView: tooltipContentView, presenter: self)) } //set the titleLabel diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index 9c55747f..8010a81f 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -135,7 +135,8 @@ open class Tooltip: Control, TooltipLaunchable { title: tooltip.title, content: tooltip.content, contentView: tooltip.contentView, - closeButtonText: tooltip.closeButtonText) + closeButtonText: tooltip.closeButtonText, + presenter: self) }) } @@ -176,8 +177,10 @@ open class Tooltip: Control, TooltipLaunchable { if label == nil { label = content } + accessibilityHint = "Tooltip" + accessibilityValue = "collapsed" if let label { - accessibilityLabel = "Tooltip: \(label)" + accessibilityLabel = label } } } diff --git a/VDS/Components/Tooltip/TooltipLaunchable.swift b/VDS/Components/Tooltip/TooltipLaunchable.swift index 17c3f680..33d09b16 100644 --- a/VDS/Components/Tooltip/TooltipLaunchable.swift +++ b/VDS/Components/Tooltip/TooltipLaunchable.swift @@ -9,11 +9,11 @@ import Foundation import UIKit public protocol TooltipLaunchable { - func presentTooltip(surface: Surface, title: String?, content: String?, contentView: UIView?, closeButtonText: String) + func presentTooltip(surface: Surface, title: String?, content: String?, contentView: UIView?, closeButtonText: String, presenter: UIView?) } extension TooltipLaunchable { - public func presentTooltip(surface: Surface, title: String?, content: String?, contentView: UIView? = nil, closeButtonText: String = "Close") { + public func presentTooltip(surface: Surface, title: String?, content: String?, contentView: UIView? = nil, closeButtonText: String = "Close", presenter: UIView? = nil) { if let presenting = UIApplication.topViewController() { let tooltipViewController = TooltipAlertViewController(nibName: nil, bundle: nil).with { $0.surface = surface @@ -21,6 +21,7 @@ extension TooltipLaunchable { $0.contentText = content $0.contentView = contentView $0.closeButtonText = closeButtonText + $0.presenter = presenter $0.modalPresentationStyle = .overCurrentContext $0.modalTransitionStyle = .crossDissolve } diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index 00cbc8f3..6986dd3a 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -57,7 +57,8 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { self.presentTooltip(surface: self.surface, title: self.tooltipTitle, content: self.tooltipContent, - closeButtonText: self.tooltipCloseButtonText) + closeButtonText: self.tooltipCloseButtonText, + presenter: self) }.store(in: &subscribers) } @@ -126,7 +127,8 @@ extension Label { closeButtonText: model.closeButtonText, title: model.title, content: model.content, - contentView: model.contentView) + contentView: model.contentView, + presenter: self) newAttributes.append(tooltip) }