Commit ad0295bc by Daniel Dahan

added CollectionView example to App example project

parent 686c77a7
......@@ -17,6 +17,9 @@
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; };
9663F9521C7A751D00AF0965 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* FeedViewController.swift */; };
96CC08821C7FC0CF0034FF84 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96CC08811C7FC0CF0034FF84 /* Material.framework */; };
96CC08831C7FC0CF0034FF84 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96CC08811C7FC0CF0034FF84 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -26,6 +29,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96CC08831C7FC0CF0034FF84 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -45,6 +49,8 @@
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 /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
96CC08811C7FC0CF0034FF84 /* 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>"; };
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InboxViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -52,6 +58,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96CC08821C7FC0CF0034FF84 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -61,6 +68,7 @@
9663F9251C7A744500AF0965 = {
isa = PBXGroup;
children = (
96CC08811C7FC0CF0034FF84 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */,
);
......@@ -83,8 +91,9 @@
9663F94B1C7A74C700AF0965 /* AppMenuViewController.swift */,
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */,
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */,
9663F9511C7A751D00AF0965 /* FeedViewController.swift */,
9663F9331C7A744600AF0965 /* SearchListViewController.swift */,
9663F9511C7A751D00AF0965 /* FeedViewController.swift */,
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */,
9663F9381C7A744600AF0965 /* Assets.xcassets */,
9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */,
9663F93D1C7A744600AF0965 /* Info.plist */,
......@@ -164,6 +173,7 @@
buildActionMask = 2147483647;
files = (
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */,
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */,
9663F9481C7A749400AF0965 /* AppNavigationBarViewController.swift in Sources */,
9663F9341C7A744600AF0965 /* SearchListViewController.swift in Sources */,
......
......@@ -36,7 +36,7 @@ within a SideNavigationViewController.
import UIKit
import Material
private struct Cell {
private struct Item {
var text: String
var imageName: String
var selected: Bool
......@@ -47,7 +47,7 @@ class AppLeftViewController: UIViewController {
private let tableView: UITableView = UITableView()
/// A list of all the navigation items.
private var items: Array<Cell> = Array<Cell>()
private var items: Array<Item> = Array<Item>()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -76,12 +76,8 @@ class AppLeftViewController: UIViewController {
/// Prepares the items that are displayed within the tableView.
private func prepareCells() {
items.append(Cell(text: "Inbox", imageName: "ic_inbox", selected: true))
items.append(Cell(text: "Today", imageName: "ic_today", selected: false))
items.append(Cell(text: "Bookmarks", imageName: "ic_book", selected: false))
items.append(Cell(text: "Work", imageName: "ic_work", selected: false))
items.append(Cell(text: "Contacts", imageName: "ic_contacts", selected: false))
items.append(Cell(text: "Settings", imageName: "ic_settings", selected: false))
items.append(Item(text: "Feed", imageName: "ic_today", selected: true))
items.append(Item(text: "Inbox", imageName: "ic_inbox", selected: true))
}
/// Prepares profile view.
......@@ -140,7 +136,7 @@ extension AppLeftViewController: UITableViewDataSource {
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row]
let item: Item = items[indexPath.row]
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.medium
cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate)
......@@ -163,4 +159,14 @@ extension AppLeftViewController: UITableViewDelegate {
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Cell selected")
}
func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
let item: Item = items[indexPath.row]
if let a: MenuViewController = sideNavigationViewController?.mainViewController as? MenuViewController {
if let b: NavigationBarViewController = a.mainViewController as? NavigationBarViewController {
b.transitionFromMainViewController("Feed" == item.text ? FeedViewController() : InboxViewController(), options: [.TransitionCrossDissolve])
}
}
return indexPath
}
}
......@@ -76,7 +76,6 @@ class AppNavigationBarViewController: NavigationBarViewController {
private func prepareNavigationBarView() {
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "Feed"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
......
......@@ -69,7 +69,7 @@ class AppRightViewController: UIViewController {
/// Prepares the items that are displayed within the tableView.
private func prepareCells() {
items.append(Cell(text: "Inbox", imageName: "ic_inbox", selected: false))
items.append(Cell(text: "Today", imageName: "ic_today", selected: true))
items.append(Cell(text: "Feed", imageName: "ic_today", selected: true))
items.append(Cell(text: "Bookmarks", imageName: "ic_book", selected: false))
items.append(Cell(text: "Work", imageName: "ic_work", selected: false))
items.append(Cell(text: "Contacts", imageName: "ic_contacts", selected: false))
......
......@@ -31,120 +31,128 @@
import UIKit
import Material
private struct Item {
var text: String
var detail: String
var image: UIImage?
}
class FeedViewController: UIViewController {
/// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView()
/// A list of all the Author Bond types.
private var items: Array<Item> = Array<Item>()
private var collectionView: MaterialCollectionView = MaterialCollectionView(frame: CGRectNull)
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareItems()
prepareTableView()
prepareCollectionView()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
collectionView.frame = view.bounds
collectionView.reloadData()
}
/**
Handles the search button click, which opens the
SideNavigationViewController.
*/
func handleSearchButton() {
sideNavigationViewController?.openRightView()
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationBarViewController?.navigationBarView.titleLabel?.text = "Feed"
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
view.backgroundColor = MaterialColor.grey.lighten5
}
/// Prepares the items Array.
private func prepareItems() {
items.append(Item(text: "Summer BBQ", detail: "Wish I could come, but I am out of town this weekend.", image: UIImage(named: "Profile1")))
items.append(Item(text: "Birthday gift", detail: "Have any ideas about what we should get Heidi for her birthday?", image: UIImage(named: "Profile2")))
items.append(Item(text: "Brunch this weekend?", detail: "I'll be in your neighborhood doing errands this weekend.", image: UIImage(named: "Profile3")))
items.append(Item(text: "Giants game", detail: "Are we on this weekend for the game?", image: UIImage(named: "Profile4")))
items.append(Item(text: "Recipe to try", detail: "We should eat this: Squash, Corn and tomatillo Tacos.", image: UIImage(named: "Profile5")))
items.append(Item(text: "Interview", detail: "The candidate will be arriving at 11:30, are you free?", image: UIImage(named: "Profile6")))
items.append(Item(text: "Book recommendation", detail: "I found the book title, Surely You’re Joking, Mr. Feynman!", image: UIImage(named: "Profile7")))
items.append(Item(text: "Oui oui", detail: "Do you have Paris recommendations? Have you ever been?", image: UIImage(named: "Profile8")))
/// Prepares the collectionView
private func prepareCollectionView() {
collectionView.dataSource = self
collectionView.delegate = self
collectionView.registerClass(BasicCollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
if let v: MaterialCollectionViewLayout = collectionView.collectionViewLayout as? MaterialCollectionViewLayout {
v.spacing = 4
v.contentInset = UIEdgeInsetsMake(4, 4, 4, 4)
// v.scrollDirection = .Horizontal
}
view.addSubview(collectionView)
}
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.dataSource = self
tableView.delegate = self
extension FeedViewController: MaterialCollectionViewDataSource {
/// Retrieves the items for the collectionView.
func items() -> Array<Array<MaterialDataSourceItem>> {
return [[
MaterialDataSourceItem(data: ["title": "Material", "detail": "#Pumpkin #pie - Preheat oven to 425 degrees F. Whisk pumpkin, sweetened condensed milk, eggs..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["detail": "Wow!!! I really really need this fabulous pair. Action is ending tonight #sneakerhead"], width: 125, height: 125),
MaterialDataSourceItem(data: ["detail": "Discovered an amazing #cofeeshop with the best #latte at Adelaide and Spadina #Toronto They also..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Talk to that agency guy, a friend of #Jen, about renting..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["title": "Material", "detail": "#Pumpkin #pie - Preheat oven to 425 degrees F. Whisk pumpkin, sweetened condensed milk, eggs..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["detail": "Wow!!! I really really need this fabulous pair. Action is ending tonight #sneakerhead"], width: 125, height: 125),
MaterialDataSourceItem(data: ["detail": "Discovered an amazing #cofeeshop with the best #latte at Adelaide and Spadina #Toronto They also..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Talk to that agency guy, a friend of #Jen, about renting..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["title": "Material", "detail": "#Pumpkin #pie - Preheat oven to 425 degrees F. Whisk pumpkin, sweetened condensed milk, eggs..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["detail": "Wow!!! I really really need this fabulous pair. Action is ending tonight #sneakerhead"], width: 125, height: 125),
MaterialDataSourceItem(data: ["detail": "Discovered an amazing #cofeeshop with the best #latte at Adelaide and Spadina #Toronto They also..."], width: 125, height: 125),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Talk to that agency guy, a friend of #Jen, about renting..."], width: 125, height: 125)
]]
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView)
}
}
/// TableViewDataSource methods.
extension FeedViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
/// Number of sections.
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return items().count
}
/// Returns the number of sections.
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
/// Number of cells in each section.
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items()[section].count
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = MaterialTableViewCell(style: .Subtitle, reuseIdentifier: "MaterialTableViewCell")
let item: Item = items[indexPath.row]
cell.selectionStyle = .None
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.regular
cell.detailTextLabel!.text = item.detail
cell.detailTextLabel!.font = RobotoFont.regular
cell.detailTextLabel!.textColor = MaterialColor.grey.darken1
cell.imageView!.image = item.image?.resize(toWidth: 40)
cell.imageView!.layer.cornerRadius = 20
return cell
/// Retrieves a UICollectionViewCell.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let c: BasicCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! BasicCollectionViewCell
let item: MaterialDataSourceItem = items()[indexPath.section][indexPath.item]
if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> {
if nil == data["title"] {
c.titleLabel = nil
} else if nil == c.titleLabel {
c.titleLabel = UILabel()
c.titleLabel?.textColor = MaterialColor.blueGrey.darken4
c.titleLabel?.backgroundColor = MaterialColor.clear
}
/// Prepares the header within the tableView.
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView(frame: CGRectMake(0, 0, view.bounds.width, 48))
header.backgroundColor = MaterialColor.white
if nil == data["detail"] {
c.detailView = nil
} else if nil == c.detailView {
let detailLabel: UILabel = UILabel()
detailLabel.numberOfLines = 0
detailLabel.lineBreakMode = .ByTruncatingTail
detailLabel.font = RobotoFont.regularWithSize(12)
detailLabel.textColor = MaterialColor.blueGrey.darken4
detailLabel.backgroundColor = MaterialColor.clear
c.detailView = detailLabel
}
let label: UILabel = UILabel()
label.font = RobotoFont.medium
label.textColor = MaterialColor.grey.darken1
label.text = "Today"
if nil == c.controlView {
c.controlView = ControlView()
c.controlView!.backgroundColor = nil
header.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(header, child: label, left: navigationBarViewController!.navigationBarView.contentInset.left + navigationBarViewController!.navigationBarView.spacing)
let date: UILabel = UILabel()
date.text = "Monday 6, 2016"
date.font = RobotoFont.regularWithSize(12)
date.textColor = MaterialColor.grey.lighten1
c.controlView!.contentView.addSubview(date)
c.controlView!.contentView.grid.views = [date]
}
return header
c.titleLabel?.text = data["title"] as? String
(c.detailView as? UILabel)?.text = data["detail"] as? String
c.reloadView()
}
}
/// UITableViewDelegate methods.
extension FeedViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80
return c
}
}
/// Sets the tableView header height.
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 48
/// MaterialCollectionViewDelegate methods.
extension FeedViewController: MaterialCollectionViewDelegate {
/// Executed when an item is selected.
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print(indexPath)
}
}
\ No newline at end of file
/*
* 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
private struct Item {
var text: String
var detail: String
var image: UIImage?
}
class InboxViewController: UIViewController {
/// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView()
/// A list of all the Author Bond types.
private var items: Array<Item> = Array<Item>()
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareItems()
prepareTableView()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationBarViewController?.navigationBarView.titleLabel?.text = "Inbox"
}
/**
Handles the search button click, which opens the
SideNavigationViewController.
*/
func handleSearchButton() {
sideNavigationViewController?.openRightView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
}
/// Prepares the items Array.
private func prepareItems() {
items.append(Item(text: "Summer BBQ", detail: "Wish I could come, but I am out of town this weekend.", image: UIImage(named: "Profile1")))
items.append(Item(text: "Birthday gift", detail: "Have any ideas about what we should get Heidi for her birthday?", image: UIImage(named: "Profile2")))
items.append(Item(text: "Brunch this weekend?", detail: "I'll be in your neighborhood doing errands this weekend.", image: UIImage(named: "Profile3")))
items.append(Item(text: "Giants game", detail: "Are we on this weekend for the game?", image: UIImage(named: "Profile4")))
items.append(Item(text: "Recipe to try", detail: "We should eat this: Squash, Corn and tomatillo Tacos.", image: UIImage(named: "Profile5")))
items.append(Item(text: "Interview", detail: "The candidate will be arriving at 11:30, are you free?", image: UIImage(named: "Profile6")))
items.append(Item(text: "Book recommendation", detail: "I found the book title, Surely You’re Joking, Mr. Feynman!", image: UIImage(named: "Profile7")))
items.append(Item(text: "Oui oui", detail: "Do you have Paris recommendations? Have you ever been?", image: UIImage(named: "Profile8")))
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.dataSource = self
tableView.delegate = self
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView)
}
}
/// TableViewDataSource methods.
extension InboxViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
}
/// Returns the number of sections.
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = MaterialTableViewCell(style: .Subtitle, reuseIdentifier: "MaterialTableViewCell")
let item: Item = items[indexPath.row]
cell.selectionStyle = .None
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.regular
cell.detailTextLabel!.text = item.detail
cell.detailTextLabel!.font = RobotoFont.regular
cell.detailTextLabel!.textColor = MaterialColor.grey.darken1
cell.imageView!.image = item.image?.resize(toWidth: 40)
cell.imageView!.layer.cornerRadius = 20
return cell
}
/// Prepares the header within the tableView.
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView(frame: CGRectMake(0, 0, view.bounds.width, 48))
header.backgroundColor = MaterialColor.white
let label: UILabel = UILabel()
label.font = RobotoFont.medium
label.textColor = MaterialColor.grey.darken1
label.text = "Today"
header.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(header, child: label, left: navigationBarViewController!.navigationBarView.contentInset.left + navigationBarViewController!.navigationBarView.spacing)
return header
}
}
/// UITableViewDelegate methods.
extension InboxViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80
}
/// Sets the tableView header height.
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 48
}
}
......@@ -11,6 +11,8 @@
96A71ED71C6FFF7300C0C4AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71ED61C6FFF7300C0C4AE /* ViewController.swift */; };
96A71EDC1C6FFF7300C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */; };
96A71EDF1C6FFF7300C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDD1C6FFF7300C0C4AE /* LaunchScreen.storyboard */; };
96CC08851C7FC2710034FF84 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96CC08841C7FC2710034FF84 /* Material.framework */; };
96CC08861C7FC2710034FF84 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96CC08841C7FC2710034FF84 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96CC08861C7FC2710034FF84 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -33,6 +36,7 @@
96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A71EDE1C6FFF7300C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A71EE01C6FFF7300C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96CC08841C7FC2710034FF84 /* 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 */
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96CC08851C7FC2710034FF84 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
96A71EC81C6FFF7300C0C4AE = {
isa = PBXGroup;
children = (
96CC08841C7FC2710034FF84 /* Material.framework */,
96A71ED31C6FFF7300C0C4AE /* MaterialSwitch */,
96A71ED21C6FFF7300C0C4AE /* Products */,
);
......
......@@ -57,6 +57,13 @@
96CC08381C7CCB7C0034FF84 /* NavigationBarViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A71F2F1C72E41100C0C4AE /* NavigationBarViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96CC083D1C7CF9D40034FF84 /* StatusBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC083C1C7CF9D40034FF84 /* StatusBarViewController.swift */; };
96CC083E1C7CFF2A0034FF84 /* StatusBarViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96CC083C1C7CF9D40034FF84 /* StatusBarViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96CC08911C7FEC170034FF84 /* BasicCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088A1C7FEC170034FF84 /* BasicCollectionViewCell.swift */; };
96CC08921C7FEC170034FF84 /* MaterialCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */; };
96CC08931C7FEC170034FF84 /* MaterialCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */; };
96CC08941C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088D1C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift */; };
96CC08951C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088E1C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift */; };
96CC08961C7FEC170034FF84 /* MaterialCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088F1C7FEC170034FF84 /* MaterialCollectionViewLayout.swift */; };
96CC08971C7FEC170034FF84 /* MaterialDataSourceItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08901C7FEC170034FF84 /* MaterialDataSourceItem.swift */; };
96D88C1E1C1328D800B91418 /* CaptureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF51C1328D800B91418 /* CaptureView.swift */; };
96D88C1F1C1328D800B91418 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF61C1328D800B91418 /* CardView.swift */; };
96D88C201C1328D800B91418 /* CapturePreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */; };
......@@ -164,6 +171,13 @@
96A71FB01C7649F800C0C4AE /* ControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlView.swift; sourceTree = "<group>"; };
96A71FB21C764E3200C0C4AE /* StatusBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarView.swift; sourceTree = "<group>"; };
96CC083C1C7CF9D40034FF84 /* StatusBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarViewController.swift; sourceTree = "<group>"; };
96CC088A1C7FEC170034FF84 /* BasicCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCollectionViewCell.swift; sourceTree = "<group>"; };
96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionView.swift; sourceTree = "<group>"; };
96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewCell.swift; sourceTree = "<group>"; };
96CC088D1C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewDataSource.swift; sourceTree = "<group>"; };
96CC088E1C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewDelegate.swift; sourceTree = "<group>"; };
96CC088F1C7FEC170034FF84 /* MaterialCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewLayout.swift; sourceTree = "<group>"; };
96CC08901C7FEC170034FF84 /* MaterialDataSourceItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialDataSourceItem.swift; sourceTree = "<group>"; };
96D88BF51C1328D800B91418 /* CaptureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureView.swift; sourceTree = "<group>"; };
96D88BF61C1328D800B91418 /* CardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = "<group>"; };
96D88BF71C1328D800B91418 /* CapturePreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapturePreviewView.swift; sourceTree = "<group>"; };
......@@ -324,10 +338,25 @@
96CC08561C7E0EC00034FF84 /* ControlView */ = {
isa = PBXGroup;
children = (
96A71FB01C7649F800C0C4AE /* ControlView.swift */,
);
name = ControlView;
sourceTree = "<group>";
};
96CC08891C7FEBE10034FF84 /* CollectionView */ = {
isa = PBXGroup;
children = (
96CC088A1C7FEC170034FF84 /* BasicCollectionViewCell.swift */,
96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */,
96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */,
96CC088D1C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift */,
96CC088E1C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift */,
96CC088F1C7FEC170034FF84 /* MaterialCollectionViewLayout.swift */,
96CC08901C7FEC170034FF84 /* MaterialDataSourceItem.swift */,
);
name = CollectionView;
sourceTree = "<group>";
};
96D88BF41C1328D800B91418 /* Sources */ = {
isa = PBXGroup;
children = (
......@@ -348,11 +377,11 @@
96D88C471C1328F500B91418 /* Font */,
966F57B61C226D65009185B7 /* Text */,
96442ADC1C28EF1400C3C574 /* TableView */,
96CC08891C7FEBE10034FF84 /* CollectionView */,
965C58BD1C6B8D3300CFB4E1 /* Grid */,
96A71E921C6FBC2900C0C4AE /* Menu */,
96A71EC51C6FFEF300C0C4AE /* Switch */,
96CC08561C7E0EC00034FF84 /* ControlView */,
96A71FB01C7649F800C0C4AE /* ControlView.swift */,
96D88C541C132A7700B91418 /* StatusBar */,
9626C2DB1C794FBB007CA8E0 /* SearchBar */,
9626C2DA1C794FA5007CA8E0 /* NavigationBar */,
......@@ -680,6 +709,7 @@
960036151C77E1B600EBA579 /* SearchBarViewController.swift in Sources */,
96A71EF61C71127100C0C4AE /* SearchBarView.swift in Sources */,
96D88C371C1328D800B91418 /* MaterialRadius.swift in Sources */,
96CC08961C7FEC170034FF84 /* MaterialCollectionViewLayout.swift in Sources */,
960B232F1C383EAA00E96216 /* Material+UIImage+Crop.swift in Sources */,
96D88C241C1328D800B91418 /* ImageCardView.swift in Sources */,
96D88C2B1C1328D800B91418 /* MaterialButton.swift in Sources */,
......@@ -693,8 +723,12 @@
96D88C231C1328D800B91418 /* FlatButton.swift in Sources */,
966F57B81C226D75009185B7 /* TextField.swift in Sources */,
96DBA7361C61198400844821 /* Material+UIImage+Color.swift in Sources */,
96CC08931C7FEC170034FF84 /* MaterialCollectionViewCell.swift in Sources */,
96D88C201C1328D800B91418 /* CapturePreviewView.swift in Sources */,
96CC08921C7FEC170034FF84 /* MaterialCollectionView.swift in Sources */,
96A71EC71C6FFF0500C0C4AE /* MaterialSwitch.swift in Sources */,
96CC08951C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift in Sources */,
96CC08971C7FEC170034FF84 /* MaterialDataSourceItem.swift in Sources */,
96D88C3E1C1328D800B91418 /* NavigationBarView.swift in Sources */,
96D88C221C1328D800B91418 /* FabButton.swift in Sources */,
96D88C3F1C1328D800B91418 /* RaisedButton.swift in Sources */,
......@@ -706,6 +740,7 @@
960B23301C383EAA00E96216 /* Material+UIImage+Network.swift in Sources */,
96D88C1E1C1328D800B91418 /* CaptureView.swift in Sources */,
96D88C2D1C1328D800B91418 /* MaterialDepth.swift in Sources */,
96CC08941C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift in Sources */,
96D88C331C1328D800B91418 /* MaterialLabel.swift in Sources */,
96D88C281C1328D800B91418 /* MaterialAnimation.swift in Sources */,
96A71F301C72E41100C0C4AE /* NavigationBarViewController.swift in Sources */,
......@@ -722,6 +757,7 @@
96D88C341C1328D800B91418 /* MaterialLayer.swift in Sources */,
96D88C461C1328D800B91418 /* SideNavigationViewController.swift in Sources */,
96D88C381C1328D800B91418 /* MaterialShape.swift in Sources */,
96CC08911C7FEC170034FF84 /* BasicCollectionViewCell.swift in Sources */,
960B23331C383EAA00E96216 /* Material+UIImage+Size.swift in Sources */,
9626C2DE1C795017007CA8E0 /* MenuViewController.swift in Sources */,
96A71FB61C7651AA00C0C4AE /* ControlView.swift in Sources */,
......
/*
* 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
public class BasicCollectionViewCell : MaterialCollectionViewCell {
/// An Optional title UILabel.
public var titleLabel: UILabel? {
didSet {
reloadView()
}
}
/// An Optional detail UILabel.
public var detailView: UIView? {
didSet {
reloadView()
}
}
/// An Optional ControlView.
public var controlView: ControlView? {
didSet {
reloadView()
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
contentInsetPreset = .Square3
backgroundColor = MaterialColor.white
}
/// Reloads the view.
public func reloadView() {
contentView.grid.views = []
contentView.grid.axis.rows = 12
contentView.grid.axis.inherited = false
contentView.grid.axis.direction = .Vertical
for v in contentView.subviews {
v.removeFromSuperview()
}
var a: Int = 0
var b: Int = 0
var c: Int = 0
if nil != titleLabel && nil == detailView && nil == controlView {
a = 12
} else if nil == titleLabel && nil != detailView && nil == controlView {
b = 12
} else if nil == titleLabel && nil == detailView && nil != controlView {
c = 12
} else if nil != titleLabel && nil != detailView && nil == controlView {
a = 3
b = 9
} else if nil != titleLabel && nil == detailView && nil != controlView {
a = 9
c = 3
} else if nil == titleLabel && nil != detailView && nil != controlView {
b = 9
c = 3
} else if nil != titleLabel && nil != detailView && nil != controlView {
a = 3
b = 6
c = 3
}
if let v: UILabel = titleLabel {
v.grid.rows = a
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: UIView = detailView {
v.grid.rows = b
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: ControlView = controlView {
v.grid.rows = c
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
contentView.grid.reloadLayout()
}
}
/*
* 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
public class MaterialCollectionView : UICollectionView {
/**
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)
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
- Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/
public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
prepareView()
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
*/
public init(frame: CGRect) {
super.init(frame: frame, collectionViewLayout: MaterialCollectionViewLayout())
prepareView()
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public func prepareView() {
backgroundColor = MaterialColor.clear
contentInset = UIEdgeInsetsZero
}
}
/*
* 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
@objc(MaterialCollectionViewCell)
public class MaterialCollectionViewCell : UICollectionViewCell {
/// A preset wrapper around contentInset.
public var contentInsetPreset: MaterialEdgeInset {
get {
return contentView.grid.contentInsetPreset
}
set(value) {
contentView.grid.contentInsetPreset = value
}
}
/// A wrapper around grid.contentInset.
public var contentInset: UIEdgeInsets {
get {
return contentView.grid.contentInset
}
set(value) {
contentView.grid.contentInset = value
}
}
/// A wrapper around grid.spacing.
public var spacing: CGFloat {
get {
return contentView.grid.spacing
}
set(value) {
contentView.grid.spacing = value
}
}
/**
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
*/
public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer()
/**
A base delegate reference used when subclassing MaterialView.
*/
public weak var delegate: MaterialDelegate?
/// Sets whether the scaling animation should be used.
public lazy var pulseScale: Bool = true
/// The opcaity value for the pulse animation.
public var pulseColorOpacity: CGFloat = 0.25
/// The color of the pulse effect.
public var pulseColor: UIColor?
/**
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
the image property, then this value does not need to be set, since the
visualLayer's maskToBounds is set to true by default.
*/
public var masksToBounds: Bool {
get {
return layer.masksToBounds
}
set(value) {
layer.masksToBounds = value
}
}
/// A property that accesses the backing layer's backgroundColor.
public override var backgroundColor: UIColor? {
didSet {
layer.backgroundColor = backgroundColor?.CGColor
}
}
/// A property that accesses the layer.frame.origin.x property.
public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.origin.width property.
When setting this property in conjunction with the shape property having a
value that is not .None, the height will be adjusted to maintain the correct
shape.
*/
public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
if .None != shape {
layer.frame.size.height = value
}
}
}
/**
A property that accesses the layer.frame.origin.height property.
When setting this property in conjunction with the shape property having a
value that is not .None, the width will be adjusted to maintain the correct
shape.
*/
public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
if .None != shape {
layer.frame.size.width = value
}
}
}
/// A property that accesses the backing layer's shadowColor.
public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
}
}
/// A property that accesses the backing layer's shadowOffset.
public var shadowOffset: CGSize {
get {
return layer.shadowOffset
}
set(value) {
layer.shadowOffset = value
}
}
/// A property that accesses the backing layer's shadowOpacity.
public var shadowOpacity: Float {
get {
return layer.shadowOpacity
}
set(value) {
layer.shadowOpacity = value
}
}
/// A property that accesses the backing layer's shadowRadius.
public var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set(value) {
layer.shadowRadius = value
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public var depth: MaterialDepth {
didSet {
let value: MaterialDepthType = MaterialDepthToValue(depth)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
}
}
/**
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
*/
public var cornerRadiusPreset: MaterialRadius {
didSet {
if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
}
}
}
/// A property that accesses the layer.cornerRadius.
public var cornerRadius: CGFloat = 0 {
didSet {
layer.cornerRadius = cornerRadius
}
}
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
public var shape: MaterialShape {
didSet {
if .None != shape {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
}
}
}
/// A property that accesses the layer.borderWith.
public var borderWidth: CGFloat {
didSet {
layer.borderWidth = borderWidth
}
}
/// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? {
didSet {
layer.borderColor = borderColor?.CGColor
}
}
/// A property that accesses the layer.position property.
public var position: CGPoint {
get {
return layer.position
}
set(value) {
layer.position = value
}
}
/// A property that accesses the layer.zPosition property.
public var zPosition: CGFloat {
get {
return layer.zPosition
}
set(value) {
layer.zPosition = value
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
depth = .None
cornerRadiusPreset = .None
shape = .None
borderWidth = 0
super.init(coder: aDecoder)
prepareView()
}
/**
An initializer that initializes the object with a CGRect object.
If AutoLayout is used, it is better to initilize the instance
using the init() initializer.
- Parameter frame: A CGRect instance.
*/
public override init(frame: CGRect) {
depth = .None
cornerRadiusPreset = .None
shape = .None
borderWidth = 0
super.init(frame: frame)
prepareView()
}
/// A convenience initializer.
public convenience init() {
self.init(frame: CGRectNull)
}
/// Overriding the layout callback for sublayers.
public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer)
if self.layer == layer {
layoutShape()
layoutVisualLayer()
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
public func animate(animation: CAAnimation) {
animation.delegate = self
if let a: CABasicAnimation = animation as? CABasicAnimation {
a.fromValue = (nil == layer.presentationLayer() ? layer : layer.presentationLayer() as! CALayer).valueForKeyPath(a.keyPath!)
}
if let a: CAPropertyAnimation = animation as? CAPropertyAnimation {
layer.addAnimation(a, forKey: a.keyPath!)
} else if let a: CAAnimationGroup = animation as? CAAnimationGroup {
layer.addAnimation(a, forKey: nil)
} else if let a: CATransition = animation as? CATransition {
layer.addAnimation(a, forKey: kCATransition)
}
}
/**
A delegation method that is executed when the backing layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
*/
public override func animationDidStart(anim: CAAnimation) {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(anim)
}
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if anim is CAPropertyAnimation {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
animationDidStop(x, finished: true)
}
}
layoutVisualLayer()
}
/**
A delegation method that is executed when the view has began a
touch event.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
pulseAnimation(layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer))
}
/**
A delegation method that is executed when the view touch event has
ended.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
shrinkAnimation()
}
/**
A delegation method that is executed when the view touch event has
been cancelled.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
shrinkAnimation()
}
/**
Triggers the pulse animation.
- Parameter point: A Optional point to pulse from, otherwise pulses
from the center.
*/
public func pulse(var point: CGPoint? = nil) {
if nil == point {
point = CGPointMake(CGFloat(width / 2), CGFloat(height / 2))
}
if let v: CFTimeInterval = pulseAnimation(point!) {
MaterialAnimation.delay(v) { [weak self] in
self?.shrinkAnimation()
}
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public func prepareView() {
prepareVisualLayer()
pulseColor = MaterialColor.grey.lighten1
pulseScale = false
}
/// Prepares the visualLayer property.
internal func prepareVisualLayer() {
visualLayer.zPosition = 0
visualLayer.masksToBounds = true
layer.addSublayer(visualLayer)
}
/// Manages the layout for the visualLayer property.
internal func layoutVisualLayer() {
visualLayer.frame = bounds
visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = layer.cornerRadius
}
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
layer.cornerRadius = width / 2
}
}
/**
Triggers the pulse animation.
- Parameter point: A point to pulse from.
- Returns: A Ooptional CFTimeInternal if the point exists within
the view. The time internal represents the animation time.
*/
internal func pulseAnimation(point: CGPoint) -> CFTimeInterval? {
if true == layer.containsPoint(point) {
let r: CGFloat = (width < height ? height : width) / 2
let f: CGFloat = 3
let v: CGFloat = r / f
let d: CGFloat = 2 * f
let s: CGFloat = 1.05
var t: CFTimeInterval = CFTimeInterval(1.5 * width / UIScreen.mainScreen().bounds.width)
if 0.55 < t || 0.25 > t {
t = 0.55
}
t /= 1.3
if nil != pulseColor && 0 < pulseColorOpacity {
let pulseLayer: CAShapeLayer = CAShapeLayer()
pulseLayer.hidden = true
pulseLayer.zPosition = 1
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor
visualLayer.addSublayer(pulseLayer)
MaterialAnimation.animationDisabled {
pulseLayer.bounds = CGRectMake(0, 0, v, v)
pulseLayer.position = point
pulseLayer.cornerRadius = r / d
pulseLayer.hidden = false
}
pulseLayer.addAnimation(MaterialAnimation.scale(3 * d, duration: t), forKey: nil)
MaterialAnimation.delay(t) { [weak self] in
if nil != self && nil != self!.pulseColor && 0 < self!.pulseColorOpacity {
MaterialAnimation.animateWithDuration(t, animations: {
pulseLayer.hidden = true
}) {
pulseLayer.removeFromSuperlayer()
}
}
}
}
if pulseScale {
layer.addAnimation(MaterialAnimation.scale(s, duration: t), forKey: nil)
return t
}
}
return nil
}
/// Executes the shrink animation for the pulse effect.
internal func shrinkAnimation() {
if pulseScale {
var t: CFTimeInterval = CFTimeInterval(1.5 * width / UIScreen.mainScreen().bounds.width)
if 0.55 < t || 0.25 > t {
t = 0.55
}
t /= 1.3
layer.addAnimation(MaterialAnimation.scale(1, duration: t), forKey: nil)
}
}
}
\ No newline at end of file
/*
* 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.
*/
public protocol MaterialCollectionViewDataSource : MaterialDelegate, UICollectionViewDataSource {
/**
Retrieves the items for the collectionView.
- Returns: An Array of Arrays of MaterialDataSourceItem objects.
*/
func items() -> Array<Array<MaterialDataSourceItem>>
}
\ No newline at end of file
/*
* 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.
*/
public protocol MaterialCollectionViewDelegate : MaterialDelegate, UICollectionViewDelegate {
}
\ No newline at end of file
/*
* 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
public class MaterialCollectionViewLayout : UICollectionViewLayout {
/// A preset wrapper around contentInset.
public var contentInsetPreset: MaterialEdgeInset = .None {
didSet {
contentInset = MaterialEdgeInsetToValue(contentInsetPreset)
}
}
/// A wrapper around grid.contentInset.
public var contentInset: UIEdgeInsets = UIEdgeInsetsZero
/// Size of the content.
private var contentSize: CGSize = CGSizeZero
/// Layout attribute items.
private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)> = Array<(UICollectionViewLayoutAttributes, NSIndexPath)>()
/// Used to calculate the dimensions of the cells.
private var offset: CGPoint = CGPointZero
/// Cell items.
private var items: Array<Array<MaterialDataSourceItem>>?
/// Scroll direction.
public var scrollDirection: UICollectionViewScrollDirection = .Vertical
/// Scale of the screen.
public var scale: CGFloat = 2
/// Spacing between items.
public var spacing: CGFloat = 0
/**
Retrieves the index paths for the items within the passed in CGRect.
- Parameter rect: A CGRect that acts as the bounds to find the items within.
- Returns: An Array of NSIndexPath objects.
*/
public func indexPathsOfItemsInRect(rect: CGRect) -> Array<NSIndexPath> {
var paths: Array<NSIndexPath> = Array<NSIndexPath>()
for (attribute, indexPath) in layoutItems {
if CGRectIntersectsRect(rect, attribute.frame) {
paths.append(indexPath)
}
}
return paths
}
public override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
let attributes: UICollectionViewLayoutAttributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath)
let item: MaterialDataSourceItem = items![indexPath.section][indexPath.item]
switch scrollDirection {
case .Vertical:
attributes.frame = CGRectMake(contentInset.left, offset.y, collectionView!.bounds.width - contentInset.left - contentInset.right, nil == item.height ? collectionView!.bounds.height : item.height!)
case .Horizontal:
attributes.frame = CGRectMake(offset.x, contentInset.top, nil == item.width ? collectionView!.bounds.width : item.width!, collectionView!.bounds.height - contentInset.top - contentInset.bottom)
}
return attributes
}
public override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var layoutAttributes: Array<UICollectionViewLayoutAttributes> = Array<UICollectionViewLayoutAttributes>()
for (attribute, _) in layoutItems {
if CGRectIntersectsRect(rect, attribute.frame) {
layoutAttributes.append(attribute)
}
}
return layoutAttributes
}
public override func shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) -> Bool {
return .Vertical == scrollDirection ? newBounds.width != collectionView!.bounds.width : newBounds.height != collectionView!.bounds.height
}
public override func collectionViewContentSize() -> CGSize {
return contentSize
}
public override func prepareLayout() {
let dataSource: MaterialCollectionViewDataSource = collectionView!.dataSource as! MaterialCollectionViewDataSource
items = dataSource.items()
layoutItems.removeAll()
offset.x = contentInset.left
offset.y = contentInset.top
var indexPath: NSIndexPath?
for var i: Int = 0, l: Int = items!.count - 1; i <= l; ++i {
let v: Array<MaterialDataSourceItem> = items![i]
for var j: Int = 0, k: Int = v.count - 1; j <= k; ++j {
let item: MaterialDataSourceItem = v[j]
indexPath = NSIndexPath(forItem: j, inSection: i)
layoutItems.append((layoutAttributesForItemAtIndexPath(indexPath!)!, indexPath!))
offset.x += spacing
offset.x += nil == item.width ? 0 : item.width!
offset.y += spacing
offset.y += nil == item.height ? 0 : item.height!
}
}
offset.x += contentInset.right - spacing
offset.y += contentInset.bottom - spacing
contentSize = .Vertical == scrollDirection ? CGSizeMake(collectionView!.bounds.width, offset.y) : CGSizeMake(offset.x, collectionView!.bounds.height)
}
public override func targetContentOffsetForProposedContentOffset(proposedContentOffset: CGPoint) -> CGPoint {
return proposedContentOffset
}
}
/*
* 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
public struct MaterialDataSourceItem {
public var data: AnyObject?
public var size: CGSize?
public var x: CGFloat?
public var y: CGFloat?
public var width: CGFloat?
public var height: CGFloat?
public init(data: AnyObject? = nil, x: CGFloat? = nil, y: CGFloat? = nil, width: CGFloat? = nil, height: CGFloat? = nil) {
self.data = data
self.x = x
self.y = y
self.width = width
self.height = height
}
}
\ No newline at end of file
......@@ -779,7 +779,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
leftView!.hidden = true
leftView!.position.x = -leftViewWidth / 2
leftView!.zPosition = 1000
leftView!.zPosition = 2000
} else {
enabledLeftView = false
}
......@@ -795,7 +795,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
rightView!.hidden = true
rightView!.position.x = view.bounds.width + rightViewWidth / 2
rightView!.zPosition = 1000
rightView!.zPosition = 2000
} else {
enabledRightView = false
}
......@@ -804,7 +804,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/// A method that prepares the backdropLayer.
private func prepareBackdropLayer() {
backdropColor = MaterialColor.black
backdropLayer.zPosition = 900
backdropLayer.zPosition = 1500
backdropLayer.hidden = true
view.layer.addSublayer(backdropLayer)
}
......
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