Add the option to select the user interface color palette. Issue #1900

This commit is contained in:
Maurice Parker
2020-03-15 04:25:25 -05:00
parent 07dc4f1f10
commit a620a20588
7 changed files with 310 additions and 135 deletions

View File

@@ -21,10 +21,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window = UIWindow(windowScene: scene as! UIWindowScene)
window!.tintColor = AppAssets.primaryAccentColor
updateUserInterfaceStyle()
window!.rootViewController = coordinator.start(for: window!.frame.size)
coordinator.restoreWindowState(session.stateRestorationActivity)
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange), name: UserDefaults.didChangeNotification, object: nil)
if let shortcutItem = connectionOptions.shortcutItem {
window!.makeKeyAndVisible()
handleShortcutItem(shortcutItem)
@@ -102,4 +105,19 @@ private extension SceneDelegate {
}
}
@objc func userDefaultsDidChange() {
updateUserInterfaceStyle()
}
func updateUserInterfaceStyle() {
switch AppDefaults.userInterfaceColorPalette {
case .automatic:
window!.overrideUserInterfaceStyle = .unspecified
case .light:
window!.overrideUserInterfaceStyle = .light
case .dark:
window!.overrideUserInterfaceStyle = .dark
}
}
}