Commit 4f4e0033 authored by Robert Gordon's avatar Robert Gordon Committed by Soomin Lee

Update status bar style in dark mode

This commit updates the status bar style to match the current theme that is selected.
The rootViewController has been switched to a UITabBarController from a regular UIViewController.

(fixes #403)
parent f034375d
...@@ -46,7 +46,7 @@ class AppearanceManager: NSObject { ...@@ -46,7 +46,7 @@ class AppearanceManager: NSObject {
//extensions so that preferredStatusBarStyle is called on all childViewControllers otherwise this is not forwarded //extensions so that preferredStatusBarStyle is called on all childViewControllers otherwise this is not forwarded
extension UINavigationController { extension UINavigationController {
override open var childForStatusBarStyle: UIViewController? { override open var preferredStatusBarStyle: UIStatusBarStyle {
return self.topViewController return PresentationTheme.current.colors.statusBarStyle
} }
} }
...@@ -18,17 +18,15 @@ class Services: NSObject { ...@@ -18,17 +18,15 @@ class Services: NSObject {
@objc class AppCoordinator: NSObject { @objc class AppCoordinator: NSObject {
private var childCoordinators: [NSObject] = [] private var childCoordinators: [NSObject] = []
private var viewController: UIViewController
private var playerController: VLCPlayerDisplayController private var playerController: VLCPlayerDisplayController
private var tabBarController: UITabBarController private var tabBarController: UITabBarController
private var services = Services() private var services = Services()
private var migrationViewController = VLCMigrationViewController(nibName: String(describing: VLCMigrationViewController.self), private var migrationViewController = VLCMigrationViewController(nibName: String(describing: VLCMigrationViewController.self),
bundle: nil) bundle: nil)
@objc init(viewController: UIViewController) { @objc init(tabBarController: UITabBarController) {
self.viewController = viewController
self.playerController = VLCPlayerDisplayController(services: services) self.playerController = VLCPlayerDisplayController(services: services)
self.tabBarController = UITabBarController() self.tabBarController = tabBarController
super.init() super.init()
setupChildViewControllers() setupChildViewControllers()
...@@ -39,19 +37,14 @@ class Services: NSObject { ...@@ -39,19 +37,14 @@ class Services: NSObject {
} }
private func setupChildViewControllers() { private func setupChildViewControllers() {
viewController.addChild(tabBarController) self.tabBarController.addChild(playerController)
viewController.view.addSubview(tabBarController.view) self.tabBarController.view.addSubview(playerController.view)
tabBarController.view.frame = viewController.view.frame
tabBarController.didMove(toParent: viewController)
viewController.addChild(playerController)
viewController.view.addSubview(playerController.view)
playerController.view.layoutMargins = UIEdgeInsets(top: 0, playerController.view.layoutMargins = UIEdgeInsets(top: 0,
left: 0, left: 0,
bottom: tabBarController.tabBar.frame.size.height, bottom: tabBarController.tabBar.frame.size.height,
right: 0) right: 0)
playerController.realBottomAnchor = tabBarController.tabBar.topAnchor playerController.realBottomAnchor = tabBarController.tabBar.topAnchor
playerController.didMove(toParent: viewController) playerController.didMove(toParent: self.tabBarController)
} }
@objc func start() { @objc func start() {
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
BOOL _isComingFromHandoff; BOOL _isComingFromHandoff;
VLCKeychainCoordinator *_keychainCoordinator; VLCKeychainCoordinator *_keychainCoordinator;
AppCoordinator *appCoordinator; AppCoordinator *appCoordinator;
UIViewController *rootViewController; UITabBarController *rootViewController;
} }
@end @end
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
- (void)setup - (void)setup
{ {
void (^setupAppCoordinator)(void) = ^{ void (^setupAppCoordinator)(void) = ^{
self->appCoordinator = [[AppCoordinator alloc] initWithViewController:self->rootViewController]; self->appCoordinator = [[AppCoordinator alloc] initWithTabBarController:self->rootViewController];
[self->appCoordinator start]; [self->appCoordinator start];
}; };
[self validatePasscodeIfNeededWithCompletion:setupAppCoordinator]; [self validatePasscodeIfNeededWithCompletion:setupAppCoordinator];
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
[VLCApperanceManager setupAppearanceWithTheme:PresentationTheme.current]; [VLCApperanceManager setupAppearanceWithTheme:PresentationTheme.current];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
rootViewController = [UIViewController new]; rootViewController = [UITabBarController new];
self.window.rootViewController = rootViewController; self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
[self setup]; [self setup];
......
...@@ -32,6 +32,7 @@ class VLCTabBarCoordinator: NSObject { ...@@ -32,6 +32,7 @@ class VLCTabBarCoordinator: NSObject {
tabBarController.tabBar.isTranslucent = false tabBarController.tabBar.isTranslucent = false
tabBarController.tabBar.backgroundColor = PresentationTheme.current.colors.tabBarColor tabBarController.tabBar.backgroundColor = PresentationTheme.current.colors.tabBarColor
tabBarController.tabBar.barTintColor = PresentationTheme.current.colors.tabBarColor tabBarController.tabBar.barTintColor = PresentationTheme.current.colors.tabBarColor
tabBarController.tabBar.itemPositioning = .fill
tabBarController.viewControllers?.forEach { tabBarController.viewControllers?.forEach {
if let navController = $0 as? UINavigationController, navController.topViewController is VLCSettingsController { if let navController = $0 as? UINavigationController, navController.topViewController is VLCSettingsController {
navController.navigationBar.barTintColor = PresentationTheme.current.colors.navigationbarColor navController.navigationBar.barTintColor = PresentationTheme.current.colors.navigationbarColor
...@@ -58,3 +59,9 @@ class VLCTabBarCoordinator: NSObject { ...@@ -58,3 +59,9 @@ class VLCTabBarCoordinator: NSObject {
tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0) } tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0) }
} }
} }
extension UITabBarController {
open override var preferredStatusBarStyle: UIStatusBarStyle {
return PresentationTheme.current.colors.statusBarStyle
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment