Enable Dark theme

TODO:
- fix the app freeze when user changes the app theme.
This commit is contained in:
Giom Foret
2017-08-11 16:56:09 +02:00
parent 1c9fc7a910
commit c4aa8013be
109 changed files with 1528 additions and 339 deletions
+34 -4
View File
@@ -49,6 +49,9 @@
// Keep reference on the pushed view controllers to release them correctly
NSMutableArray *childViewControllers;
// Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
id kRiotDesignValuesDidChangeThemeNotificationObserver;
}
@property(nonatomic,getter=isHidden) BOOL hidden;
@@ -70,9 +73,7 @@
// Sanity check
NSAssert(_homeViewController && _favouritesViewController && _peopleViewController && _roomsViewController, @"Something wrong in Main.storyboard");
self.tabBar.tintColor = kRiotColorGreen;
// Adjust the display of the icons in the tabbar.
for (UITabBarItem *tabBarItem in self.tabBar.items)
{
@@ -83,6 +84,29 @@
// Initialize here the data sources if a matrix session has been already set.
[self initializeDataSources];
// 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.tabBar.tintColor = kRiotColorGreen;
self.tabBar.barTintColor = kRiotSecondaryBgColor;
self.view.backgroundColor = kRiotPrimaryBgColor;
[self setNeedsStatusBarAppearanceUpdate];
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return kRiotDesignStatusBarStyle;
}
- (void)viewWillAppear:(BOOL)animated
@@ -172,6 +196,12 @@
authViewControllerObserver = nil;
}
if (kRiotDesignValuesDidChangeThemeNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kRiotDesignValuesDidChangeThemeNotificationObserver];
kRiotDesignValuesDidChangeThemeNotificationObserver = nil;
}
childViewControllers = nil;
}
@@ -640,7 +670,7 @@
{
_hidden = hidden;
[self.view superview].backgroundColor = [UIColor whiteColor];
[self.view superview].backgroundColor = kRiotPrimaryBgColor;
self.view.hidden = hidden;
self.navigationController.navigationBar.hidden = hidden;
}