feat(settings): 默认启用短动效并提供独立减弱动画选项

This commit is contained in:
2026-11-04 11:53:17 +08:00
parent 40a7a55edf
commit f18f6652ff
23 changed files with 443 additions and 34 deletions
+41
View File
@@ -0,0 +1,41 @@
import Foundation
@main struct MotionPreferencesChecks {
@MainActor static func main() {
let suite = "kymo.motion." + UUID().uuidString
let defaults = UserDefaults(suiteName: suite)!
defer { defaults.removePersistentDomain(forName: suite) }
let sampling = SamplingPreferences(defaults: defaults)
let appearance = AppearancePreferences(defaults: defaults)
precondition(!appearance.reduceMotion && !sampling.backgroundEnabled)
let interval = sampling.backgroundMilliseconds
appearance.reduceMotion = true
precondition(AppearancePreferences(defaults: defaults).reduceMotion)
precondition(!sampling.backgroundEnabled && sampling.backgroundMilliseconds == interval)
sampling.backgroundEnabled = true; sampling.backgroundMilliseconds = 5_000
appearance.reduceMotion = false
precondition(sampling.backgroundEnabled && sampling.backgroundMilliseconds == 5_000)
precondition(!AppearancePreferences(defaults: defaults).reduceMotion)
for value in ["YES" as Any, 1 as Any] {
defaults.set(value, forKey: "appearance.reduceMotion")
precondition(!AppearancePreferences(defaults: defaults).reduceMotion, "Invalid persisted types must retain the default")
}
let previousArguments = defaults.volatileDomain(forName: UserDefaults.argumentDomain)
defaults.setVolatileDomain(["appearance.reduceMotion": "YES"], forName: UserDefaults.argumentDomain)
precondition(AppearancePreferences(defaults: defaults).reduceMotion, "Launch overrides must be honored without writing persistent settings")
defaults.setVolatileDomain(previousArguments, forName: UserDefaults.argumentDomain)
for reduced in [false, true] {
for system in [false, true] {
for visible in [false, true] {
for paused in [false, true] {
for sleeping in [false, true] {
let value = MetricMotionPolicy.enabled(reduced: reduced, systemReduced: system, visible: visible, paused: paused, sleeping: sleeping)
precondition(value == (!reduced && !system && visible && !paused && !sleeping))
}
}
}
}
}
print("PASS: default high-motion preference, persistence/type safety, independent background controls and system/visibility/pause/sleep policy")
}
}