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.

69 lines
2.1 KiB

// Copyright © 2015 Abhishek Banthia
import Cocoa
import CoreLoggerKit
class AppDefaults {
class func initialize() {
initializeDefaults()
}
5 years ago
private class func initializeDefaults() {
let userDefaults = UserDefaults.standard
3 years ago
let dataStore = DataStore.shared()
5 years ago
3 years ago
let timezones = dataStore.timezones()
let selectedCalendars = userDefaults.object(forKey: CLSelectedCalendars)
5 years ago
// Register the usual suspects
userDefaults.register(defaults: defaultsDictionary())
5 years ago
dataStore.setTimezones(timezones)
userDefaults.set(selectedCalendars, forKey: CLSelectedCalendars)
5 years ago
// Set the theme default as Light!
2 years ago
setDefaultTheme(userDefaults)
}
5 years ago
2 years ago
private class func setDefaultTheme(_ userDefaults: UserDefaults) {
if userDefaults.object(forKey: CLThemeKey) == nil {
Themer.shared().set(theme: 0)
}
}
2 years ago
private class func defaultsDictionary() -> [String: Any] {
return [CLThemeKey: 0,
CLDisplayFutureSliderKey: 0,
CLSelectedTimeZoneFormatKey: 0, // 12-hour format
CLRelativeDateKey: 0,
CLShowDayInMenu: 0,
CLShowDateInMenu: 1,
CLShowPlaceInMenu: 0,
CLStartAtLogin: 0,
CLSunriseSunsetTime: 1,
CLUserFontSizePreference: 4,
CLShowUpcomingEventView: "YES",
CLShowAppInForeground: 0,
CLFutureSliderRange: 0,
CLShowAllDayEventsInUpcomingView: 1,
CLShowMeetingInMenubar: 1,
CLTruncateTextLength: 30,
CLSelectedCalendars: [],
4 years ago
CLAppDisplayOptions: 0,
CLMenubarCompactMode: 1]
}
}
5 years ago
extension String {
func localized() -> String {
return NSLocalizedString(self, comment: "Title for \(self)")
}
}
extension UserDefaults {
5 years ago
// Use this with caution. Exposing this for debugging purposes only.
2 years ago
func wipe(for bundleID: String) {
removePersistentDomain(forName: bundleID)
}
}