Commit e3720155 by Daniel Dahan

development: added NavigationDrawerController and updated API

parent 9823fb29
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
location = "container:" location = "container:"
name = "Programmatic"> name = "Programmatic">
<FileRef <FileRef
location = "group:Programmatic/NavigationDrawerController/NavigationDrawerController.xcodeproj">
</FileRef>
<FileRef
location = "group:Programmatic/NavigationController/NavigationController.xcodeproj"> location = "group:Programmatic/NavigationController/NavigationController.xcodeproj">
</FileRef> </FileRef>
<FileRef <FileRef
......
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
96784E771D8FFE230061C06C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E761D8FFE230061C06C /* AppDelegate.swift */; };
96784E791D8FFE230061C06C /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E781D8FFE230061C06C /* RootViewController.swift */; };
96784E7E1D8FFE230061C06C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96784E7D1D8FFE230061C06C /* Assets.xcassets */; };
96784E811D8FFE230061C06C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96784E7F1D8FFE230061C06C /* LaunchScreen.storyboard */; };
96784E8C1D8FFEA20061C06C /* LeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E8B1D8FFEA10061C06C /* LeftViewController.swift */; };
96784E8E1D8FFEC80061C06C /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E8D1D8FFEC80061C06C /* RightViewController.swift */; };
96784E901D8FFEEF0061C06C /* AppNavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
96784E941D9000290061C06C /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
96784E731D8FFE230061C06C /* NavigationDrawerController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationDrawerController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96784E761D8FFE230061C06C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96784E781D8FFE230061C06C /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
96784E7D1D8FFE230061C06C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96784E801D8FFE230061C06C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96784E821D8FFE240061C06C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96784E8B1D8FFEA10061C06C /* LeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftViewController.swift; sourceTree = "<group>"; };
96784E8D1D8FFEC80061C06C /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; };
96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppNavigationDrawerController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
96784E701D8FFE230061C06C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
96784E6A1D8FFE230061C06C = {
isa = PBXGroup;
children = (
96784E751D8FFE230061C06C /* NavigationDrawerController */,
96784E741D8FFE230061C06C /* Products */,
);
sourceTree = "<group>";
};
96784E741D8FFE230061C06C /* Products */ = {
isa = PBXGroup;
children = (
96784E731D8FFE230061C06C /* NavigationDrawerController.app */,
);
name = Products;
sourceTree = "<group>";
};
96784E751D8FFE230061C06C /* NavigationDrawerController */ = {
isa = PBXGroup;
children = (
96784E761D8FFE230061C06C /* AppDelegate.swift */,
96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */,
96784E781D8FFE230061C06C /* RootViewController.swift */,
96784E8B1D8FFEA10061C06C /* LeftViewController.swift */,
96784E8D1D8FFEC80061C06C /* RightViewController.swift */,
96784E7D1D8FFE230061C06C /* Assets.xcassets */,
96784E7F1D8FFE230061C06C /* LaunchScreen.storyboard */,
96784E821D8FFE240061C06C /* Info.plist */,
);
path = NavigationDrawerController;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
96784E721D8FFE230061C06C /* NavigationDrawerController */ = {
isa = PBXNativeTarget;
buildConfigurationList = 96784E851D8FFE240061C06C /* Build configuration list for PBXNativeTarget "NavigationDrawerController" */;
buildPhases = (
96784E6F1D8FFE230061C06C /* Sources */,
96784E701D8FFE230061C06C /* Frameworks */,
96784E711D8FFE230061C06C /* Resources */,
96784E941D9000290061C06C /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = NavigationDrawerController;
productName = NavigationDrawerController;
productReference = 96784E731D8FFE230061C06C /* NavigationDrawerController.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
96784E6B1D8FFE230061C06C /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = CosmicMind;
TargetAttributes = {
96784E721D8FFE230061C06C = {
CreatedOnToolsVersion = 8.0;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 96784E6E1D8FFE230061C06C /* Build configuration list for PBXProject "NavigationDrawerController" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 96784E6A1D8FFE230061C06C;
productRefGroup = 96784E741D8FFE230061C06C /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
96784E721D8FFE230061C06C /* NavigationDrawerController */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
96784E711D8FFE230061C06C /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96784E811D8FFE230061C06C /* LaunchScreen.storyboard in Resources */,
96784E7E1D8FFE230061C06C /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
96784E6F1D8FFE230061C06C /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96784E8C1D8FFEA20061C06C /* LeftViewController.swift in Sources */,
96784E8E1D8FFEC80061C06C /* RightViewController.swift in Sources */,
96784E901D8FFEEF0061C06C /* AppNavigationDrawerController.swift in Sources */,
96784E791D8FFE230061C06C /* RootViewController.swift in Sources */,
96784E771D8FFE230061C06C /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
96784E7F1D8FFE230061C06C /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
96784E801D8FFE230061C06C /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
96784E831D8FFE240061C06C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
96784E841D8FFE240061C06C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
96784E861D8FFE240061C06C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = NavigationDrawerController/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.NavigationDrawerController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
96784E871D8FFE240061C06C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = NavigationDrawerController/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.NavigationDrawerController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
96784E6E1D8FFE230061C06C /* Build configuration list for PBXProject "NavigationDrawerController" */ = {
isa = XCConfigurationList;
buildConfigurations = (
96784E831D8FFE240061C06C /* Debug */,
96784E841D8FFE240061C06C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
96784E851D8FFE240061C06C /* Build configuration list for PBXNativeTarget "NavigationDrawerController" */ = {
isa = XCConfigurationList;
buildConfigurations = (
96784E861D8FFE240061C06C /* Debug */,
96784E871D8FFE240061C06C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 96784E6B1D8FFE230061C06C /* Project object */;
}
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:NavigationDrawerController.xcodeproj">
</FileRef>
</Workspace>
/*
* 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 CosmicMind 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
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func applicationDidFinishLaunching(_ application: UIApplication) {
window = UIWindow(frame: Device.bounds)
window!.rootViewController = AppNavigationDrawerController(rootViewController: RootViewController(), leftViewController: LeftViewController(), rightViewController: RightViewController())
window!.makeKeyAndVisible()
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
/*
* 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 CosmicMind 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 {
open override func prepare() {
super.prepare()
delegate = self
}
}
extension AppNavigationDrawerController: NavigationDrawerControllerDelegate {
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, willOpen position: NavigationDrawerPosition) {
print("navigationDrawerController willOpen")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didOpen position: NavigationDrawerPosition) {
print("navigationDrawerController didOpen")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, willClose position: NavigationDrawerPosition) {
print("navigationDrawerController willClose")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didClose position: NavigationDrawerPosition) {
print("navigationDrawerController didClose")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didBeginPanAt point: CGPoint, position: NavigationDrawerPosition) {
print("navigationDrawerController didBeginPanAt: ", point, "with position:", .left == position ? "Left" : "Right")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didChangePanAt point: CGPoint, position: NavigationDrawerPosition) {
print("navigationDrawerController didChangePanAt: ", point, "with position:", .left == position ? "Left" : "Right")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didEndPanAt point: CGPoint, position: NavigationDrawerPosition) {
print("navigationDrawerController didEndPanAt: ", point, "with position:", .left == position ? "Left" : "Right")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didTapAt point: CGPoint, position: NavigationDrawerPosition) {
print("navigationDrawerController didTapAt: ", point, "with position:", .left == position ? "Left" : "Right")
}
func navigationDrawerController(navigationDrawerController: NavigationDrawerController, statusBar isHidden: Bool) {
print("navigationDrawerController statusBar is hidden:", isHidden ? "Yes" : "No")
}
}
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
/*
* 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 CosmicMind 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 LeftViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.grey.darken4
}
}
/*
* 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 CosmicMind 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 RightViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.grey.darken4
}
}
/*
* 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 CosmicMind 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 RootViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1
}
}
...@@ -59,65 +59,87 @@ public protocol NavigationDrawerControllerDelegate { ...@@ -59,65 +59,87 @@ public protocol NavigationDrawerControllerDelegate {
/** /**
An optional delegation method that is fired before the An optional delegation method that is fired before the
NavigationDrawerController opens. NavigationDrawerController opens.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerWillOpen(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, willOpen position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired after the An optional delegation method that is fired after the
NavigationDrawerController opened. NavigationDrawerController opened.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerDidOpen(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didOpen position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired before the An optional delegation method that is fired before the
NavigationDrawerController closes. NavigationDrawerController closes.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerWillClose(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, willClose position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired after the An optional delegation method that is fired after the
NavigationDrawerController closed. NavigationDrawerController closed.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerDidClose(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didClose position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController pan gesture begins. NavigationDrawerController pan gesture begins.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter didBeginPanAt point: A CGPoint.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerPanDidBegin(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didBeginPanAt point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController pan gesture changes position. NavigationDrawerController pan gesture changes position.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter didChangePanAt point: A CGPoint.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerPanDidChange(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didChangePanAt point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController pan gesture ends. NavigationDrawerController pan gesture ends.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter didEndPanAt point: A CGPoint.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerPanDidEnd(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didEndPanAt point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController tap gesture executes. NavigationDrawerController tap gesture executes.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter didTapAt point: A CGPoint.
- Parameter position: The NavigationDrawerPosition.
*/ */
@objc @objc
optional func navigationDrawerDidTap(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, didTapAt point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
status bar is about to change display, hidden or not. status bar is about to change display, isHidden or not.
- Parameter navigationDrawerController: A NavigationDrawerController.
- Parameter statusBar isHidden: A boolean.
*/ */
@objc @objc
optional func navigationDrawerStatusBarHiddenState(navigationDrawerController: NavigationDrawerController, hidden: Bool) optional func navigationDrawerController(navigationDrawerController: NavigationDrawerController, statusBar isHidden: Bool)
} }
@objc(NavigationDrawerController) @objc(NavigationDrawerController)
...@@ -135,18 +157,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -135,18 +157,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
internal private(set) var leftPanGesture: UIPanGestureRecognizer? internal private(set) var leftPanGesture: UIPanGestureRecognizer?
/** /**
A UIPanGestureRecognizer property internally used for the
rightView pan gesture.
*/
internal private(set) var rightPanGesture: UIPanGestureRecognizer?
/**
A UITapGestureRecognizer property internally used for the A UITapGestureRecognizer property internally used for the
leftView tap gesture. leftView tap gesture.
*/ */
internal private(set) var leftTapGesture: UITapGestureRecognizer? internal private(set) var leftTapGesture: UITapGestureRecognizer?
/** /**
A UIPanGestureRecognizer property internally used for the
rightView pan gesture.
*/
internal private(set) var rightPanGesture: UIPanGestureRecognizer?
/**
A UITapGestureRecognizer property internally used for the A UITapGestureRecognizer property internally used for the
rightView tap gesture. rightView tap gesture.
*/ */
...@@ -279,13 +301,13 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -279,13 +301,13 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
} }
/** /**
A Boolean property that triggers the status bar to be hidden A Boolean property that triggers the status bar to be isHidden
when the leftView is opened. Defaults to true. when the leftView is opened. Defaults to true.
*/ */
@IBInspectable @IBInspectable
open var isHiddenStatusBarEnabled = true open var isHiddenStatusBarEnabled = true
/// Sets the statusBar to hidden or not. /// Sets the statusBar to isHidden or not.
open internal(set) var isStatusBarHidden = false open internal(set) var isStatusBarHidden = false
/** /**
...@@ -331,9 +353,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -331,9 +353,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/** /**
Content view controller to encompase the entire component. This is Content view controller to encompase the entire component. This is
primarily used when the StatusBar is being hidden. The alpha value of primarily used when the StatusBar is being isHidden. The alpha value of
the rootViewController decreases, and shows the StatusBar. To avoid the rootViewController decreases, and shows the StatusBar. To avoid
this, and to add a hidden transition viewController for complex this, and to add a isHidden transition viewController for complex
situations, the contentViewController was added. situations, the contentViewController was added.
*/ */
open private(set) lazy var contentViewController = UIViewController() open private(set) lazy var contentViewController = UIViewController()
...@@ -422,7 +444,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -422,7 +444,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
v.width = leftViewWidth v.width = leftViewWidth
v.height = view.bounds.height v.height = view.bounds.height
leftViewThreshold = leftViewWidth / 2 leftViewThreshold = leftViewWidth / 2
if let vc: UIViewController = leftViewController { if let vc = leftViewController {
vc.view.width = v.width vc.view.width = v.width
vc.view.height = v.height vc.view.height = v.height
vc.view.center = CGPoint(x: v.width / 2, y: v.height / 2) vc.view.center = CGPoint(x: v.width / 2, y: v.height / 2)
...@@ -433,7 +455,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -433,7 +455,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
v.width = rightViewWidth v.width = rightViewWidth
v.height = view.bounds.height v.height = view.bounds.height
rightViewThreshold = view.bounds.width - rightViewWidth / 2 rightViewThreshold = view.bounds.width - rightViewWidth / 2
if let vc: UIViewController = rightViewController { if let vc = rightViewController {
vc.view.width = v.width vc.view.width = v.width
vc.view.height = v.height vc.view.height = v.height
vc.view.center = CGPoint(x: v.width / 2, y: v.height / 2) vc.view.center = CGPoint(x: v.width / 2, y: v.height / 2)
...@@ -443,10 +465,12 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -443,10 +465,12 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator) super.viewWillTransition(to: size, with: coordinator)
// Ensures the view is hidden. // Ensures the view is isHidden.
if let v: View = rightView { guard let v = rightView else {
v.position.x = size.width + (isRightViewOpened ? -v.width : v.width) / 2 return
} }
v.position.x = size.width + (isRightViewOpened ? -v.width : v.width) / 2
} }
/** /**
...@@ -454,16 +478,19 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -454,16 +478,19 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opened. This is the recommended method of setting the leftView opened. This is the recommended method of setting the leftView
width. width.
- Parameter width: A CGFloat value to set as the new width. - Parameter width: A CGFloat value to set as the new width.
- Parameter hidden: A Boolean value of whether the leftView - Parameter isHidden: A Boolean value of whether the leftView
should be hidden after the width has been updated or not. should be isHidden after the width has been updated or not.
- Parameter animated: A Boolean value that indicates to animate - Parameter animated: A Boolean value that indicates to animate
the leftView width change. the leftView width change.
*/ */
open func setLeftViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) { open func setLeftViewWidth(width: CGFloat, isHidden: Bool, animated: Bool, duration: TimeInterval = 0.5) {
if let v: View = leftView { guard let v = leftView else {
return
}
leftViewWidth = width leftViewWidth = width
var hide: Bool = hidden var hide = isHidden
if isRightViewOpened { if isRightViewOpened {
hide = true hide = true
...@@ -519,8 +546,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -519,8 +546,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
} }
layoutSubviews() layoutSubviews()
} }
}
} }
/** /**
...@@ -528,16 +553,19 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -528,16 +553,19 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opened. This is the recommended method of setting the rightView opened. This is the recommended method of setting the rightView
width. width.
- Parameter width: A CGFloat value to set as the new width. - Parameter width: A CGFloat value to set as the new width.
- Parameter hidden: A Boolean value of whether the rightView - Parameter isHidden: A Boolean value of whether the rightView
should be hidden after the width has been updated or not. should be isHidden after the width has been updated or not.
- Parameter animated: A Boolean value that indicates to animate - Parameter animated: A Boolean value that indicates to animate
the rightView width change. the rightView width change.
*/ */
open func setRightViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) { open func setRightViewWidth(width: CGFloat, isHidden: Bool, animated: Bool, duration: TimeInterval = 0.5) {
if let v: View = rightView { guard let v = rightView else {
return
}
rightViewWidth = width rightViewWidth = width
var hide: Bool = hidden var hide = isHidden
if isLeftViewOpened { if isLeftViewOpened {
hide = true hide = true
...@@ -594,7 +622,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -594,7 +622,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
layoutSubviews() layoutSubviews()
} }
} }
}
/** /**
A method that toggles the leftView opened if previously closed, A method that toggles the leftView opened if previously closed,
...@@ -625,22 +652,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -625,22 +652,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
open func openLeftView(velocity: CGFloat = 0) { open func openLeftView(velocity: CGFloat = 0) {
if isLeftViewEnabled { guard isLeftViewEnabled else {
if let v: View = leftView { return
}
guard let v = leftView else {
return
}
hideStatusBar() hideStatusBar()
showView(container: v) showView(container: v)
isUserInteractionEnabled = false isUserInteractionEnabled = false
delegate?.navigationDrawerWillOpen?(navigationDrawerController: self, position: .left)
delegate?.navigationDrawerController?(navigationDrawerController: self, willOpen: .left)
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { animations: { [weak self, v = v] in
guard let s = self else {
return
}
v.position.x = v.width / 2 v.position.x = v.width / 2
self.rootViewController.view.alpha = 0.5 s.rootViewController.view.alpha = 0.5
}) { [weak self] _ in }) { [weak self] _ in
if let s = self { guard let s = self else {
s.delegate?.navigationDrawerDidOpen?(navigationDrawerController: s, position: .left) return
}
}
} }
s.delegate?.navigationDrawerController?(navigationDrawerController: s, didOpen: .left)
} }
} }
...@@ -651,24 +691,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -651,24 +691,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
open func openRightView(velocity: CGFloat = 0) { open func openRightView(velocity: CGFloat = 0) {
if isRightViewEnabled { guard isRightViewEnabled else {
if let v: View = rightView { return
}
guard let v = rightView else {
return
}
hideStatusBar() hideStatusBar()
showView(container: v) showView(container: v)
isUserInteractionEnabled = false isUserInteractionEnabled = false
delegate?.navigationDrawerWillOpen?(navigationDrawerController: self, position: .right)
delegate?.navigationDrawerController?(navigationDrawerController: self, willOpen: .right)
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [weak self] in animations: { [weak self, v = v] in
if let s = self { guard let s = self else {
return
}
v.position.x = s.view.bounds.width - v.width / 2 v.position.x = s.view.bounds.width - v.width / 2
s.rootViewController.view.alpha = 0.5 s.rootViewController.view.alpha = 0.5
}
}) { [weak self] _ in }) { [weak self] _ in
if let s = self { guard let s = self else {
s.delegate?.navigationDrawerDidOpen?(navigationDrawerController: s, position: .right) return
}
}
} }
s.delegate?.navigationDrawerController?(navigationDrawerController: s, didOpen: .right)
} }
} }
...@@ -679,24 +730,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -679,24 +730,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
open func closeLeftView(velocity: CGFloat = 0) { open func closeLeftView(velocity: CGFloat = 0) {
if isLeftViewEnabled { guard isLeftViewEnabled else {
if let v: View = leftView { return
}
guard let v = leftView else {
return
}
isUserInteractionEnabled = true isUserInteractionEnabled = true
delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .left)
delegate?.navigationDrawerController?(navigationDrawerController: self, willClose: .left)
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [weak self] in animations: { [weak self, v = v] in
if let s = self { guard let s = self else {
return
}
v.position.x = -v.width / 2 v.position.x = -v.width / 2
s.rootViewController.view.alpha = 1 s.rootViewController.view.alpha = 1
}
}) { [weak self] _ in }) { [weak self] _ in
if let s = self { guard let s = self else {
return
}
s.hideView(container: v) s.hideView(container: v)
s.toggleStatusBar() s.toggleStatusBar()
s.delegate?.navigationDrawerDidClose?(navigationDrawerController: s, position: .left)
} s.delegate?.navigationDrawerController?(navigationDrawerController: s, didClose: .left)
}
}
} }
} }
...@@ -707,24 +769,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -707,24 +769,35 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
open func closeRightView(velocity: CGFloat = 0) { open func closeRightView(velocity: CGFloat = 0) {
if isRightViewEnabled { guard isRightViewEnabled else {
if let v: View = rightView { return
}
guard let v = rightView else {
return
}
isUserInteractionEnabled = true isUserInteractionEnabled = true
delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .right)
delegate?.navigationDrawerController?(navigationDrawerController: self, willClose: .right)
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [weak self] in animations: { [weak self, v = v] in
if let s = self { guard let s = self else {
return
}
v.position.x = s.view.bounds.width + v.width / 2 v.position.x = s.view.bounds.width + v.width / 2
s.rootViewController.view.alpha = 1 s.rootViewController.view.alpha = 1
}
}) { [weak self] _ in }) { [weak self] _ in
if let s = self { guard let s = self else {
return
}
s.hideView(container: v) s.hideView(container: v)
s.toggleStatusBar() s.toggleStatusBar()
s.delegate?.navigationDrawerDidClose?(navigationDrawerController: s, position: .right)
} s.delegate?.navigationDrawerController?(navigationDrawerController: s, didClose: .right)
}
}
} }
} }
...@@ -759,34 +832,38 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -759,34 +832,38 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
@objc @objc
internal func handleLeftViewPanGesture(recognizer: UIPanGestureRecognizer) { internal func handleLeftViewPanGesture(recognizer: UIPanGestureRecognizer) {
if isLeftViewEnabled && (isLeftViewOpened || !isRightViewOpened && isPointContainedWithinLeftThreshold(point: recognizer.location(in: view))) { if isLeftViewEnabled && (isLeftViewOpened || !isRightViewOpened && isPointContainedWithinLeftThreshold(point: recognizer.location(in: view))) {
if let v: View = leftView { guard let v = leftView else {
let point: CGPoint = recognizer.location(in: view) return
}
let point = recognizer.location(in: view)
// Animate the panel. // Animate the panel.
switch recognizer.state { switch recognizer.state {
case .began: case .began:
originalX = v.position.x originalX = v.position.x
showView(container: v) showView(container: v)
delegate?.navigationDrawerPanDidBegin?(navigationDrawerController: self, point: point, position: .left)
delegate?.navigationDrawerController?(navigationDrawerController: self, didBeginPanAt: point, position: .left)
case .changed: case .changed:
let w: CGFloat = v.width let w = v.width
let translationX: CGFloat = recognizer.translation(in: v).x let translationX = recognizer.translation(in: v).x
v.position.x = originalX + translationX > (w / 2) ? (w / 2) : originalX + translationX v.position.x = originalX + translationX > (w / 2) ? (w / 2) : originalX + translationX
let a: CGFloat = 1 - v.position.x / v.width let a = 1 - v.position.x / v.width
rootViewController.view.alpha = 0.5 < a && v.position.x <= v.width / 2 ? a : 0.5 rootViewController.view.alpha = 0.5 < a && v.position.x <= v.width / 2 ? a : 0.5
if translationX >= leftThreshold { if translationX >= leftThreshold {
hideStatusBar() hideStatusBar()
} }
delegate?.navigationDrawerPanDidChange?(navigationDrawerController: self, point: point, position: .left) delegate?.navigationDrawerController?(navigationDrawerController: self, didChangePanAt: point, position: .left)
case .ended, .cancelled, .failed: case .ended, .cancelled, .failed:
let p: CGPoint = recognizer.velocity(in: recognizer.view) let p = recognizer.velocity(in: recognizer.view)
let x: CGFloat = p.x >= 1000 || p.x <= -1000 ? p.x : 0 let x = p.x >= 1000 || p.x <= -1000 ? p.x : 0
delegate?.navigationDrawerPanDidEnd?(navigationDrawerController: self, point: point, position: .left) delegate?.navigationDrawerController?(navigationDrawerController: self, didEndPanAt: point, position: .left)
if v.x <= -leftViewWidth + leftViewThreshold || x < -1000 { if v.x <= -leftViewWidth + leftViewThreshold || x < -1000 {
closeLeftView(velocity: x) closeLeftView(velocity: x)
...@@ -797,7 +874,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -797,7 +874,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
} }
} }
} }
}
/** /**
A method that is fired when the pan gesture is recognized A method that is fired when the pan gesture is recognized
...@@ -808,34 +884,38 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -808,34 +884,38 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
@objc @objc
internal func handleRightViewPanGesture(recognizer: UIPanGestureRecognizer) { internal func handleRightViewPanGesture(recognizer: UIPanGestureRecognizer) {
if isRightViewEnabled && (isRightViewOpened || !isLeftViewOpened && isPointContainedWithinRighThreshold(point: recognizer.location(in: view))) { if isRightViewEnabled && (isRightViewOpened || !isLeftViewOpened && isPointContainedWithinRighThreshold(point: recognizer.location(in: view))) {
if let v: View = rightView { guard let v = rightView else {
let point: CGPoint = recognizer.location(in: view) return
}
let point = recognizer.location(in: view)
// Animate the panel. // Animate the panel.
switch recognizer.state { switch recognizer.state {
case .began: case .began:
originalX = v.position.x originalX = v.position.x
showView(container: v) showView(container: v)
delegate?.navigationDrawerPanDidBegin?(navigationDrawerController: self, point: point, position: .right)
delegate?.navigationDrawerController?(navigationDrawerController: self, didBeginPanAt: point, position: .right)
case .changed: case .changed:
let w: CGFloat = v.width let w = v.width
let translationX: CGFloat = recognizer.translation(in: v).x let translationX = recognizer.translation(in: v).x
v.position.x = originalX + translationX < view.bounds.width - (w / 2) ? view.bounds.width - (w / 2) : originalX + translationX v.position.x = originalX + translationX < view.bounds.width - (w / 2) ? view.bounds.width - (w / 2) : originalX + translationX
let a: CGFloat = 1 - (view.bounds.width - v.position.x) / v.width let a = 1 - (view.bounds.width - v.position.x) / v.width
rootViewController.view.alpha = 0.5 < a && v.position.x >= v.width / 2 ? a : 0.5 rootViewController.view.alpha = 0.5 < a && v.position.x >= v.width / 2 ? a : 0.5
if translationX <= -rightThreshold { if translationX <= -rightThreshold {
hideStatusBar() hideStatusBar()
} }
delegate?.navigationDrawerPanDidChange?(navigationDrawerController: self, point: point, position: .right) delegate?.navigationDrawerController?(navigationDrawerController: self, didChangePanAt: point, position: .right)
case .ended, .cancelled, .failed: case .ended, .cancelled, .failed:
let p: CGPoint = recognizer.velocity(in: recognizer.view) let p = recognizer.velocity(in: recognizer.view)
let x: CGFloat = p.x >= 1000 || p.x <= -1000 ? p.x : 0 let x = p.x >= 1000 || p.x <= -1000 ? p.x : 0
delegate?.navigationDrawerPanDidEnd?(navigationDrawerController: self, point: point, position: .right) delegate?.navigationDrawerController?(navigationDrawerController: self, didEndPanAt: point, position: .right)
if v.x >= rightViewThreshold || x > 1000 { if v.x >= rightViewThreshold || x > 1000 {
closeRightView(velocity: x) closeRightView(velocity: x)
...@@ -846,7 +926,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -846,7 +926,6 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
} }
} }
} }
}
/** /**
A method that is fired when the tap gesture is recognized A method that is fired when the tap gesture is recognized
...@@ -856,13 +935,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -856,13 +935,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/ */
@objc @objc
internal func handleLeftViewTapGesture(recognizer: UITapGestureRecognizer) { internal func handleLeftViewTapGesture(recognizer: UITapGestureRecognizer) {
if isLeftViewOpened { guard isLeftViewOpened else {
if let v: View = leftView { return
delegate?.navigationDrawerDidTap?(navigationDrawerController: self, point: recognizer.location(in: view), position: .left)
if isLeftViewEnabled && isLeftViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
closeLeftView()
} }
guard let v = leftView else {
return
} }
delegate?.navigationDrawerController?(navigationDrawerController: self, didTapAt: recognizer.location(in: view), position: .left)
if isLeftViewEnabled && isLeftViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
closeLeftView()
} }
} }
...@@ -874,13 +958,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -874,13 +958,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/ */
@objc @objc
internal func handleRightViewTapGesture(recognizer: UITapGestureRecognizer) { internal func handleRightViewTapGesture(recognizer: UITapGestureRecognizer) {
if isRightViewOpened { guard isRightViewOpened else {
if let v: View = rightView { return
delegate?.navigationDrawerDidTap?(navigationDrawerController: self, point: recognizer.location(in: view), position: .right)
if isRightViewEnabled && isRightViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
closeRightView()
} }
guard let v = rightView else {
return
} }
delegate?.navigationDrawerController?(navigationDrawerController: self, didTapAt: recognizer.location(in: view), position: .right)
if isRightViewEnabled && isRightViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
closeRightView()
} }
} }
...@@ -902,7 +991,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -902,7 +991,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// A method that prepares the rightViewController. /// A method that prepares the rightViewController.
private func prepareRightViewController() { private func prepareRightViewController() {
guard let v = leftView else { guard let v = rightView else {
return return
} }
...@@ -911,7 +1000,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -911,7 +1000,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// A method that prepares the leftView. /// A method that prepares the leftView.
private func prepareLeftView() { private func prepareLeftView() {
guard let _: UIViewController = leftViewController else { guard nil != leftViewController else {
return return
} }
...@@ -920,7 +1009,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -920,7 +1009,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftViewWidth = .phone == Device.userInterfaceIdiom ? 280 : 320 leftViewWidth = .phone == Device.userInterfaceIdiom ? 280 : 320
leftView = View() leftView = View()
leftView!.frame = CGRect(x: 0, y: 0, width: leftViewWidth, height: view.height) leftView!.frame = CGRect(x: 0, y: 0, width: leftViewWidth, height: view.height)
leftView!.backgroundColor = Color.clear leftView!.backgroundColor = nil
view.addSubview(leftView!) view.addSubview(leftView!)
leftView!.isHidden = true leftView!.isHidden = true
...@@ -931,7 +1020,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -931,7 +1020,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// A method that prepares the leftView. /// A method that prepares the leftView.
private func prepareRightView() { private func prepareRightView() {
guard let _: UIViewController = rightViewController else { guard nil != rightViewController else {
return return
} }
...@@ -939,8 +1028,8 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -939,8 +1028,8 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
rightViewWidth = .phone == Device.userInterfaceIdiom ? 280 : 320 rightViewWidth = .phone == Device.userInterfaceIdiom ? 280 : 320
rightView = View() rightView = View()
rightView!.frame = CGRect(x: 0, y: 0, width: rightViewWidth, height: view.height) rightView!.frame = CGRect(x: view.width, y: 0, width: rightViewWidth, height: view.height)
rightView!.backgroundColor = Color.clear rightView!.backgroundColor = nil
view.addSubview(rightView!) view.addSubview(rightView!)
rightView!.isHidden = true rightView!.isHidden = true
...@@ -951,41 +1040,49 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -951,41 +1040,49 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Prepare the left pan gesture. /// Prepare the left pan gesture.
private func prepareLeftPanGesture() { private func prepareLeftPanGesture() {
if nil == leftPanGesture { guard nil == leftPanGesture else {
return
}
leftPanGesture = UIPanGestureRecognizer(target: self, action: #selector(handleLeftViewPanGesture(recognizer:))) leftPanGesture = UIPanGestureRecognizer(target: self, action: #selector(handleLeftViewPanGesture(recognizer:)))
leftPanGesture!.delegate = self leftPanGesture!.delegate = self
view.addGestureRecognizer(leftPanGesture!) view.addGestureRecognizer(leftPanGesture!)
} }
}
/// Prepare the left tap gesture. /// Prepare the left tap gesture.
private func prepareLeftTapGesture() { private func prepareLeftTapGesture() {
if nil == leftTapGesture { guard nil == leftTapGesture else {
return
}
leftTapGesture = UITapGestureRecognizer(target: self, action: #selector(handleLeftViewTapGesture(recognizer:))) leftTapGesture = UITapGestureRecognizer(target: self, action: #selector(handleLeftViewTapGesture(recognizer:)))
leftTapGesture!.delegate = self leftTapGesture!.delegate = self
leftTapGesture!.cancelsTouchesInView = false leftTapGesture!.cancelsTouchesInView = false
view.addGestureRecognizer(leftTapGesture!) view.addGestureRecognizer(leftTapGesture!)
} }
}
/// Prepares the right pan gesture. /// Prepares the right pan gesture.
private func prepareRightPanGesture() { private func prepareRightPanGesture() {
if nil == rightPanGesture { guard nil == rightPanGesture else {
return
}
rightPanGesture = UIPanGestureRecognizer(target: self, action: #selector(handleRightViewPanGesture(recognizer:))) rightPanGesture = UIPanGestureRecognizer(target: self, action: #selector(handleRightViewPanGesture(recognizer:)))
rightPanGesture!.delegate = self rightPanGesture!.delegate = self
view.addGestureRecognizer(rightPanGesture!) view.addGestureRecognizer(rightPanGesture!)
} }
}
/// Prepares the right tap gesture. /// Prepares the right tap gesture.
private func prepareRightTapGesture() { private func prepareRightTapGesture() {
if nil == rightTapGesture { guard nil == rightTapGesture else {
return
}
rightTapGesture = UITapGestureRecognizer(target: self, action: #selector(handleRightViewTapGesture(recognizer:))) rightTapGesture = UITapGestureRecognizer(target: self, action: #selector(handleRightViewTapGesture(recognizer:)))
rightTapGesture!.delegate = self rightTapGesture!.delegate = self
rightTapGesture!.cancelsTouchesInView = false rightTapGesture!.cancelsTouchesInView = false
view.addGestureRecognizer(rightTapGesture!) view.addGestureRecognizer(rightTapGesture!)
} }
}
/// A method that removes the passed in pan and leftView tap gesture recognizers. /// A method that removes the passed in pan and leftView tap gesture recognizers.
private func removeLeftViewGestures() { private func removeLeftViewGestures() {
...@@ -995,19 +1092,23 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -995,19 +1092,23 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Removes the left pan gesture. /// Removes the left pan gesture.
private func removeLeftPanGesture() { private func removeLeftPanGesture() {
if let v: UIPanGestureRecognizer = leftPanGesture { guard let v = leftPanGesture else {
return
}
view.removeGestureRecognizer(v) view.removeGestureRecognizer(v)
leftPanGesture = nil leftPanGesture = nil
} }
}
/// Removes the left tap gesture. /// Removes the left tap gesture.
private func removeLeftTapGesture() { private func removeLeftTapGesture() {
if let v: UITapGestureRecognizer = leftTapGesture { guard let v = leftTapGesture else {
return
}
view.removeGestureRecognizer(v) view.removeGestureRecognizer(v)
leftTapGesture = nil leftTapGesture = nil
} }
}
/// A method that removes the passed in pan and rightView tap gesture recognizers. /// A method that removes the passed in pan and rightView tap gesture recognizers.
private func removeRightViewGestures() { private func removeRightViewGestures() {
...@@ -1018,49 +1119,71 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -1018,49 +1119,71 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Removes the right pan gesture. /// Removes the right pan gesture.
private func removeRightPanGesture() { private func removeRightPanGesture() {
if let v: UIPanGestureRecognizer = rightPanGesture { guard let v = rightPanGesture else {
return
}
view.removeGestureRecognizer(v) view.removeGestureRecognizer(v)
rightPanGesture = nil rightPanGesture = nil
} }
}
/// Removes the right tap gesture. /// Removes the right tap gesture.
private func removeRightTapGesture() { private func removeRightTapGesture() {
if let v: UITapGestureRecognizer = rightTapGesture { guard let v = rightTapGesture else {
return
}
view.removeGestureRecognizer(v) view.removeGestureRecognizer(v)
rightTapGesture = nil rightTapGesture = nil
} }
}
/// Shows the statusBar. /// Shows the statusBar.
private func showStatusBar() { private func showStatusBar() {
if isStatusBarHidden { guard isStatusBarHidden else {
return
}
isStatusBarHidden = false isStatusBarHidden = false
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
if let s = self { guard let s = self else {
if let v = UIApplication.shared.keyWindow { return
v.windowLevel = UIWindowLevelNormal
s.delegate?.navigationDrawerStatusBarHiddenState?(navigationDrawerController: s, hidden: false)
}
} }
guard let v = UIApplication.shared.keyWindow else {
return
} }
v.windowLevel = UIWindowLevelNormal
s.delegate?.navigationDrawerController?(navigationDrawerController: s, statusBar: false)
} }
} }
/// Hides the statusBar. /// Hides the statusBar.
private func hideStatusBar() { private func hideStatusBar() {
if isHiddenStatusBarEnabled { guard isHiddenStatusBarEnabled else {
if !isStatusBarHidden { return
isStatusBarHidden = true
DispatchQueue.main.async { [weak self] in
if let s = self {
if let v = UIApplication.shared.keyWindow {
v.windowLevel = UIWindowLevelStatusBar + 1
s.delegate?.navigationDrawerStatusBarHiddenState?(navigationDrawerController: s, hidden: true)
} }
guard !isStatusBarHidden else {
return
} }
isStatusBarHidden = true
DispatchQueue.main.async { [weak self] in
guard let s = self else {
return
} }
guard let v = UIApplication.shared.keyWindow else {
return
} }
v.windowLevel = UIWindowLevelStatusBar + 1
s.delegate?.navigationDrawerController?(navigationDrawerController: s, statusBar: true)
} }
} }
......
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