added presenter

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-07-31 10:13:37 -05:00
parent 16d37e1c45
commit 1bed04dae0
5 changed files with 19 additions and 9 deletions

View File

@ -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<Void, Never> = PassthroughSubject<Void, Never>(), 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<Void, Never> = PassthroughSubject<Void, Never>(), 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)
}
}

View File

@ -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

View File

@ -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
}
}
}

View File

@ -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
}

View File

@ -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)
}