Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
146 lines
5.5 KiB
Swift
146 lines
5.5 KiB
Swift
import Observation
|
|
import SwiftUI
|
|
|
|
enum AppAppearancePreference: String, CaseIterable, Identifiable {
|
|
case system
|
|
case light
|
|
case dark
|
|
|
|
static let storageKey = "appearance.preference"
|
|
|
|
static var launchArgumentPreference: AppAppearancePreference? {
|
|
let arguments = ProcessInfo.processInfo.arguments
|
|
guard let flagIndex = arguments.firstIndex(of: "--openclaw-appearance") else {
|
|
return nil
|
|
}
|
|
let valueIndex = arguments.index(after: flagIndex)
|
|
guard arguments.indices.contains(valueIndex) else { return nil }
|
|
return AppAppearancePreference(rawValue: arguments[valueIndex].lowercased())
|
|
}
|
|
|
|
var id: String {
|
|
self.rawValue
|
|
}
|
|
|
|
var label: String {
|
|
switch self {
|
|
case .system: "System"
|
|
case .light: "Light"
|
|
case .dark: "Dark"
|
|
}
|
|
}
|
|
|
|
var systemImage: String {
|
|
switch self {
|
|
case .system: "circle.lefthalf.filled"
|
|
case .light: "sun.max"
|
|
case .dark: "moon.stars"
|
|
}
|
|
}
|
|
|
|
var colorScheme: ColorScheme? {
|
|
switch self {
|
|
case .system: nil
|
|
case .light: .light
|
|
case .dark: .dark
|
|
}
|
|
}
|
|
}
|
|
|
|
@MainActor
|
|
@Observable
|
|
final class AppAppearanceModel {
|
|
private(set) var preference: AppAppearancePreference
|
|
|
|
init(userDefaults: UserDefaults = .standard) {
|
|
let storedPreference = userDefaults.string(forKey: AppAppearancePreference.storageKey)
|
|
.flatMap(AppAppearancePreference.init(rawValue:))
|
|
self.preference = AppAppearancePreference.launchArgumentPreference ?? storedPreference ?? .system
|
|
if AppAppearancePreference.launchArgumentPreference != nil {
|
|
userDefaults.set(self.preference.rawValue, forKey: AppAppearancePreference.storageKey)
|
|
}
|
|
}
|
|
|
|
func select(_ preference: AppAppearancePreference, userDefaults: UserDefaults = .standard) {
|
|
guard self.preference != preference else { return }
|
|
userDefaults.set(preference.rawValue, forKey: AppAppearancePreference.storageKey)
|
|
var transaction = Transaction()
|
|
transaction.disablesAnimations = true
|
|
withTransaction(transaction) {
|
|
self.preference = preference
|
|
}
|
|
}
|
|
}
|
|
|
|
enum OpenClawBrand {
|
|
// Accent fills stay dark enough for white content; foreground accents adapt
|
|
// separately so small labels retain 4.5:1 contrast on dark surfaces and tinted pills.
|
|
static let uiAccent = adaptiveUIColor(light: (183, 56, 51), dark: (198, 62, 56))
|
|
static let uiAccentForeground = adaptiveUIColor(light: (183, 56, 51), dark: (255, 107, 102))
|
|
static let uiAccentHot = adaptiveUIColor(light: (204, 75, 69), dark: (232, 92, 86))
|
|
static let uiAccentHotForeground = adaptiveUIColor(light: (166, 55, 50), dark: (255, 123, 115))
|
|
static let uiAccentPressed = adaptiveUIColor(light: (148, 40, 36), dark: (148, 40, 36))
|
|
static let uiTeal = adaptiveUIColor(light: (0, 196, 176), dark: (0, 196, 176))
|
|
static let uiVoid = adaptiveUIColor(light: (246, 247, 249), dark: (11, 12, 17))
|
|
static let uiObsidian = adaptiveUIColor(light: (255, 255, 255), dark: (19, 21, 28))
|
|
static let uiTextPrimary = adaptiveUIColor(light: (11, 12, 17), dark: (242, 239, 232))
|
|
static let uiTextSecondary = adaptiveUIColor(light: (90, 94, 110), dark: (168, 170, 191))
|
|
static let uiOK = adaptiveUIColor(light: (19, 122, 62), dark: (48, 209, 88))
|
|
static let uiWarn = adaptiveUIColor(light: (154, 87, 0), dark: (255, 214, 10))
|
|
static let uiDanger = adaptiveUIColor(light: (185, 28, 28), dark: (252, 165, 165))
|
|
static let uiInfo = adaptiveUIColor(light: (0, 91, 196), dark: (100, 168, 255))
|
|
|
|
static let accent = Color(uiColor: Self.uiAccent)
|
|
static let accentForeground = Color(uiColor: Self.uiAccentForeground)
|
|
static let accentHot = Color(uiColor: Self.uiAccentHot)
|
|
static let accentHotForeground = Color(uiColor: Self.uiAccentHotForeground)
|
|
static let accentPressed = Color(uiColor: Self.uiAccentPressed)
|
|
static let teal = Color(uiColor: Self.uiTeal)
|
|
static let void = Color(uiColor: Self.uiVoid)
|
|
static let obsidian = Color(uiColor: Self.uiObsidian)
|
|
static let textPrimary = Color(uiColor: Self.uiTextPrimary)
|
|
static let textSecondary = Color(uiColor: Self.uiTextSecondary)
|
|
static let danger = Color(uiColor: Self.uiDanger)
|
|
static let ok = Color(uiColor: Self.uiOK)
|
|
static let warn = Color(uiColor: Self.uiWarn)
|
|
static let info = Color(uiColor: Self.uiInfo)
|
|
static let graphite = void
|
|
static let graphiteElevated = obsidian
|
|
|
|
static var sheetBackground: LinearGradient {
|
|
LinearGradient(
|
|
colors: [
|
|
graphite,
|
|
graphiteElevated.opacity(0.96),
|
|
Color(uiColor: .systemBackground),
|
|
],
|
|
startPoint: .topLeading,
|
|
endPoint: .bottomTrailing)
|
|
}
|
|
|
|
private static func adaptiveUIColor(
|
|
light: (red: CGFloat, green: CGFloat, blue: CGFloat),
|
|
dark: (red: CGFloat, green: CGFloat, blue: CGFloat)) -> UIColor
|
|
{
|
|
UIColor { traits in
|
|
let components = traits.userInterfaceStyle == .dark ? dark : light
|
|
return UIColor(
|
|
red: components.red / 255,
|
|
green: components.green / 255,
|
|
blue: components.blue / 255,
|
|
alpha: 1)
|
|
}
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func openClawSheetChrome() -> some View {
|
|
self
|
|
.tint(OpenClawBrand.accent)
|
|
.background {
|
|
OpenClawBrand.sheetBackground
|
|
.ignoresSafeArea()
|
|
}
|
|
}
|
|
}
|