refactored naming convention to tooltipModel

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-09-13 17:40:54 -05:00
parent 1dd626d766
commit fdb7e955e2
6 changed files with 19 additions and 19 deletions

View File

@ -81,7 +81,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable
//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 }
self.presentTooltip(surface: surface, model: model, presenter: self.presenter) self.presentTooltip(surface: surface, tooltipModel: model, presenter: self.presenter)
} }
} }

View File

@ -134,7 +134,7 @@ open class Tooltip: Control, TooltipLaunchable {
.sink(receiveValue: { [weak self] tooltip in .sink(receiveValue: { [weak self] tooltip in
guard let self else { return} guard let self else { return}
self.presentTooltip(surface: tooltip.surface, self.presentTooltip(surface: tooltip.surface,
model: .init(closeButtonText: tooltip.closeButtonText, tooltipModel: .init(closeButtonText: tooltip.closeButtonText,
title: tooltip.title, title: tooltip.title,
content: tooltip.content, content: tooltip.content,
contentView: tooltip.contentView), contentView: tooltip.contentView),

View File

@ -33,7 +33,7 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
//-------------------------------------------------- //--------------------------------------------------
/// Current Surface and this is used to pass down to child objects that implement Surfacable /// Current Surface and this is used to pass down to child objects that implement Surfacable
open var surface: Surface = .light { didSet { updateView() }} 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() }} open var presenter: UIView? { didSet { updateView() }}
//-------------------------------------------------- //--------------------------------------------------
@ -103,6 +103,6 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
open func updateView() { open func updateView() {
view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.3) view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.3)
tooltipDialog.surface = surface tooltipDialog.surface = surface
tooltipDialog.model = model tooltipDialog.tooltipModel = tooltipModel
} }
} }

View File

@ -55,7 +55,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Public Properties // MARK: - Public Properties
//-------------------------------------------------- //--------------------------------------------------
open var model = Tooltip.TooltipModel() { didSet { setNeedsUpdate() } } open var tooltipModel = Tooltip.TooltipModel() { didSet { setNeedsUpdate() } }
open var titleLabel = Label().with { label in open var titleLabel = Label().with { label in
label.isAccessibilityElement = true label.isAccessibilityElement = true
@ -152,24 +152,24 @@ open class TooltipDialog: View, UIScrollViewDelegate {
contentLabel.surface = surface contentLabel.surface = surface
line.surface = surface line.surface = surface
titleLabel.text = model.title titleLabel.text = tooltipModel.title
contentLabel.text = model.content contentLabel.text = tooltipModel.content
titleLabel.sizeToFit() titleLabel.sizeToFit()
contentLabel.sizeToFit() contentLabel.sizeToFit()
var addedTitle = false var addedTitle = false
if let titleText = model.title, !titleText.isEmpty { if let titleText = tooltipModel.title, !titleText.isEmpty {
contentStackView.addArrangedSubview(titleLabel) contentStackView.addArrangedSubview(titleLabel)
addedTitle = true addedTitle = true
} }
var addedContent = false var addedContent = false
if let contentText = model.content, !contentText.isEmpty { if let contentText = tooltipModel.content, !contentText.isEmpty {
contentStackView.addArrangedSubview(contentLabel) contentStackView.addArrangedSubview(contentLabel)
addedContent = true addedContent = true
} else if let contentView = model.contentView { } else if let contentView = tooltipModel.contentView {
contentView.translatesAutoresizingMaskIntoConstraints = false contentView.translatesAutoresizingMaskIntoConstraints = false
if var surfaceable = contentView as? Surfaceable { if var surfaceable = contentView as? Surfaceable {
surfaceable.surface = surface surfaceable.surface = surface
@ -185,8 +185,8 @@ open class TooltipDialog: View, UIScrollViewDelegate {
let closeButtonTextColor = closeButtonTextColorConfiguration.getColor(self) let closeButtonTextColor = closeButtonTextColorConfiguration.getColor(self)
closeButton.setTitleColor(closeButtonTextColor, for: .normal) closeButton.setTitleColor(closeButtonTextColor, for: .normal)
closeButton.setTitleColor(closeButtonTextColor, for: .highlighted) closeButton.setTitleColor(closeButtonTextColor, for: .highlighted)
closeButton.setTitle(model.closeButtonText, for: .normal) closeButton.setTitle(tooltipModel.closeButtonText, for: .normal)
closeButton.accessibilityLabel = model.closeButtonText closeButton.accessibilityLabel = tooltipModel.closeButtonText
contentStackView.setNeedsLayout() contentStackView.setNeedsLayout()
contentStackView.layoutIfNeeded() contentStackView.layoutIfNeeded()
@ -220,7 +220,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
open override func updateAccessibility() { open override func updateAccessibility() {
super.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] var elements: [Any] = [primaryAccessibilityElement]
contentStackView.arrangedSubviews.forEach{ elements.append($0) } contentStackView.arrangedSubviews.forEach{ elements.append($0) }

View File

@ -9,15 +9,15 @@ import Foundation
import UIKit import UIKit
public protocol TooltipLaunchable { public protocol TooltipLaunchable {
func presentTooltip(surface: Surface, model: Tooltip.TooltipModel, presenter: UIView?) func presentTooltip(surface: Surface, tooltipModel: Tooltip.TooltipModel, presenter: UIView?)
} }
extension TooltipLaunchable { 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() { 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
$0.model = model $0.tooltipModel = tooltipModel
$0.presenter = presenter $0.presenter = presenter
$0.modalPresentationStyle = .overCurrentContext $0.modalPresentationStyle = .overCurrentContext
$0.modalTransitionStyle = .crossDissolve $0.modalTransitionStyle = .crossDissolve

View File

@ -80,7 +80,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
//add tooltip //add tooltip
if let labelText, let tooltipModel, !labelText.isEmpty { 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 { extension Label {
/// Helper to add a tool tip attribute to an existing 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] = [] var newAttributes: [any LabelAttributeModel] = []
if let attributes { if let attributes {
@ -114,7 +114,7 @@ extension Label {
} }
if let text = text, !text.isEmpty { 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) newAttributes.append(tooltip)
} }