added AnylabelAttribute
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
42d3fc5c9a
commit
cd94bfde67
@ -44,6 +44,7 @@
|
||||
EA89200628B526D6006B9984 /* CheckboxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200528B526D6006B9984 /* CheckboxGroup.swift */; };
|
||||
EA89201328B568D8006B9984 /* RadioBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201228B568D8006B9984 /* RadioBox.swift */; };
|
||||
EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */; };
|
||||
EA978EC5291D6AFE00ACC883 /* AnyLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA978EC4291D6AFE00ACC883 /* AnyLabelAttribute.swift */; };
|
||||
EAA5EEB528ECBFB4003B3210 /* ImageLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEB428ECBFB4003B3210 /* ImageLabelAttribute.swift */; };
|
||||
EAA5EEB728ECC03A003B3210 /* ToolTipLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEB628ECC03A003B3210 /* ToolTipLabelAttribute.swift */; };
|
||||
EAA5EEB928ECD24B003B3210 /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAA5EEB828ECD24B003B3210 /* Icons.xcassets */; };
|
||||
@ -130,6 +131,7 @@
|
||||
EA89200528B526D6006B9984 /* CheckboxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxGroup.swift; sourceTree = "<group>"; };
|
||||
EA89201228B568D8006B9984 /* RadioBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBox.swift; sourceTree = "<group>"; };
|
||||
EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroup.swift; sourceTree = "<group>"; };
|
||||
EA978EC4291D6AFE00ACC883 /* AnyLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyLabelAttribute.swift; sourceTree = "<group>"; };
|
||||
EAA5EEB428ECBFB4003B3210 /* ImageLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageLabelAttribute.swift; sourceTree = "<group>"; };
|
||||
EAA5EEB628ECC03A003B3210 /* ToolTipLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolTipLabelAttribute.swift; sourceTree = "<group>"; };
|
||||
EAA5EEB828ECD24B003B3210 /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = "<group>"; };
|
||||
@ -480,6 +482,7 @@
|
||||
children = (
|
||||
EAF7F0A3289B017C00B287F5 /* LabelAttributeModel.swift */,
|
||||
EAF7F0B2289B1ADC00B287F5 /* ActionLabelAttribute.swift */,
|
||||
EA978EC4291D6AFE00ACC883 /* AnyLabelAttribute.swift */,
|
||||
EAF7F13228A2A16500B287F5 /* AttachmentLabelAttributeModel.swift */,
|
||||
EAF7F0B0289B177F00B287F5 /* ColorLabelAttribute.swift */,
|
||||
EAF7F0AA289B13FD00B287F5 /* FontLabelAttribute.swift */,
|
||||
@ -631,6 +634,7 @@
|
||||
EAF7F0AF289B144C00B287F5 /* UnderlineLabelAttribute.swift in Sources */,
|
||||
EAC925842911C63100091998 /* Colorable.swift in Sources */,
|
||||
EA3361C5289030FC0071C351 /* Accessable.swift in Sources */,
|
||||
EA978EC5291D6AFE00ACC883 /* AnyLabelAttribute.swift in Sources */,
|
||||
EA33622C2891E73B0071C351 /* FontProtocol.swift in Sources */,
|
||||
EAF7F11728A1475A00B287F5 /* RadioButton.swift in Sources */,
|
||||
EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */,
|
||||
|
||||
36
VDS/Components/Label/Attributes/AnyLabelAttribute.swift
Normal file
36
VDS/Components/Label/Attributes/AnyLabelAttribute.swift
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// AnyAttribute.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 11/10/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct AnyAttribute: LabelAttributeModel {
|
||||
public var id = UUID()
|
||||
public var location: Int
|
||||
public var length: Int
|
||||
public var key: NSAttributedString.Key
|
||||
public var value: AnyHashable
|
||||
|
||||
public init(location: Int, length: Int, key: NSAttributedString.Key, value: AnyHashable) {
|
||||
self.location = location
|
||||
self.length = length
|
||||
self.key = key
|
||||
self.value = value
|
||||
}
|
||||
|
||||
public func isEqual(_ equatable: AnyAttribute) -> Bool {
|
||||
return id == equatable.id && range == equatable.range && key == equatable.key && value == equatable.value
|
||||
}
|
||||
|
||||
public static func == (lhs: AnyAttribute, rhs: AnyAttribute) -> Bool {
|
||||
lhs.isEqual(rhs)
|
||||
}
|
||||
|
||||
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
||||
attributedString.removeAttribute(key, range: range)
|
||||
attributedString.addAttribute(key, value: value, range: range)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user