|
|
|
@ -254,6 +254,9 @@ static NSTimeInterval launchStartedAt;
|
|
|
|
|
mainWindow.rootViewController = [LoadingViewController new];
|
|
|
|
|
[mainWindow makeKeyAndVisible];
|
|
|
|
|
|
|
|
|
|
LKAppMode appMode = [NSUserDefaults.standardUserDefaults integerForKey:@"appMode"];
|
|
|
|
|
[self setCurrentAppMode:appMode];
|
|
|
|
|
|
|
|
|
|
if (@available(iOS 11, *)) {
|
|
|
|
|
// This must happen in appDidFinishLaunching or earlier to ensure we don't
|
|
|
|
|
// miss notifications.
|
|
|
|
@ -308,6 +311,9 @@ static NSTimeInterval launchStartedAt;
|
|
|
|
|
|
|
|
|
|
[self ensureRootViewController];
|
|
|
|
|
|
|
|
|
|
LKAppMode appMode = [NSUserDefaults.standardUserDefaults integerForKey:@"appMode"];
|
|
|
|
|
[self setCurrentAppMode:appMode];
|
|
|
|
|
|
|
|
|
|
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
|
|
|
|
[self handleActivation];
|
|
|
|
|
}];
|
|
|
|
@ -937,21 +943,24 @@ static NSTimeInterval launchStartedAt;
|
|
|
|
|
|
|
|
|
|
# pragma mark - App Mode
|
|
|
|
|
|
|
|
|
|
- (LKAppMode)getCurrentAppMode {
|
|
|
|
|
- (LKAppMode)getCurrentAppMode
|
|
|
|
|
{
|
|
|
|
|
UIWindow *window = UIApplication.sharedApplication.keyWindow;
|
|
|
|
|
if (window == nil) { return LKAppModeLight; }
|
|
|
|
|
UIUserInterfaceStyle userInterfaceStyle = window.traitCollection.userInterfaceStyle;
|
|
|
|
|
BOOL isLightMode = userInterfaceStyle == UIUserInterfaceStyleUnspecified || userInterfaceStyle == UIUserInterfaceStyleLight;
|
|
|
|
|
BOOL isLightMode = userInterfaceStyle == UIUserInterfaceStyleLight || userInterfaceStyle == UIUserInterfaceStyleUnspecified;
|
|
|
|
|
return isLightMode ? LKAppModeLight : LKAppModeDark;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setCurrentAppModeTo:(LKAppMode)appMode {
|
|
|
|
|
- (void)setCurrentAppMode:(LKAppMode)appMode
|
|
|
|
|
{
|
|
|
|
|
UIWindow *window = UIApplication.sharedApplication.keyWindow;
|
|
|
|
|
if (window == nil) { return; }
|
|
|
|
|
[NSUserDefaults.standardUserDefaults setInteger:appMode forKey:@"appMode"];
|
|
|
|
|
switch (appMode) {
|
|
|
|
|
case LKAppModeLight: {
|
|
|
|
|
if (@available(iOS 13.0, *)) {
|
|
|
|
|
window.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
|
|
|
window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -962,6 +971,7 @@ static NSTimeInterval launchStartedAt;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.appModeChanged object:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# pragma mark - Other
|
|
|
|
|