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