Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Prepare Dark Theme #328

Merged
merged 1 commit into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions MatrixKit/Controllers/MXKTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down
48 changes: 44 additions & 4 deletions MatrixKit/Controllers/MXKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}

}
}
}
Expand Down