Dark Theme - Improvement

Add a top view in pickers (country, language) to display the right background in case of vertical bounce.
This commit is contained in:
Giom Foret 2017-08-14 13:09:11 +02:00
parent 41e6001db1
commit e4e9a2aa7c
2 changed files with 34 additions and 2 deletions

View file

@ -24,6 +24,11 @@
Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
*/
id kRiotDesignValuesDidChangeThemeNotificationObserver;
/**
The fake top view displayed in case of vertical bounce.
*/
UIView *topview;
}
@end
@ -48,6 +53,12 @@
// Note: UISearchDisplayController is deprecated in iOS 8.
// MXKCountryPickerViewController should use UISearchController to manage the presentation of a search bar and display search results.
self.searchDisplayController.searchResultsTableView.tableFooterView = [[UIView alloc] init];
// Add a top view which will be displayed in case of vertical bounce.
CGFloat height = self.tableView.frame.size.height;
topview = [[UIView alloc] initWithFrame:CGRectMake(0,-height,self.tableView.frame.size.width,height)];
topview.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.tableView addSubview:topview];
// Observe user interface theme change.
kRiotDesignValuesDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kRiotDesignValuesDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
@ -68,6 +79,7 @@
// Use the primary bg color for the table view in plain style.
self.tableView.backgroundColor = kRiotPrimaryBgColor;
topview.backgroundColor = kRiotPrimaryBgColor;
self.searchDisplayController.searchResultsTableView.backgroundColor = self.tableView.backgroundColor;
if (self.tableView.dataSource)
@ -98,6 +110,9 @@
{
[super destroy];
[topview removeFromSuperview];
topview = nil;
if (kRiotDesignValuesDidChangeThemeNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kRiotDesignValuesDidChangeThemeNotificationObserver];

View file

@ -24,6 +24,11 @@
Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
*/
id kRiotDesignValuesDidChangeThemeNotificationObserver;
/**
The fake top view displayed in case of vertical bounce.
*/
UIView *topview;
}
@end
@ -46,6 +51,12 @@
// Hide line separators of empty cells
self.tableView.tableFooterView = [[UIView alloc] init];
// Add a top view which will be displayed in case of vertical bounce.
CGFloat height = self.tableView.frame.size.height;
topview = [[UIView alloc] initWithFrame:CGRectMake(0,-height,self.tableView.frame.size.width,height)];
topview.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.tableView addSubview:topview];
// Observe user interface theme change.
kRiotDesignValuesDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kRiotDesignValuesDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
@ -63,8 +74,9 @@
self.searchBar.barStyle = kRiotDesignSearchBarStyle;
self.searchBar.tintColor = kRiotDesignSearchBarTintColor;
// Check the table view style to select its bg color.
self.tableView.backgroundColor = ((self.tableView.style == UITableViewStylePlain) ? kRiotPrimaryBgColor : kRiotSecondaryBgColor);
// Use the primary bg color for the table view in plain style.
self.tableView.backgroundColor = kRiotPrimaryBgColor;
topview.backgroundColor = kRiotPrimaryBgColor;
if (self.tableView.dataSource)
{
@ -81,6 +93,9 @@
{
[super destroy];
[topview removeFromSuperview];
topview = nil;
if (kRiotDesignValuesDidChangeThemeNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kRiotDesignValuesDidChangeThemeNotificationObserver];
@ -103,6 +118,8 @@
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
{
cell.textLabel.textColor = kRiotPrimaryTextColor;
cell.detailTextLabel.textColor = kRiotSecondaryTextColor;
cell.backgroundColor = kRiotPrimaryBgColor;
// Update the selected background view