refactored trailing tooltip label
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
f6af646d09
commit
24bad2c371
@ -82,7 +82,7 @@
|
|||||||
EAB2376229E9880400AABE9A /* TrailingTooltipLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */; };
|
EAB2376229E9880400AABE9A /* TrailingTooltipLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */; };
|
||||||
EAB2376629E9952D00AABE9A /* UIApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376529E9952D00AABE9A /* UIApplication.swift */; };
|
EAB2376629E9952D00AABE9A /* UIApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376529E9952D00AABE9A /* UIApplication.swift */; };
|
||||||
EAB2376829E9992800AABE9A /* TooltipAlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */; };
|
EAB2376829E9992800AABE9A /* TooltipAlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */; };
|
||||||
EAB2376A29E9E59100AABE9A /* ToolTipLaunchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376929E9E59100AABE9A /* ToolTipLaunchable.swift */; };
|
EAB2376A29E9E59100AABE9A /* TooltipLaunchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */; };
|
||||||
EAB5FED429267EB300998C17 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FED329267EB300998C17 /* UIView.swift */; };
|
EAB5FED429267EB300998C17 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FED329267EB300998C17 /* UIView.swift */; };
|
||||||
EAB5FEED2927E1B200998C17 /* ButtonGroupPositionLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEEC2927E1B200998C17 /* ButtonGroupPositionLayout.swift */; };
|
EAB5FEED2927E1B200998C17 /* ButtonGroupPositionLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEEC2927E1B200998C17 /* ButtonGroupPositionLayout.swift */; };
|
||||||
EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEF02927F4AA00998C17 /* SelfSizingCollectionView.swift */; };
|
EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEF02927F4AA00998C17 /* SelfSizingCollectionView.swift */; };
|
||||||
@ -205,7 +205,7 @@
|
|||||||
EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrailingTooltipLabel.swift; sourceTree = "<group>"; };
|
EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrailingTooltipLabel.swift; sourceTree = "<group>"; };
|
||||||
EAB2376529E9952D00AABE9A /* UIApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplication.swift; sourceTree = "<group>"; };
|
EAB2376529E9952D00AABE9A /* UIApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplication.swift; sourceTree = "<group>"; };
|
||||||
EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipAlertViewController.swift; sourceTree = "<group>"; };
|
EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipAlertViewController.swift; sourceTree = "<group>"; };
|
||||||
EAB2376929E9E59100AABE9A /* ToolTipLaunchable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolTipLaunchable.swift; sourceTree = "<group>"; };
|
EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipLaunchable.swift; sourceTree = "<group>"; };
|
||||||
EAB5FED329267EB300998C17 /* UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; };
|
EAB5FED329267EB300998C17 /* UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; };
|
||||||
EAB5FEEC2927E1B200998C17 /* ButtonGroupPositionLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroupPositionLayout.swift; sourceTree = "<group>"; };
|
EAB5FEEC2927E1B200998C17 /* ButtonGroupPositionLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroupPositionLayout.swift; sourceTree = "<group>"; };
|
||||||
EAB5FEF02927F4AA00998C17 /* SelfSizingCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizingCollectionView.swift; sourceTree = "<group>"; };
|
EAB5FEF02927F4AA00998C17 /* SelfSizingCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizingCollectionView.swift; sourceTree = "<group>"; };
|
||||||
@ -596,9 +596,9 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
EAB2375C29E8789100AABE9A /* Tooltip.swift */,
|
EAB2375C29E8789100AABE9A /* Tooltip.swift */,
|
||||||
EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */,
|
|
||||||
EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */,
|
EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */,
|
||||||
EAB2376929E9E59100AABE9A /* ToolTipLaunchable.swift */,
|
EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */,
|
||||||
|
EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */,
|
||||||
);
|
);
|
||||||
path = Tooltip;
|
path = Tooltip;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -807,7 +807,7 @@
|
|||||||
EAC9258C2911C9DE00091998 /* InputField.swift in Sources */,
|
EAC9258C2911C9DE00091998 /* InputField.swift in Sources */,
|
||||||
EA3362402892EF6C0071C351 /* Label.swift in Sources */,
|
EA3362402892EF6C0071C351 /* Label.swift in Sources */,
|
||||||
EAB2376229E9880400AABE9A /* TrailingTooltipLabel.swift in Sources */,
|
EAB2376229E9880400AABE9A /* TrailingTooltipLabel.swift in Sources */,
|
||||||
EAB2376A29E9E59100AABE9A /* ToolTipLaunchable.swift in Sources */,
|
EAB2376A29E9E59100AABE9A /* TooltipLaunchable.swift in Sources */,
|
||||||
EAB2375D29E8789100AABE9A /* Tooltip.swift in Sources */,
|
EAB2375D29E8789100AABE9A /* Tooltip.swift in Sources */,
|
||||||
EA985C23296E033A00F2FF2E /* TextArea.swift in Sources */,
|
EA985C23296E033A00F2FF2E /* TextArea.swift in Sources */,
|
||||||
EAF7F0B3289B1ADC00B287F5 /* ActionLabelAttribute.swift in Sources */,
|
EAF7F0B3289B1ADC00B287F5 /* ActionLabelAttribute.swift in Sources */,
|
||||||
|
|||||||
@ -16,24 +16,31 @@ public struct ToolTipLabelAttribute: ActionLabelAttributeModel {
|
|||||||
public var location: Int
|
public var location: Int
|
||||||
public var length: Int
|
public var length: Int
|
||||||
public var tintColor: UIColor
|
public var tintColor: UIColor
|
||||||
|
public var lineHeight: CGFloat
|
||||||
|
public var size: Tooltip.Size
|
||||||
|
|
||||||
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
||||||
|
let size = size.dimensions.height
|
||||||
|
var yPos = (lineHeight / 2) - size
|
||||||
|
if yPos < 0 { yPos = 0 }
|
||||||
let image = ImageLabelAttribute(location: location,
|
let image = ImageLabelAttribute(location: location,
|
||||||
length: length,
|
length: length,
|
||||||
imageName: "info",
|
imageName: "info",
|
||||||
frame: .init(x: 0, y: -2, width: 13.3, height: 13.3),
|
frame: .init(x: 0, y: yPos, width: size, height: size),
|
||||||
tintColor: tintColor)
|
tintColor: tintColor)
|
||||||
|
|
||||||
image.setAttribute(on: attributedString)
|
image.setAttribute(on: attributedString)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(action: PassthroughSubject<Void, Never> = .init(), location: Int, length: Int, tintColor: UIColor = .black, accessibleText: String? = nil){
|
public init(action: PassthroughSubject<Void, Never> = .init(), location: Int, length: Int, tintColor: UIColor = .black, accessibleText: String? = nil, size: Tooltip.Size = .medium, lineHeight: CGFloat = 0.0){
|
||||||
self.action = action
|
self.action = action
|
||||||
self.location = location
|
self.location = location
|
||||||
self.length = length
|
self.length = length
|
||||||
self.tintColor = tintColor
|
self.tintColor = tintColor
|
||||||
self.accessibleText = accessibleText
|
self.accessibleText = accessibleText
|
||||||
|
self.lineHeight = lineHeight
|
||||||
|
self.size = size
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func == (lhs: ToolTipLabelAttribute, rhs: ToolTipLabelAttribute) -> Bool {
|
public static func == (lhs: ToolTipLabelAttribute, rhs: ToolTipLabelAttribute) -> Bool {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
label.textColorConfiguration
|
label.textColorConfiguration
|
||||||
}() { didSet { didChange() }}
|
}() { didSet { didChange() }}
|
||||||
|
|
||||||
open var closeButtonText: String = "Close" { didSet { didChange() }}
|
open var tooltipCloseButtonText: String = "Close" { didSet { didChange() }}
|
||||||
|
|
||||||
open var tooltipSize: Tooltip.Size = .medium { didSet { didChange() }}
|
open var tooltipSize: Tooltip.Size = .medium { didSet { didChange() }}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ 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.closeButtonText)
|
closeButtonText: self.tooltipCloseButtonText)
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,18 +68,20 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var updatedLabelText = labelText
|
var updatedLabelText = labelText
|
||||||
|
|
||||||
//add the tool tip
|
//add the tool tip
|
||||||
if let oldText = updatedLabelText {
|
if let oldText = updatedLabelText, !tooltipTitle.isEmpty, !tooltipContent.isEmpty {
|
||||||
let toolTipUpdateText = "\(oldText) " //create a little space between the final character and tooltip image
|
let toolTipUpdateText = "\(oldText) " //create a little space between the final character and tooltip image
|
||||||
let toolTipAttribute = ToolTipLabelAttribute(action: toolTipAction,
|
let toolTipAttribute = ToolTipLabelAttribute(action: toolTipAction,
|
||||||
location: toolTipUpdateText.count - 1,
|
location: toolTipUpdateText.count - 1,
|
||||||
length: 1,
|
length: 1,
|
||||||
tintColor: textColorConfiguration.getColor(self))
|
tintColor: textColorConfiguration.getColor(self),
|
||||||
|
size: tooltipSize,
|
||||||
|
lineHeight: labelTextStyle.lineHeight)
|
||||||
updatedLabelText = toolTipUpdateText
|
updatedLabelText = toolTipUpdateText
|
||||||
attributes.append(toolTipAttribute)
|
attributes.append(toolTipAttribute)
|
||||||
}
|
}
|
||||||
|
label.debugBorder()
|
||||||
//set the titleLabel
|
//set the titleLabel
|
||||||
label.text = updatedLabelText
|
label.text = updatedLabelText
|
||||||
label.attributes = attributes
|
label.attributes = attributes
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user