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
@@ -34,6 +34,11 @@
The default country code used to initialize the mobile phone number input.
*/
NSString *defaultCountryCode;
/**
Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
*/
id kRiotDesignValuesDidChangeThemeNotificationObserver;
}
@end
@@ -59,7 +64,6 @@
[super finalizeInit];
// Setup `MXKViewControllerHandling` properties
self.defaultBarTintColor = kRiotNavBarTintColor;
self.enableBarTintColorStatusChange = NO;
self.rageShakeManager = [RageShakeManager sharedManager];
@@ -76,12 +80,8 @@
self.rightBarButtonItem.title = NSLocalizedStringFromTable(@"auth_register", @"Vector", nil);
self.defaultHomeServerUrl = [[NSUserDefaults standardUserDefaults] objectForKey:@"homeserverurl"];
self.homeServerTextField.textColor = kRiotTextColorBlack;
self.homeServerLabel.textColor = kRiotTextColorGray;
self.defaultIdentityServerUrl = [[NSUserDefaults standardUserDefaults] objectForKey:@"identityserverurl"];
self.identityServerTextField.textColor = kRiotTextColorBlack;
self.identityServerLabel.textColor = kRiotTextColorGray;
self.welcomeImageView.image = [UIImage imageNamed:@"logo"];
@@ -129,6 +129,32 @@
MXAuthenticationSession *authSession = [MXAuthenticationSession modelFromJSON:@{@"flows":@[@{@"stages":@[kMXLoginFlowTypePassword]}]}];
[authInputsView setAuthSession:authSession withAuthType:MXKAuthenticationTypeLogin];
self.authInputsView = authInputsView;
// 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.view.backgroundColor = kRiotSecondaryBgColor;
self.navigationBar.barTintColor = kRiotSecondaryBgColor;
self.authenticationScrollView.backgroundColor = kRiotPrimaryBgColor;
self.authFallbackContentView.backgroundColor = kRiotPrimaryBgColor;
self.homeServerTextField.textColor = kRiotPrimaryTextColor;
self.homeServerLabel.textColor = kRiotTextColorGray;
self.identityServerTextField.textColor = kRiotPrimaryTextColor;
self.identityServerLabel.textColor = kRiotTextColorGray;
self.defaultBarTintColor = kRiotSecondaryBgColor;
[[UIApplication sharedApplication] setStatusBarStyle:kRiotDesignStatusBarStyle animated:NO];
}
- (void)viewWillAppear:(BOOL)animated
@@ -144,6 +170,17 @@
}
}
- (void)destroy
{
[super destroy];
if (kRiotDesignValuesDidChangeThemeNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kRiotDesignValuesDidChangeThemeNotificationObserver];
kRiotDesignValuesDidChangeThemeNotificationObserver = nil;
}
}
- (void)setAuthType:(MXKAuthenticationType)authType
{
if (self.authType == MXKAuthenticationTypeRegister)