|
|
@ -41,8 +41,6 @@ class DataStore: NSObject { |
|
|
|
init(with defaults: UserDefaults) { |
|
|
|
init(with defaults: UserDefaults) { |
|
|
|
super.init() |
|
|
|
super.init() |
|
|
|
userDefaults = defaults |
|
|
|
userDefaults = defaults |
|
|
|
shouldDisplayDayInMenubar = shouldDisplay(.dayInMenubar) |
|
|
|
|
|
|
|
shouldDisplayDateInMenubar = shouldDisplay(.dateInMenubar) |
|
|
|
|
|
|
|
setupSyncNotification() |
|
|
|
setupSyncNotification() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -113,20 +111,14 @@ class DataStore: NSObject { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func updateDayPreference() { |
|
|
|
// MARK: Date (May 8th) in Compact Menubar |
|
|
|
shouldDisplayDayInMenubar = shouldDisplay(.dayInMenubar) |
|
|
|
func shouldShowDateInMenubar() -> Bool { |
|
|
|
} |
|
|
|
return shouldDisplay(.dateInMenubar) |
|
|
|
|
|
|
|
|
|
|
|
func updateDateInPreference() { |
|
|
|
|
|
|
|
shouldDisplayDateInMenubar = shouldDisplay(.dateInMenubar) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Day (Sun, Mon etc.) in Compact Menubar |
|
|
|
func shouldShowDayInMenubar() -> Bool { |
|
|
|
func shouldShowDayInMenubar() -> Bool { |
|
|
|
return shouldDisplayDayInMenubar |
|
|
|
return shouldDisplay(.dayInMenubar) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func shouldShowDateInMenubar() -> Bool { |
|
|
|
|
|
|
|
return shouldDisplayDateInMenubar |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func retrieve(key: String) -> Any? { |
|
|
|
func retrieve(key: String) -> Any? { |
|
|
@ -189,11 +181,11 @@ class DataStore: NSObject { |
|
|
|
} |
|
|
|
} |
|
|
|
return value.isEqual(to: NSNumber(value: 1)) |
|
|
|
return value.isEqual(to: NSNumber(value: 1)) |
|
|
|
case .dateInMenubar: |
|
|
|
case .dateInMenubar: |
|
|
|
return shouldDisplayHelper(CLShowDateInMenu) |
|
|
|
return shouldDisplayNonObjectHelper(CLShowDateInMenu) |
|
|
|
case .placeInMenubar: |
|
|
|
case .placeInMenubar: |
|
|
|
return shouldDisplayHelper(CLShowPlaceInMenu) |
|
|
|
return shouldDisplayHelper(CLShowPlaceInMenu) |
|
|
|
case .dayInMenubar: |
|
|
|
case .dayInMenubar: |
|
|
|
return shouldDisplayHelper(CLShowDayInMenu) |
|
|
|
return shouldDisplayNonObjectHelper(CLShowDayInMenu) |
|
|
|
case .appDisplayOptions: |
|
|
|
case .appDisplayOptions: |
|
|
|
return shouldDisplayHelper(CLAppDisplayOptions) |
|
|
|
return shouldDisplayHelper(CLAppDisplayOptions) |
|
|
|
case .menubarCompactMode: |
|
|
|
case .menubarCompactMode: |
|
|
@ -215,6 +207,12 @@ class DataStore: NSObject { |
|
|
|
} |
|
|
|
} |
|
|
|
return value.isEqual(to: NSNumber(value: 0)) |
|
|
|
return value.isEqual(to: NSNumber(value: 0)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Some values are stored as plain integers; objectForKey: will return nil, so using integerForKey: |
|
|
|
|
|
|
|
private func shouldDisplayNonObjectHelper(_ key: String) -> Bool { |
|
|
|
|
|
|
|
let value = userDefaults.integer(forKey: key) |
|
|
|
|
|
|
|
return value == 0 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
extension DataStore { |
|
|
|
extension DataStore { |
|
|
|