diff --git a/MatrixKit/Controllers/MXKTableViewController.m b/MatrixKit/Controllers/MXKTableViewController.m index 04fbe54fd..ef16fb33a 100644 --- a/MatrixKit/Controllers/MXKTableViewController.m +++ b/MatrixKit/Controllers/MXKTableViewController.m @@ -90,6 +90,9 @@ - (void)viewDidLoad activityIndicator.center = self.view.center; [self.view addSubview:activityIndicator]; + + // Apply the navigation bar tint color. + self.defaultBarTintColor = defaultBarTintColor; } - (void)dealloc @@ -181,6 +184,38 @@ - (void)setEnableBarTintColorStatusChange:(BOOL)enable } } +- (void)setDefaultBarTintColor:(UIColor *)barTintColor +{ + defaultBarTintColor = barTintColor; + + // Retrieve the main navigation controller if the current view controller is embedded inside a split view controller. + UINavigationController *mainNavigationController = nil; + if (self.splitViewController) + { + mainNavigationController = self.navigationController; + UIViewController *parentViewController = self.parentViewController; + while (parentViewController) + { + if (parentViewController.navigationController) + { + mainNavigationController = parentViewController.navigationController; + parentViewController = parentViewController.parentViewController; + } + else + { + break; + } + } + } + + // Set default tintColor + self.navigationController.navigationBar.barTintColor = defaultBarTintColor; + if (mainNavigationController) + { + mainNavigationController.navigationBar.barTintColor = defaultBarTintColor; + } +} + - (void)setView:(UIView *)view { [super setView:view]; @@ -433,11 +468,15 @@ - (void)onMatrixSessionChange // Hide potential activity indicator [self stopActivityIndicator]; - // Restore default tintColor - self.navigationController.navigationBar.barTintColor = defaultBarTintColor; - if (mainNavigationController) + // Check whether the navigation bar color depends on homeserver reachability. + if (enableBarTintColorStatusChange) { - mainNavigationController.navigationBar.barTintColor = defaultBarTintColor; + // Restore default tintColor + self.navigationController.navigationBar.barTintColor = defaultBarTintColor; + if (mainNavigationController) + { + mainNavigationController.navigationBar.barTintColor = defaultBarTintColor; + } } } } diff --git a/MatrixKit/Controllers/MXKViewController.m b/MatrixKit/Controllers/MXKViewController.m index 2b8ae799c..cf46187da 100644 --- a/MatrixKit/Controllers/MXKViewController.m +++ b/MatrixKit/Controllers/MXKViewController.m @@ -91,6 +91,9 @@ - (void)viewDidLoad activityIndicator.center = self.view.center; [self.view addSubview:activityIndicator]; + + // Apply the navigation bar tint color. + self.defaultBarTintColor = defaultBarTintColor; } - (void)dealloc @@ -192,6 +195,38 @@ - (void)setEnableBarTintColorStatusChange:(BOOL)enable } } +- (void)setDefaultBarTintColor:(UIColor *)barTintColor +{ + defaultBarTintColor = barTintColor; + + // Retrieve the main navigation controller if the current view controller is embedded inside a split view controller. + UINavigationController *mainNavigationController = nil; + if (self.splitViewController) + { + mainNavigationController = self.navigationController; + UIViewController *parentViewController = self.parentViewController; + while (parentViewController) + { + if (parentViewController.navigationController) + { + mainNavigationController = parentViewController.navigationController; + parentViewController = parentViewController.parentViewController; + } + else + { + break; + } + } + } + + // Set default tintColor + self.navigationController.navigationBar.barTintColor = defaultBarTintColor; + if (mainNavigationController) + { + mainNavigationController.navigationBar.barTintColor = defaultBarTintColor; + } +} + - (void)setView:(UIView *)view { [super setView:view]; @@ -449,11 +484,16 @@ - (void)onMatrixSessionChange // Hide potential activity indicator [self stopActivityIndicator]; - // Restore default tintColor - self.navigationController.navigationBar.barTintColor = defaultBarTintColor; - if (mainNavigationController) + // Check whether the navigation bar color depends on homeserver reachability. + if (enableBarTintColorStatusChange) { - mainNavigationController.navigationBar.barTintColor = defaultBarTintColor; + // Restore default tintColor + self.navigationController.navigationBar.barTintColor = defaultBarTintColor; + if (mainNavigationController) + { + mainNavigationController.navigationBar.barTintColor = defaultBarTintColor; + } + } } }