Ariver
2026-06-25 77896f65b92c756da699e84499b180d35b0f8835
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import Foundation
 
enum AppDefaults {
    static let schemaVersionKey = "initialDefaultsSchemaVersion"
    static let currentSchemaVersion = 3
 
    static let tagFontSize: Double = 22
    static let iconSize: Double = 64
    static let tagPosition = "right"
    static let displayMode = "coloredGridContainer"
    static let hideAppNames = true
    static let showDockIcon = true
    static let launchAtLogin = true
    static let showUncommonAppBubbles = false
    static let hideUsageTips = false
    static let appGridThemeID = AppGridTheme.defaultLight.rawValue
    static let useAppKitTagNavigation = true
 
    static func register() {
        migrateAppGridThemePreferenceIfNeeded()
        UserDefaults.standard.register(defaults: [
            "tagFontSize": tagFontSize,
            "iconSize": iconSize,
            "tagPosition": tagPosition,
            "displayMode": displayMode,
            "hideAppNames": hideAppNames,
            "showDockIcon": showDockIcon,
            "launchAtLogin": launchAtLogin,
            "showUncommonAppBubbles": showUncommonAppBubbles,
            "hideUsageTips": hideUsageTips,
            AppGridTheme.storageKey: appGridThemeID,
            "useAppKitTagNavigation": useAppKitTagNavigation,
            "skipTagRemovalDropConfirm": false,
            "skipUncategorizedDropConfirm": false,
            "skipUsageTipsCloseReminder": false,
            LauncherHotkeyRegistrationStore.mainStateKey: LauncherHotkeyRegistrationState.active.rawValue,
            LauncherHotkeyRegistrationStore.quickSearchStateKey: LauncherHotkeyRegistrationState.active.rawValue
        ])
        removeShortcutCustomizationDefaults()
    }
 
    static func hasStoredValue(for key: String) -> Bool {
        let domain = Bundle.main.bundleIdentifier ?? AppIdentity.bundleIdentifier
        return UserDefaults.standard.persistentDomain(forName: domain)?[key] != nil
    }
 
    private static func migrateAppGridThemePreferenceIfNeeded() {
        let defaults = UserDefaults.standard
        guard !hasStoredValue(for: AppGridTheme.storageKey),
              hasStoredValue(for: "useDarkAppGrid"),
              defaults.bool(forKey: "useDarkAppGrid")
        else { return }
        defaults.set(AppGridTheme.deepBlue.rawValue, forKey: AppGridTheme.storageKey)
    }
 
    private static func removeShortcutCustomizationDefaults() {
        let defaults = UserDefaults.standard
        [
            "mainHotkey",
            "quickSearchHotkey",
            "mainHotkeyPending",
            "quickSearchHotkeyPending",
            "mainHotkeyStatus",
            "quickSearchHotkeyStatus",
            "mainHotkeyConflictMessage",
            "quickSearchHotkeyConflictMessage"
        ].forEach { defaults.removeObject(forKey: $0) }
        defaults.set(currentSchemaVersion, forKey: schemaVersionKey)
    }
}