Removing func as the static dictionary can carry the weight.

This commit is contained in:
Kevin G Christiano 2020-02-03 09:00:03 -05:00
parent c81f68d66d
commit be2e9473b3
2 changed files with 3 additions and 8 deletions

View File

@ -6,11 +6,11 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
public typealias ColorHexTuple = (uiColor: UIColor, hex: String)
extension UIColor {
/// Dictionary to access brand approved colors by name.
@ -200,9 +200,4 @@ extension UIColor {
return nil
}
public class func getColorAndHexFromName(_ name: String) -> ColorHexTuple? {
return names[name]
}
}

View File

@ -56,7 +56,7 @@ public final class Color: Codable {
}
init?(name: String) {
guard let colorTuple = UIColor.getColorAndHexFromName(name) else { return nil }
guard let colorTuple = UIColor.names[name] else { return nil }
self.uiColor = colorTuple.uiColor
self.hex = colorTuple.hex
determineRGBA()
@ -73,7 +73,7 @@ public final class Color: Codable {
if colorString.hasPrefix("#") {
hex = colorString.replacingOccurrences(of: "#", with: "")
} else {
guard let hex = UIColor.getColorAndHexFromName(colorString)?.hex else { throw ColorError.badName(reason: "Check the spelling of your color.") }
guard let hex = UIColor.names[colorString]?.hex else { throw ColorError.badName(reason: "Check the spelling of your color.") }
self.hex = hex.replacingOccurrences(of: "#", with: "")
name = colorString
}