2022-12-20 15:08:09 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
extension Color {
|
|
|
|
public static var brand: Color {
|
2022-12-29 09:39:34 +00:00
|
|
|
Color(red: 187/255, green: 59/255, blue: 226/255)
|
2022-12-20 15:08:09 +00:00
|
|
|
}
|
2022-12-24 13:55:04 +00:00
|
|
|
|
|
|
|
public static var primaryBackground: Color {
|
2022-12-29 09:39:34 +00:00
|
|
|
Color(red: 16/255, green: 21/255, blue: 35/255)
|
2022-12-24 13:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static var secondaryBackground: Color {
|
2022-12-29 09:39:34 +00:00
|
|
|
Color(red: 30/255, green: 35/255, blue: 62/255)
|
2022-12-24 13:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static var label: Color {
|
|
|
|
Color("label", bundle: .module)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Color: RawRepresentable {
|
|
|
|
public init?(rawValue: Int) {
|
|
|
|
let red = Double((rawValue & 0xFF0000) >> 16) / 0xFF
|
|
|
|
let green = Double((rawValue & 0x00FF00) >> 8) / 0xFF
|
|
|
|
let blue = Double(rawValue & 0x0000FF) / 0xFF
|
|
|
|
self = Color(red: red, green: green, blue: blue)
|
|
|
|
}
|
|
|
|
|
|
|
|
public var rawValue: Int {
|
|
|
|
guard let coreImageColor = coreImageColor else {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
let red = Int(coreImageColor.red * 255 + 0.5)
|
|
|
|
let green = Int(coreImageColor.green * 255 + 0.5)
|
|
|
|
let blue = Int(coreImageColor.blue * 255 + 0.5)
|
|
|
|
return (red << 16) | (green << 8) | blue
|
|
|
|
}
|
|
|
|
|
|
|
|
private var coreImageColor: CIColor? {
|
|
|
|
return CIColor(color: .init(self))
|
|
|
|
}
|
2022-12-20 15:08:09 +00:00
|
|
|
}
|
2022-12-30 19:55:23 +00:00
|
|
|
|
|
|
|
extension Color {
|
|
|
|
init(hex: Int, opacity: Double = 1.0) {
|
|
|
|
let red = Double((hex & 0xff0000) >> 16) / 255.0
|
|
|
|
let green = Double((hex & 0xff00) >> 8) / 255.0
|
|
|
|
let blue = Double((hex & 0xff) >> 0) / 255.0
|
|
|
|
self.init(.sRGB, red: red, green: green, blue: blue, opacity: opacity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|