1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import SwiftUI
import UIKit
enum AppPalette {
private static let background = (red: 0.66, green: 0.25, blue: 0.15)
private static let mark = (red: 0.98, green: 0.89, blue: 0.73)
private static func color(lightMix: Double, darkMix: Double) -> Color {
Color(
uiColor: UIColor { traits in
let mix = traits.userInterfaceStyle == .dark ? darkMix : lightMix
return UIColor(
red: background.red + (mark.red - background.red) * mix,
green: background.green + (mark.green - background.green) * mix,
blue: background.blue + (mark.blue - background.blue) * mix,
alpha: 1
)
})
}
private static func shiftedColor(hueShift: CGFloat) -> Color {
Color(
uiColor: UIColor { traits in
let base = UIColor(red: background.red, green: background.green, blue: background.blue, alpha: 1)
var hue: CGFloat = 0
var saturation: CGFloat = 0
var brightness: CGFloat = 0
base.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: nil)
let isDark = traits.userInterfaceStyle == .dark
return UIColor(
hue: (hue + hueShift).truncatingRemainder(dividingBy: 1),
saturation: saturation * (isDark ? 0.65 : 0.85),
brightness: isDark ? 0.85 : 0.52,
alpha: 1
)
})
}
static let accent = color(lightMix: 0, darkMix: 0.65)
static let mediaWarningBackground = Color(
uiColor: UIColor { traits in
UIColor(
red: background.red,
green: background.green,
blue: background.blue,
alpha: traits.userInterfaceStyle == .dark ? 0.4 : 0.2
)
})
static let root = color(lightMix: 0.05, darkMix: 0.75)
static let mention = shiftedColor(hueShift: 0.25)
static let reply = shiftedColor(hueShift: 0.5)
static let quote = shiftedColor(hueShift: 0.75)
}