Prepare Dark Theme

Observe user interface theme change.

https://github.com/vector-im/riot-meta/issues/22
This commit is contained in:
Giom Foret
2017-07-21 11:28:17 +02:00
parent 45491d73c9
commit 4e5fa4ef5e
29 changed files with 795 additions and 70 deletions
+29 -4
View File
@@ -172,6 +172,9 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
// Observe kAppDelegateDidTapStatusBarNotification to handle tap on clock status bar.
id kAppDelegateDidTapStatusBarNotificationObserver;
// Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
id kRiotDesignValuesDidChangeThemeNotificationObserver;
// Postpone destroy operation when saving, pwd reset or email binding is in progress
BOOL isSavingInProgress;
BOOL isResetPwdInProgress;
@@ -212,7 +215,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
[super finalizeInit];
// Setup `MXKViewControllerHandling` properties
self.defaultBarTintColor = kRiotNavBarTintColor;
self.enableBarTintColorStatusChange = NO;
self.rageShakeManager = [RageShakeManager sharedManager];
@@ -278,6 +280,26 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSave:)];
self.navigationItem.rightBarButtonItem.accessibilityIdentifier=@"SettingsVCNavBarSaveButton";
// Observe user interface theme change.
kRiotDesignValuesDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kRiotDesignValuesDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
[self userInterfaceThemeDidChange];
}];
[self userInterfaceThemeDidChange];
}
- (void)userInterfaceThemeDidChange
{
self.defaultBarTintColor = kRiotSecondaryBgColor;
if (self.tableView.dataSource)
{
[self refreshSettings];
}
[[UIApplication sharedApplication] setStatusBarStyle:kRiotDesignStatusBarStyle animated:NO];
}
- (void)didReceiveMemoryWarning
@@ -294,6 +316,12 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
[documentInteractionController dismissMenuAnimated:NO];
documentInteractionController = nil;
}
if (kRiotDesignValuesDidChangeThemeNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kRiotDesignValuesDidChangeThemeNotificationObserver];
kRiotDesignValuesDidChangeThemeNotificationObserver = nil;
}
if (isSavingInProgress || isResetPwdInProgress || is3PIDBindingInProgress)
{
@@ -3495,9 +3523,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
// The user wants to select this theme
[[NSUserDefaults standardUserDefaults] setObject:theme forKey:@"userInterfaceTheme"];
[[NSUserDefaults standardUserDefaults] synchronize];
// Select the tapped tag
[uiThemeCell setCheckBoxValue:YES atIndex:index];
}
}
}