~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/old-fella

Old people's social media app

0
1
main
53 lines · 2.1 KB Raw History
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)
}