Compare commits
No commits in common. "123831adf623ec16bbd2587906089091b5398a5b" and "a266af0db299789887fc9a123fd43142ac147847" have entirely different histories.
123831adf6
...
a266af0db2
@ -62,8 +62,6 @@
|
|||||||
EA5F86C82A1BD99100BC83E4 /* TabModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5F86C72A1BD99100BC83E4 /* TabModel.swift */; };
|
EA5F86C82A1BD99100BC83E4 /* TabModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5F86C72A1BD99100BC83E4 /* TabModel.swift */; };
|
||||||
EA5F86CC2A1D28B500BC83E4 /* ReleaseNotes.txt in Resources */ = {isa = PBXBuildFile; fileRef = EA5F86CB2A1D28B500BC83E4 /* ReleaseNotes.txt */; };
|
EA5F86CC2A1D28B500BC83E4 /* ReleaseNotes.txt in Resources */ = {isa = PBXBuildFile; fileRef = EA5F86CB2A1D28B500BC83E4 /* ReleaseNotes.txt */; };
|
||||||
EA5F86D02A1F936100BC83E4 /* TabsContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5F86CF2A1F936100BC83E4 /* TabsContainer.swift */; };
|
EA5F86D02A1F936100BC83E4 /* TabsContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5F86CF2A1F936100BC83E4 /* TabsContainer.swift */; };
|
||||||
EA7B311D2A7018B600329654 /* TooltipModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7B311C2A7018B600329654 /* TooltipModel.swift */; };
|
|
||||||
EA7B311F2A701AE400329654 /* Children.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7B311E2A701AE400329654 /* Children.swift */; };
|
|
||||||
EA81410B2A0E8E3C004F60D2 /* ButtonIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA81410A2A0E8E3C004F60D2 /* ButtonIcon.swift */; };
|
EA81410B2A0E8E3C004F60D2 /* ButtonIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA81410A2A0E8E3C004F60D2 /* ButtonIcon.swift */; };
|
||||||
EA8141102A127066004F60D2 /* UIColor+VDSColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */; };
|
EA8141102A127066004F60D2 /* UIColor+VDSColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */; };
|
||||||
EA89200428AECF4B006B9984 /* UITextField+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */; };
|
EA89200428AECF4B006B9984 /* UITextField+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */; };
|
||||||
@ -209,8 +207,6 @@
|
|||||||
EA5F86C72A1BD99100BC83E4 /* TabModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabModel.swift; sourceTree = "<group>"; };
|
EA5F86C72A1BD99100BC83E4 /* TabModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabModel.swift; sourceTree = "<group>"; };
|
||||||
EA5F86CB2A1D28B500BC83E4 /* ReleaseNotes.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = ReleaseNotes.txt; sourceTree = "<group>"; };
|
EA5F86CB2A1D28B500BC83E4 /* ReleaseNotes.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = ReleaseNotes.txt; sourceTree = "<group>"; };
|
||||||
EA5F86CF2A1F936100BC83E4 /* TabsContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsContainer.swift; sourceTree = "<group>"; };
|
EA5F86CF2A1F936100BC83E4 /* TabsContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsContainer.swift; sourceTree = "<group>"; };
|
||||||
EA7B311C2A7018B600329654 /* TooltipModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipModel.swift; sourceTree = "<group>"; };
|
|
||||||
EA7B311E2A701AE400329654 /* Children.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Children.swift; sourceTree = "<group>"; };
|
|
||||||
EA81410A2A0E8E3C004F60D2 /* ButtonIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonIcon.swift; sourceTree = "<group>"; };
|
EA81410A2A0E8E3C004F60D2 /* ButtonIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonIcon.swift; sourceTree = "<group>"; };
|
||||||
EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+VDSColor.swift"; sourceTree = "<group>"; };
|
EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+VDSColor.swift"; sourceTree = "<group>"; };
|
||||||
EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Publisher.swift"; sourceTree = "<group>"; };
|
EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Publisher.swift"; sourceTree = "<group>"; };
|
||||||
@ -507,7 +503,6 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
EA985C1C296CD13600F2FF2E /* BundleManager.swift */,
|
EA985C1C296CD13600F2FF2E /* BundleManager.swift */,
|
||||||
EA7B311E2A701AE400329654 /* Children.swift */,
|
|
||||||
EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */,
|
EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */,
|
||||||
EA3361B5288B2A410071C351 /* Control.swift */,
|
EA3361B5288B2A410071C351 /* Control.swift */,
|
||||||
EAF7F09F289AB7EC00B287F5 /* View.swift */,
|
EAF7F09F289AB7EC00B287F5 /* View.swift */,
|
||||||
@ -684,7 +679,6 @@
|
|||||||
EAB2375C29E8789100AABE9A /* Tooltip.swift */,
|
EAB2375C29E8789100AABE9A /* Tooltip.swift */,
|
||||||
EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */,
|
EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */,
|
||||||
EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */,
|
EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */,
|
||||||
EA7B311C2A7018B600329654 /* TooltipModel.swift */,
|
|
||||||
EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */,
|
EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */,
|
||||||
);
|
);
|
||||||
path = Tooltip;
|
path = Tooltip;
|
||||||
@ -929,7 +923,6 @@
|
|||||||
EA5E305A29510F8B0082B959 /* EnumSubset.swift in Sources */,
|
EA5E305A29510F8B0082B959 /* EnumSubset.swift in Sources */,
|
||||||
EA985BF7296C665E00F2FF2E /* IconName.swift in Sources */,
|
EA985BF7296C665E00F2FF2E /* IconName.swift in Sources */,
|
||||||
EA8141102A127066004F60D2 /* UIColor+VDSColor.swift in Sources */,
|
EA8141102A127066004F60D2 /* UIColor+VDSColor.swift in Sources */,
|
||||||
EA7B311D2A7018B600329654 /* TooltipModel.swift in Sources */,
|
|
||||||
EAF7F0AF289B144C00B287F5 /* UnderlineLabelAttribute.swift in Sources */,
|
EAF7F0AF289B144C00B287F5 /* UnderlineLabelAttribute.swift in Sources */,
|
||||||
EA0D1C412A6AD61C00E5C127 /* Typography+Additional.swift in Sources */,
|
EA0D1C412A6AD61C00E5C127 /* Typography+Additional.swift in Sources */,
|
||||||
EAC925842911C63100091998 /* Colorable.swift in Sources */,
|
EAC925842911C63100091998 /* Colorable.swift in Sources */,
|
||||||
@ -945,7 +938,6 @@
|
|||||||
EAC846F3294B95CE00F685BA /* ButtonGroupCollectionViewCell.swift in Sources */,
|
EAC846F3294B95CE00F685BA /* ButtonGroupCollectionViewCell.swift in Sources */,
|
||||||
EAF7F0952899861000B287F5 /* CheckboxItem.swift in Sources */,
|
EAF7F0952899861000B287F5 /* CheckboxItem.swift in Sources */,
|
||||||
EA985BE82968951C00F2FF2E /* TileletTitleModel.swift in Sources */,
|
EA985BE82968951C00F2FF2E /* TileletTitleModel.swift in Sources */,
|
||||||
EA7B311F2A701AE400329654 /* Children.swift in Sources */,
|
|
||||||
EA297A5529FB07760031ED56 /* TooltipLabelAttribute.swift in Sources */,
|
EA297A5529FB07760031ED56 /* TooltipLabelAttribute.swift in Sources */,
|
||||||
EA985BEA29689B6D00F2FF2E /* TileletSubTitleModel.swift in Sources */,
|
EA985BEA29689B6D00F2FF2E /* TileletSubTitleModel.swift in Sources */,
|
||||||
EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */,
|
EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */,
|
||||||
|
|||||||
@ -1,106 +0,0 @@
|
|||||||
//
|
|
||||||
// Children.swift
|
|
||||||
// VDS
|
|
||||||
//
|
|
||||||
// Created by Matt Bruce on 7/25/23.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
open class Children: View {
|
|
||||||
|
|
||||||
public enum Mode {
|
|
||||||
case textOnly
|
|
||||||
case viewOnly
|
|
||||||
case textViewOnly
|
|
||||||
|
|
||||||
public var errorMessage: String {
|
|
||||||
switch self {
|
|
||||||
case .textOnly:
|
|
||||||
return "Invalid type passed. Expected String."
|
|
||||||
case .viewOnly:
|
|
||||||
return "Invalid type passed. Expected a UIView."
|
|
||||||
case .textViewOnly:
|
|
||||||
return "Invalid type passed. Expected a UIView or String."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open var mode: Mode = .textViewOnly
|
|
||||||
|
|
||||||
open var child: Any? {
|
|
||||||
didSet {
|
|
||||||
updateChildView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open var textStyle: TextStyle? {
|
|
||||||
didSet {
|
|
||||||
updateChildView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open lazy var label: Label = {
|
|
||||||
let lbl = Label()
|
|
||||||
lbl.lineBreakMode = .byWordWrapping
|
|
||||||
lbl.numberOfLines = 0
|
|
||||||
lbl.layer.masksToBounds = true
|
|
||||||
lbl.textAlignment = .left
|
|
||||||
return lbl
|
|
||||||
}()
|
|
||||||
|
|
||||||
open var customSubview: UIView?
|
|
||||||
|
|
||||||
private func updateChildView() {
|
|
||||||
// Remove previous views if any
|
|
||||||
label.removeFromSuperview()
|
|
||||||
customSubview?.removeFromSuperview()
|
|
||||||
|
|
||||||
guard let child else { return }
|
|
||||||
|
|
||||||
var view: UIView? = nil
|
|
||||||
|
|
||||||
switch mode {
|
|
||||||
|
|
||||||
case .textOnly:
|
|
||||||
if let string = child as? String {
|
|
||||||
label.text = string
|
|
||||||
if let textStyle = textStyle {
|
|
||||||
label.textStyle = textStyle
|
|
||||||
}
|
|
||||||
view = label
|
|
||||||
}
|
|
||||||
case .viewOnly:
|
|
||||||
if let customView = child as? View {
|
|
||||||
customSubview = customView
|
|
||||||
view = customView
|
|
||||||
}
|
|
||||||
case .textViewOnly:
|
|
||||||
if let customView = child as? View {
|
|
||||||
customSubview = customView
|
|
||||||
view = customView
|
|
||||||
} else if let string = child as? String {
|
|
||||||
label.text = string
|
|
||||||
if let textStyle = textStyle {
|
|
||||||
label.textStyle = textStyle
|
|
||||||
}
|
|
||||||
view = label
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let unwrappedView = view else {
|
|
||||||
print(mode.errorMessage)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
addSubview(unwrappedView)
|
|
||||||
unwrappedView.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
NSLayoutConstraint.activate([
|
|
||||||
unwrappedView.topAnchor.constraint(equalTo: self.topAnchor),
|
|
||||||
unwrappedView.bottomAnchor.constraint(equalTo: self.bottomAnchor),
|
|
||||||
unwrappedView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
|
|
||||||
unwrappedView.trailingAnchor.constraint(equalTo: self.trailingAnchor)
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -13,19 +13,16 @@ import VDSColorTokens
|
|||||||
public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable {
|
public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable {
|
||||||
public var id = UUID()
|
public var id = UUID()
|
||||||
public var action = PassthroughSubject<Void, Never>()
|
public var action = PassthroughSubject<Void, Never>()
|
||||||
|
|
||||||
private var subscriber: AnyCancellable?
|
private var subscriber: AnyCancellable?
|
||||||
private var size: Tooltip.Size = .small
|
private var size: Tooltip.Size = .small
|
||||||
private var tooltipModel: TooltipModel {
|
|
||||||
.init(surface: surface, closeButtonText: closeButtonText, title: title, child: child)
|
|
||||||
}
|
|
||||||
public var location: Int = 0
|
public var location: Int = 0
|
||||||
public var length: Int = 3
|
public var length: Int = 3
|
||||||
public var surface: Surface = .light
|
public var surface: Surface = .light
|
||||||
public var accessibleText: String? = "Tool Tip"
|
public var accessibleText: String? = "Tool Tip"
|
||||||
public var closeButtonText: String = "Close"
|
public var closeButtonText: String = "Close"
|
||||||
public var title: String?
|
public var title: String?
|
||||||
public var child: Any?
|
public var content: String?
|
||||||
|
public var contentView: UIView?
|
||||||
|
|
||||||
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
||||||
//update the location
|
//update the location
|
||||||
@ -69,7 +66,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, child: Any? = 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) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.action = action
|
self.action = action
|
||||||
self.subscriber = subscriber
|
self.subscriber = subscriber
|
||||||
@ -77,11 +74,16 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable
|
|||||||
self.accessibleText = accessibleText
|
self.accessibleText = accessibleText
|
||||||
self.closeButtonText = closeButtonText
|
self.closeButtonText = closeButtonText
|
||||||
self.title = title
|
self.title = title
|
||||||
self.child = child
|
self.content = content
|
||||||
|
self.contentView = contentView
|
||||||
//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(tooltip: tooltipModel)
|
self.presentTooltip(surface: self.surface,
|
||||||
|
title: self.title,
|
||||||
|
content: self.content,
|
||||||
|
contentView: contentView,
|
||||||
|
closeButtonText: self.closeButtonText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -149,7 +149,9 @@ open class EntryField: Control, Changeable {
|
|||||||
|
|
||||||
open var tooltipTitle: String? { didSet { setNeedsUpdate() }}
|
open var tooltipTitle: String? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var tooltipChild: Any? { didSet { setNeedsUpdate() }}
|
open var tooltipContent: String? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var tooltipContentView: UIView? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var transparentBackground: Bool = false { didSet { setNeedsUpdate() }}
|
open var transparentBackground: Bool = false { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
@ -244,7 +246,7 @@ open class EntryField: Control, Changeable {
|
|||||||
showError = false
|
showError = false
|
||||||
errorText = nil
|
errorText = nil
|
||||||
tooltipTitle = nil
|
tooltipTitle = nil
|
||||||
tooltipChild = nil
|
tooltipContent = nil
|
||||||
transparentBackground = false
|
transparentBackground = false
|
||||||
width = nil
|
width = nil
|
||||||
maxLength = nil
|
maxLength = nil
|
||||||
@ -291,7 +293,9 @@ open class EntryField: Control, Changeable {
|
|||||||
updatedLabelText = "\(oldText) Optional"
|
updatedLabelText = "\(oldText) Optional"
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.append(TooltipLabelAttribute(surface: surface, title: tooltipTitle, child: tooltipChild))
|
if let tooltipTitle, let tooltipContent {
|
||||||
|
attributes.append(TooltipLabelAttribute(surface: surface, title: tooltipTitle, content: tooltipContent, contentView: tooltipContentView))
|
||||||
|
}
|
||||||
|
|
||||||
//set the titleLabel
|
//set the titleLabel
|
||||||
titleLabel.text = updatedLabelText
|
titleLabel.text = updatedLabelText
|
||||||
|
|||||||
@ -34,9 +34,6 @@ open class Tooltip: Control, TooltipLaunchable {
|
|||||||
private var widthConstraint: NSLayoutConstraint?
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
private var heightConstraint: NSLayoutConstraint?
|
private var heightConstraint: NSLayoutConstraint?
|
||||||
private var infoImage = UIImage()
|
private var infoImage = UIImage()
|
||||||
private var tooltipModel: TooltipModel {
|
|
||||||
.init(surface: surface, closeButtonText: closeButtonText, title: title, child: child)
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
@ -55,7 +52,9 @@ open class Tooltip: Control, TooltipLaunchable {
|
|||||||
|
|
||||||
open var title: String? { didSet { setNeedsUpdate() }}
|
open var title: String? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var child: Any? { didSet { setNeedsUpdate() }}
|
open var content: String? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var contentView: UIView? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
@ -132,17 +131,24 @@ open class Tooltip: Control, TooltipLaunchable {
|
|||||||
onClickSubscriber = publisher(for: .touchUpInside)
|
onClickSubscriber = publisher(for: .touchUpInside)
|
||||||
.sink(receiveValue: { [weak self] tooltip in
|
.sink(receiveValue: { [weak self] tooltip in
|
||||||
guard let self else { return}
|
guard let self else { return}
|
||||||
self.presentTooltip(tooltip: tooltipModel)
|
self.presentTooltip(surface: tooltip.surface,
|
||||||
|
title: tooltip.title,
|
||||||
|
content: tooltip.content,
|
||||||
|
contentView: tooltip.contentView,
|
||||||
|
closeButtonText: tooltip.closeButtonText)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
size = .medium
|
size = .medium
|
||||||
title = ""
|
title = ""
|
||||||
|
content = ""
|
||||||
fillColor = .primary
|
fillColor = .primary
|
||||||
closeButtonText = "Close"
|
closeButtonText = "Close"
|
||||||
imageView.image = nil
|
imageView.image = nil
|
||||||
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +173,7 @@ open class Tooltip: Control, TooltipLaunchable {
|
|||||||
}
|
}
|
||||||
var label = title
|
var label = title
|
||||||
if label == nil {
|
if label == nil {
|
||||||
label = child as? String
|
label = content
|
||||||
}
|
}
|
||||||
if let label {
|
if let label {
|
||||||
accessibilityLabel = "Tooltip: \(label)"
|
accessibilityLabel = "Tooltip: \(label)"
|
||||||
|
|||||||
@ -33,7 +33,8 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var surface: Surface = .light { didSet { updateView() }}
|
open var surface: Surface = .light { didSet { updateView() }}
|
||||||
open var titleText: String? { didSet { updateView() }}
|
open var titleText: String? { didSet { updateView() }}
|
||||||
open var child: Any? { didSet { updateView() }}
|
open var contentText: String? { didSet { updateView() }}
|
||||||
|
open var contentView: UIView? { didSet { updateView() }}
|
||||||
open var closeButtonText: String = "Close" { didSet { updateView() }}
|
open var closeButtonText: String = "Close" { didSet { updateView() }}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -90,7 +91,8 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
|||||||
view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.3)
|
view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.3)
|
||||||
tooltipDialog.surface = surface
|
tooltipDialog.surface = surface
|
||||||
tooltipDialog.titleText = titleText
|
tooltipDialog.titleText = titleText
|
||||||
tooltipDialog.child = children
|
tooltipDialog.contentText = contentText
|
||||||
|
tooltipDialog.contentView = contentView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +121,13 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
|||||||
open var titleLabel = Label().with { label in
|
open var titleLabel = Label().with { label in
|
||||||
label.textStyle = .boldTitleMedium
|
label.textStyle = .boldTitleMedium
|
||||||
}
|
}
|
||||||
open var child: Any? { didSet { setNeedsUpdate() }}
|
|
||||||
|
|
||||||
private var childrenView = Children().with { $0.textStyle = .bodyLarge; $0.mode = .textViewOnly }
|
open var contentText: String? { didSet { setNeedsUpdate() }}
|
||||||
|
open var contentLabel = Label().with { label in
|
||||||
|
label.textStyle = .bodyLarge
|
||||||
|
}
|
||||||
|
|
||||||
|
open var contentView: UIView? = nil
|
||||||
|
|
||||||
open var closeButtonText: String = "Close" { didSet { setNeedsUpdate() }}
|
open var closeButtonText: String = "Close" { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
@ -158,7 +164,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
|||||||
layer.cornerRadius = 8
|
layer.cornerRadius = 8
|
||||||
|
|
||||||
contentStackView.addArrangedSubview(titleLabel)
|
contentStackView.addArrangedSubview(titleLabel)
|
||||||
contentStackView.addArrangedSubview(childrenView)
|
contentStackView.addArrangedSubview(contentLabel)
|
||||||
scrollView.addSubview(contentStackView)
|
scrollView.addSubview(contentStackView)
|
||||||
addSubview(scrollView)
|
addSubview(scrollView)
|
||||||
addSubview(line)
|
addSubview(line)
|
||||||
@ -203,17 +209,20 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
|||||||
scrollView.indicatorStyle = surface == .light ? .black : .white
|
scrollView.indicatorStyle = surface == .light ? .black : .white
|
||||||
|
|
||||||
titleLabel.removeFromSuperview()
|
titleLabel.removeFromSuperview()
|
||||||
childrenView.removeFromSuperview()
|
contentLabel.removeFromSuperview()
|
||||||
|
contentView?.removeFromSuperview()
|
||||||
|
|
||||||
titleLabel.surface = surface
|
titleLabel.surface = surface
|
||||||
childrenView.surface = surface
|
contentLabel.surface = surface
|
||||||
line.surface = surface
|
line.surface = surface
|
||||||
|
|
||||||
titleLabel.text = titleText
|
titleLabel.text = titleText
|
||||||
|
contentLabel.text = contentText
|
||||||
|
|
||||||
titleLabel.sizeToFit()
|
titleLabel.sizeToFit()
|
||||||
|
contentLabel.sizeToFit()
|
||||||
|
|
||||||
var addedTitle = false
|
var addedTitle = false
|
||||||
childrenView.child = child
|
|
||||||
|
|
||||||
if let titleText, !titleText.isEmpty {
|
if let titleText, !titleText.isEmpty {
|
||||||
contentStackView.addArrangedSubview(titleLabel)
|
contentStackView.addArrangedSubview(titleLabel)
|
||||||
@ -221,11 +230,22 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var addedContent = false
|
var addedContent = false
|
||||||
if let child {
|
if let contentText, !contentText.isEmpty {
|
||||||
if var surfaceable = child as? Surfaceable {
|
contentStackView.addArrangedSubview(contentLabel)
|
||||||
|
addedContent = true
|
||||||
|
} else if let contentView {
|
||||||
|
contentView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
if var surfaceable = contentView as? Surfaceable {
|
||||||
surfaceable.surface = surface
|
surfaceable.surface = surface
|
||||||
}
|
}
|
||||||
contentStackView.addArrangedSubview(childrenView)
|
let wrapper = View()
|
||||||
|
wrapper.addSubview(contentView)
|
||||||
|
contentView.pinTop()
|
||||||
|
contentView.pinLeading()
|
||||||
|
contentView.pinBottom()
|
||||||
|
contentView.pinTrailingLessThanOrEqualTo()
|
||||||
|
contentView.setNeedsLayout()
|
||||||
|
contentStackView.addArrangedSubview(wrapper)
|
||||||
addedContent = true
|
addedContent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,17 +9,18 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
public protocol TooltipLaunchable {
|
public protocol TooltipLaunchable {
|
||||||
func presentTooltip(tooltip: TooltipModel)
|
func presentTooltip(surface: Surface, title: String?, content: String?, contentView: UIView?, closeButtonText: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TooltipLaunchable {
|
extension TooltipLaunchable {
|
||||||
public func presentTooltip(tooltip: TooltipModel) {
|
public func presentTooltip(surface: Surface, title: String?, content: String?, contentView: UIView? = nil, closeButtonText: String = "Close") {
|
||||||
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 = tooltip.surface
|
$0.surface = surface
|
||||||
$0.titleText = tooltip.title
|
$0.titleText = title
|
||||||
$0.child = tooltip.child
|
$0.contentText = content
|
||||||
$0.closeButtonText = tooltip.closeButtonText
|
$0.contentView = contentView
|
||||||
|
$0.closeButtonText = closeButtonText
|
||||||
$0.modalPresentationStyle = .overCurrentContext
|
$0.modalPresentationStyle = .overCurrentContext
|
||||||
$0.modalTransitionStyle = .crossDissolve
|
$0.modalTransitionStyle = .crossDissolve
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
//
|
|
||||||
// TooltipModel.swift
|
|
||||||
// VDS
|
|
||||||
//
|
|
||||||
// Created by Matt Bruce on 7/25/23.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
public struct TooltipModel {
|
|
||||||
public var surface: Surface
|
|
||||||
public var closeButtonText: String
|
|
||||||
public var title: String?
|
|
||||||
public var child: Any?
|
|
||||||
public init(surface: Surface = .light, closeButtonText: String = "Close", title: String?, child: Any? = nil) {
|
|
||||||
self.surface = surface
|
|
||||||
self.closeButtonText = closeButtonText
|
|
||||||
self.title = title
|
|
||||||
self.child = child
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -16,9 +16,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private let tooltipAction = PassthroughSubject<Void, Never>()
|
private let tooltipAction = PassthroughSubject<Void, Never>()
|
||||||
private var tooltipModel: TooltipModel {
|
|
||||||
.init(surface: surface, closeButtonText: tooltipCloseButtonText, title: tooltipTitle, child: tooltipChild)
|
|
||||||
}
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -40,8 +38,9 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
|
|
||||||
open var tooltipTitle: String? { didSet { setNeedsUpdate() } }
|
open var tooltipTitle: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var tooltipChild: Any? { didSet { setNeedsUpdate() } }
|
open var tooltipContent: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
|
open var tooltipContentView: UIView? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
@ -55,7 +54,10 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
//create the tooltip click event
|
//create the tooltip click event
|
||||||
tooltipAction.sink { [weak self] in
|
tooltipAction.sink { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
self.presentTooltip(tooltip: tooltipModel)
|
self.presentTooltip(surface: self.surface,
|
||||||
|
title: self.tooltipTitle,
|
||||||
|
content: self.tooltipContent,
|
||||||
|
closeButtonText: self.tooltipCloseButtonText)
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +72,9 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
label.disabled = disabled
|
label.disabled = disabled
|
||||||
|
|
||||||
//add tooltip
|
//add tooltip
|
||||||
label.addTooltip(model: tooltipModel)
|
if let labelText, !labelText.isEmpty {
|
||||||
|
label.addTooltip(model: .init(surface: surface, closeButtonText: tooltipCloseButtonText, title: tooltipTitle, content: tooltipContent, contentView: tooltipContentView))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
@ -82,7 +86,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
labelTextPosition = .left
|
labelTextPosition = .left
|
||||||
tooltipCloseButtonText = "Close"
|
tooltipCloseButtonText = "Close"
|
||||||
tooltipTitle = ""
|
tooltipTitle = ""
|
||||||
tooltipChild = nil
|
tooltipContent = ""
|
||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
@ -90,6 +94,20 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
|
|
||||||
|
|
||||||
extension Label {
|
extension Label {
|
||||||
|
public struct TooltipModel {
|
||||||
|
public var surface: Surface
|
||||||
|
public var closeButtonText: String
|
||||||
|
public var title: String?
|
||||||
|
public var content: String?
|
||||||
|
public var contentView: UIView?
|
||||||
|
public init(surface: Surface = .light, closeButtonText: String = "Close", title: String?, content: String?, contentView: UIView?) {
|
||||||
|
self.surface = surface
|
||||||
|
self.closeButtonText = closeButtonText
|
||||||
|
self.title = title
|
||||||
|
self.content = content
|
||||||
|
self.contentView = contentView
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func addTooltip(model: TooltipModel) {
|
public func addTooltip(model: TooltipModel) {
|
||||||
|
|
||||||
@ -106,7 +124,8 @@ extension Label {
|
|||||||
let tooltip = TooltipLabelAttribute(surface: surface,
|
let tooltip = TooltipLabelAttribute(surface: surface,
|
||||||
closeButtonText: model.closeButtonText,
|
closeButtonText: model.closeButtonText,
|
||||||
title: model.title,
|
title: model.title,
|
||||||
child: model.child)
|
content: model.content,
|
||||||
|
contentView: model.contentView)
|
||||||
newAttributes.append(tooltip)
|
newAttributes.append(tooltip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user