diff --git a/Examples/Apps/Task/Task.xcodeproj/project.pbxproj b/Examples/Apps/Task/Task.xcodeproj/project.pbxproj new file mode 100644 index 000000000..1525dcb40 --- /dev/null +++ b/Examples/Apps/Task/Task.xcodeproj/project.pbxproj @@ -0,0 +1,304 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 96DBA7771C613B7800844821 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DBA7761C613B7800844821 /* AppDelegate.swift */; }; + 96DBA7791C613B7800844821 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DBA7781C613B7800844821 /* MainViewController.swift */; }; + 96DBA77E1C613B7800844821 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96DBA77D1C613B7800844821 /* Assets.xcassets */; }; + 96DBA7811C613B7800844821 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96DBA77F1C613B7800844821 /* LaunchScreen.storyboard */; }; + 96DBA7891C613C6B00844821 /* LeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DBA7881C613C6B00844821 /* LeftViewController.swift */; }; + 96DBA7921C6140D600844821 /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DBA7911C6140D600844821 /* RightViewController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 96DBA78D1C613C9100844821 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 96DBA7731C613B7800844821 /* Task.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Task.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 96DBA7761C613B7800844821 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 96DBA7781C613B7800844821 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; + 96DBA77D1C613B7800844821 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 96DBA7801C613B7800844821 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 96DBA7821C613B7800844821 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 96DBA7881C613C6B00844821 /* LeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftViewController.swift; sourceTree = ""; }; + 96DBA7911C6140D600844821 /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 96DBA7701C613B7800844821 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 96DBA76A1C613B7800844821 = { + isa = PBXGroup; + children = ( + 96DBA7751C613B7800844821 /* Task */, + 96DBA7741C613B7800844821 /* Products */, + ); + sourceTree = ""; + }; + 96DBA7741C613B7800844821 /* Products */ = { + isa = PBXGroup; + children = ( + 96DBA7731C613B7800844821 /* Task.app */, + ); + name = Products; + sourceTree = ""; + }; + 96DBA7751C613B7800844821 /* Task */ = { + isa = PBXGroup; + children = ( + 96DBA7761C613B7800844821 /* AppDelegate.swift */, + 96DBA7781C613B7800844821 /* MainViewController.swift */, + 96DBA7881C613C6B00844821 /* LeftViewController.swift */, + 96DBA7911C6140D600844821 /* RightViewController.swift */, + 96DBA77D1C613B7800844821 /* Assets.xcassets */, + 96DBA77F1C613B7800844821 /* LaunchScreen.storyboard */, + 96DBA7821C613B7800844821 /* Info.plist */, + ); + path = Task; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 96DBA7721C613B7800844821 /* Task */ = { + isa = PBXNativeTarget; + buildConfigurationList = 96DBA7851C613B7800844821 /* Build configuration list for PBXNativeTarget "Task" */; + buildPhases = ( + 96DBA76F1C613B7800844821 /* Sources */, + 96DBA7701C613B7800844821 /* Frameworks */, + 96DBA7711C613B7800844821 /* Resources */, + 96DBA78D1C613C9100844821 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Task; + productName = Task; + productReference = 96DBA7731C613B7800844821 /* Task.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 96DBA76B1C613B7800844821 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0720; + LastUpgradeCheck = 0720; + ORGANIZATIONNAME = "CosmicMind, Inc."; + TargetAttributes = { + 96DBA7721C613B7800844821 = { + CreatedOnToolsVersion = 7.2; + }; + }; + }; + buildConfigurationList = 96DBA76E1C613B7800844821 /* Build configuration list for PBXProject "Task" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 96DBA76A1C613B7800844821; + productRefGroup = 96DBA7741C613B7800844821 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 96DBA7721C613B7800844821 /* Task */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 96DBA7711C613B7800844821 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 96DBA7811C613B7800844821 /* LaunchScreen.storyboard in Resources */, + 96DBA77E1C613B7800844821 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 96DBA76F1C613B7800844821 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 96DBA7891C613C6B00844821 /* LeftViewController.swift in Sources */, + 96DBA7921C6140D600844821 /* RightViewController.swift in Sources */, + 96DBA7791C613B7800844821 /* MainViewController.swift in Sources */, + 96DBA7771C613B7800844821 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 96DBA77F1C613B7800844821 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 96DBA7801C613B7800844821 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 96DBA7831C613B7800844821 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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 = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 96DBA7841C613B7800844821 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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 = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 96DBA7861C613B7800844821 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Task/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.Task; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 96DBA7871C613B7800844821 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Task/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.Task; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 96DBA76E1C613B7800844821 /* Build configuration list for PBXProject "Task" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 96DBA7831C613B7800844821 /* Debug */, + 96DBA7841C613B7800844821 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 96DBA7851C613B7800844821 /* Build configuration list for PBXNativeTarget "Task" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 96DBA7861C613B7800844821 /* Debug */, + 96DBA7871C613B7800844821 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 96DBA76B1C613B7800844821 /* Project object */; +} diff --git a/Examples/Apps/Task/Task.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Examples/Apps/Task/Task.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..24cc02099 --- /dev/null +++ b/Examples/Apps/Task/Task.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Examples/Apps/Task/Task/AppDelegate.swift b/Examples/Apps/Task/Task/AppDelegate.swift new file mode 100644 index 000000000..eff342196 --- /dev/null +++ b/Examples/Apps/Task/Task/AppDelegate.swift @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. . +* 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 + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + // Override point for customization after application launch. + window = UIWindow(frame: UIScreen.mainScreen().bounds) + window!.rootViewController = SideNavigationViewController(mainViewController: MainViewController(), leftViewController: LeftViewController(), rightViewController: RightViewController()) + window!.makeKeyAndVisible() + return true + } + + 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 throttle down OpenGL ES frame rates. 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 inactive 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:. + } + + +} + diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..5e8cc2252 --- /dev/null +++ b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,86 @@ +{ + "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Material-Icon-29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Material-Icon-29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Material-Icon-40@2x-1.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Material-Icon-40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Material-Icon-60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Material-Icon-60@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Material-Icon-29.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Material-Icon-29@2x-1.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Material-Icon-40.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Material-Icon-40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Material-Icon-76.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Material-Icon-76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Material-Icon-83.5@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29.png new file mode 100644 index 000000000..5b40b694a Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x-1.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x-1.png new file mode 100644 index 000000000..789c7ae39 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x-1.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x.png new file mode 100644 index 000000000..789c7ae39 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@3x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@3x.png new file mode 100644 index 000000000..6b83993ea Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@3x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40.png new file mode 100644 index 000000000..5179f42ab Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x-1.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x-1.png new file mode 100644 index 000000000..11ecb3a29 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x-1.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x.png new file mode 100644 index 000000000..11ecb3a29 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@3x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@3x.png new file mode 100644 index 000000000..0441adc01 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@3x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@2x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@2x.png new file mode 100644 index 000000000..0441adc01 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@2x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@3x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@3x.png new file mode 100644 index 000000000..88a80a2f1 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@3x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-76.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-76.png new file mode 100644 index 000000000..ff49c12be Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-76.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-76@2x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-76@2x.png new file mode 100644 index 000000000..2ca4c2689 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-76@2x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-83.5@2x.png b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-83.5@2x.png new file mode 100644 index 000000000..16f1740a3 Binary files /dev/null and b/Examples/Apps/Task/Task/Assets.xcassets/AppIcon.appiconset/Material-Icon-83.5@2x.png differ diff --git a/Examples/Apps/Task/Task/Assets.xcassets/Contents.json b/Examples/Apps/Task/Task/Assets.xcassets/Contents.json new file mode 100644 index 000000000..da4a164c9 --- /dev/null +++ b/Examples/Apps/Task/Task/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Apps/Task/Task/Base.lproj/LaunchScreen.storyboard b/Examples/Apps/Task/Task/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..2e721e183 --- /dev/null +++ b/Examples/Apps/Task/Task/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/Apps/Task/Task/Info.plist b/Examples/Apps/Task/Task/Info.plist new file mode 100644 index 000000000..a945f5d4b --- /dev/null +++ b/Examples/Apps/Task/Task/Info.plist @@ -0,0 +1,46 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Examples/Apps/Task/Task/LeftViewController.swift b/Examples/Apps/Task/Task/LeftViewController.swift new file mode 100644 index 000000000..a5b80dc73 --- /dev/null +++ b/Examples/Apps/Task/Task/LeftViewController.swift @@ -0,0 +1,155 @@ +/* +* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. . +* 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 + +private struct Item { + var text: String + var imageName: String + var selected: Bool +} + +class LeftViewController: UIViewController { + /// A tableView used to display navigation items. + private let tableView: UITableView = UITableView() + + /// A list of all the navigation items. + private var items: Array = Array() + + override func viewDidLoad() { + super.viewDidLoad() + prepareView() + prepareItems() + prepareProfileView() + prepareTableView() + } + + /// General preparation statements. + private func prepareView() { + view.backgroundColor = MaterialColor.clear + } + + /// Prepares the items that are displayed within the tableView. + private func prepareItems() { + items.append(Item(text: "Inbox", imageName: "ic_inbox", selected: true)) + items.append(Item(text: "Today", imageName: "ic_today", selected: false)) + items.append(Item(text: "Bookmarks", imageName: "ic_book", selected: false)) + items.append(Item(text: "Work", imageName: "ic_work", selected: false)) + items.append(Item(text: "Contacts", imageName: "ic_contacts", selected: false)) + items.append(Item(text: "Settings", imageName: "ic_settings", selected: false)) + } + + /// Prepares profile view. + private func prepareProfileView() { + let backgroundView: MaterialView = MaterialView() + backgroundView.image = UIImage(named: "MaterialBackground") + + let profileView: MaterialView = MaterialView() + profileView.image = UIImage(named: "Profile9")?.resize(toWidth: 72) + profileView.shape = .Circle + profileView.borderColor = MaterialColor.white + profileView.borderWidth = .Border3 + + let nameLabel: UILabel = UILabel() + nameLabel.text = "Michael Smith" + nameLabel.textColor = MaterialColor.white + nameLabel.font = RobotoFont.mediumWithSize(18) + + view.addSubview(backgroundView) + backgroundView.translatesAutoresizingMaskIntoConstraints = false + MaterialLayout.alignFromTop(view, child: backgroundView) + MaterialLayout.alignToParentHorizontally(view, child: backgroundView) + MaterialLayout.height(view, child: backgroundView, height: 170) + + backgroundView.addSubview(profileView) + profileView.translatesAutoresizingMaskIntoConstraints = false + MaterialLayout.alignFromTopLeft(backgroundView, child: profileView, top: 20, left: 20) + MaterialLayout.size(backgroundView, child: profileView, width: 72, height: 72) + + backgroundView.addSubview(nameLabel) + nameLabel.translatesAutoresizingMaskIntoConstraints = false + MaterialLayout.alignFromBottom(backgroundView, child: nameLabel, bottom: 20) + MaterialLayout.alignToParentHorizontally(backgroundView, child: nameLabel, left: 20, right: 20) + } + + /// Prepares the tableView. + private func prepareTableView() { + tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") + tableView.dataSource = self + tableView.delegate = self + tableView.separatorStyle = .None + + // Use MaterialLayout to easily align the tableView. + view.addSubview(tableView) + tableView.translatesAutoresizingMaskIntoConstraints = false + MaterialLayout.alignToParent(view, child: tableView, top: 170) + } +} + +/// TableViewDataSource methods. +extension LeftViewController: UITableViewDataSource { + /// Determines the number of rows in the tableView. + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return items.count; + } + + /// Prepares the cells within the tableView. + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell + cell.backgroundColor = MaterialColor.clear + + let item: Item = items[indexPath.row] + cell.selectionStyle = .None + cell.textLabel!.text = item.text + cell.textLabel!.font = RobotoFont.medium + cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate) + cell.imageView!.tintColor = MaterialColor.cyan.darken4 + + if item.selected { + cell.textLabel!.textColor = MaterialColor.cyan.base + } + + return cell + } +} + +/// UITableViewDelegate methods. +extension LeftViewController: UITableViewDelegate { + /// Sets the tableView cell height. + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + return 64 + } + + /// Select item at row in tableView. + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + print("Item selected") + } +} diff --git a/Examples/Apps/Task/Task/MainViewController.swift b/Examples/Apps/Task/Task/MainViewController.swift new file mode 100644 index 000000000..d62274077 --- /dev/null +++ b/Examples/Apps/Task/Task/MainViewController.swift @@ -0,0 +1,61 @@ +/* +* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. . +* 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 GraphKit 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 MainViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + prepareView() + } + + override func viewWillAppear(animated: Bool) { + super.viewWillAppear(animated) + + /* + Set the width of the SideNavigationViewController. Be mindful + of when setting this value. It is set in the viewWillAppear method, + because any earlier may cause a race condition when instantiating + the MainViewController and SideViewController. + */ + sideNavigationViewController?.setLeftViewWidth(view.bounds.width - 88, hidden: true, animated: true) + sideNavigationViewController?.setRightViewWidth(view.bounds.width - 88, hidden: false, animated: true) + sideNavigationViewController?.enabledLeftView = false + sideNavigationViewController?.enabledRightView = false + sideNavigationViewController?.enabled = true + } + + /// General preparation statements. + private func prepareView() { + view.backgroundColor = MaterialColor.white + } +} diff --git a/Examples/Apps/Task/Task/RightViewController.swift b/Examples/Apps/Task/Task/RightViewController.swift new file mode 100644 index 000000000..01795bbb4 --- /dev/null +++ b/Examples/Apps/Task/Task/RightViewController.swift @@ -0,0 +1,128 @@ +/* +* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. . +* 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 + +private struct Item { + var text: String + var imageName: String + var selected: Bool +} + +class RightViewController: UIViewController { + /// A tableView used to display navigation items. + private let tableView: UITableView = UITableView() + + /// A list of all the navigation items. + private var items: Array = Array() + + override func viewDidLoad() { + super.viewDidLoad() + prepareView() + prepareItems() + prepareTableView() + } + + /// General preparation statements. + private func prepareView() { + view.backgroundColor = MaterialColor.blueGrey.darken4 + } + + override func viewWillAppear(animated: Bool) { + super.viewWillAppear(animated) + } + + + /// Prepares the items that are displayed within the tableView. + private func prepareItems() { + items.append(Item(text: "Inbox", imageName: "ic_inbox", selected: false)) + items.append(Item(text: "Today", imageName: "ic_today", selected: true)) + items.append(Item(text: "Bookmarks", imageName: "ic_book", selected: false)) + items.append(Item(text: "Work", imageName: "ic_work", selected: false)) + items.append(Item(text: "Contacts", imageName: "ic_contacts", selected: false)) + items.append(Item(text: "Settings", imageName: "ic_settings", selected: false)) + } + + /// Prepares the tableView. + private func prepareTableView() { + tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") + tableView.backgroundColor = MaterialColor.clear + tableView.dataSource = self + tableView.delegate = self + tableView.separatorStyle = .None + + // Use MaterialLayout to easily align the tableView. + view.addSubview(tableView) + tableView.translatesAutoresizingMaskIntoConstraints = false + MaterialLayout.alignToParent(view, child: tableView) + } +} + +/// TableViewDataSource methods. +extension RightViewController: UITableViewDataSource { + /// Determines the number of rows in the tableView. + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return items.count; + } + + /// Prepares the cells within the tableView. + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell + cell.backgroundColor = MaterialColor.clear + + let item: Item = items[indexPath.row] + cell.selectionStyle = .None + cell.textLabel!.text = item.text + cell.textLabel!.textColor = MaterialColor.white + cell.textLabel!.font = RobotoFont.medium + cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate) + cell.imageView!.tintColor = MaterialColor.cyan.lighten4 + + if item.selected { + cell.textLabel!.textColor = MaterialColor.cyan.lighten3 + } + + return cell + } +} + +/// UITableViewDelegate methods. +extension RightViewController: UITableViewDelegate { + /// Sets the tableView cell height. + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + return 64 + } + + /// Select item at row in tableView. + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + print("Item selected") + } +} diff --git a/Examples/Material.xcworkspace/contents.xcworkspacedata b/Examples/Material.xcworkspace/contents.xcworkspacedata index da0304434..1fd27f292 100644 --- a/Examples/Material.xcworkspace/contents.xcworkspacedata +++ b/Examples/Material.xcworkspace/contents.xcworkspacedata @@ -1,6 +1,13 @@ + + + + diff --git a/Material.podspec b/Material.podspec index f1313694e..50e80383a 100755 --- a/Material.podspec +++ b/Material.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Material' - s.version = '1.29.2' + s.version = '1.29.3' s.license = 'BSD' s.summary = 'A beautiful graphics framework for Material Design in Swift.' s.homepage = 'http://cosmicmind.io' diff --git a/Sources/Info.plist b/Sources/Info.plist index 5099a18c4..e79173fd5 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.29.2 + 1.29.3 CFBundleSignature ???? CFBundleVersion diff --git a/Sources/SideNavigationViewController.swift b/Sources/SideNavigationViewController.swift index 05f9c160a..3c16cd278 100644 --- a/Sources/SideNavigationViewController.swift +++ b/Sources/SideNavigationViewController.swift @@ -182,10 +182,13 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer A Boolean property that enables and disables the leftView from opening and closing. Defaults to true. */ - public var enabled: Bool = true { - didSet { - enabledLeftView = enabled - enabledRightView = enabled + public var enabled: Bool { + get { + return enabledLeftView || enabledRightView + } + set(value) { + enabledLeftView = value + enabledRightView = value } } @@ -326,37 +329,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer public override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() - - MaterialAnimation.animationDisabled { [unowned self] in - self.backdropLayer.frame = self.view.bounds - } - - if let v: MaterialView = leftView { - v.width = self.leftViewWidth - v.height = self.view.bounds.height - leftViewThreshold = leftViewWidth / 2 - if let vc: UIViewController = leftViewController { - vc.view.frame.size.width = v.width - vc.view.frame.size.height = v.height - vc.view.center = CGPointMake(v.width / 2, v.height / 2) - } - } - - if let v: MaterialView = rightView { - v.width = self.rightViewWidth - v.height = self.view.bounds.height - rightViewThreshold = view.bounds.width - rightViewWidth / 2 - if let vc: UIViewController = rightViewController { - vc.view.frame.size.width = v.width - vc.view.frame.size.height = v.height - vc.view.center = CGPointMake(v.width / 2, v.height / 2) - } - } + layoutSubviews() } public override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) { if let v: MaterialView = rightView { - v.x = self.view.bounds.height - (self.openedRightView ? self.rightViewWidth : 0) + v.x = view.bounds.height - (openedRightView ? rightViewWidth : 0) } } @@ -385,8 +363,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer duration: duration, options: options, animations: animations, - completion: { [unowned self, mainViewController = self.mainViewController] (result: Bool) in - mainViewController.removeFromParentViewController() + completion: { [unowned self] (result: Bool) in + self.mainViewController.removeFromParentViewController() toViewController.didMoveToParentViewController(self) self.mainViewController = toViewController self.userInteractionEnabled = !self.opened @@ -404,22 +382,50 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer - Parameter animated: A Boolean value that indicates to animate the leftView width change. */ - public func setLeftViewWidth(width: CGFloat, hidden: Bool, animated: Bool) { - leftViewWidth = width - + public func setLeftViewWidth(width: CGFloat, var hidden: Bool, animated: Bool, duration: NSTimeInterval = 0.5) { if let v: MaterialView = leftView { - let w: CGFloat = (hidden ? -width : width) / 2 + leftViewWidth = width + layoutSubviews() + + if openedRightView { + hidden = true + } else { + backdropLayer.hidden = hidden + } if animated { - UIView.animateWithDuration(0.25, animations: { - v.width = width - v.position.x = w - }) { _ in - self.userInteractionEnabled = false + if hidden { + UIView.animateWithDuration(duration, + animations: { + v.width = width + v.position = CGPointMake(-width / 2, v.height / 2) + }) { _ in + self.userInteractionEnabled = true + self.hideDepth(v) + self.hideView(v) + } + } else { + showView(v) + UIView.animateWithDuration(duration, + animations: { + v.width = width + v.position = CGPointMake(width / 2, v.height / 2) + }) { _ in + self.userInteractionEnabled = true + self.showDepth(v) + } } } else { v.width = width - v.position.x = w + if hidden { + hideView(v) + v.position = CGPointMake(-v.width / 2, v.height / 2) + hideDepth(v) + } else { + showView(v) + v.position = CGPointMake(v.width / 2, v.height / 2) + showDepth(v) + } } } } @@ -434,22 +440,50 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer - Parameter animated: A Boolean value that indicates to animate the rightView width change. */ - public func setRightViewWidth(width: CGFloat, hidden: Bool, animated: Bool) { - rightViewWidth = width - + public func setRightViewWidth(width: CGFloat, var hidden: Bool, animated: Bool, duration: NSTimeInterval = 0.5) { if let v: MaterialView = rightView { - let w: CGFloat = (hidden ? -width : width) / 2 + rightViewWidth = width + layoutSubviews() + + if openedLeftView { + hidden = true + } else { + backdropLayer.hidden = hidden + } if animated { - UIView.animateWithDuration(0.25, animations: { - v.width = width - v.position.x = w - }) { _ in - self.userInteractionEnabled = false + if hidden { + UIView.animateWithDuration(duration, + animations: { + v.width = width + v.position = CGPointMake(self.view.bounds.width + width / 2, v.height / 2) + }) { _ in + self.userInteractionEnabled = true + self.hideDepth(v) + self.hideView(v) + } + } else { + showView(v) + UIView.animateWithDuration(duration, + animations: { + v.width = width + v.position = CGPointMake(self.view.bounds.width - width / 2, v.height / 2) + }) { _ in + self.userInteractionEnabled = true + self.showDepth(v) + } } } else { v.width = width - v.position.x = w + if hidden { + hideView(v) + v.position = CGPointMake(self.view.bounds.width + v.width / 2, v.height / 2) + hideDepth(v) + } else { + showView(v) + v.position = CGPointMake(self.view.bounds.width - v.width / 2, v.height / 2) + showDepth(v) + } } } } @@ -586,10 +620,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer if gestureRecognizer == panGesture { return opened || isPointContainedWithinLeftViewThreshold(touch.locationInView(view)) || isPointContainedWithinRightViewThreshold(touch.locationInView(view)) } - if opened && gestureRecognizer == tapGesture { - return true - } - return false + return opened && gestureRecognizer == tapGesture } /** @@ -611,7 +642,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer originalX = v.position.x toggleStatusBar(true) - showDepth(v) showView(v) delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Right) @@ -619,7 +649,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer let w: CGFloat = v.width let translationX: CGFloat = recognizer.translationInView(v).x - v.position.x = self.originalX + translationX < self.view.bounds.width - (w / 2) ? self.view.bounds.width - (w / 2) : self.originalX + translationX + v.position.x = originalX + translationX < view.bounds.width - (w / 2) ? view.bounds.width - (w / 2) : originalX + translationX delegate?.sideNavigationViewPanDidChange?(self, point: point, position: .Right) case .Ended, .Cancelled, .Failed: let p: CGPoint = recognizer.velocityInView(recognizer.view) @@ -635,7 +665,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer case .Possible:break } } - } else if enabledLeftView { + } else if enabledLeftView && (openedLeftView || !openedRightView && isPointContainedWithinLeftViewThreshold(recognizer.locationInView(view))) { if let v: MaterialView = leftView { let point: CGPoint = recognizer.locationInView(view) @@ -646,7 +676,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer originalX = v.position.x toggleStatusBar(true) - showDepth(v) showView(v) delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Left) @@ -654,7 +683,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer let w: CGFloat = v.width let translationX: CGFloat = recognizer.translationInView(v).x - v.position.x = self.originalX + translationX > (w / 2) ? (w / 2) : self.originalX + translationX + v.position.x = originalX + translationX > (w / 2) ? (w / 2) : originalX + translationX delegate?.sideNavigationViewPanDidChange?(self, point: point, position: .Left) case .Ended, .Cancelled, .Failed: let p: CGPoint = recognizer.velocityInView(recognizer.view) @@ -740,8 +769,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer view.addSubview(leftView!) leftView!.hidden = true - leftView!.position.x = -self.leftViewWidth / 2 + leftView!.position.x = -leftViewWidth / 2 leftView!.zPosition = 1000 + } else { + enabledLeftView = false } } @@ -754,8 +785,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer view.addSubview(rightView!) rightView!.hidden = true - rightView!.position.x = self.view.bounds.width + self.rightViewWidth / 2 + rightView!.position.x = view.bounds.width + rightViewWidth / 2 rightView!.zPosition = 1000 + } else { + enabledRightView = false } } @@ -889,7 +922,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer - Parameter container: A container view. */ private func showDepth(container: MaterialView) { - container.depth = self.depth + container.depth = depth } /** @@ -915,4 +948,33 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer private func hideView(container: UIView) { container.hidden = true } + + /// Layout subviews. + private func layoutSubviews() { + MaterialAnimation.animationDisabled { [unowned self] in + self.backdropLayer.frame = self.view.bounds + } + + if let v: MaterialView = leftView { + v.width = leftViewWidth + v.height = view.bounds.height + leftViewThreshold = leftViewWidth / 2 + if let vc: UIViewController = leftViewController { + vc.view.frame.size.width = v.width + vc.view.frame.size.height = v.height + vc.view.center = CGPointMake(v.width / 2, v.height / 2) + } + } + + if let v: MaterialView = rightView { + v.width = rightViewWidth + v.height = view.bounds.height + rightViewThreshold = view.bounds.width - rightViewWidth / 2 + if let vc: UIViewController = rightViewController { + vc.view.frame.size.width = v.width + vc.view.frame.size.height = v.height + vc.view.center = CGPointMake(v.width / 2, v.height / 2) + } + } + } } \ No newline at end of file