Commit 7cccc6ec by Daniel Dahan

added a demonstration of how to eliminate the animation when hiding the…

added a demonstration of how to eliminate the animation when hiding the statusBar in the App example project
parent b5da540b
......@@ -19,7 +19,6 @@
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9491C7A74B500AF0965 /* AppSearchBarViewController.swift */; };
9663F94C1C7A74C700AF0965 /* AppMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94B1C7A74C700AF0965 /* AppMenuViewController.swift */; };
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; };
9663F9521C7A751D00AF0965 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* ItemViewController.swift */; };
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; };
/* End PBXBuildFile section */
......@@ -52,7 +51,6 @@
9663F9491C7A74B500AF0965 /* AppSearchBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppSearchBarViewController.swift; sourceTree = "<group>"; };
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>"; };
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; };
9663F9511C7A751D00AF0965 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; };
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -94,7 +92,6 @@
9663F9491C7A74B500AF0965 /* AppSearchBarViewController.swift */,
9663F94B1C7A74C700AF0965 /* AppMenuViewController.swift */,
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */,
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */,
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */,
9663F9331C7A744600AF0965 /* RecommendationViewController.swift */,
9663F9511C7A751D00AF0965 /* ItemViewController.swift */,
......@@ -180,7 +177,6 @@
files = (
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */,
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */,
9663F9481C7A749400AF0965 /* AppNavigationController.swift in Sources */,
9663F9341C7A744600AF0965 /* RecommendationViewController.swift in Sources */,
9663F94C1C7A74C700AF0965 /* AppMenuViewController.swift in Sources */,
......
......@@ -38,15 +38,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let navigationController: NavigationController = AppNavigationController(rootViewController: RecipesViewController())
let menuViewController: MenuViewController = AppMenuViewController(rootViewController: navigationController)
menuViewController.edgesForExtendedLayout = .None
let bottomNavigationController: BottomNavigationController = BottomNavigationController()
bottomNavigationController.viewControllers = [AppMenuViewController(rootViewController: AppNavigationController(rootViewController: RecipesViewController())), VideoViewController(), PhotoViewController()]
bottomNavigationController.viewControllers = [menuViewController, VideoViewController(), PhotoViewController()]
bottomNavigationController.selectedIndex = 0
bottomNavigationController.tabBar.tintColor = MaterialColor.white
bottomNavigationController.tabBar.backgroundColor = MaterialColor.grey.darken4
let sideNavigationController: SideNavigationController = SideNavigationController(rootViewController: bottomNavigationController, leftViewController: AppLeftViewController())
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = SideNavigationController(rootViewController: bottomNavigationController, leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window!.rootViewController = sideNavigationController
window!.makeKeyAndVisible()
return true
}
......
......@@ -156,6 +156,6 @@ extension AppLeftViewController: UITableViewDelegate {
/// Select item at row in tableView.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Cell selected")
// print("Cell selected")
}
}
/*
* 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.
*/
/*
The following is an example of setting a UITableView as the RightViewController
within a SideNavigationController.
*/
import UIKit
import Material
private struct Item {
var text: String
var imageName: String
}
class AppRightViewController: UIViewController {
/// A tableView used to display navigation items.
private let tableView: UITableView = UITableView()
/// A list of all the navigation items.
private var items: Array<Item> = Array<Item>()
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareCells()
prepareTableView()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.grey.darken4
}
/// Prepares the items that are displayed within the tableView.
private func prepareCells() {
items.append(Item(text: "Recipes", imageName: "ic_inbox"))
items.append(Item(text: "Feed", imageName: "ic_today"))
items.append(Item(text: "Bookmarks", imageName: "ic_book"))
items.append(Item(text: "Work", imageName: "ic_work"))
items.append(Item(text: "Contacts", imageName: "ic_contacts"))
items.append(Item(text: "Settings", imageName: "ic_settings"))
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.backgroundColor = MaterialColor.clear
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .None
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView)
}
}
/// TableViewDataSource methods.
extension AppRightViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
let item: Item = items[indexPath.row]
cell.textLabel!.text = item.text
cell.textLabel!.textColor = MaterialColor.grey.lighten2
cell.textLabel!.font = RobotoFont.medium
cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate)
cell.imageView!.tintColor = MaterialColor.grey.lighten2
cell.backgroundColor = MaterialColor.clear
return cell
}
}
/// UITableViewDelegate methods.
extension AppRightViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 64
}
/// Select item at row in tableView.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Cell selected")
}
}
......@@ -119,10 +119,10 @@ class AppSearchBarController: SearchBarController {
extension AppSearchBarController: TextFieldDelegate {
func textFieldDidBeginEditing(textField: UITextField) {
print("Begin searching....")
// print("Begin searching....")
}
func textFieldDidEndEditing(textField: UITextField) {
print("End searching....")
// print("End searching....")
}
}
......@@ -50,9 +50,6 @@ class ItemViewController: UIViewController {
/// MaterialScrollView.
private var scrollView: UIScrollView!
/// Image height for the imageCardView.
private var imageHeight: CGFloat = 300
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
......@@ -85,12 +82,12 @@ class ItemViewController: UIViewController {
scrollView.contentSize = CGSizeMake(view.bounds.width, imageCardView.height)
imageCardView.reloadView()
imageCardView.contentsGravityPreset = .ResizeAspectFill
print(scrollView.frame)
print(scrollView.contentSize)
imageCardView.titleLabelInset.top = imageCardView.imageLayer!.frame.height
}
private func prepareView() {
view.backgroundColor = MaterialColor.white
automaticallyAdjustsScrollViewInsets = false
}
/// Prepares the titleLabel.
......@@ -144,12 +141,12 @@ class ItemViewController: UIViewController {
imageCardView.depth = .None
imageCardView.contentInsetPreset = .Square3
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.titleLabelInset.top = imageHeight
let detailLabel: UILabel = UILabel()
detailLabel.text = data["detail"] as? String
......@@ -160,11 +157,9 @@ class ItemViewController: UIViewController {
imageCardView.detailView = detailLabel
imageCardView.detailViewInset.top = 52
if let v: CGFloat = view.bounds.width {
let image: UIImage? = UIImage(named: data["image"] as! String)?.resize(toWidth: v)?.crop(toWidth: v, toHeight: imageHeight)
imageCardView.image = image
}
let image: UIImage? = UIImage(named: data["image"] as! String)
imageCardView.image = image
scrollView.addSubview(imageCardView)
imageCardView.translatesAutoresizingMaskIntoConstraints = false
}
......
......@@ -75,7 +75,7 @@ class RecipesViewController: UIViewController {
// Show the menuView.
menuViewController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(0 - tabBarController!.tabBar.frame.height)
MaterialAnimation.translateY(0)
]))
}
......@@ -87,7 +87,7 @@ class RecipesViewController: UIViewController {
// Hide the menuView.
menuViewController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(150 + tabBarController!.tabBar.frame.height)
MaterialAnimation.translateY(150)
]))
}
......@@ -158,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"
]
)
]
}
......@@ -165,6 +213,7 @@ class RecipesViewController: UIViewController {
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
automaticallyAdjustsScrollViewInsets = false
}
/// Prepares the titleLabel.
......
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