Made app default to system-defined dark/light mode on first launch
This commit is contained in:
parent
67e8191c2c
commit
9a27e5d7bb
|
@ -194,7 +194,7 @@ static NSTimeInterval launchStartedAt;
|
|||
mainWindow.rootViewController = [LoadingViewController new];
|
||||
[mainWindow makeKeyAndVisible];
|
||||
|
||||
LKAppMode appMode = [NSUserDefaults.standardUserDefaults integerForKey:@"appMode"];
|
||||
LKAppMode appMode = [self getAppModeOrSystemDefault];
|
||||
[self setCurrentAppMode:appMode];
|
||||
|
||||
if (@available(iOS 11, *)) {
|
||||
|
@ -245,7 +245,7 @@ static NSTimeInterval launchStartedAt;
|
|||
|
||||
[self ensureRootViewController];
|
||||
|
||||
LKAppMode appMode = [NSUserDefaults.standardUserDefaults integerForKey:@"appMode"];
|
||||
LKAppMode appMode = [self getCurrentAppMode];
|
||||
[self setCurrentAppMode:appMode];
|
||||
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
|
|
|
@ -40,4 +40,20 @@ extension AppDelegate {
|
|||
@objc func stopClosedGroupPoller() {
|
||||
ClosedGroupPoller.shared.stop()
|
||||
}
|
||||
|
||||
@objc func getAppModeOrSystemDefault() -> AppMode {
|
||||
let userDefaults = UserDefaults.standard
|
||||
|
||||
guard userDefaults.dictionaryRepresentation().keys.contains("appMode") else {
|
||||
if #available(iOS 13.0, *) {
|
||||
return UITraitCollection.current.userInterfaceStyle == .dark ? .dark : .light
|
||||
} else {
|
||||
return .light
|
||||
}
|
||||
}
|
||||
|
||||
let mode = userDefaults.integer(forKey: "appMode")
|
||||
return AppMode(rawValue: mode) ?? .light
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue