added comments for the UIColor+VDSColor extension

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-05-26 16:47:24 -05:00
parent 54abcf8c8d
commit cc0c0fbfb2

View File

@ -9,6 +9,8 @@ import Foundation
import VDSColorTokens
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 {
case paletteBlack
case paletteWhite
@ -96,7 +98,7 @@ extension UIColor {
case elementsLowcontrastOnlight
case elementsLowcontrastOndark
// Map each color name to its corresponding UIColor object.
/// Map each color name to its corresponding UIColor object.
public var uiColor: UIColor {
do {
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 {
guard let hex = color.hexString else { return false }
let found = VDSColor.allCases.first{ $0.uiColor.hexString == hex }