added presenter
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
16d37e1c45
commit
1bed04dae0
@ -23,6 +23,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable
|
|||||||
public var title: String?
|
public var title: String?
|
||||||
public var content: String?
|
public var content: String?
|
||||||
public var contentView: UIView?
|
public var contentView: UIView?
|
||||||
|
public var presenter: UIView?
|
||||||
|
|
||||||
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
||||||
//update the location
|
//update the location
|
||||||
@ -66,7 +67,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable
|
|||||||
addHandler(on: attributedString)
|
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.id = id
|
||||||
self.action = action
|
self.action = action
|
||||||
self.subscriber = subscriber
|
self.subscriber = subscriber
|
||||||
@ -76,6 +77,8 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable
|
|||||||
self.title = title
|
self.title = title
|
||||||
self.content = content
|
self.content = content
|
||||||
self.contentView = contentView
|
self.contentView = contentView
|
||||||
|
self.presenter = presenter
|
||||||
|
|
||||||
//create the tooltip click event
|
//create the tooltip click event
|
||||||
self.subscriber = action.sink { [weak self] in
|
self.subscriber = action.sink { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
@ -83,7 +86,8 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable
|
|||||||
title: self.title,
|
title: self.title,
|
||||||
content: self.content,
|
content: self.content,
|
||||||
contentView: contentView,
|
contentView: contentView,
|
||||||
closeButtonText: self.closeButtonText)
|
closeButtonText: self.closeButtonText,
|
||||||
|
presenter: self.presenter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -295,7 +295,7 @@ open class EntryField: Control, Changeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let tooltipTitle, let tooltipContent {
|
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
|
//set the titleLabel
|
||||||
|
|||||||
@ -135,7 +135,8 @@ open class Tooltip: Control, TooltipLaunchable {
|
|||||||
title: tooltip.title,
|
title: tooltip.title,
|
||||||
content: tooltip.content,
|
content: tooltip.content,
|
||||||
contentView: tooltip.contentView,
|
contentView: tooltip.contentView,
|
||||||
closeButtonText: tooltip.closeButtonText)
|
closeButtonText: tooltip.closeButtonText,
|
||||||
|
presenter: self)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +177,10 @@ open class Tooltip: Control, TooltipLaunchable {
|
|||||||
if label == nil {
|
if label == nil {
|
||||||
label = content
|
label = content
|
||||||
}
|
}
|
||||||
|
accessibilityHint = "Tooltip"
|
||||||
|
accessibilityValue = "collapsed"
|
||||||
if let label {
|
if let label {
|
||||||
accessibilityLabel = "Tooltip: \(label)"
|
accessibilityLabel = label
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,11 +9,11 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
public protocol TooltipLaunchable {
|
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 {
|
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() {
|
if let presenting = UIApplication.topViewController() {
|
||||||
let tooltipViewController = TooltipAlertViewController(nibName: nil, bundle: nil).with {
|
let tooltipViewController = TooltipAlertViewController(nibName: nil, bundle: nil).with {
|
||||||
$0.surface = surface
|
$0.surface = surface
|
||||||
@ -21,6 +21,7 @@ extension TooltipLaunchable {
|
|||||||
$0.contentText = content
|
$0.contentText = content
|
||||||
$0.contentView = contentView
|
$0.contentView = contentView
|
||||||
$0.closeButtonText = closeButtonText
|
$0.closeButtonText = closeButtonText
|
||||||
|
$0.presenter = presenter
|
||||||
$0.modalPresentationStyle = .overCurrentContext
|
$0.modalPresentationStyle = .overCurrentContext
|
||||||
$0.modalTransitionStyle = .crossDissolve
|
$0.modalTransitionStyle = .crossDissolve
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,8 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
self.presentTooltip(surface: self.surface,
|
self.presentTooltip(surface: self.surface,
|
||||||
title: self.tooltipTitle,
|
title: self.tooltipTitle,
|
||||||
content: self.tooltipContent,
|
content: self.tooltipContent,
|
||||||
closeButtonText: self.tooltipCloseButtonText)
|
closeButtonText: self.tooltipCloseButtonText,
|
||||||
|
presenter: self)
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +127,8 @@ extension Label {
|
|||||||
closeButtonText: model.closeButtonText,
|
closeButtonText: model.closeButtonText,
|
||||||
title: model.title,
|
title: model.title,
|
||||||
content: model.content,
|
content: model.content,
|
||||||
contentView: model.contentView)
|
contentView: model.contentView,
|
||||||
|
presenter: self)
|
||||||
newAttributes.append(tooltip)
|
newAttributes.append(tooltip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user