diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index df6253dc8..de048f57a 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -429,8 +429,6 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN [NSBundle mxk_setLanguage:language]; [NSBundle mxk_setFallbackLanguage:@"en"]; - // Define the navigation bar text color - [[UINavigationBar appearance] setTintColor:ThemeService.shared.theme.tintColor]; // Customize the localized string table [NSBundle mxk_customizeLocalizedStringTableName:@"Vector"]; diff --git a/Riot/Managers/Theme/Theme.swift b/Riot/Managers/Theme/Theme.swift index 839f4641c..50970fed0 100644 --- a/Riot/Managers/Theme/Theme.swift +++ b/Riot/Managers/Theme/Theme.swift @@ -80,6 +80,11 @@ import UIKit // MARK: - Customisation methods + + /// Apply the theme on a button. + /// + /// - Parameter tabBar: The tabBar to customise. + func applyStyle(onTabBar tabBar: UITabBar) /// Apply the theme on a navigation bar /// diff --git a/Riot/Managers/Theme/ThemeService.m b/Riot/Managers/Theme/ThemeService.m index 2c54ec5ad..0cbe1bd97 100644 --- a/Riot/Managers/Theme/ThemeService.m +++ b/Riot/Managers/Theme/ThemeService.m @@ -51,8 +51,8 @@ NSString *const kThemeServiceDidChangeThemeNotification = @"kThemeServiceDidChan - (void)setTheme:(id _Nonnull)theme { _theme = theme; - - [UIScrollView appearance].indicatorStyle = self.theme.scrollBarStyle; + + [self updateAppearance]; [[NSNotificationCenter defaultCenter] postNotificationName:kThemeServiceDidChangeThemeNotification object:nil]; } @@ -112,5 +112,15 @@ NSString *const kThemeServiceDidChangeThemeNotification = @"kThemeServiceDidChan } } +- (void)updateAppearance +{ + [UIScrollView appearance].indicatorStyle = self.theme.scrollBarStyle; + + // Define the navigation bar text color + [[UINavigationBar appearance] setTintColor:self.theme.tintColor]; + + // Define the UISearchBar cancel button color + [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTitleTextAttributes:@{ NSForegroundColorAttributeName : self.theme.searchPlaceholderColor } forState: UIControlStateNormal]; +} @end diff --git a/Riot/Managers/Theme/Themes/DarkTheme.swift b/Riot/Managers/Theme/Themes/DarkTheme.swift index 89d3cc92b..8e50e1b7b 100644 --- a/Riot/Managers/Theme/Themes/DarkTheme.swift +++ b/Riot/Managers/Theme/Themes/DarkTheme.swift @@ -23,15 +23,15 @@ class DarkTheme: NSObject, Theme { var backgroundColor: UIColor = UIColor(rgb: 0x181B21) - var baseColor: UIColor = UIColor(rgb: 0x1B1F25) + var baseColor: UIColor = UIColor(rgb: 0x15171B) var baseTextPrimaryColor: UIColor = UIColor(rgb: 0xEDF3FF) var baseTextSecondaryColor: UIColor = UIColor(rgb: 0xEDF3FF) var searchBackgroundColor: UIColor = UIColor(rgb: 0x181B21) var searchPlaceholderColor: UIColor = UIColor(rgb: 0x61708B) - var headerBackgroundColor: UIColor = UIColor(rgb: 0x22262E) - var headerBorderColor: UIColor = UIColor(rgb: 0x181B21) + var headerBackgroundColor: UIColor = UIColor(rgb: 0x15171B) + var headerBorderColor: UIColor = UIColor(rgb: 0x22262E) var headerTextPrimaryColor: UIColor = UIColor(rgb: 0xA1B2D1) var headerTextSecondaryColor: UIColor = UIColor(rgb: 0xC8C8CD) @@ -60,6 +60,12 @@ class DarkTheme: NSObject, Theme { var selectedBackgroundColor: UIColor? = UIColor.black var overlayBackgroundColor: UIColor = UIColor(white: 0.7, alpha: 0.5) var matrixSearchBackgroundImageTintColor: UIColor = UIColor(rgb: 0x7E7E7E) + + func applyStyle(onTabBar tabBar: UITabBar) { + tabBar.tintColor = self.tintColor; + tabBar.barTintColor = self.headerBackgroundColor; + tabBar.isTranslucent = false; + } func applyStyle(onNavigationBar navigationBar: UINavigationBar) { navigationBar.tintColor = self.baseTextPrimaryColor; @@ -75,9 +81,7 @@ class DarkTheme: NSObject, Theme { func applyStyle(onSearchBar searchBar: UISearchBar) { searchBar.barStyle = .black searchBar.tintColor = self.searchPlaceholderColor; - searchBar.barTintColor = self.headerBackgroundColor; - searchBar.layer.borderWidth = 1; - searchBar.layer.borderColor = self.headerBorderColor.cgColor; + searchBar.barTintColor = self.headerBackgroundColor; } func applyStyle(onTextField texField: UITextField) { diff --git a/Riot/Managers/Theme/Themes/DefaultTheme.swift b/Riot/Managers/Theme/Themes/DefaultTheme.swift index 3a14b3f95..fb43f1fec 100644 --- a/Riot/Managers/Theme/Themes/DefaultTheme.swift +++ b/Riot/Managers/Theme/Themes/DefaultTheme.swift @@ -60,6 +60,12 @@ class DefaultTheme: NSObject, Theme { var selectedBackgroundColor: UIColor? = nil // Use the default selection color var overlayBackgroundColor: UIColor = UIColor(white: 0.7, alpha: 0.5) var matrixSearchBackgroundImageTintColor: UIColor = UIColor(rgb: 0xE7E7E7) + + func applyStyle(onTabBar tabBar: UITabBar) { + tabBar.tintColor = self.tintColor; + tabBar.barTintColor = self.headerBackgroundColor; + tabBar.isTranslucent = false; + } func applyStyle(onNavigationBar navigationBar: UINavigationBar) { navigationBar.tintColor = self.baseTextPrimaryColor; @@ -76,8 +82,6 @@ class DefaultTheme: NSObject, Theme { searchBar.barStyle = .default searchBar.tintColor = self.searchPlaceholderColor; searchBar.barTintColor = self.headerBackgroundColor; - searchBar.layer.borderWidth = 1; - searchBar.layer.borderColor = self.headerBorderColor.cgColor; } func applyStyle(onTextField texField: UITextField) { diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index d926c8781..b7290b760 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -116,8 +116,7 @@ { [ThemeService.shared.theme applyStyleOnNavigationBar:self.navigationController.navigationBar]; - self.tabBar.tintColor = ThemeService.shared.theme.tintColor; - self.tabBar.barTintColor = ThemeService.shared.theme.headerBackgroundColor; + [ThemeService.shared.theme applyStyleOnTabBar:self.tabBar]; self.view.backgroundColor = ThemeService.shared.theme.backgroundColor;