added comments for the UIColor+VDSColor extension
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
54abcf8c8d
commit
cc0c0fbfb2
@ -9,6 +9,8 @@ import Foundation
|
|||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
|
|
||||||
extension UIColor {
|
extension UIColor {
|
||||||
|
|
||||||
|
/// Since VDSColorTokens is just a Class with Static Properties, this is an Enum for each property of that class for each of use within the VDS Library
|
||||||
public enum VDSColor: String, CaseIterable {
|
public enum VDSColor: String, CaseIterable {
|
||||||
case paletteBlack
|
case paletteBlack
|
||||||
case paletteWhite
|
case paletteWhite
|
||||||
@ -96,7 +98,7 @@ extension UIColor {
|
|||||||
case elementsLowcontrastOnlight
|
case elementsLowcontrastOnlight
|
||||||
case elementsLowcontrastOndark
|
case elementsLowcontrastOndark
|
||||||
|
|
||||||
// Map each color name to its corresponding UIColor object.
|
/// Map each color name to its corresponding UIColor object.
|
||||||
public var uiColor: UIColor {
|
public var uiColor: UIColor {
|
||||||
do {
|
do {
|
||||||
let color = try VDSColorTokens.VDSColor.getTokenByString(tokenName: "VDSColor.\(rawValue)")
|
let color = try VDSColorTokens.VDSColor.getTokenByString(tokenName: "VDSColor.\(rawValue)")
|
||||||
@ -107,7 +109,10 @@ extension UIColor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper method to see if a UIColor exists in the VDSColor enumeration
|
||||||
|
/// - Parameter color: UIColor needed to compare
|
||||||
|
/// - Returns: True if found, false in not found in VDSColor enumeration
|
||||||
public static func isVDSColor(color: UIColor) -> Bool {
|
public static func isVDSColor(color: UIColor) -> Bool {
|
||||||
guard let hex = color.hexString else { return false }
|
guard let hex = color.hexString else { return false }
|
||||||
let found = VDSColor.allCases.first{ $0.uiColor.hexString == hex }
|
let found = VDSColor.allCases.first{ $0.uiColor.hexString == hex }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user