refactor(settings): 改用常规关于选项卡并统一蓝色强调色

This commit is contained in:
2026-11-03 20:55:11 +08:00
parent 418fc360c6
commit 7bf8cfff19
15 changed files with 108 additions and 487 deletions
+4 -4
View File
@@ -20,12 +20,12 @@ import Foundation
defaults.set("unsupported", forKey: "language")
precondition(LanguagePreferences(defaults: defaults).language == .system)
let bundle = Bundle(path: CommandLine.arguments[1])!
for (language, title, custom) in [("en", "Kymo Settings", "Custom color"),
("zh-Hans", "Kymo 设置", "自选颜色"),
("zh-Hant", "Kymo 設定", "自選顏色")] {
for (language, title, general) in [("en", "Kymo Settings", "General"),
("zh-Hans", "Kymo 设置", "常规"),
("zh-Hant", "Kymo 設定", "一般")] {
let locale = Locale(identifier: language)
precondition(AppLocalization.string("settings.title", locale: locale, bundle: bundle) == title)
precondition(AppLocalization.string("accent.custom", locale: locale, bundle: bundle) == custom)
precondition(AppLocalization.string("settings.general", locale: locale, bundle: bundle) == general)
for (table, key) in [("StatusItem", "status.open"), ("Process", "copyPID"), ("CPUDetails", "cpu.kind.efficiency")] {
let value = AppLocalization.string(key, locale: locale, bundle: bundle, table: table)
precondition(!value.isEmpty && value != key, "Missing built translation: \(language)/\(table)/\(key)")
+1 -22
View File
@@ -28,27 +28,6 @@ import CoreGraphics
precondition(SystemAppearanceObserver.isDark(globalDomain: ["AppleInterfaceStyle": "Dark"]))
precondition(!SystemAppearanceObserver.isDark(globalDomain: [:]))
_ = NSApplication.shared
let swatch = CustomColorWell.SwatchButton(frame: CGRect(x: 0, y: 0, width: 44, height: 26))
var clicked = false
swatch.open = { clicked = true }
precondition(swatch.acceptsFirstMouse(for: nil))
swatch.performClick(nil)
precondition(clicked)
swatch.swatchColor = NSColor(srgbRed: 0.2, green: 0.5, blue: 0.9, alpha: 1)
let bitmap = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: 44, pixelsHigh: 26,
bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true,
isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
NSGraphicsContext.saveGraphicsState()
NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: bitmap)
NSColor.clear.setFill()
swatch.bounds.fill(using: .copy)
swatch.draw(swatch.bounds)
NSGraphicsContext.restoreGraphicsState()
let center = bitmap.colorAt(x: 22, y: 13)!.usingColorSpace(.sRGB)!
precondition(abs(center.redComponent - 0.2) < 0.02)
precondition(abs(center.greenComponent - 0.5) < 0.02)
precondition(abs(center.blueComponent - 0.9) < 0.02)
precondition(bitmap.colorAt(x: 0, y: 0)!.alphaComponent == 0)
let global = NSApp.appearance
let window = NSWindow(contentRect: .zero, styleMask: .borderless, backing: .buffered, defer: true)
window.isReleasedWhenClosed = false
@@ -63,6 +42,6 @@ import CoreGraphics
precondition(NSApp.appearance === global)
}
window.close()
print("PASS: outward placement, edge fallback, negative screen origins, vertical limits, explicit/system window appearance reset, independent system resolution, native swatch target/action")
print("PASS: outward placement, edge fallback, negative screen origins, vertical limits, explicit/system window appearance reset, independent system resolution")
}
}
-1
View File
@@ -52,7 +52,6 @@ swiftc -module-cache-path /private/tmp/kymo-check-cache \
kymo/Core/Services/AppearancePreferences.swift kymo/Core/Services/LanguagePreferences.swift \
kymo/UI/Components/AppearanceStyle.swift kymo/UI/Components/DetailPlacement.swift \
kymo/UI/Components/AppLocalization.swift \
kymo/Features/Settings/CustomColorPicker.swift kymo/Features/Settings/CustomColorWell.swift \
kymoTests/PresentationChecks.swift -o /private/tmp/kymo-presentation-checks
/private/tmp/kymo-presentation-checks
```
+5 -5
View File
@@ -69,16 +69,16 @@ import Foundation
let defaults = UserDefaults(suiteName: suite)!
defer { defaults.removePersistentDomain(forName: suite) }
let preferences = AppearancePreferences(defaults: defaults)
precondition(preferences.appearance == .system && preferences.accent == .system)
precondition(preferences.appearance == .system)
preferences.appearance = .dark
preferences.accent = .custom
preferences.red = 0.75
defaults.set("custom", forKey: "accent")
defaults.set(0.75, forKey: "accent.red")
let restored = AppearancePreferences(defaults: defaults)
precondition(restored.appearance == .dark && restored.accent == .custom && restored.red == 0.75)
precondition(restored.appearance == .dark)
defaults.set("invalid", forKey: "appearance")
defaults.set(2.0, forKey: "accent.red")
let recovered = AppearancePreferences(defaults: defaults)
precondition(recovered.appearance == .system && recovered.red == 1)
precondition(recovered.appearance == .system)
print("PASS: bounded history, missing samples, format boundaries, appearance persistence and invalid defaults")
let sampler = SystemSampler()
let initial = await sampler.sample()