Commit 77143ea2 by Daniel Dahan

updated example projects for new NavigationBar, Toolbar, and SearchBar

parent 01fe9110
......@@ -18,8 +18,6 @@
9663F94C1C7A74C700AF0965 /* AppMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94B1C7A74C700AF0965 /* AppMenuViewController.swift */; };
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
9663F9521C7A751D00AF0965 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* ItemViewController.swift */; };
9692C91F1CE4303F008C2766 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9692C91E1CE4303F008C2766 /* Material.framework */; };
9692C9201CE4303F008C2766 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9692C91E1CE4303F008C2766 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; };
/* End PBXBuildFile section */
......@@ -30,7 +28,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
9692C9201CE4303F008C2766 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -51,7 +48,6 @@
9663F94B1C7A74C700AF0965 /* AppMenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMenuViewController.swift; sourceTree = "<group>"; };
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; };
9663F9511C7A751D00AF0965 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; };
9692C91E1CE4303F008C2766 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/CosmicMind-hgvxkqfizbxkrsfcxbtlafgqkbve/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -60,7 +56,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9692C91F1CE4303F008C2766 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -70,7 +65,6 @@
9663F9251C7A744500AF0965 = {
isa = PBXGroup;
children = (
9692C91E1CE4303F008C2766 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */,
);
......
......@@ -33,29 +33,29 @@ import Material
class AppNavigationController: NavigationController {
/// StatusBar color reference.
private var statusBarView: MaterialView?
// private var statusBarView: MaterialView?
override func viewDidLoad() {
super.viewDidLoad()
prepareStatusBarView()
// prepareStatusBarView()
prepareNavigationBar()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
statusBarView?.hidden = MaterialDevice.statusBarHidden
// statusBarView?.hidden = MaterialDevice.statusBarHidden
}
/// Prepares the statusBarView
private func prepareStatusBarView() {
statusBarView = MaterialView()
statusBarView!.backgroundColor = MaterialColor.blue.darken2
view.addSubview(statusBarView!)
MaterialLayout.alignFromTop(view, child: statusBarView!)
MaterialLayout.alignToParentHorizontally(view, child: statusBarView!)
MaterialLayout.height(view, child: statusBarView!, height: 20)
}
// private func prepareStatusBarView() {
// statusBarView = MaterialView()
// statusBarView!.backgroundColor = MaterialColor.blue.darken2
//
// view.addSubview(statusBarView!)
// MaterialLayout.alignFromTop(view, child: statusBarView!)
// MaterialLayout.alignToParentHorizontally(view, child: statusBarView!)
// MaterialLayout.height(view, child: statusBarView!, height: 20)
// }
/// Prepares the navigationBar
private func prepareNavigationBar() {
......
......@@ -78,6 +78,16 @@ class ItemViewController: UIViewController {
// Stops the scrollView contentInsets from being automatically adjusted.
automaticallyAdjustsScrollViewInsets = false
// Customize the navigationItem.backButton image here.
// (navigationController?.navigationBar as? NavigationBar)?.backButtonImage = MaterialIcon.cm.audioLibrary
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// Access the navigationItem.backButton here.
// navigationItem.backButton
}
override func viewWillLayoutSubviews() {
......@@ -111,11 +121,11 @@ class ItemViewController: UIViewController {
/// Prepares the navigationItem.
private func prepareNavigationItem() {
navigationItem.titleLabel.text = "Itempppyyggg"
navigationItem.titleLabel.text = "Item"
navigationItem.titleLabel.textAlignment = .Left
navigationItem.titleLabel.textColor = MaterialColor.white
navigationItem.detailLabel.text = "January 22pppyyyggg, 2016"
navigationItem.detailLabel.text = "January 22, 2016"
navigationItem.detailLabel.textAlignment = .Left
navigationItem.detailLabel.textColor = MaterialColor.white
......@@ -141,11 +151,11 @@ class ItemViewController: UIViewController {
imageCardView.cornerRadiusPreset = .None
imageCardView.maxImageHeight = 300
// imageCardView.titleLabel = UILabel()
// imageCardView.titleLabel?.text = data["title"] as? String
// imageCardView.titleLabel?.textColor = MaterialColor.grey.darken4
// imageCardView.titleLabel?.font = RobotoFont.regularWithSize(20)
//
imageCardView.titleLabel = UILabel()
imageCardView.titleLabel?.text = data["title"] as? String
imageCardView.titleLabel?.textColor = MaterialColor.grey.darken4
imageCardView.titleLabel?.font = RobotoFont.regularWithSize(20)
let detailLabel: UILabel = UILabel()
detailLabel.text = data["detail"] as? String
detailLabel.textColor = MaterialColor.grey.darken2
......@@ -154,11 +164,12 @@ class ItemViewController: UIViewController {
imageCardView.contentView = detailLabel
imageCardView.contentViewInset.top = 52
//
// let image: UIImage? = UIImage(named: data["image"] as! String)
// imageCardView.image = image
let image: UIImage? = UIImage(named: data["image"] as! String)
imageCardView.image = image
scrollView.addSubview(imageCardView)
imageCardView.translatesAutoresizingMaskIntoConstraints = false
}
}
}
......@@ -244,8 +244,9 @@ class RecipesViewController: UIViewController {
/// Prepares the navigationItem.
private func prepareNavigationItem() {
navigationItem.titleLabel.text = "Recipesqqggyy"
navigationItem.titleLabel.text = "Recipes"
navigationItem.titleLabel.textColor = MaterialColor.white
navigationItem.titleLabel.font = RobotoFont.mediumWithSize(20)
navigationItem.leftControls = [menuButton]
navigationItem.rightControls = [switchControl, searchButton]
......
......@@ -11,8 +11,6 @@
96F2F1F51C97A60800A5FE27 /* AppSearchBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1EC1C97A60800A5FE27 /* AppSearchBarController.swift */; };
96F2F1F61C97A60800A5FE27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1ED1C97A60800A5FE27 /* Assets.xcassets */; };
96F2F1F71C97A60800A5FE27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1EE1C97A60800A5FE27 /* LaunchScreen.storyboard */; };
96F2F1F81C97A60800A5FE27 /* BlueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1F01C97A60800A5FE27 /* BlueViewController.swift */; };
96F2F1F91C97A60800A5FE27 /* GreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1F11C97A60800A5FE27 /* GreenViewController.swift */; };
96F2F1FB1C97A60800A5FE27 /* YellowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1F31C97A60800A5FE27 /* YellowViewController.swift */; };
/* End PBXBuildFile section */
......@@ -35,8 +33,6 @@
96F2F1EC1C97A60800A5FE27 /* AppSearchBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppSearchBarController.swift; sourceTree = "<group>"; };
96F2F1ED1C97A60800A5FE27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96F2F1EF1C97A60800A5FE27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96F2F1F01C97A60800A5FE27 /* BlueViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueViewController.swift; sourceTree = "<group>"; };
96F2F1F11C97A60800A5FE27 /* GreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GreenViewController.swift; sourceTree = "<group>"; };
96F2F1F21C97A60800A5FE27 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96F2F1F31C97A60800A5FE27 /* YellowViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YellowViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -73,8 +69,6 @@
children = (
96F2F1EB1C97A60800A5FE27 /* AppDelegate.swift */,
96F2F1EC1C97A60800A5FE27 /* AppSearchBarController.swift */,
96F2F1F01C97A60800A5FE27 /* BlueViewController.swift */,
96F2F1F11C97A60800A5FE27 /* GreenViewController.swift */,
96F2F1F31C97A60800A5FE27 /* YellowViewController.swift */,
96F2F1ED1C97A60800A5FE27 /* Assets.xcassets */,
96F2F1EE1C97A60800A5FE27 /* LaunchScreen.storyboard */,
......@@ -154,9 +148,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96F2F1F91C97A60800A5FE27 /* GreenViewController.swift in Sources */,
96F2F1F51C97A60800A5FE27 /* AppSearchBarController.swift in Sources */,
96F2F1F81C97A60800A5FE27 /* BlueViewController.swift in Sources */,
96F2F1F41C97A60800A5FE27 /* AppDelegate.swift in Sources */,
96F2F1FB1C97A60800A5FE27 /* YellowViewController.swift in Sources */,
);
......
......@@ -43,31 +43,6 @@ class AppSearchBarController: SearchBarController {
prepareSearchBar()
}
/// Loads the BlueViewController into the searchBarControllers rootViewController.
func handleBlueButton() {
if rootViewController is BlueViewController {
return
}
transitionFromRootViewController(BlueViewController(), options: [.TransitionCrossDissolve])
}
/// Loads the GreenViewController into the searchBarControllers rootViewController.
func handleGreenButton() {
if rootViewController is GreenViewController {
return
}
transitionFromRootViewController(GreenViewController(), options: [.TransitionCrossDissolve])
}
/// Loads the YellowViewController into the searchBarControllers rootViewController.
func handleYellowButton() {
if (rootViewController as? ToolbarController)?.rootViewController is YellowViewController {
return
}
transitionFromRootViewController(YellowViewController(), options: [.TransitionCrossDissolve])
searchBar.textField.resignFirstResponder()
}
/// Prepares view.
override func prepareView() {
super.prepareView()
......@@ -83,7 +58,6 @@ class AppSearchBarController: SearchBarController {
backButton.tintColor = MaterialColor.blueGrey.darken4
backButton.setImage(image, forState: .Normal)
backButton.setImage(image, forState: .Highlighted)
backButton.addTarget(self, action: #selector(handleBlueButton), forControlEvents: .TouchUpInside)
// More button.
image = MaterialIcon.cm.moreHorizontal
......@@ -91,7 +65,6 @@ class AppSearchBarController: SearchBarController {
moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted)
moreButton.addTarget(self, action: #selector(handleGreenButton), forControlEvents: .TouchUpInside)
/*
To lighten the status bar - add the
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of 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 BlueViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.blue.base
}
}
/*
* 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 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 GreenViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.green.base
}
}
......@@ -33,6 +33,7 @@
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
......
......@@ -57,18 +57,12 @@ class ViewController: UIViewController {
toolbar = Toolbar()
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "Material"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regular
toolbar.titleLabel.text = "Material"
toolbar.titleLabel.textColor = MaterialColor.white
// Detail label.
let detailLabel: UILabel = UILabel()
detailLabel.text = "Build Beautiful Software"
detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regular
toolbar.detailLabel.text = "Build Beautiful Software"
toolbar.detailLabel.textColor = MaterialColor.white
var image: UIImage? = MaterialIcon.cm.menu
......@@ -97,8 +91,6 @@ class ViewController: UIViewController {
*/
toolbar.statusBarStyle = .LightContent
toolbar.backgroundColor = MaterialColor.blue.base
toolbar.titleLabel = titleLabel
toolbar.detailLabel = detailLabel
toolbar.leftControls = [menuButton]
toolbar.rightControls = [switchControl, searchButton]
......
......@@ -7,12 +7,11 @@
objects = {
/* Begin PBXBuildFile section */
9692C92A1CE44C0C008C2766 /* GreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9692C9281CE44C0C008C2766 /* GreenViewController.swift */; };
96F2F1D61C97A55B00A5FE27 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1CD1C97A55B00A5FE27 /* AppDelegate.swift */; };
96F2F1D71C97A55B00A5FE27 /* AppToolbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1CE1C97A55B00A5FE27 /* AppToolbarController.swift */; };
96F2F1D81C97A55B00A5FE27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1CF1C97A55B00A5FE27 /* Assets.xcassets */; };
96F2F1D91C97A55B00A5FE27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F1D01C97A55B00A5FE27 /* LaunchScreen.storyboard */; };
96F2F1DA1C97A55B00A5FE27 /* BlueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1D21C97A55B00A5FE27 /* BlueViewController.swift */; };
96F2F1DB1C97A55B00A5FE27 /* GreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1D31C97A55B00A5FE27 /* GreenViewController.swift */; };
96F2F1DD1C97A55B00A5FE27 /* YellowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F1D51C97A55B00A5FE27 /* YellowViewController.swift */; };
/* End PBXBuildFile section */
......@@ -30,13 +29,12 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
9692C9281CE44C0C008C2766 /* GreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GreenViewController.swift; sourceTree = "<group>"; };
96A71FC01C765FDF00C0C4AE /* ToolbarController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ToolbarController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96F2F1CD1C97A55B00A5FE27 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96F2F1CE1C97A55B00A5FE27 /* AppToolbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppToolbarController.swift; sourceTree = "<group>"; };
96F2F1CF1C97A55B00A5FE27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96F2F1D11C97A55B00A5FE27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96F2F1D21C97A55B00A5FE27 /* BlueViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueViewController.swift; sourceTree = "<group>"; };
96F2F1D31C97A55B00A5FE27 /* GreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GreenViewController.swift; sourceTree = "<group>"; };
96F2F1D41C97A55B00A5FE27 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96F2F1D51C97A55B00A5FE27 /* YellowViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YellowViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -73,8 +71,7 @@
children = (
96F2F1CD1C97A55B00A5FE27 /* AppDelegate.swift */,
96F2F1CE1C97A55B00A5FE27 /* AppToolbarController.swift */,
96F2F1D21C97A55B00A5FE27 /* BlueViewController.swift */,
96F2F1D31C97A55B00A5FE27 /* GreenViewController.swift */,
9692C9281CE44C0C008C2766 /* GreenViewController.swift */,
96F2F1D51C97A55B00A5FE27 /* YellowViewController.swift */,
96F2F1CF1C97A55B00A5FE27 /* Assets.xcassets */,
96F2F1D01C97A55B00A5FE27 /* LaunchScreen.storyboard */,
......@@ -154,11 +151,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96F2F1DB1C97A55B00A5FE27 /* GreenViewController.swift in Sources */,
96F2F1D71C97A55B00A5FE27 /* AppToolbarController.swift in Sources */,
96F2F1DA1C97A55B00A5FE27 /* BlueViewController.swift in Sources */,
96F2F1D61C97A55B00A5FE27 /* AppDelegate.swift in Sources */,
96F2F1DD1C97A55B00A5FE27 /* YellowViewController.swift in Sources */,
9692C92A1CE44C0C008C2766 /* GreenViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -59,14 +59,9 @@ class AppToolbarController: ToolbarController {
view.backgroundColor = MaterialColor.black
}
/// Toggle SideNavigationController left UIViewController.
internal func handleMenuButton() {
transitionFromRootViewController(GreenViewController(), options: [.TransitionCrossDissolve])
}
/// Toggle SideNavigationController right UIViewController.
internal func handleSearchButton() {
floatingViewController = BlueViewController()
floatingViewController = GreenViewController()
MaterialAnimation.delay(1.5) { [weak self] in
// Removes the ViewController from the view stack.
......@@ -77,32 +72,28 @@ class AppToolbarController: ToolbarController {
/// Prepares the toolbar.
private func prepareToolbar() {
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "Material"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regular
toolbar.titleLabel.text = "Material"
toolbar.titleLabel.textAlignment = .Left
toolbar.titleLabel.textColor = MaterialColor.white
toolbar.titleLabel.font = RobotoFont.regular
// Detail label. Uncomment the code below to use a detail label.
// let detailLabel: UILabel = UILabel()
// detailLabel.text = "Build Beautiful Software"
// detailLabel.textAlignment = .Left
// detailLabel.textColor = MaterialColor.white
// detailLabel.font = RobotoFont.regular
// toolbar.detailLabel = detailLabel
// toolbar.detailLabel.text = "Build Beautiful Software"
// toolbar.detailLabel.textAlignment = .Left
// toolbar.detailLabel.textColor = MaterialColor.white
// toolbar.detailLabel.font = RobotoFont.regular
var image: UIImage? = MaterialIcon.cm.menu
// Menu button.
let menuButton: IconButton = IconButton()
menuButton.tintColor = MaterialColor.white
menuButton.pulseColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted)
menuButton.addTarget(self, action: #selector(handleMenuButton), forControlEvents: .TouchUpInside)
// Switch control.
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small)
switchControl.delegate = self
// Search button.
image = MaterialIcon.cm.search
......@@ -112,16 +103,8 @@ class AppToolbarController: ToolbarController {
searchButton.setImage(image, forState: .Highlighted)
searchButton.addTarget(self, action: #selector(handleSearchButton), forControlEvents: .TouchUpInside)
toolbar.backgroundColor = MaterialColor.blue.base
toolbar.titleLabel = titleLabel
toolbar.leftControls = [menuButton]
toolbar.rightControls = [switchControl, searchButton]
toolbar.backgroundColor = MaterialColor.blue.base
}
}
extension AppToolbarController: MaterialSwitchDelegate {
func materialSwitchStateChanged(control: MaterialSwitch) {
transitionFromRootViewController(YellowViewController(), options: [.TransitionCrossDissolve])
}
}
/*
* 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 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 BlueViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.blue.base
}
}
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
96D2D8B11CAC5482008AA4AA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D2D8B01CAC5482008AA4AA /* AppDelegate.swift */; };
96D2D8B31CAC5482008AA4AA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D2D8B21CAC5482008AA4AA /* ViewController.swift */; };
96D2D8B61CAC5482008AA4AA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96D2D8B41CAC5482008AA4AA /* Main.storyboard */; };
96D2D8B81CAC5482008AA4AA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D2D8B71CAC5482008AA4AA /* Assets.xcassets */; };
96D2D8BB1CAC5482008AA4AA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96D2D8B91CAC5482008AA4AA /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
96D2D8C51CAC54A9008AA4AA /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
96D2D8AD1CAC5482008AA4AA /* NavigationController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96D2D8B01CAC5482008AA4AA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96D2D8B21CAC5482008AA4AA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
96D2D8B51CAC5482008AA4AA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
96D2D8B71CAC5482008AA4AA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96D2D8BA1CAC5482008AA4AA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96D2D8BC1CAC5482008AA4AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
96D2D8AA1CAC5482008AA4AA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
96D2D8A41CAC5482008AA4AA = {
isa = PBXGroup;
children = (
96D2D8AF1CAC5482008AA4AA /* NavigationController */,
96D2D8AE1CAC5482008AA4AA /* Products */,
);
sourceTree = "<group>";
};
96D2D8AE1CAC5482008AA4AA /* Products */ = {
isa = PBXGroup;
children = (
96D2D8AD1CAC5482008AA4AA /* NavigationController.app */,
);
name = Products;
sourceTree = "<group>";
};
96D2D8AF1CAC5482008AA4AA /* NavigationController */ = {
isa = PBXGroup;
children = (
96D2D8B01CAC5482008AA4AA /* AppDelegate.swift */,
96D2D8B21CAC5482008AA4AA /* ViewController.swift */,
96D2D8B41CAC5482008AA4AA /* Main.storyboard */,
96D2D8B71CAC5482008AA4AA /* Assets.xcassets */,
96D2D8B91CAC5482008AA4AA /* LaunchScreen.storyboard */,
96D2D8BC1CAC5482008AA4AA /* Info.plist */,
);
path = NavigationController;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
96D2D8AC1CAC5482008AA4AA /* NavigationController */ = {
isa = PBXNativeTarget;
buildConfigurationList = 96D2D8BF1CAC5482008AA4AA /* Build configuration list for PBXNativeTarget "NavigationController" */;
buildPhases = (
96D2D8A91CAC5482008AA4AA /* Sources */,
96D2D8AA1CAC5482008AA4AA /* Frameworks */,
96D2D8AB1CAC5482008AA4AA /* Resources */,
96D2D8C51CAC54A9008AA4AA /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = NavigationController;
productName = NavigationController;
productReference = 96D2D8AD1CAC5482008AA4AA /* NavigationController.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
96D2D8A51CAC5482008AA4AA /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "CosmicMind, Inc.";
TargetAttributes = {
96D2D8AC1CAC5482008AA4AA = {
CreatedOnToolsVersion = 7.3;
};
};
};
buildConfigurationList = 96D2D8A81CAC5482008AA4AA /* Build configuration list for PBXProject "NavigationController" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 96D2D8A41CAC5482008AA4AA;
productRefGroup = 96D2D8AE1CAC5482008AA4AA /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
96D2D8AC1CAC5482008AA4AA /* NavigationController */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
96D2D8AB1CAC5482008AA4AA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96D2D8BB1CAC5482008AA4AA /* LaunchScreen.storyboard in Resources */,
96D2D8B81CAC5482008AA4AA /* Assets.xcassets in Resources */,
96D2D8B61CAC5482008AA4AA /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
96D2D8A91CAC5482008AA4AA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96D2D8B31CAC5482008AA4AA /* ViewController.swift in Sources */,
96D2D8B11CAC5482008AA4AA /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
96D2D8B41CAC5482008AA4AA /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
96D2D8B51CAC5482008AA4AA /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
96D2D8B91CAC5482008AA4AA /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
96D2D8BA1CAC5482008AA4AA /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
96D2D8BD1CAC5482008AA4AA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_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;
};
96D2D8BE1CAC5482008AA4AA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_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;
};
96D2D8C01CAC5482008AA4AA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = NavigationController/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.NavigationController;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
96D2D8C11CAC5482008AA4AA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = NavigationController/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.NavigationController;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
96D2D8A81CAC5482008AA4AA /* Build configuration list for PBXProject "NavigationController" */ = {
isa = XCConfigurationList;
buildConfigurations = (
96D2D8BD1CAC5482008AA4AA /* Debug */,
96D2D8BE1CAC5482008AA4AA /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
96D2D8BF1CAC5482008AA4AA /* Build configuration list for PBXNativeTarget "NavigationController" */ = {
isa = XCConfigurationList;
buildConfigurations = (
96D2D8C01CAC5482008AA4AA /* Debug */,
96D2D8C11CAC5482008AA4AA /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 96D2D8A51CAC5482008AA4AA /* Project object */;
}
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:NavigationController.xcodeproj">
</FileRef>
</Workspace>
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of 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
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
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:.
}
}
{
"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
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="3vT-XQ-F0b">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="VnK-O2-p3g">
<objects>
<navigationController id="3vT-XQ-F0b" customClass="NavigationController" customModule="Material" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="y1W-vf-i0D" customClass="NavigationBar" customModule="Material">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
<color key="value" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</navigationBar>
<connections>
<segue destination="1Pa-h7-2vi" kind="relationship" relationship="rootViewController" id="r6u-U1-TVx"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="AcS-D5-fxN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-809" y="554"/>
</scene>
<!--View Controller-->
<scene sceneID="wfS-wQ-VBd">
<objects>
<viewController id="1Pa-h7-2vi" customClass="ViewController" customModule="NavigationController" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="to9-NS-pFA"/>
<viewControllerLayoutGuide type="bottom" id="Psm-NS-6bN"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="4I1-xf-zSj">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="Jew-05-VYd"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ogd-7a-PgV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-119" y="554"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of 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
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
......@@ -78,20 +78,12 @@ class ViewController: UIViewController {
toolbar.statusBarStyle = .LightContent
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "Material"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regular
toolbar.titleLabel = titleLabel
toolbar.titleLabel.text = "Material"
toolbar.titleLabel.textColor = MaterialColor.white
// Detail label.
let detailLabel: UILabel = UILabel()
detailLabel.text = "Build Beautiful Software"
detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regular
toolbar.detailLabel = detailLabel
toolbar.detailLabel.text = "Build Beautiful Software"
toolbar.detailLabel.textColor = MaterialColor.white
// Menu button.
let img1: UIImage? = MaterialIcon.cm.menu
......
......@@ -143,42 +143,56 @@ public class ControlView : MaterialView {
public override func layoutSubviews() {
super.layoutSubviews()
if willRenderView {
// Size of single grid column.
if let g: CGFloat = width / CGFloat(0 < grid.axis.columns ? grid.axis.columns : 1) {
let factor: CGFloat = 24
if let g: Int = Int(width / factor) {
let columns: Int = g + 1
frame.origin = CGPointZero
frame.size = intrinsicContentSize()
grid.views = []
contentView.grid.views = []
contentView.grid.columns = grid.axis.columns
grid.axis.columns = columns
contentView.grid.columns = columns
// leftControls
if let v: Array<UIControl> = leftControls {
for c in v {
let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton {
b.contentEdgeInsets = UIEdgeInsetsZero
}
c.frame.size.height = height - contentInset.top - contentInset.bottom
c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
(c as? UIButton)?.contentEdgeInsets = UIEdgeInsetsZero
c.frame.size.height = frame.size.height - contentInset.top - contentInset.bottom
let q: Int = Int(w / factor)
c.grid.columns = q + 1
contentView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
}
}
addSubview(contentView)
grid.views?.append(contentView)
// rightControls
if let v: Array<UIControl> = rightControls {
for c in v {
let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton {
b.contentEdgeInsets = UIEdgeInsetsZero
}
c.frame.size.height = height - contentInset.top - contentInset.bottom
c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
(c as? UIButton)?.contentEdgeInsets = UIEdgeInsetsZero
c.frame.size.height = frame.size.height - contentInset.top - contentInset.bottom
let q: Int = Int(w / factor)
c.grid.columns = q + 1
contentView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
}
}
grid.contentInset = contentInset
grid.spacing = spacing
grid.reloadLayout()
}
}
......
......@@ -87,9 +87,6 @@ public class NavigationBar : UINavigationBar {
}
}
/// Reference to the backButton.
public private(set) lazy var backButton: IconButton = IconButton()
/**
The back button image writes to the backIndicatorImage property and
backIndicatorTransitionMaskImage property.
......@@ -99,11 +96,9 @@ public class NavigationBar : UINavigationBar {
return backIndicatorImage
}
set(value) {
let image: UIImage? = nil == value ? MaterialIcon.cm.arrowBack : value
let image: UIImage? = value
backIndicatorImage = image
backIndicatorTransitionMaskImage = image
backButton.setImage(image, forState: .Normal)
backButton.setImage(image, forState: .Highlighted)
}
}
......@@ -324,9 +319,9 @@ public class NavigationBar : UINavigationBar {
if let titleView: UIView = prepareTitleView(item) {
if let contentView: UIView = prepareContentView(item) {
let factor: CGFloat = 24
if let grid: Int = Int(width / factor) {
let columns: Int = grid + 1
if let g: Int = Int(width / factor) {
let columns: Int = g + 1
titleView.frame.origin = CGPointZero
titleView.frame.size = intrinsicContentSize()
titleView.grid.views = []
......@@ -424,26 +419,25 @@ public class NavigationBar : UINavigationBar {
spacingPreset = .Spacing1
contentInsetPreset = .Square1
contentScaleFactor = MaterialDevice.scale
prepareBackButton()
}
/// Prepares the backButton.
private func prepareBackButton() {
backButton.pulseColor = MaterialColor.white
backButton.setImage(backButtonImage, forState: .Normal)
backButton.setImage(backButtonImage, forState: .Highlighted)
backButtonImage = nil
backButtonImage = MaterialIcon.cm.arrowBack
let image: UIImage? = UIImage.imageWithColor(MaterialColor.clear, size: CGSizeMake(1, 1))
shadowImage = image
setBackgroundImage(image, forBarMetrics: .Default)
}
/// Prepares the item.
/**
Prepare the item by setting the title property to equal an empty string.
- Parameter item: A UINavigationItem to layout.
*/
private func prepareItem(item: UINavigationItem) {
item.title = ""
}
/// Prepare the titleView.
/**
Prepare the titleView.
- Parameter item: A UINavigationItem to layout.
- Returns: A UIView, which is the item.titleView.
*/
private func prepareTitleView(item: UINavigationItem) -> UIView {
if nil == item.titleView {
item.titleView = UIView(frame: CGRectZero)
......@@ -451,7 +445,11 @@ public class NavigationBar : UINavigationBar {
return item.titleView!
}
/// Prepare the contentView.
/**
Prepare the contentView.
- Parameter item: A UINavigationItem to layout.
- Returns: A UIView, which is the item.contentView.
*/
private func prepareContentView(item: UINavigationItem) -> UIView {
if nil == item.contentView {
item.contentView = UIView(frame: CGRectZero)
......
......@@ -114,15 +114,21 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
*/
public func navigationBar(navigationBar: UINavigationBar, shouldPushItem item: UINavigationItem) -> Bool {
if let v: NavigationBar = navigationBar as? NavigationBar {
item.hidesBackButton = true
let backButton: IconButton = IconButton()
backButton.pulseColor = MaterialColor.white
backButton.setImage(v.backButtonImage, forState: .Normal)
backButton.setImage(v.backButtonImage, forState: .Highlighted)
backButton.addTarget(self, action: #selector(handleBackButton), forControlEvents: .TouchUpInside)
if var c: Array<UIControl> = item.leftControls {
c.append(v.backButton)
c.append(backButton)
item.leftControls = c
} else {
item.leftControls = [v.backButton]
item.leftControls = [backButton]
}
v.backButton.removeTarget(self, action: #selector(handleBackButton), forControlEvents: .TouchUpInside)
v.backButton.addTarget(self, action: #selector(handleBackButton), forControlEvents: .TouchUpInside)
item.backButton = backButton
item.hidesBackButton = true
v.layoutNavigationItem(item)
}
return true
......
......@@ -34,7 +34,10 @@ import UIKit
private var MaterialAssociatedObjectNavigationItemKey: UInt8 = 0
public class MaterialAssociatedObjectNavigationItem {
/// Detail View.
/// Back Button.
public var backButton: IconButton?
/// Content View.
public var contentView: UIView?
/// Title label.
......@@ -86,7 +89,17 @@ public extension UINavigationItem {
}
}
/// Detail View.
/// Back Button.
public internal(set) var backButton: IconButton? {
get {
return item.backButton
}
set(value) {
item.backButton = value
}
}
/// Content View.
public internal(set) var contentView: UIView? {
get {
return item.contentView
......
......@@ -93,8 +93,7 @@ public class SearchBar : StatusBarView {
public override func layoutSubviews() {
super.layoutSubviews()
if willRenderView {
contentView.grid.views?.append(textField)
contentView.grid.reloadLayout()
textField.frame = contentView.bounds
layoutClearButton()
}
}
......
......@@ -32,72 +32,38 @@ import UIKit
public class Toolbar : StatusBarView {
/// Title label.
public var titleLabel: UILabel? {
didSet {
if let v: UILabel = titleLabel {
contentView.addSubview(v)
}
layoutSubviews()
}
}
public private(set) var titleLabel: UILabel!
/// Detail label.
public var detailLabel: UILabel? {
didSet {
if let v: UILabel = detailLabel {
contentView.addSubview(v)
}
layoutSubviews()
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
/**
A convenience initializer with parameter settings.
- Parameter titleLabel: UILabel for the title.
- Parameter detailLabel: UILabel for the details.
- Parameter leftControls: An Array of UIControls that go on the left side.
- Parameter rightControls: An Array of UIControls that go on the right side.
*/
public init(titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, leftControls: Array<UIControl>? = nil, rightControls: Array<UIControl>? = nil) {
super.init(frame: CGRectZero)
prepareProperties(titleLabel, detailLabel: detailLabel, leftControls: leftControls, rightControls: rightControls)
}
public private(set) var detailLabel: UILabel!
public override func layoutSubviews() {
super.layoutSubviews()
if willRenderView {
contentView.grid.views = []
// TitleView alignment.
if let t: UILabel = titleLabel {
t.grid.rows = 1
contentView.grid.views?.append(t)
if let _: String = titleLabel.text {
if nil == titleLabel.superview {
contentView.addSubview(titleLabel)
}
if let d: UILabel = detailLabel {
t.font = t.font.fontWithSize(17)
if let _: String = detailLabel.text {
if nil == detailLabel.superview {
contentView.addSubview(detailLabel)
}
d.grid.rows = 1
d.font = d.font.fontWithSize(12)
contentView.grid.axis.rows = 2
contentView.grid.views?.append(d)
titleLabel.sizeToFit()
detailLabel.sizeToFit()
let diff: CGFloat = (contentView.frame.height - titleLabel.frame.height - detailLabel.frame.height) / 2
titleLabel.frame.size.height += diff
detailLabel.frame.size.height += diff
detailLabel.frame.origin.y = titleLabel.frame.height
} else {
t.font = t.font?.fontWithSize(20)
contentView.grid.axis.rows = 1
detailLabel.removeFromSuperview()
titleLabel.frame = contentView.bounds
}
} else {
titleLabel.removeFromSuperview()
contentView.grid.reloadLayout()
}
grid.reloadLayout()
contentView.grid.reloadLayout()
}
}
......@@ -110,19 +76,21 @@ public class Toolbar : StatusBarView {
*/
public override func prepareView() {
super.prepareView()
contentView.grid.axis.direction = .Vertical
prepareTitleLabel()
prepareDetailLabel()
}
/**
Used to trigger property changes that initializers avoid.
- Parameter titleLabel: UILabel for the title.
- Parameter detailLabel: UILabel for the details.
- Parameter leftControls: An Array of UIControls that go on the left side.
- Parameter rightControls: An Array of UIControls that go on the right side.
*/
internal func prepareProperties(titleLabel: UILabel?, detailLabel: UILabel?, leftControls: Array<UIControl>?, rightControls: Array<UIControl>?) {
prepareProperties(leftControls, rightControls: rightControls)
self.titleLabel = titleLabel
self.detailLabel = detailLabel
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.font = RobotoFont.mediumWithSize(17)
titleLabel.textAlignment = .Left
}
/// Prepares the detailLabel.
private func prepareDetailLabel() {
detailLabel = UILabel()
detailLabel.font = RobotoFont.regularWithSize(12)
detailLabel.textAlignment = .Left
}
}
\ No newline at end of file
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