6a2a69825d
Replaces custom accent-only themes with the seven themes from org-social-ios-lib (Default, Emacs, Dracula, One Dark, Monokai, Material, Thankful Eyes). Swatches now show background/secondaryBackground/accent. Selecting a theme applies tint and preferredColorScheme app-wide immediately.
108 lines
3.2 KiB
Swift
108 lines
3.2 KiB
Swift
import SwiftUI
|
|
|
|
struct AppTheme: Identifiable, Equatable {
|
|
let id: String
|
|
let name: String
|
|
let colorScheme: ColorScheme?
|
|
let accent: Color
|
|
let background: Color
|
|
let secondaryBackground: Color
|
|
let primaryText: Color
|
|
let secondaryText: Color
|
|
|
|
static func == (lhs: AppTheme, rhs: AppTheme) -> Bool { lhs.id == rhs.id }
|
|
}
|
|
|
|
extension AppTheme {
|
|
static let all: [AppTheme] = [.default, .emacs, .dracula, .oneDark, .monokai, .material, .thankfulEyes]
|
|
|
|
static let `default` = AppTheme(
|
|
id: "default",
|
|
name: "Default",
|
|
colorScheme: .light,
|
|
accent: Color(hex: "#006DAF"),
|
|
background: Color(hex: "#FFFFFF"),
|
|
secondaryBackground: Color(hex: "#F0F0F0"),
|
|
primaryText: Color(hex: "#333333"),
|
|
secondaryText: Color(hex: "#9A9FA4")
|
|
)
|
|
|
|
static let emacs = AppTheme(
|
|
id: "emacs",
|
|
name: "Emacs",
|
|
colorScheme: .dark,
|
|
accent: Color(hex: "#4ac1f7"),
|
|
background: Color(hex: "#1c1e1f"),
|
|
secondaryBackground: Color(hex: "#252729"),
|
|
primaryText: Color(hex: "#dcdccc"),
|
|
secondaryText: Color(hex: "#7f9f7f")
|
|
)
|
|
|
|
static let dracula = AppTheme(
|
|
id: "dracula",
|
|
name: "Dracula",
|
|
colorScheme: .dark,
|
|
accent: Color(hex: "#bd93f9"),
|
|
background: Color(hex: "#282a36"),
|
|
secondaryBackground: Color(hex: "#44475a"),
|
|
primaryText: Color(hex: "#f8f8f2"),
|
|
secondaryText: Color(hex: "#6272a4")
|
|
)
|
|
|
|
static let oneDark = AppTheme(
|
|
id: "one_dark",
|
|
name: "One Dark",
|
|
colorScheme: .dark,
|
|
accent: Color(hex: "#61afef"),
|
|
background: Color(hex: "#282c34"),
|
|
secondaryBackground: Color(hex: "#21252b"),
|
|
primaryText: Color(hex: "#abb2bf"),
|
|
secondaryText: Color(hex: "#5c6370")
|
|
)
|
|
|
|
static let monokai = AppTheme(
|
|
id: "monokai",
|
|
name: "Monokai",
|
|
colorScheme: .dark,
|
|
accent: Color(hex: "#a6e22e"),
|
|
background: Color(hex: "#272822"),
|
|
secondaryBackground: Color(hex: "#49483e"),
|
|
primaryText: Color(hex: "#f8f8f2"),
|
|
secondaryText: Color(hex: "#75715e")
|
|
)
|
|
|
|
static let material = AppTheme(
|
|
id: "material",
|
|
name: "Material",
|
|
colorScheme: .dark,
|
|
accent: Color(hex: "#80cbc4"),
|
|
background: Color(hex: "#263238"),
|
|
secondaryBackground: Color(hex: "#2e3c43"),
|
|
primaryText: Color(hex: "#eeffff"),
|
|
secondaryText: Color(hex: "#546e7a")
|
|
)
|
|
|
|
static let thankfulEyes = AppTheme(
|
|
id: "thankful_eyes",
|
|
name: "Thankful Eyes",
|
|
colorScheme: .dark,
|
|
accent: Color(hex: "#a8e1fe"),
|
|
background: Color(hex: "#122b3b"),
|
|
secondaryBackground: Color(hex: "#1c2f3b"),
|
|
primaryText: Color(hex: "#faf6e4"),
|
|
secondaryText: Color(hex: "#6c8b9f")
|
|
)
|
|
}
|
|
|
|
extension Color {
|
|
init(hex: String) {
|
|
let hex = hex.trimmingCharacters(in: .alphanumerics.inverted)
|
|
var value: UInt64 = 0
|
|
Scanner(string: hex).scanHexInt64(&value)
|
|
let r = Double((value >> 16) & 0xff) / 255
|
|
let g = Double((value >> 8) & 0xff) / 255
|
|
let b = Double(value & 0xff) / 255
|
|
self.init(red: r, green: g, blue: b)
|
|
}
|
|
}
|