From fdb7e955e210db8f3998a90b7aecdb97b2b2e2fa Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 13 Sep 2023 17:40:54 -0500 Subject: [PATCH] refactored naming convention to tooltipModel Signed-off-by: Matt Bruce --- .../Attributes/TooltipLabelAttribute.swift | 2 +- VDS/Components/Tooltip/Tooltip.swift | 2 +- .../Tooltip/TooltipAlertViewController.swift | 4 ++-- VDS/Components/Tooltip/TooltipDialog.swift | 18 +++++++++--------- VDS/Components/Tooltip/TooltipLaunchable.swift | 6 +++--- .../Tooltip/TrailingTooltipLabel.swift | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift index a98024b1..914a8783 100644 --- a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift @@ -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) } } diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index 1333cc7e..5b8390c8 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -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), diff --git a/VDS/Components/Tooltip/TooltipAlertViewController.swift b/VDS/Components/Tooltip/TooltipAlertViewController.swift index b71d92cf..60300997 100644 --- a/VDS/Components/Tooltip/TooltipAlertViewController.swift +++ b/VDS/Components/Tooltip/TooltipAlertViewController.swift @@ -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 } } diff --git a/VDS/Components/Tooltip/TooltipDialog.swift b/VDS/Components/Tooltip/TooltipDialog.swift index fa15325e..a3db25c3 100644 --- a/VDS/Components/Tooltip/TooltipDialog.swift +++ b/VDS/Components/Tooltip/TooltipDialog.swift @@ -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) } diff --git a/VDS/Components/Tooltip/TooltipLaunchable.swift b/VDS/Components/Tooltip/TooltipLaunchable.swift index 514110b4..bcd988b8 100644 --- a/VDS/Components/Tooltip/TooltipLaunchable.swift +++ b/VDS/Components/Tooltip/TooltipLaunchable.swift @@ -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 diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index f4701b24..f1f26abc 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -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) }