Merge branch 'feature/new_color' into 'develop'

Adding color and removing pointless func.

See merge request BPHV_MIPS/mvm_core_ui!239
This commit is contained in:
Pfeil, Scott Robert 2020-02-03 15:44:19 -05:00
commit 6fa74c11cf
2 changed files with 7 additions and 14 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.
@ -25,6 +25,7 @@ extension UIColor {
"coolGray1": (.mvmCoolGray1, "#F6F6F6"),
"coolGray3": (.mvmCoolGray3, "#D8DADA"),
"coolGray6": (.mvmCoolGray6, "#747676"),
"coolGray10": (.mvmCoolGray10, "#333333"),
"vzupGold": (.vzupGold, "#B89B56"),
"vzupYellow1": (.vzupYellow1, "#F9D542"),
"vzupYellow2": (.vzupYellow2, "#F4CA53"),
@ -67,6 +68,9 @@ extension UIColor {
/// HEX: #747676
public static let mvmCoolGray6 = UIColor.color8Bits(red: 116, green: 118, blue: 118)
/// HEX: #333333
public static let mvmCoolGray10 = UIColor.grayscale(rgb: 51)
//--------------------------------------------------
// MARK: - VZ UP Brand
//--------------------------------------------------
@ -196,15 +200,4 @@ extension UIColor {
return nil
}
public class func getColorAndHexFromName(_ name: String) -> ColorHexTuple? {
for row in names {
if name == row.key {
return row.value
}
}
return nil
}
}

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
}