Commit f4c2a71a by Daniel Dahan

added fix for StatusBar not hiding

parent ae33ab43
......@@ -20,7 +20,6 @@
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
9663F9521C7A751D00AF0965 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* ItemViewController.swift */; };
967A481B1D0F58F800B8CEB7 /* AppNavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A481A1D0F58F800B8CEB7 /* AppNavigationDrawerController.swift */; };
967A481D1D0F5AFC00B8CEB7 /* AppStatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A481C1D0F5AFC00B8CEB7 /* AppStatusBarController.swift */; };
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; };
/* End PBXBuildFile section */
......@@ -53,7 +52,6 @@
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; };
9663F9511C7A751D00AF0965 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; };
967A481A1D0F58F800B8CEB7 /* AppNavigationDrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppNavigationDrawerController.swift; sourceTree = "<group>"; };
967A481C1D0F5AFC00B8CEB7 /* AppStatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppStatusBarController.swift; sourceTree = "<group>"; };
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -88,7 +86,6 @@
isa = PBXGroup;
children = (
9663F9311C7A744600AF0965 /* AppDelegate.swift */,
967A481C1D0F5AFC00B8CEB7 /* AppStatusBarController.swift */,
9663F9471C7A749400AF0965 /* AppNavigationController.swift */,
967A481A1D0F58F800B8CEB7 /* AppNavigationDrawerController.swift */,
960CDA481D09FF3E00387CE8 /* AppBottomNavigationController.swift */,
......@@ -178,7 +175,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
967A481D1D0F5AFC00B8CEB7 /* AppStatusBarController.swift in Sources */,
967A481B1D0F58F800B8CEB7 /* AppNavigationDrawerController.swift in Sources */,
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */,
......
......@@ -39,11 +39,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let bottomNavigationController: AppBottomNavigationController = AppBottomNavigationController()
let navigationController: AppNavigationController = AppNavigationController(rootViewController: bottomNavigationController)
let navigationDrawerController: AppNavigationDrawerController = AppNavigationDrawerController(rootViewController: navigationController, leftViewController: AppLeftViewController())
let statusBarController: AppStatusBarController = AppStatusBarController(rootViewController: navigationDrawerController)
let menuController: AppMenuController = AppMenuController(rootViewController: navigationController)
let navigationDrawerController: AppNavigationDrawerController = AppNavigationDrawerController(rootViewController: menuController, leftViewController: AppLeftViewController())
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = statusBarController
window!.rootViewController = navigationDrawerController
window!.makeKeyAndVisible()
return true
}
......
......@@ -38,32 +38,38 @@ class AppNavigationDrawerController: NavigationDrawerController, NavigationDrawe
}
func navigationDrawerPanDidBegin(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
showStatusBarView()
print("NavigationDrawerController - Pan Began");
}
func navigationDrawerPanDidEnd(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
hideStatusBarView()
print("NavigationDrawerController - Pan Ended");
}
func navigationDrawerWillOpen(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
showStatusBarView()
print("NavigationDrawerController - Will Open");
}
func navigationDrawerDidOpen(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
print("NavigationDrawerController - DId Open");
}
func navigationDrawerWillClose(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
hideStatusBarView()
print("NavigationDrawerController - Will Close");
}
func navigationDrawerDidClose(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
print("NavigationDrawerController - Did Close");
}
func navigationDrawerStatusBarHiddenState(navigationDrawerController: NavigationDrawerController, hidden: Bool) {
print("NavigationDrawerController - Status Bar Hidden: ", hidden ? "Yes" : "No");
}
/// Shows the transparent statusBarView.
private func showStatusBarView() {
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 1
})
func navigationDrawerDidTap(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
print("NavigationDrawerController - Did Tap");
}
/// Hides the transparent statusBarView.
private func hideStatusBarView() {
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 0
})
func navigationDrawerPanDidChange(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
// print("NavigationDrawerController - Did Change");
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class AppStatusBarController: StatusBarController {
override func prepareView() {
super.prepareView()
statusBarView.alpha = 0
}
}
......@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
967A48071D0E0EA300B8CEB7 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48061D0E0EA300B8CEB7 /* AppRightViewController.swift */; };
967A48221D0F601B00B8CEB7 /* AppNavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48211D0F601B00B8CEB7 /* AppNavigationDrawerController.swift */; };
967A48241D0F603200B8CEB7 /* AppStatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48231D0F603200B8CEB7 /* AppStatusBarController.swift */; };
96CB75011D0DFDBB0012D9F2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CB75001D0DFDBB0012D9F2 /* AppDelegate.swift */; };
96CB75031D0DFDBB0012D9F2 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CB75021D0DFDBB0012D9F2 /* AppLeftViewController.swift */; };
96CB75081D0DFDBB0012D9F2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96CB75071D0DFDBB0012D9F2 /* Assets.xcassets */; };
......@@ -37,7 +36,6 @@
/* Begin PBXFileReference section */
967A48061D0E0EA300B8CEB7 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; };
967A48211D0F601B00B8CEB7 /* AppNavigationDrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppNavigationDrawerController.swift; sourceTree = "<group>"; };
967A48231D0F603200B8CEB7 /* AppStatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppStatusBarController.swift; sourceTree = "<group>"; };
96CB74FD1D0DFDBB0012D9F2 /* NavigationDrawerController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationDrawerController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96CB75001D0DFDBB0012D9F2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96CB75021D0DFDBB0012D9F2 /* AppLeftViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; };
......@@ -82,7 +80,6 @@
isa = PBXGroup;
children = (
96CB75001D0DFDBB0012D9F2 /* AppDelegate.swift */,
967A48231D0F603200B8CEB7 /* AppStatusBarController.swift */,
967A48211D0F601B00B8CEB7 /* AppNavigationDrawerController.swift */,
96CB75021D0DFDBB0012D9F2 /* AppLeftViewController.swift */,
967A48061D0E0EA300B8CEB7 /* AppRightViewController.swift */,
......@@ -174,7 +171,6 @@
96CB75131D0DFF6F0012D9F2 /* YellowViewController.swift in Sources */,
96CB75191D0DFFAE0012D9F2 /* PurpleViewController.swift in Sources */,
96CB75151D0DFF840012D9F2 /* BlueViewController.swift in Sources */,
967A48241D0F603200B8CEB7 /* AppStatusBarController.swift in Sources */,
96CB75011D0DFDBB0012D9F2 /* AppDelegate.swift in Sources */,
967A48071D0E0EA300B8CEB7 /* AppRightViewController.swift in Sources */,
96CB751B1D0DFFC10012D9F2 /* OrangeViewController.swift in Sources */,
......
......@@ -40,20 +40,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let navigationController: NavigationController = NavigationController(rootViewController: YellowViewController())
let navigationDrawerController: AppNavigationDrawerController = AppNavigationDrawerController(rootViewController: navigationController, leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
// navigationDrawerController.enabled = true
//
// navigationDrawerController.enabledLeftView = true
// navigationDrawerController.enabledLeftTapGesture = true
// navigationDrawerController.enabledLeftPanGesture = true
//
// navigationDrawerController.enabledRightView = true
// navigationDrawerController.enabledRightTapGesture = true
// navigationDrawerController.enabledRightPanGesture = true
let statusBarController: AppStatusBarController = AppStatusBarController(rootViewController: navigationDrawerController)
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = statusBarController
window!.rootViewController = navigationDrawerController
window!.makeKeyAndVisible()
return true
}
......
......@@ -38,34 +38,38 @@ class AppNavigationDrawerController: NavigationDrawerController, NavigationDrawe
}
func navigationDrawerPanDidBegin(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
showStatusBarView()
print("NavigationDrawerController - Pan Began");
}
func navigationDrawerPanDidEnd(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
hideStatusBarView()
print("NavigationDrawerController - Pan Ended");
}
func navigationDrawerWillOpen(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
showStatusBarView()
print("NavigationDrawerController - Will Open");
}
func navigationDrawerDidOpen(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
print("NavigationDrawerController - DId Open");
}
func navigationDrawerWillClose(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
hideStatusBarView()
print("NavigationDrawerController - Will Close");
}
func navigationDrawerDidClose(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
print("NavigationDrawerController - Did Close");
}
func navigationDrawerStatusBarHiddenState(navigationDrawerController: NavigationDrawerController, hidden: Bool) {
print("NavigationDrawerController - Status Bar Hidden: ", hidden ? "Yes" : "No");
}
/// Shows the transparent statusBarView.
private func showStatusBarView() {
statusBarController?.statusBarStyle = .LightContent
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 1
})
func navigationDrawerDidTap(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
print("NavigationDrawerController - Did Tap");
}
/// Hides the transparent statusBarView.
private func hideStatusBarView() {
statusBarController?.statusBarStyle = .Default
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 0
})
func navigationDrawerPanDidChange(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
// print("NavigationDrawerController - Did Change");
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class AppStatusBarController: StatusBarController {
override func prepareView() {
super.prepareView()
statusBarView.alpha = 0
statusBarStyle = .LightContent
}
}
......@@ -114,9 +114,6 @@ public protocol NavigationDrawerControllerDelegate {
@IBDesignable
@objc(NavigationDrawerController)
public class NavigationDrawerController : UIViewController, UIGestureRecognizerDelegate {
/// A Boolean to determine if the statusBar will be hidden.
private var willHideStatusBar: Bool = false
/**
A CGFloat property that is used internally to track
the original (x) position of the container view when panning.
......@@ -169,22 +166,6 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
@IBInspectable public var rightThreshold: CGFloat = 64
private var rightViewThreshold: CGFloat = 0
/// Sets the animation type for the statusBar when hiding.
public var statusBarUpdateAnimation: UIStatusBarAnimation = .Fade
/// Sets the statusBar style.
public var statusBarStyle: UIStatusBarStyle = .Default
/// Sets the statusBar to hidden or not.
public var statusBarHidden: Bool {
get {
return MaterialDevice.statusBarHidden
}
set(value) {
MaterialDevice.statusBarHidden = value
}
}
/**
A NavigationDrawerControllerDelegate property used to bind
the delegation object.
......@@ -304,7 +285,10 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
A Boolean property that triggers the status bar to be hidden
when the leftView is opened. Defaults to true.
*/
@IBInspectable public var enableHideStatusbar: Bool = false
@IBInspectable public var enableHideStatusbar: Bool = true
/// Sets the statusBar to hidden or not.
public private(set) var statusBarHidden: Bool = false
/**
A MaterialDepth property that is used to set the depth of the
......@@ -409,18 +393,6 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
}
}
public override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
return statusBarUpdateAnimation
}
public override func prefersStatusBarHidden() -> Bool {
return willHideStatusBar
}
public override func preferredStatusBarStyle() -> UIStatusBarStyle {
return statusBarStyle
}
/**
A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap
......@@ -907,7 +879,13 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
/// A method that prepares the rootViewController.
private func prepareRootViewController() {
prepareViewControllerWithinContainer(rootViewController, container: view)
let vc: UIViewController = UIViewController()
vc.view.frame = view.bounds
vc.view.backgroundColor = MaterialColor.black
prepareViewControllerWithinContainer(vc, container: view)
rootViewController.view.frame = view.bounds
prepareViewControllerWithinContainer(rootViewController, container: vc.view)
}
/// A method that prepares the leftViewController.
......@@ -1083,15 +1061,15 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
/// Shows the statusBar.
private func showStatusBar() {
if statusBarHidden {
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in
statusBarHidden = false
dispatch_async(dispatch_get_main_queue(), { [weak self] in
if let s: NavigationDrawerController = self {
s.statusBarHidden = false
s.willHideStatusBar = false
s.setNeedsStatusBarAppearanceUpdate()
if let v: UIWindow = UIApplication.sharedApplication().keyWindow {
v.windowLevel = UIWindowLevelNormal
s.delegate?.navigationDrawerStatusBarHiddenState?(s, hidden: false)
}
}
})
delegate?.navigationDrawerStatusBarHiddenState?(self, hidden: false)
}
}
......@@ -1099,15 +1077,15 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
private func hideStatusBar() {
if enableHideStatusbar {
if !statusBarHidden {
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in
statusBarHidden = true
dispatch_async(dispatch_get_main_queue(), { [weak self] in
if let s: NavigationDrawerController = self {
s.statusBarHidden = true
s.willHideStatusBar = true
s.setNeedsStatusBarAppearanceUpdate()
if let v: UIWindow = UIApplication.sharedApplication().keyWindow {
v.windowLevel = UIWindowLevelStatusBar + 1
s.delegate?.navigationDrawerStatusBarHiddenState?(s, hidden: true)
}
}
})
delegate?.navigationDrawerStatusBarHiddenState?(self, hidden: true)
}
}
}
......@@ -1181,8 +1159,6 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
/// Layout subviews.
private func layoutSubviews() {
rootViewController.view.frame = view.bounds
if let v: MaterialView = leftView {
v.width = leftViewWidth
v.height = view.bounds.height
......
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