You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
2.0 KiB

// Copyright © 2015 Abhishek Banthia
import Cocoa
import CoreLoggerKit
class AppDefaults {
class func initialize(with store: DataStore, defaults: UserDefaults) {
initializeDefaults(with: store, defaults: defaults)
}
6 years ago
private class func initializeDefaults(with store: DataStore, defaults: UserDefaults) {
let timezones = store.timezones()
9 months ago
let selectedCalendars = store.selectedCalendars()
6 years ago
// Register the usual suspects
defaults.register(defaults: defaultsDictionary())
6 years ago
store.setTimezones(timezones)
defaults.set(selectedCalendars, forKey: UserDefaultKeys.selectedCalendars)
}
3 years ago
private class func defaultsDictionary() -> [String: Any] {
let calendars: [String] = []
return [UserDefaultKeys.themeKey: 0,
UserDefaultKeys.displayFutureSliderKey: 0,
UserDefaultKeys.selectedTimeZoneFormatKey: 0, // 12-hour format
UserDefaultKeys.relativeDateKey: 0,
UserDefaultKeys.showDayInMenu: 0,
UserDefaultKeys.showDateInMenu: 1,
UserDefaultKeys.showPlaceInMenu: 0,
UserDefaultKeys.startAtLogin: 0,
UserDefaultKeys.sunriseSunsetTime: 1,
UserDefaultKeys.userFontSizePreference: 4,
UserDefaultKeys.showUpcomingEventView: "YES",
UserDefaultKeys.showAppInForeground: 0,
UserDefaultKeys.futureSliderRange: 0,
UserDefaultKeys.showAllDayEventsInUpcomingView: 1,
UserDefaultKeys.showMeetingInMenubar: 0,
UserDefaultKeys.truncateTextLength: 30,
UserDefaultKeys.selectedCalendars: calendars,
UserDefaultKeys.appDisplayOptions: 0,
UserDefaultKeys.menubarCompactMode: 1]
}
}
extension UserDefaults {
5 years ago
// Use this with caution. Exposing this for debugging purposes only.
func wipe(for bundleID: String = "com.abhishek.Clocker") {
3 years ago
removePersistentDomain(forName: bundleID)
}
}