Commit 8d47964e by Daniel Dahan

updated selectors for swift 2.3

parent 8121a69b
......@@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
96162C691CA7191800E3A235 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96162C681CA7191800E3A235 /* Material.framework */; };
96162C6A1CA7191800E3A235 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96162C681CA7191800E3A235 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96162C6C1CA71C8700E3A235 /* VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6B1CA71C8700E3A235 /* VideoViewController.swift */; };
96162C6E1CA7274E00E3A235 /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */; };
9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9311C7A744600AF0965 /* AppDelegate.swift */; };
9663F9341C7A744600AF0965 /* RecommendationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9331C7A744600AF0965 /* RecommendationViewController.swift */; };
9663F9391C7A744600AF0965 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9663F9381C7A744600AF0965 /* Assets.xcassets */; };
......@@ -27,6 +31,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96162C6A1CA7191800E3A235 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -34,6 +39,9 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
96162C681CA7191800E3A235 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96162C6B1CA71C8700E3A235 /* VideoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoViewController.swift; sourceTree = "<group>"; };
96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; };
9663F92E1C7A744600AF0965 /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
9663F9311C7A744600AF0965 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
9663F9331C7A744600AF0965 /* RecommendationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendationViewController.swift; sourceTree = "<group>"; };
......@@ -54,6 +62,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96162C691CA7191800E3A235 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -63,6 +72,7 @@
9663F9251C7A744500AF0965 = {
isa = PBXGroup;
children = (
96162C681CA7191800E3A235 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */,
);
......@@ -88,6 +98,8 @@
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */,
9663F9331C7A744600AF0965 /* RecommendationViewController.swift */,
9663F9511C7A751D00AF0965 /* ItemViewController.swift */,
96162C6B1CA71C8700E3A235 /* VideoViewController.swift */,
96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */,
9663F9381C7A744600AF0965 /* Assets.xcassets */,
9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */,
9663F93D1C7A744600AF0965 /* Info.plist */,
......@@ -174,7 +186,9 @@
9663F94C1C7A74C700AF0965 /* AppMenuViewController.swift in Sources */,
9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */,
9663F9521C7A751D00AF0965 /* ItemViewController.swift in Sources */,
96162C6C1CA71C8700E3A235 /* VideoViewController.swift in Sources */,
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */,
96162C6E1CA7274E00E3A235 /* PhotoViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -37,9 +37,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let bottomNavigationController: BottomNavigationController = BottomNavigationController()
bottomNavigationController.viewControllers = [AppMenuViewController(mainViewController: AppNavigationController(rootViewController: RecipesViewController())), VideoViewController(), PhotoViewController()]
bottomNavigationController.selectedIndex = 0
bottomNavigationController.tabBar.tintColor = MaterialColor.lightBlue.base
bottomNavigationController.tabBar.backgroundColor = MaterialColor.grey.darken4
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = SideNavigationController(mainViewController: AppMenuViewController(mainViewController: AppNavigationController(rootViewController: RecipesViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window!.rootViewController = SideNavigationController(mainViewController: bottomNavigationController, leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window!.makeKeyAndVisible()
return true
}
......
......@@ -43,12 +43,30 @@ class AppMenuViewController: MenuViewController {
/// MenuView inset.
private let menuViewInset: CGFloat = 16
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
init() {
super.init(nibName: nil, bundle: nil)
prepareTabBarItem()
}
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareMenuView()
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
closeMenu()
}
override func openMenu(completion: (() -> Void)? = nil) {
super.openMenu(completion)
sideNavigationController?.enabled = false
......@@ -97,7 +115,7 @@ class AppMenuViewController: MenuViewController {
menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted)
menuButton.addTarget(self, action: "handleMenu", forControlEvents: .TouchUpInside)
menuButton.addTarget(self, action: #selector(handleMenu), forControlEvents: .TouchUpInside)
menuView.addSubview(menuButton)
image = UIImage(named: "ic_create_white")
......@@ -106,7 +124,7 @@ class AppMenuViewController: MenuViewController {
blueButton.setImage(image, forState: .Normal)
blueButton.setImage(image, forState: .Highlighted)
menuView.addSubview(blueButton)
blueButton.addTarget(self, action: "handleBlueButton", forControlEvents: .TouchUpInside)
blueButton.addTarget(self, action: #selector(handleBlueButton), forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_photo_camera_white")
let greenButton: FabButton = FabButton()
......@@ -114,7 +132,7 @@ class AppMenuViewController: MenuViewController {
greenButton.setImage(image, forState: .Normal)
greenButton.setImage(image, forState: .Highlighted)
menuView.addSubview(greenButton)
greenButton.addTarget(self, action: "handleGreenButton", forControlEvents: .TouchUpInside)
greenButton.addTarget(self, action: #selector(handleGreenButton), forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_note_add_white")
let yellowButton: FabButton = FabButton()
......@@ -122,7 +140,7 @@ class AppMenuViewController: MenuViewController {
yellowButton.setImage(image, forState: .Normal)
yellowButton.setImage(image, forState: .Highlighted)
menuView.addSubview(yellowButton)
yellowButton.addTarget(self, action: "handleYellowButton", forControlEvents: .TouchUpInside)
yellowButton.addTarget(self, action: #selector(handleYellowButton), forControlEvents: .TouchUpInside)
// Initialize the menu and setup the configuration options.
menuView.menu.baseViewSize = baseViewSize
......@@ -133,5 +151,13 @@ class AppMenuViewController: MenuViewController {
MaterialLayout.size(view, child: menuView, width: baseViewSize.width, height: baseViewSize.height)
MaterialLayout.alignFromBottomRight(view, child: menuView, bottom: menuViewInset, right: menuViewInset)
}
/// Prepare tabBarItem.
private func prepareTabBarItem() {
tabBarItem.title = "Recipes"
tabBarItem.image = MaterialIcon.photoLibrary
tabBarItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
tabBarItem.setTitleColor(MaterialColor.lightBlue.base, forState: .Selected)
}
}
......@@ -60,11 +60,6 @@ class AppRightViewController: UIViewController {
view.backgroundColor = MaterialColor.grey.darken4
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
/// Prepares the items that are displayed within the tableView.
private func prepareCells() {
items.append(Item(text: "Recipes", imageName: "ic_inbox"))
......
......@@ -91,7 +91,7 @@ class AppSearchBarController: SearchBarController {
backButton.tintColor = MaterialColor.grey.darken4
backButton.setImage(image, forState: .Normal)
backButton.setImage(image, forState: .Highlighted)
backButton.addTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside)
backButton.addTarget(self, action: #selector(handleBackButton), forControlEvents: .TouchUpInside)
// More button.
image = MaterialIcon.moreHorizontal
......
......@@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "ic_close_white.png",
"filename" : "ic_camera_front_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white@2x.png",
"filename" : "ic_camera_front_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white@3x.png",
"filename" : "ic_camera_front_white@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_camera_rear_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_camera_rear_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_camera_rear_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_flash_auto_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_auto_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_auto_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_flash_off_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_off_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_off_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_flash_on_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_on_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_on_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_videocam_white_36pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_videocam_white_36pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_videocam_white_36pt@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -108,7 +108,7 @@ class ItemViewController: UIViewController {
shareButton.pulseColor = MaterialColor.white
shareButton.setImage(image, forState: .Normal)
shareButton.setImage(image, forState: .Highlighted)
shareButton.addTarget(self, action: "handleShareButton", forControlEvents: .TouchUpInside)
shareButton.addTarget(self, action: #selector(handleShareButton), forControlEvents: .TouchUpInside)
}
/// Prepares view.
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class PhotoViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
init() {
super.init(nibName: nil, bundle: nil)
prepareTabBarItem()
}
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.green.base
}
/// Prepare tabBarItem.
private func prepareTabBarItem() {
tabBarItem.title = "Photo"
tabBarItem.image = MaterialIcon.photoCamera
tabBarItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
tabBarItem.setTitleColor(MaterialColor.lightBlue.base, forState: .Selected)
}
}
......@@ -68,7 +68,10 @@ class RecipesViewController: UIViewController {
// Enable the SideNavigation.
sideNavigationController?.enabled = true
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// Show the menuView.
menuViewController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3),
......@@ -155,6 +158,54 @@ class RecipesViewController: UIViewController {
"date": "February 26, 2016",
"image": "VeganPieAbove"
]
),
MaterialDataSourceItem(
data: [
"title": "Crepe Indulgence",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016",
"image": "AssortmentOfDessert"
]
),
MaterialDataSourceItem(
data: [
"title": "Avocado Chocolate Cake",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016",
"image": "AssortmentOfFood"
]
),
MaterialDataSourceItem(
data: [
"title": "Avocado Ice-Cream",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016",
"image": "AvocadoIceCream"
]
),
MaterialDataSourceItem(
data: [
"title": "Raw Vegan Chocolate Cookies",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016",
"image": "HeartCookies"
]
),
MaterialDataSourceItem(
data: [
"title": "Raw Vegan Nutty Sweets",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016",
"image": "VeganHempBalls"
]
),
MaterialDataSourceItem(
data: [
"title": "Blueberry Tart",
"detail": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"date": "February 26, 2016",
"image": "VeganPieAbove"
]
)
]
}
......@@ -180,7 +231,7 @@ class RecipesViewController: UIViewController {
menuButton.pulseColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted)
menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
menuButton.addTarget(self, action: #selector(handleMenuButton), forControlEvents: .TouchUpInside)
}
/// Prepares the switchControl.
......@@ -196,7 +247,7 @@ class RecipesViewController: UIViewController {
searchButton.pulseColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted)
searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
searchButton.addTarget(self, action: #selector(handleSearchButton), forControlEvents: .TouchUpInside)
}
/// Prepares the NavigationBar.
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class VideoViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
init() {
super.init(nibName: nil, bundle: nil)
prepareTabBarItem()
}
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.yellow.base
}
/// Prepare tabBarItem.
private func prepareTabBarItem() {
tabBarItem.title = "Video"
tabBarItem.image = MaterialIcon.videocam
tabBarItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
tabBarItem.setTitleColor(MaterialColor.lightBlue.base, forState: .Selected)
}
}
......@@ -11,8 +11,6 @@
96A536751CA3A5450069B3CC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A536741CA3A5450069B3CC /* ViewController.swift */; };
96A5367A1CA3A5450069B3CC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A536791CA3A5450069B3CC /* Assets.xcassets */; };
96A5367D1CA3A5450069B3CC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A5367B1CA3A5450069B3CC /* LaunchScreen.storyboard */; };
96BAECE51CA3B0F10048037C /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96BAECE41CA3B0F10048037C /* Material.framework */; };
96BAECE61CA3B0F10048037C /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96BAECE41CA3B0F10048037C /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -22,7 +20,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96BAECE61CA3B0F10048037C /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -36,7 +33,6 @@
96A536791CA3A5450069B3CC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A5367C1CA3A5450069B3CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A5367E1CA3A5450069B3CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96BAECE41CA3B0F10048037C /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96BAECE51CA3B0F10048037C /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -54,7 +49,6 @@
96A536661CA3A5450069B3CC = {
isa = PBXGroup;
children = (
96BAECE41CA3B0F10048037C /* Material.framework */,
96A536711CA3A5450069B3CC /* BottomNavigationBar */,
96A536701CA3A5450069B3CC /* Products */,
);
......
......@@ -12,8 +12,6 @@
96162C341CA7064900E3A235 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96162C321CA7064900E3A235 /* Main.storyboard */; };
96162C361CA7064900E3A235 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96162C351CA7064900E3A235 /* Assets.xcassets */; };
96162C391CA7064900E3A235 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96162C371CA7064900E3A235 /* LaunchScreen.storyboard */; };
96162C411CA7068900E3A235 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96162C401CA7068900E3A235 /* Material.framework */; };
96162C421CA7068900E3A235 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96162C401CA7068900E3A235 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96162C451CA7083000E3A235 /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C441CA7083000E3A235 /* PhotoViewController.swift */; };
96162C471CA708B000E3A235 /* LibraryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C461CA708B000E3A235 /* LibraryViewController.swift */; };
/* End PBXBuildFile section */
......@@ -25,7 +23,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96162C421CA7068900E3A235 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -40,7 +37,6 @@
96162C351CA7064900E3A235 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96162C381CA7064900E3A235 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96162C3A1CA7064900E3A235 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96162C401CA7068900E3A235 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96162C441CA7083000E3A235 /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; };
96162C461CA708B000E3A235 /* LibraryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -50,7 +46,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96162C411CA7068900E3A235 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -60,7 +55,6 @@
96162C221CA7064900E3A235 = {
isa = PBXGroup;
children = (
96162C401CA7068900E3A235 /* Material.framework */,
96162C2D1CA7064900E3A235 /* BottomNavigationController */,
96162C2C1CA7064900E3A235 /* Products */,
);
......
......@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let bottomNavigationController: BottomNavigationController = BottomNavigationController()
bottomNavigationController.setViewControllers([VideoViewController(), PhotoViewController(), LibraryViewController()], animated: true)
bottomNavigationController.viewControllers = [VideoViewController(), PhotoViewController(), LibraryViewController()]
bottomNavigationController.selectedIndex = 0
bottomNavigationController.tabBar.tintColor = MaterialColor.teal.base
bottomNavigationController.tabBar.backgroundColor = MaterialColor.grey.darken4
......
......@@ -131,7 +131,7 @@ class ViewController: UIViewController {
btn1.pulseColor = nil
btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: "handleFabMenu", forControlEvents: .TouchUpInside)
btn1.addTarget(self, action: #selector(handleFabMenu), forControlEvents: .TouchUpInside)
view.addSubview(btn1)
image = UIImage(named: "ic_create_white")
......@@ -165,7 +165,7 @@ class ViewController: UIViewController {
/// Prepares the FlatMenu example.
private func prepareFlatbMenuExample() {
let btn1: FlatButton = FlatButton()
btn1.addTarget(self, action: "handleFlatMenu", forControlEvents: .TouchUpInside)
btn1.addTarget(self, action: #selector(handleFlatMenu), forControlEvents: .TouchUpInside)
btn1.setTitleColor(MaterialColor.white, forState: .Normal)
btn1.backgroundColor = MaterialColor.blue.accent3
btn1.pulseColor = MaterialColor.white
......@@ -212,7 +212,7 @@ class ViewController: UIViewController {
btn1.tintColor = MaterialColor.blueGrey.darken4
btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: "handleFlashMenu", forControlEvents: .TouchUpInside)
btn1.addTarget(self, action: #selector(handleFlashMenu), forControlEvents: .TouchUpInside)
view.addSubview(btn1)
image = UIImage(named: "ic_flash_off_white")?.imageWithRenderingMode(.AlwaysTemplate)
......
......@@ -69,6 +69,7 @@ class ViewController: UIViewController {
}
/// Handle the menuView touch event.
@objc(handleButton:)
internal func handleButton(button: UIButton) {
print("Hit Button \(button)")
}
......@@ -90,7 +91,7 @@ class ViewController: UIViewController {
btn1.borderWidth = 1
btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: "handleMenu", forControlEvents: .TouchUpInside)
btn1.addTarget(self, action: #selector(handleMenu), forControlEvents: .TouchUpInside)
menuView.addSubview(btn1)
image = UIImage(named: "ic_create_white")?.imageWithRenderingMode(.AlwaysTemplate)
......@@ -103,7 +104,7 @@ class ViewController: UIViewController {
btn2.borderWidth = 1
btn2.setImage(image, forState: .Normal)
btn2.setImage(image, forState: .Highlighted)
btn2.addTarget(self, action: "handleButton:", forControlEvents: .TouchUpInside)
btn2.addTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside)
menuView.addSubview(btn2)
image = UIImage(named: "ic_photo_camera_white")?.imageWithRenderingMode(.AlwaysTemplate)
......@@ -116,7 +117,7 @@ class ViewController: UIViewController {
btn3.borderWidth = 1
btn3.setImage(image, forState: .Normal)
btn3.setImage(image, forState: .Highlighted)
btn3.addTarget(self, action: "handleButton:", forControlEvents: .TouchUpInside)
btn3.addTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside)
menuView.addSubview(btn3)
image = UIImage(named: "ic_note_add_white")?.imageWithRenderingMode(.AlwaysTemplate)
......@@ -129,7 +130,7 @@ class ViewController: UIViewController {
btn4.borderWidth = 1
btn4.setImage(image, forState: .Normal)
btn4.setImage(image, forState: .Highlighted)
btn4.addTarget(self, action: "handleButton:", forControlEvents: .TouchUpInside)
btn4.addTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside)
menuView.addSubview(btn4)
// Initialize the menu and setup the configuration options.
......
......@@ -104,7 +104,7 @@ class AppMenuViewController: MenuViewController {
let btn1: FabButton = FabButton()
btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: "handleMenu", forControlEvents: .TouchUpInside)
btn1.addTarget(self, action: #selector(handleMenu), forControlEvents: .TouchUpInside)
menuView.addSubview(btn1)
image = UIImage(named: "ic_create_white")
......@@ -113,7 +113,7 @@ class AppMenuViewController: MenuViewController {
btn2.setImage(image, forState: .Normal)
btn2.setImage(image, forState: .Highlighted)
menuView.addSubview(btn2)
btn2.addTarget(self, action: "handleBlueButton", forControlEvents: .TouchUpInside)
btn2.addTarget(self, action: #selector(handleBlueButton), forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_photo_camera_white")
let btn3: FabButton = FabButton()
......@@ -121,7 +121,7 @@ class AppMenuViewController: MenuViewController {
btn3.setImage(image, forState: .Normal)
btn3.setImage(image, forState: .Highlighted)
menuView.addSubview(btn3)
btn3.addTarget(self, action: "handleGreenButton", forControlEvents: .TouchUpInside)
btn3.addTarget(self, action: #selector(handleGreenButton), forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_note_add_white")
let btn4: FabButton = FabButton()
......@@ -129,7 +129,7 @@ class AppMenuViewController: MenuViewController {
btn4.setImage(image, forState: .Normal)
btn4.setImage(image, forState: .Highlighted)
menuView.addSubview(btn4)
btn4.addTarget(self, action: "handleYellowButton", forControlEvents: .TouchUpInside)
btn4.addTarget(self, action: #selector(handleYellowButton), forControlEvents: .TouchUpInside)
// Initialize the menu and setup the configuration options.
menuView.menu.baseViewSize = baseViewSize
......
......@@ -84,7 +84,7 @@ class AppSearchBarController: SearchBarController {
clearButton.tintColor = MaterialColor.blueGrey.darken4
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
clearButton.addTarget(self, action: "handleYellowButton", forControlEvents: .TouchUpInside)
clearButton.addTarget(self, action: #selector(handleYellowButton), forControlEvents: .TouchUpInside)
// Back button.
image = MaterialIcon.arrowBack
......@@ -94,7 +94,7 @@ class AppSearchBarController: SearchBarController {
backButton.tintColor = MaterialColor.blueGrey.darken4
backButton.setImage(image, forState: .Normal)
backButton.setImage(image, forState: .Highlighted)
backButton.addTarget(self, action: "handleBlueButton", forControlEvents: .TouchUpInside)
backButton.addTarget(self, action: #selector(handleBlueButton), forControlEvents: .TouchUpInside)
// More button.
image = MaterialIcon.moreHorizontal
......@@ -104,7 +104,7 @@ class AppSearchBarController: SearchBarController {
moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted)
moreButton.addTarget(self, action: "handleGreenButton", forControlEvents: .TouchUpInside)
moreButton.addTarget(self, action: #selector(handleGreenButton), forControlEvents: .TouchUpInside)
/*
To lighten the status bar - add the
......
......@@ -100,7 +100,7 @@ class AppToolbarController: ToolbarController {
menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted)
menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
menuButton.addTarget(self, action: #selector(handleMenuButton), forControlEvents: .TouchUpInside)
// Switch control.
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small)
......@@ -114,7 +114,7 @@ class AppToolbarController: ToolbarController {
searchButton.tintColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted)
searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
searchButton.addTarget(self, action: #selector(handleSearchButton), forControlEvents: .TouchUpInside)
toolbar.backgroundColor = MaterialColor.blue.base
toolbar.titleLabel = titleLabel
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
......@@ -17,11 +17,8 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tabBar contentMode="scaleToFill" misplaced="YES" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sMP-AS-Zl9" customClass="BottomNavigationBar" customModule="Material">
<tabBar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sMP-AS-Zl9" customClass="BottomNavigationBar" customModule="Material">
<rect key="frame" x="0.0" y="551" width="600" height="49"/>
<constraints>
<constraint firstAttribute="height" constant="56" id="2xR-RQ-MBH"/>
</constraints>
<items>
<tabBarItem title="Video" id="BkO-Yq-m1c" customClass="BottomNavigationBarItem" customModule="Material"/>
<tabBarItem title="Photo" id="vsG-AI-jYq" customClass="BottomNavigationBarItem" customModule="Material"/>
......
......@@ -41,7 +41,7 @@ class MainViewController: UIViewController {
let fabButton: FabButton = FabButton()
fabButton.setImage(img, forState: .Normal)
fabButton.setImage(img, forState: .Highlighted)
fabButton.addTarget(self, action: "handleFabButton", forControlEvents: .TouchUpInside)
fabButton.addTarget(self, action: #selector(handleFabButton), forControlEvents: .TouchUpInside)
view.addSubview(fabButton)
fabButton.translatesAutoresizingMaskIntoConstraints = false
......
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '1.37.3'
s.version = '1.38.0'
s.license = 'BSD'
s.summary = 'Express your creativity with Material, an animation and graphics framework for Google\'s Material Design and Apple\'s Flat UI in Swift.'
s.homepage = 'http://cosmicmind.io'
......
......@@ -109,6 +109,8 @@ Material is a growing project and will encounter changes throughout its developm
* [ToolbarController](#toolbarcontroller)
* [SearchBar](#searchbar)
* [SearchBarController](#searchbarcontroller)
* BottomNavigationBar
* BottomNavigationController
* [SideNavigationController](#sidenavigationcontroller)
#### Photo / Video Camera
......
......@@ -198,15 +198,16 @@ public class BottomNavigationBar : UITabBar {
if let v: Array<UITabBarItem> = items {
for item in v {
if nil == item.title {
item.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0)
item.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0)
} else {
item.titlePositionAdjustment.vertical = -8
item.titlePositionAdjustment.vertical = -5
}
}
}
if translatesAutoresizingMaskIntoConstraints {
if let v: UIView = superview {
frame = CGRectMake(0, v.bounds.height - 56, v.bounds.width, 56)
let h: CGFloat = intrinsicContentSize().height
frame = CGRectMake(0, v.bounds.height - h, v.bounds.width, h)
}
}
}
......@@ -221,8 +222,9 @@ public class BottomNavigationBar : UITabBar {
public func prepareView() {
depth = .Depth1
backgroundColor = MaterialColor.white
shadowImage = UIImage.imageWithColor(MaterialColor.clear, size: CGSizeMake(1, 1))
backgroundImage = UIImage()
let image: UIImage? = UIImage.imageWithColor(MaterialColor.clear, size: CGSizeMake(1, 1))
shadowImage = image
backgroundImage = image
}
}
......
......@@ -30,8 +30,39 @@
import UIKit
public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControllerAnimatedTransitioning {
public func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let fromView : UIView = transitionContext.viewForKey(UITransitionContextFromViewKey)!
let toView : UIView = transitionContext.viewForKey(UITransitionContextToViewKey)!
toView.alpha = 0
transitionContext.containerView()!.addSubview(fromView)
transitionContext.containerView()!.addSubview(toView)
UIView.animateWithDuration(transitionDuration(transitionContext),
animations: { _ in
toView.alpha = 1
fromView.alpha = 0
}) { _ in
transitionContext.completeTransition(true)
}
}
public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
return 0.35
}
}
public enum BottomNavigationTransitionAnimation {
case None
case Fade
}
@IBDesignable
public class BottomNavigationController : UITabBarController {
public class BottomNavigationController : UITabBarController, UITabBarControllerDelegate {
/// The transition animation to use when selecting a new tab.
public var transitionAnimation: BottomNavigationTransitionAnimation = .Fade
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......@@ -60,16 +91,20 @@ public class BottomNavigationController : UITabBarController {
}
public func layoutSubviews() {
tabBar.frame = CGRectMake(0, view.bounds.height - 56, view.bounds.width, 56)
if let v: Array<UITabBarItem> = tabBar.items {
for item in v {
if nil == item.title {
item.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0)
item.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0)
} else {
item.titlePositionAdjustment.vertical = -8
item.titlePositionAdjustment.vertical = -5
}
}
}
if let v: Array<UIViewController> = viewControllers {
for controller in v {
controller.edgesForExtendedLayout = .None
}
}
}
/**
......@@ -80,9 +115,14 @@ public class BottomNavigationController : UITabBarController {
when subclassing.
*/
public func prepareView() {
delegate = self
tabBar.depth = .Depth1
tabBar.backgroundColor = MaterialColor.white
tabBar.shadowImage = UIImage.imageWithColor(MaterialColor.clear, size: CGSizeMake(1, 1))
tabBar.backgroundImage = UIImage()
}
public func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return .Fade == transitionAnimation ? BottomNavigationFadeAnimatedTransitioning() : nil
}
}
......@@ -128,7 +128,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
if tapToFocusEnabled {
tapToResetEnabled = true
prepareFocusLayer()
prepareTapGesture(&tapToFocusGesture, numberOfTapsRequired: 1, numberOfTouchesRequired: 1, selector: "handleTapToFocusGesture:")
prepareTapGesture(&tapToFocusGesture, numberOfTapsRequired: 1, numberOfTouchesRequired: 1, selector: #selector(handleTapToFocusGesture(_:)))
if let v: UITapGestureRecognizer = tapToExposeGesture {
tapToFocusGesture!.requireGestureRecognizerToFail(v)
}
......@@ -148,7 +148,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
if tapToExposeEnabled {
tapToResetEnabled = true
prepareExposureLayer()
prepareTapGesture(&tapToExposeGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 1, selector: "handleTapToExposeGesture:")
prepareTapGesture(&tapToExposeGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 1, selector: #selector(handleTapToExposeGesture(_:)))
if let v: UITapGestureRecognizer = tapToFocusGesture {
v.requireGestureRecognizerToFail(tapToExposeGesture!)
}
......@@ -167,7 +167,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
didSet {
if tapToResetEnabled {
prepareResetLayer()
prepareTapGesture(&tapToResetGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 2, selector: "handleTapToResetGesture:")
prepareTapGesture(&tapToResetGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 2, selector: #selector(handleTapToResetGesture(_:)))
if let v: UITapGestureRecognizer = tapToFocusGesture {
v.requireGestureRecognizerToFail(tapToResetGesture!)
}
......@@ -231,7 +231,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
public var cameraButton: UIButton? {
didSet {
if let v: UIButton = cameraButton {
v.addTarget(self, action: "handleCameraButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: #selector(handleCameraButton), forControlEvents: .TouchUpInside)
}
reloadView()
}
......@@ -243,7 +243,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
public var captureButton: UIButton? {
didSet {
if let v: UIButton = captureButton {
v.addTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: #selector(handleCaptureButton), forControlEvents: .TouchUpInside)
}
reloadView()
}
......@@ -256,7 +256,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
public var videoButton: UIButton? {
didSet {
if let v: UIButton = videoButton {
v.addTarget(self, action: "handleVideoButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: #selector(handleVideoButton), forControlEvents: .TouchUpInside)
}
reloadView()
}
......@@ -268,7 +268,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
public var switchCamerasButton: UIButton? {
didSet {
if let v: UIButton = switchCamerasButton {
v.addTarget(self, action: "handleSwitchCamerasButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: #selector(handleSwitchCamerasButton), forControlEvents: .TouchUpInside)
}
}
}
......@@ -279,7 +279,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
public var flashButton: UIButton? {
didSet {
if let v: UIButton = flashButton {
v.addTarget(self, action: "handleFlashButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: #selector(handleFlashButton), forControlEvents: .TouchUpInside)
}
}
}
......@@ -354,7 +354,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
*/
internal func startTimer() {
timer?.invalidate()
timer = NSTimer(timeInterval: 0.5, target: self, selector: "updateTimer", userInfo: nil, repeats: true)
timer = NSTimer(timeInterval: 0.5, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true)
NSRunLoop.mainRunLoop().addTimer(timer!, forMode: NSRunLoopCommonModes)
(delegate as? CaptureViewDelegate)?.captureViewDidStartRecordTimer?(self)
}
......@@ -437,6 +437,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/**
:name: handleTapToFocusGesture
*/
@objc(handleTapToFocusGesture:)
internal func handleTapToFocusGesture(recognizer: UITapGestureRecognizer) {
if tapToFocusEnabled && captureSession.cameraSupportsTapToFocus {
let point: CGPoint = recognizer.locationInView(self)
......@@ -449,6 +450,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/**
:name: handleTapToExposeGesture
*/
@objc(handleTapToExposeGesture:)
internal func handleTapToExposeGesture(recognizer: UITapGestureRecognizer) {
if tapToExposeEnabled && captureSession.cameraSupportsTapToExpose {
let point: CGPoint = recognizer.locationInView(self)
......@@ -461,6 +463,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/**
:name: handleTapToResetGesture
*/
@objc(handleTapToResetGesture:)
internal func handleTapToResetGesture(recognizer: UITapGestureRecognizer) {
if tapToResetEnabled {
captureSession.resetFocusAndExposureModes()
......
......@@ -338,16 +338,12 @@ public class MaterialSwitch : UIControl {
}
}
/// Handles the TouchUpInside event.
internal func handleTouchUpInside() {
toggle()
}
/**
Handle the TouchUpOutside and TouchCancel events.
- Parameter sender: A UIButton.
- Parameter event: A UIEvent.
*/
@objc(handleTouchUpOutsideOrCanceled:event:)
internal func handleTouchUpOutsideOrCanceled(sender: FabButton, event: UIEvent) {
if let v: UITouch = event.touchesForView(sender)?.first {
let q: CGFloat = sender.x + v.locationInView(sender).x - v.previousLocationInView(sender).x
......@@ -355,11 +351,17 @@ public class MaterialSwitch : UIControl {
}
}
/// Handles the TouchUpInside event.
internal func handleTouchUpInside() {
toggle()
}
/**
Handle the TouchDragInside event.
- Parameter sender: A UIButton.
- Parameter event: A UIEvent.
*/
@objc(handleTouchDragInside:event:)
internal func handleTouchDragInside(sender: FabButton, event: UIEvent) {
if let v = event.touchesForView(sender)?.first {
let q: CGFloat = max(min(sender.x + v.locationInView(sender).x - v.previousLocationInView(sender).x, onPosition), offPosition)
......@@ -383,10 +385,10 @@ public class MaterialSwitch : UIControl {
/// Prepares the button.
private func prepareButton() {
button.pulseColor = nil
button.addTarget(self, action: "handleTouchUpOutsideOrCanceled:event:", forControlEvents: .TouchUpOutside)
button.addTarget(self, action: "handleTouchUpInside", forControlEvents: .TouchUpInside)
button.addTarget(self, action: "handleTouchDragInside:event:", forControlEvents: .TouchDragInside)
button.addTarget(self, action: "handleTouchUpOutsideOrCanceled:event:", forControlEvents: .TouchCancel)
button.addTarget(self, action: #selector(handleTouchUpInside), forControlEvents: .TouchUpInside)
button.addTarget(self, action: #selector(handleTouchDragInside(_: _:), forControlEvents: .TouchDragInside)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled(_: _:)), forControlEvents: .TouchCancel)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled(_: _:)), forControlEvents: .TouchUpOutside)
addSubview(button)
}
......
......@@ -40,51 +40,51 @@ public enum MenuDirection {
public class Menu {
/// A Boolean that indicates if the menu is open or not.
public private(set) var opened: Bool = false
/// The rectangular bounds that the menu animates.
public var origin: CGPoint {
didSet {
reloadLayout()
}
}
/// A preset wrapper around spacing.
public var spacingPreset: MaterialSpacing = .None {
didSet {
spacing = MaterialSpacingToValue(spacingPreset)
}
}
/// The space between views.
public var spacing: CGFloat {
didSet {
reloadLayout()
}
}
/// Enables the animations for the Menu.
public var enabled: Bool = true
/// The direction in which the animation opens the menu.
public var direction: MenuDirection = .Up {
didSet {
reloadLayout()
}
}
/// An Array of UIViews.
public var views: Array<UIView>? {
didSet {
reloadLayout()
}
}
/// Size of views, not including the first view.
public var itemViewSize: CGSize = CGSizeMake(48, 48)
/// An Optional base view size.
public var baseViewSize: CGSize?
/**
Initializer.
- Parameter origin: The origin position of the Menu.
......@@ -94,13 +94,13 @@ public class Menu {
self.origin = origin
self.spacing = spacing
}
/// Reload the view layout.
public func reloadLayout() {
opened = false
layoutButtons()
}
/**
Open the Menu component with animation options.
- Parameter duration: The time for each view's animation.
......@@ -126,7 +126,7 @@ public class Menu {
}
}
}
/**
Close the Menu component with animation options.
- Parameter duration: The time for each view's animation.
......@@ -152,7 +152,7 @@ public class Menu {
}
}
}
/**
Open the Menu component with animation options in the Up direction.
- Parameter duration: The time for each view's animation.
......@@ -166,13 +166,13 @@ public class Menu {
private func openUpAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
var base: UIView?
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
if nil == base {
base = v[0]
}
let view: UIView = v[i]
view.hidden = false
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
usingSpringWithDamping: usingSpringWithDamping,
......@@ -190,7 +190,7 @@ public class Menu {
opened = true
}
}
/**
Close the Menu component with animation options in the Up direction.
- Parameter duration: The time for each view's animation.
......@@ -203,9 +203,9 @@ public class Menu {
*/
public func closeUpAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
let view: UIView = v[i]
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
usingSpringWithDamping: usingSpringWithDamping,
......@@ -224,7 +224,7 @@ public class Menu {
opened = false
}
}
/**
Open the Menu component with animation options in the Down direction.
- Parameter duration: The time for each view's animation.
......@@ -238,14 +238,14 @@ public class Menu {
private func openDownAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
var base: UIView?
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
if nil == base {
base = v[0]
}
let view: UIView = v[i]
view.hidden = false
let h: CGFloat = nil == baseViewSize ? itemViewSize.height : baseViewSize!.height
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
......@@ -264,7 +264,7 @@ public class Menu {
opened = true
}
}
/**
Close the Menu component with animation options in the Down direction.
- Parameter duration: The time for each view's animation.
......@@ -277,9 +277,9 @@ public class Menu {
*/
public func closeDownAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
let view: UIView = v[i]
let h: CGFloat = nil == baseViewSize ? itemViewSize.height : baseViewSize!.height
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
......@@ -299,7 +299,7 @@ public class Menu {
opened = false
}
}
/**
Open the Menu component with animation options in the Left direction.
- Parameter duration: The time for each view's animation.
......@@ -313,14 +313,14 @@ public class Menu {
private func openLeftAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
var base: UIView?
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
if nil == base {
base = v[0]
}
let view: UIView = v[i]
view.hidden = false
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
usingSpringWithDamping: usingSpringWithDamping,
......@@ -338,7 +338,7 @@ public class Menu {
opened = true
}
}
/**
Close the Menu component with animation options in the Left direction.
- Parameter duration: The time for each view's animation.
......@@ -351,7 +351,7 @@ public class Menu {
*/
public func closeLeftAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
let view: UIView = v[i]
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
......@@ -371,7 +371,7 @@ public class Menu {
opened = false
}
}
/**
Open the Menu component with animation options in the Right direction.
- Parameter duration: The time for each view's animation.
......@@ -385,13 +385,13 @@ public class Menu {
private func openRightAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
var base: UIView?
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
if nil == base {
base = v[0]
}
let view: UIView = v[i]
view.hidden = false
let h: CGFloat = nil == baseViewSize ? itemViewSize.height : baseViewSize!.height
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
......@@ -410,7 +410,7 @@ public class Menu {
opened = true
}
}
/**
Close the Menu component with animation options in the Right direction.
- Parameter duration: The time for each view's animation.
......@@ -423,9 +423,9 @@ public class Menu {
*/
public func closeRightAnimation(duration: NSTimeInterval, delay: NSTimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
if let v: Array<UIView> = views {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
for i in 1..<v.count {
let view: UIView = v[i]
let w: CGFloat = nil == baseViewSize ? itemViewSize.width : baseViewSize!.width
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
......@@ -445,12 +445,12 @@ public class Menu {
opened = false
}
}
/// Layout the views.
private func layoutButtons() {
if let v: Array<UIView> = views {
let size: CGSize = nil == baseViewSize ? itemViewSize : baseViewSize!
for var i: Int = 0, l: Int = v.count; i < l; ++i {
for i in 0..<v.count {
let view: UIView = v[i]
if 0 == i {
view.frame.size = size
......@@ -467,7 +467,7 @@ public class Menu {
}
}
}
/// Disable the Menu if views exist.
private func disable() {
if let v: Array<UIView> = views {
......@@ -476,7 +476,7 @@ public class Menu {
}
}
}
/**
Enable the Menu if the last view is equal to the passed in view.
- Parameter view: UIView that is passed in to compare.
......@@ -488,4 +488,4 @@ public class Menu {
}
}
}
}
\ No newline at end of file
}
......@@ -115,8 +115,8 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
} else {
item.leftControls = [v.backButton]
}
v.backButton.removeTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside)
v.backButton.addTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside)
v.backButton.removeTarget(self, action: #selector(handleBackButton), forControlEvents: .TouchUpInside)
v.backButton.addTarget(self, action: #selector(handleBackButton), forControlEvents: .TouchUpInside)
v.layoutNavigationItem(item)
}
return true
......
......@@ -615,6 +615,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
- Parameter recognizer: A UIPanGestureRecognizer that is
passed to the handler when recognized.
*/
@objc(handlePanGesture:)
internal func handlePanGesture(recognizer: UIPanGestureRecognizer) {
// Deterine which view to pan.
if enabledRightView && (openedRightView || !openedLeftView && isPointContainedWithinRightViewThreshold(recognizer.locationInView(view))) {
......@@ -700,6 +701,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
- Parameter recognizer: A UITapGestureRecognizer that is
passed to the handler when recognized.
*/
@objc(handleTapGesture:)
internal func handleTapGesture(recognizer: UITapGestureRecognizer) {
if openedLeftView {
if let v: MaterialView = leftView {
......@@ -807,13 +809,13 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
*/
private func prepareGestures() {
if nil == panGesture {
panGesture = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture(_:)))
panGesture!.delegate = self
view.addGestureRecognizer(panGesture!)
}
if nil == tapGesture {
tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:")
tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture(_:)))
tapGesture!.delegate = self
tapGesture!.cancelsTouchesInView = false
view.addGestureRecognizer(tapGesture!)
......
......@@ -282,7 +282,7 @@ public class TextField : UITextField {
clearButtonMode = .Never
rightViewMode = .WhileEditing
v.contentEdgeInsets = UIEdgeInsetsZero
v.addTarget(self, action: "handleClearButton", forControlEvents: .TouchUpInside)
v.addTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside)
} else {
clearButtonMode = .WhileEditing
rightViewMode = .Never
......@@ -681,9 +681,9 @@ public class TextField : UITextField {
} else {
v.alpha = 0
}
addTarget(self, action: "textFieldDidBegin", forControlEvents: .EditingDidBegin)
addTarget(self, action: "textFieldDidChange", forControlEvents: .EditingChanged)
addTarget(self, action: "textFieldDidEnd", forControlEvents: .EditingDidEnd)
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd)
}
}
......@@ -698,11 +698,11 @@ public class TextField : UITextField {
showDetailLabel()
}
if nil == titleLabel {
addTarget(self, action: "textFieldDidBegin", forControlEvents: .EditingDidBegin)
addTarget(self, action: "textFieldDidChange", forControlEvents: .EditingChanged)
addTarget(self, action: "textFieldDidEnd", forControlEvents: .EditingDidEnd)
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd)
}
addTarget(self, action: "textFieldValueChanged", forControlEvents: .ValueChanged)
addTarget(self, action: #selector(textFieldValueChanged), forControlEvents: .ValueChanged)
}
}
......
......@@ -589,9 +589,9 @@ public class TextView: UITextView {
/// Prepares the Notification handlers.
private func prepareNotificationHandlers() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidBegin", name: UITextViewTextDidBeginEditingNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidChange", name: UITextViewTextDidChangeNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidEnd", name: UITextViewTextDidEndEditingNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(handleTextViewTextDidBegin), name: UITextViewTextDidBeginEditingNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(handleTextViewTextDidChange), name: UITextViewTextDidChangeNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(handleTextViewTextDidEnd), name: UITextViewTextDidEndEditingNotification, object: nil)
}
/// Removes the Notification handlers.
......
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