Commit a00bc37f by Daniel Dahan

fixed statusBar issue when using SideNavigationViewController that would close…

fixed statusBar issue when using SideNavigationViewController that would close incorrectly when rotating
parent ba7f21c2
......@@ -145,7 +145,7 @@ class MainViewController: UIViewController {
/// Prepares the navigationBarView.
private func prepareNavigationBarView() {
let navigationBarView: NavigationBarView = NavigationBarView()
navigationBarView.backgroundColor = MaterialColor.blue.base
navigationBarView.backgroundColor = MaterialColor.grey.darken4
/*
To lighten the status bar - add the
......@@ -159,7 +159,7 @@ class MainViewController: UIViewController {
titleLabel.text = "Inbox"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(22)
titleLabel.font = RobotoFont.regularWithSize(17)
navigationBarView.titleLabel = titleLabel
// Menu button.
......@@ -175,7 +175,7 @@ class MainViewController: UIViewController {
navigationBarView.leftControls = [menuButton]
// MaterialSwitch control.
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .Off, style: .Light, size: .Normal)
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .Off)
// Search button.
let img2: UIImage? = UIImage(named: "ic_more_vert_white")
......@@ -191,10 +191,6 @@ class MainViewController: UIViewController {
// To support orientation changes, use MaterialLayout.
view.addSubview(navigationBarView)
navigationBarView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(view, child: navigationBarView)
MaterialLayout.alignToParentHorizontally(view, child: navigationBarView)
MaterialLayout.height(view, child: navigationBarView, height: 70)
}
/// Prepares the add button.
......
......@@ -41,18 +41,14 @@ public class SearchBarView : MaterialView {
}
}
/**
:name: leftControls
*/
/// Left side UIControls.
public var leftControls: Array<UIControl>? {
didSet {
reloadView()
}
}
/**
:name: rightControls
*/
/// Right side UIControls.
public var rightControls: Array<UIControl>? {
didSet {
reloadView()
......
......@@ -576,7 +576,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/
public func closeLeftView(velocity: CGFloat = 0) {
if enabledLeftView {
toggleStatusBar(false)
backdropLayer.hidden = true
if let v: MaterialView = leftView {
......@@ -585,6 +584,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
animations: {
v.position = CGPointMake(-v.width / 2, v.height / 2)
}) { _ in
self.toggleStatusBar()
self.userInteractionEnabled = true
self.hideDepth(v)
self.hideView(v)
......@@ -602,7 +602,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/
public func closeRightView(velocity: CGFloat = 0) {
if enabledRightView {
toggleStatusBar(false)
backdropLayer.hidden = true
if let v: MaterialView = rightView {
......@@ -611,6 +610,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
animations: {
v.position = CGPointMake(self.view.bounds.width + v.width / 2, v.height / 2)
}) { _ in
self.toggleStatusBar()
self.userInteractionEnabled = true
self.hideDepth(v)
self.hideView(v)
......@@ -867,7 +867,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/
private func toggleStatusBar(hide: Bool = false) {
if hideStatusBar {
UIApplication.sharedApplication().statusBarHidden = hide
// General alignment.
switch UIDevice.currentDevice().orientation {
case .LandscapeLeft, .LandscapeRight:
UIApplication.sharedApplication().statusBarHidden = true
default:
UIApplication.sharedApplication().statusBarHidden = opened ? true : hide
}
}
}
......@@ -945,6 +951,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/// Layout subviews.
private func layoutSubviews() {
toggleStatusBar()
MaterialAnimation.animationDisabled { [unowned self] in
self.backdropLayer.frame = self.view.bounds
}
......
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