Commit ae33ab43 by Daniel Dahan

updated StatusBarController and updated App and NavigationDrawerController example

parent 7c7c0462
......@@ -19,6 +19,8 @@
9663F94C1C7A74C700AF0965 /* AppMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94B1C7A74C700AF0965 /* AppMenuController.swift */; };
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 */
......@@ -50,6 +52,8 @@
9663F94B1C7A74C700AF0965 /* AppMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMenuController.swift; sourceTree = "<group>"; };
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 */
......@@ -84,7 +88,9 @@
isa = PBXGroup;
children = (
9663F9311C7A744600AF0965 /* AppDelegate.swift */,
967A481C1D0F5AFC00B8CEB7 /* AppStatusBarController.swift */,
9663F9471C7A749400AF0965 /* AppNavigationController.swift */,
967A481A1D0F58F800B8CEB7 /* AppNavigationDrawerController.swift */,
960CDA481D09FF3E00387CE8 /* AppBottomNavigationController.swift */,
9663F9491C7A74B500AF0965 /* AppSearchBarViewController.swift */,
9663F94B1C7A74C700AF0965 /* AppMenuController.swift */,
......@@ -172,6 +178,8 @@
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 */,
9663F9481C7A749400AF0965 /* AppNavigationController.swift in Sources */,
......
......@@ -37,14 +37,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let bottomNavigationController: AppBottomNavigationController = AppBottomNavigationController()
let navigationController: AppNavigationController = AppNavigationController(rootViewController: bottomNavigationController)
let navigationDrawerController: NavigationDrawerController = NavigationDrawerController(rootViewController: navigationController, leftViewController: AppLeftViewController())
navigationDrawerController.statusBarStyle = .LightContent
let navigationDrawerController: AppNavigationDrawerController = AppNavigationDrawerController(rootViewController: navigationController, leftViewController: AppLeftViewController())
let statusBarController: AppStatusBarController = AppStatusBarController(rootViewController: navigationDrawerController)
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = navigationDrawerController
window!.rootViewController = statusBarController
window!.makeKeyAndVisible()
return true
}
......
/*
* 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 AppNavigationDrawerController: NavigationDrawerController, NavigationDrawerControllerDelegate {
override func prepareView() {
super.prepareView()
delegate = self
}
func navigationDrawerPanDidBegin(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
showStatusBarView()
}
func navigationDrawerPanDidEnd(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
hideStatusBarView()
}
func navigationDrawerWillOpen(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
showStatusBarView()
}
func navigationDrawerWillClose(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
hideStatusBarView()
}
/// Shows the transparent statusBarView.
private func showStatusBarView() {
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 1
})
}
/// Hides the transparent statusBarView.
private func hideStatusBarView() {
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 0
})
}
}
/*
* 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
}
}
......@@ -8,6 +8,8 @@
/* 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 */; };
......@@ -34,6 +36,8 @@
/* 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>"; };
......@@ -78,6 +82,8 @@
isa = PBXGroup;
children = (
96CB75001D0DFDBB0012D9F2 /* AppDelegate.swift */,
967A48231D0F603200B8CEB7 /* AppStatusBarController.swift */,
967A48211D0F601B00B8CEB7 /* AppNavigationDrawerController.swift */,
96CB75021D0DFDBB0012D9F2 /* AppLeftViewController.swift */,
967A48061D0E0EA300B8CEB7 /* AppRightViewController.swift */,
96CB75121D0DFF6F0012D9F2 /* YellowViewController.swift */,
......@@ -163,10 +169,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
967A48221D0F601B00B8CEB7 /* AppNavigationDrawerController.swift in Sources */,
96CB75031D0DFDBB0012D9F2 /* AppLeftViewController.swift in Sources */,
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 */,
......
......@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let navigationController: NavigationController = NavigationController(rootViewController: YellowViewController())
let navigationDrawerController: NavigationDrawerController = NavigationDrawerController(rootViewController: navigationController, leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
let navigationDrawerController: AppNavigationDrawerController = AppNavigationDrawerController(rootViewController: navigationController, leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
// navigationDrawerController.enabled = true
//
......@@ -50,8 +50,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// navigationDrawerController.enabledRightTapGesture = true
// navigationDrawerController.enabledRightPanGesture = true
let statusBarController: AppStatusBarController = AppStatusBarController(rootViewController: navigationDrawerController)
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = navigationDrawerController
window!.rootViewController = statusBarController
window!.makeKeyAndVisible()
return true
}
......
/*
* 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 AppNavigationDrawerController: NavigationDrawerController, NavigationDrawerControllerDelegate {
override func prepareView() {
super.prepareView()
delegate = self
}
func navigationDrawerPanDidBegin(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
showStatusBarView()
}
func navigationDrawerPanDidEnd(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: SideNavigationPosition) {
hideStatusBarView()
}
func navigationDrawerWillOpen(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
showStatusBarView()
}
func navigationDrawerWillClose(navigationDrawerController: NavigationDrawerController, position: SideNavigationPosition) {
hideStatusBarView()
}
/// Shows the transparent statusBarView.
private func showStatusBarView() {
statusBarController?.statusBarStyle = .LightContent
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 1
})
}
/// Hides the transparent statusBarView.
private func hideStatusBarView() {
statusBarController?.statusBarStyle = .Default
UIView.animateWithDuration(0.25, animations: { [weak self] in
self?.statusBarController?.statusBarView.alpha = 0
})
}
}
/*
* 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
}
}
......@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
......
......@@ -15,6 +15,7 @@
9660162A1CB2F04E00AAB661 /* Material.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C091C1328D800B91418 /* Material.h */; settings = {ATTRIBUTES = (Public, ); }; };
966ECF2A1CF4C20100BB0BDF /* MaterialCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF291CF4C20100BB0BDF /* MaterialCollectionReusableView.swift */; };
9679CEAB1CC69E080021685B /* Material+UIImage+TintColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */; };
967A48191D0F425A00B8CEB7 /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */; };
96815B381CA07BA20006CBE2 /* MaterialViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967887881C9777CB0037F6C9 /* MaterialViewTests.swift */; };
96977DA61CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96977DA51CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift */; };
96BCB7A11CB40DC500C806FE /* BottomNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */; };
......@@ -206,6 +207,7 @@
966ECF291CF4C20100BB0BDF /* MaterialCollectionReusableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionReusableView.swift; sourceTree = "<group>"; };
967887881C9777CB0037F6C9 /* MaterialViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialViewTests.swift; sourceTree = "<group>"; };
9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIImage+TintColor.swift"; sourceTree = "<group>"; };
967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
96977DA51CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIImage+FilterBlur.swift"; sourceTree = "<group>"; };
96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomNavigationController.swift; sourceTree = "<group>"; };
96BCB7591CB40DC500C806FE /* BottomTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomTabBar.swift; sourceTree = "<group>"; };
......@@ -361,6 +363,14 @@
name = Table;
sourceTree = "<group>";
};
967A48171D0F424B00B8CEB7 /* StatusBar */ = {
isa = PBXGroup;
children = (
967A48181D0F425A00B8CEB7 /* StatusBarController.swift */,
);
name = StatusBar;
sourceTree = "<group>";
};
96BCB7571CB40DC500C806FE /* iOS */ = {
isa = PBXGroup;
children = (
......@@ -377,6 +387,7 @@
96BCB80D1CB410FD00C806FE /* Layer */,
96BCB8041CB40F6C00C806FE /* Layout */,
96BCB8011CB40F1700C806FE /* Navigation */,
967A48171D0F424B00B8CEB7 /* StatusBar */,
966ECF2B1CF4C21B00BB0BDF /* Table */,
96BCB80E1CB4110E00C806FE /* Text */,
96BCB8061CB40FD000C806FE /* Type */,
......@@ -924,6 +935,7 @@
96BCB7A11CB40DC500C806FE /* BottomNavigationController.swift in Sources */,
96BCB7D81CB40DC500C806FE /* MenuController.swift in Sources */,
96BCB7D41CB40DC500C806FE /* MaterialTransitionAnimation.swift in Sources */,
967A48191D0F425A00B8CEB7 /* StatusBarController.swift in Sources */,
96BCB7C21CB40DC500C806FE /* MaterialDevice.swift in Sources */,
96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */,
96BCB7C51CB40DC500C806FE /* MaterialGravity.swift in Sources */,
......
......@@ -181,7 +181,7 @@ public class MaterialSwitch : UIControl {
}
/// Track view reference.
public private(set) var trackLayer: MaterialLayer {
public private(set) var trackLayer: CAShapeLayer {
didSet {
prepareTrack()
}
......@@ -285,7 +285,7 @@ public class MaterialSwitch : UIControl {
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
trackLayer = MaterialLayer()
trackLayer = CAShapeLayer()
button = FabButton()
super.init(coder: aDecoder)
prepareTrack()
......@@ -303,7 +303,7 @@ public class MaterialSwitch : UIControl {
- Parameter frame: A CGRect instance.
*/
public override init(frame: CGRect) {
trackLayer = MaterialLayer()
trackLayer = CAShapeLayer()
button = FabButton()
super.init(frame: frame)
prepareTrack()
......@@ -320,7 +320,7 @@ public class MaterialSwitch : UIControl {
- Parameter size: A MaterialSwitchSize value.
*/
public init(state: MaterialSwitchState = .Off, style: MaterialSwitchStyle = .Default, size: MaterialSwitchSize = .Default) {
trackLayer = MaterialLayer()
trackLayer = CAShapeLayer()
button = FabButton()
super.init(frame: CGRectNull)
prepareTrack()
......@@ -526,7 +526,7 @@ public class MaterialSwitch : UIControl {
let px: CGFloat = (width - w) / 2
trackLayer.frame = CGRectMake(px, (height - trackThickness) / 2, w, trackThickness)
trackLayer.cornerRadius = min(trackLayer.height, trackLayer.width) / 2
trackLayer.cornerRadius = min(trackLayer.frame.height, trackLayer.frame.width) / 2
button.frame = CGRectMake(px, (height - buttonDiameter) / 2, buttonDiameter, buttonDiameter)
onPosition = width - px - buttonDiameter
......
......@@ -304,7 +304,7 @@ 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 = true
@IBInspectable public var enableHideStatusbar: Bool = false
/**
A MaterialDepth property that is used to set the depth of the
......
/*
* 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
public extension UIViewController {
/**
A convenience property that provides access to the StatusBarController.
This is the recommended method of accessing the StatusBarController
through child UIViewControllers.
*/
public var statusBarController: StatusBarController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is StatusBarController {
return viewController as? StatusBarController
}
viewController = viewController?.parentViewController
}
return nil
}
}
@IBDesignable
public class StatusBarController : UIViewController {
/// Device status bar style.
public var statusBarStyle: UIStatusBarStyle {
get {
return MaterialDevice.statusBarStyle
}
set(value) {
MaterialDevice.statusBarStyle = value
}
}
/// A reference to the statusBarView.
public private(set) var statusBarView: MaterialView!
/**
A Boolean property used to enable and disable interactivity
with the rootViewController.
*/
@IBInspectable public var userInteractionEnabled: Bool {
get {
return rootViewController.view.userInteractionEnabled
}
set(value) {
rootViewController.view.userInteractionEnabled = value
}
}
/**
A UIViewController property that references the active
main UIViewController. To swap the rootViewController, it
is recommended to use the transitionFromRootViewController
helper method.
*/
public private(set) var rootViewController: UIViewController!
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepareView()
}
/**
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
prepareView()
}
/**
An initializer for the BarController.
- Parameter rootViewController: The main UIViewController.
*/
public init(rootViewController: UIViewController) {
super.init(nibName: nil, bundle: nil)
self.rootViewController = rootViewController
prepareView()
}
public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
layoutSubviews()
}
/**
A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active rootViewController.
- Parameter duration: A NSTimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active rootViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active rootViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active rootViewController
to the toViewController has completed.
*/
public func transitionFromRootViewController(toViewController: UIViewController, duration: NSTimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {
rootViewController.willMoveToParentViewController(nil)
addChildViewController(toViewController)
toViewController.view.frame = rootViewController.view.frame
transitionFromViewController(rootViewController,
toViewController: toViewController,
duration: duration,
options: options,
animations: animations,
completion: { [weak self] (result: Bool) in
if let s: StatusBarController = self {
toViewController.didMoveToParentViewController(s)
s.rootViewController.removeFromParentViewController()
s.rootViewController = toViewController
s.rootViewController.view.clipsToBounds = true
s.rootViewController.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
s.view.sendSubviewToBack(s.rootViewController.view)
completion?(result)
}
})
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public func prepareView() {
view.clipsToBounds = true
view.contentScaleFactor = MaterialDevice.scale
prepareStatusBarView()
prepareRootViewController()
}
/// Prepares the statusBarView.
private func prepareStatusBarView() {
statusBarView = MaterialView()
statusBarView.zPosition = 3000
statusBarView.backgroundColor = MaterialColor.black.colorWithAlphaComponent(0.12)
view.layout(statusBarView).top(0).horizontally().height(20)
}
/// A method that prepares the rootViewController.
private func prepareRootViewController() {
prepareViewControllerWithinContainer(rootViewController, container: view)
}
/**
A method that adds the passed in controller as a child of
the StatusBarController within the passed in
container view.
- Parameter viewController: A UIViewController to add as a child.
- Parameter container: A UIView that is the parent of the
passed in controller view within the view hierarchy.
*/
private func prepareViewControllerWithinContainer(viewController: UIViewController?, container: UIView) {
if let v: UIViewController = viewController {
addChildViewController(v)
v.didMoveToParentViewController(self)
v.view.clipsToBounds = true
v.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
container.addSubview(v.view)
container.sendSubviewToBack(v.view)
}
}
/// Layout subviews.
private func layoutSubviews() {
statusBarView.hidden = MaterialDevice.isLandscape && .iPhone == MaterialDevice.type
rootViewController.view.frame = 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