refactored naming convention to tooltipModel
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
1dd626d766
commit
fdb7e955e2
@ -81,7 +81,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable
|
||||
//create the tooltip click event
|
||||
self.subscriber = action.sink { [weak self] in
|
||||
guard let self else { return }
|
||||
self.presentTooltip(surface: surface, model: model, presenter: self.presenter)
|
||||
self.presentTooltip(surface: surface, tooltipModel: model, presenter: self.presenter)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ open class Tooltip: Control, TooltipLaunchable {
|
||||
.sink(receiveValue: { [weak self] tooltip in
|
||||
guard let self else { return}
|
||||
self.presentTooltip(surface: tooltip.surface,
|
||||
model: .init(closeButtonText: tooltip.closeButtonText,
|
||||
tooltipModel: .init(closeButtonText: tooltip.closeButtonText,
|
||||
title: tooltip.title,
|
||||
content: tooltip.content,
|
||||
contentView: tooltip.contentView),
|
||||
|
||||
@ -33,7 +33,7 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
||||
//--------------------------------------------------
|
||||
/// Current Surface and this is used to pass down to child objects that implement Surfacable
|
||||
open var surface: Surface = .light { didSet { updateView() }}
|
||||
open var model = Tooltip.TooltipModel() { didSet { updateView() }}
|
||||
open var tooltipModel = Tooltip.TooltipModel() { didSet { updateView() }}
|
||||
open var presenter: UIView? { didSet { updateView() }}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -103,6 +103,6 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
||||
open func updateView() {
|
||||
view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.3)
|
||||
tooltipDialog.surface = surface
|
||||
tooltipDialog.model = model
|
||||
tooltipDialog.tooltipModel = tooltipModel
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
open var model = Tooltip.TooltipModel() { didSet { setNeedsUpdate() } }
|
||||
open var tooltipModel = Tooltip.TooltipModel() { didSet { setNeedsUpdate() } }
|
||||
|
||||
open var titleLabel = Label().with { label in
|
||||
label.isAccessibilityElement = true
|
||||
@ -152,24 +152,24 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
contentLabel.surface = surface
|
||||
line.surface = surface
|
||||
|
||||
titleLabel.text = model.title
|
||||
contentLabel.text = model.content
|
||||
titleLabel.text = tooltipModel.title
|
||||
contentLabel.text = tooltipModel.content
|
||||
|
||||
titleLabel.sizeToFit()
|
||||
contentLabel.sizeToFit()
|
||||
|
||||
var addedTitle = false
|
||||
|
||||
if let titleText = model.title, !titleText.isEmpty {
|
||||
if let titleText = tooltipModel.title, !titleText.isEmpty {
|
||||
contentStackView.addArrangedSubview(titleLabel)
|
||||
addedTitle = true
|
||||
}
|
||||
|
||||
var addedContent = false
|
||||
if let contentText = model.content, !contentText.isEmpty {
|
||||
if let contentText = tooltipModel.content, !contentText.isEmpty {
|
||||
contentStackView.addArrangedSubview(contentLabel)
|
||||
addedContent = true
|
||||
} else if let contentView = model.contentView {
|
||||
} else if let contentView = tooltipModel.contentView {
|
||||
contentView.translatesAutoresizingMaskIntoConstraints = false
|
||||
if var surfaceable = contentView as? Surfaceable {
|
||||
surfaceable.surface = surface
|
||||
@ -185,8 +185,8 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
let closeButtonTextColor = closeButtonTextColorConfiguration.getColor(self)
|
||||
closeButton.setTitleColor(closeButtonTextColor, for: .normal)
|
||||
closeButton.setTitleColor(closeButtonTextColor, for: .highlighted)
|
||||
closeButton.setTitle(model.closeButtonText, for: .normal)
|
||||
closeButton.accessibilityLabel = model.closeButtonText
|
||||
closeButton.setTitle(tooltipModel.closeButtonText, for: .normal)
|
||||
closeButton.accessibilityLabel = tooltipModel.closeButtonText
|
||||
|
||||
contentStackView.setNeedsLayout()
|
||||
contentStackView.layoutIfNeeded()
|
||||
@ -220,7 +220,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
|
||||
primaryAccessibilityElement.accessibilityHint = "Double tap on the \(model.closeButtonText) button to close."
|
||||
primaryAccessibilityElement.accessibilityHint = "Double tap on the \(tooltipModel.closeButtonText) button to close."
|
||||
|
||||
var elements: [Any] = [primaryAccessibilityElement]
|
||||
contentStackView.arrangedSubviews.forEach{ elements.append($0) }
|
||||
|
||||
@ -9,15 +9,15 @@ import Foundation
|
||||
import UIKit
|
||||
|
||||
public protocol TooltipLaunchable {
|
||||
func presentTooltip(surface: Surface, model: Tooltip.TooltipModel, presenter: UIView?)
|
||||
func presentTooltip(surface: Surface, tooltipModel: Tooltip.TooltipModel, presenter: UIView?)
|
||||
}
|
||||
|
||||
extension TooltipLaunchable {
|
||||
public func presentTooltip(surface: Surface, model: Tooltip.TooltipModel, presenter: UIView? = nil) {
|
||||
public func presentTooltip(surface: Surface, tooltipModel: Tooltip.TooltipModel, presenter: UIView? = nil) {
|
||||
if let presenting = UIApplication.topViewController() {
|
||||
let tooltipViewController = TooltipAlertViewController(nibName: nil, bundle: nil).with {
|
||||
$0.surface = surface
|
||||
$0.model = model
|
||||
$0.tooltipModel = tooltipModel
|
||||
$0.presenter = presenter
|
||||
$0.modalPresentationStyle = .overCurrentContext
|
||||
$0.modalTransitionStyle = .crossDissolve
|
||||
|
||||
@ -80,7 +80,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
||||
|
||||
//add tooltip
|
||||
if let labelText, let tooltipModel, !labelText.isEmpty {
|
||||
label.addTooltip(model: tooltipModel)
|
||||
label.addTooltip(tooltipModel)
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
||||
extension Label {
|
||||
|
||||
/// Helper to add a tool tip attribute to an existing label.
|
||||
public func addTooltip(model: Tooltip.TooltipModel) {
|
||||
public func addTooltip(_ tooltipModel: Tooltip.TooltipModel) {
|
||||
|
||||
var newAttributes: [any LabelAttributeModel] = []
|
||||
if let attributes {
|
||||
@ -114,7 +114,7 @@ extension Label {
|
||||
}
|
||||
|
||||
if let text = text, !text.isEmpty {
|
||||
let tooltip = TooltipLabelAttribute(surface: surface, model: model, presenter: self)
|
||||
let tooltip = TooltipLabelAttribute(surface: surface, model: tooltipModel, presenter: self)
|
||||
newAttributes.append(tooltip)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user