Commit e28d9497 by Daniel Dahan

updated SideNavigationViewController example

parent a00bc37f
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
9656CD231C6CFA6200EBCEF1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9656CD221C6CFA6200EBCEF1 /* ViewController.swift */; }; 9656CD231C6CFA6200EBCEF1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9656CD221C6CFA6200EBCEF1 /* ViewController.swift */; };
9656CD281C6CFA6200EBCEF1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */; }; 9656CD281C6CFA6200EBCEF1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */; };
9656CD2B1C6CFA6200EBCEF1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD291C6CFA6200EBCEF1 /* LaunchScreen.storyboard */; }; 9656CD2B1C6CFA6200EBCEF1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD291C6CFA6200EBCEF1 /* LaunchScreen.storyboard */; };
96A71F241C72754D00C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F231C72754D00C0C4AE /* Material.framework */; };
96A71F251C72754D00C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F231C72754D00C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96A71F251C72754D00C0C4AE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -33,6 +36,7 @@ ...@@ -33,6 +36,7 @@
9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
9656CD2A1C6CFA6200EBCEF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 9656CD2A1C6CFA6200EBCEF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
9656CD2C1C6CFA6200EBCEF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 9656CD2C1C6CFA6200EBCEF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71F231C72754D00C0C4AE /* 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 */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71F241C72754D00C0C4AE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
9656CD141C6CFA6200EBCEF1 = { 9656CD141C6CFA6200EBCEF1 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71F231C72754D00C0C4AE /* Material.framework */,
9656CD1F1C6CFA6200EBCEF1 /* Grid */, 9656CD1F1C6CFA6200EBCEF1 /* Grid */,
9656CD1E1C6CFA6200EBCEF1 /* Products */, 9656CD1E1C6CFA6200EBCEF1 /* Products */,
); );
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "VeganCakeFull.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -43,9 +43,9 @@ class ViewController: UIViewController { ...@@ -43,9 +43,9 @@ class ViewController: UIViewController {
// prepareHorizontalGridViewExample() // prepareHorizontalGridViewExample()
// prepareVerticalGridViewExample() // prepareVerticalGridViewExample()
// prepareGridDirectionNoneExample() // prepareGridDirectionNoneExample()
// prepareSmallCardViewExample() prepareSmallCardViewExample()
// prepareMediumCardViewExample() // prepareMediumCardViewExample()
prepareLargeCardViewExample() // prepareLargeCardViewExample()
} }
...@@ -185,7 +185,7 @@ class ViewController: UIViewController { ...@@ -185,7 +185,7 @@ class ViewController: UIViewController {
cardView.depth = .Depth1 cardView.depth = .Depth1
view.addSubview(cardView) view.addSubview(cardView)
var image: UIImage? = UIImage(named: "CosmicMindInverted") var image: UIImage? = UIImage(named: "VeganCakeFull")
let imageView: MaterialView = MaterialView() let imageView: MaterialView = MaterialView()
imageView.image = image imageView.image = image
imageView.contentsGravity = .ResizeAspectFill imageView.contentsGravity = .ResizeAspectFill
......
...@@ -128,10 +128,6 @@ class ViewController: UIViewController { ...@@ -128,10 +128,6 @@ class ViewController: UIViewController {
private func prepareFabMenuExample() { private func prepareFabMenuExample() {
var image: UIImage? = UIImage(named: "ic_add_white") var image: UIImage? = UIImage(named: "ic_add_white")
let btn1: FabButton = FabButton() let btn1: FabButton = FabButton()
/**
Remove the pulse animation, so the rotation animation
doesn't seem like too much with the pulse animation.
*/
btn1.pulseColor = nil btn1.pulseColor = nil
btn1.setImage(image, forState: .Normal) btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted) btn1.setImage(image, forState: .Highlighted)
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96A71EF91C7182F100C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71EF81C7182F100C0C4AE /* Material.framework */; };
96A71EFA1C7182F100C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71EF81C7182F100C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96D88C831C132C1800B91418 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C821C132C1800B91418 /* AppDelegate.swift */; }; 96D88C831C132C1800B91418 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C821C132C1800B91418 /* AppDelegate.swift */; };
96D88C851C132C1800B91418 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C841C132C1800B91418 /* ViewController.swift */; }; 96D88C851C132C1800B91418 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C841C132C1800B91418 /* ViewController.swift */; };
96D88C8A1C132C1800B91418 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D88C891C132C1800B91418 /* Assets.xcassets */; }; 96D88C8A1C132C1800B91418 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D88C891C132C1800B91418 /* Assets.xcassets */; };
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96A71EFA1C7182F100C0C4AE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -30,7 +27,6 @@ ...@@ -30,7 +27,6 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
96A71EF81C7182F100C0C4AE /* 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>"; };
96D88C7F1C132C1800B91418 /* NavigationBarView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationBarView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 96D88C7F1C132C1800B91418 /* NavigationBarView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationBarView.app; sourceTree = BUILT_PRODUCTS_DIR; };
96D88C821C132C1800B91418 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 96D88C821C132C1800B91418 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96D88C841C132C1800B91418 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 96D88C841C132C1800B91418 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71EF91C7182F100C0C4AE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
96D88C761C132C1800B91418 = { 96D88C761C132C1800B91418 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71EF81C7182F100C0C4AE /* Material.framework */,
96D88C811C132C1800B91418 /* NavigationBarView */, 96D88C811C132C1800B91418 /* NavigationBarView */,
96D88C801C132C1800B91418 /* Products */, 96D88C801C132C1800B91418 /* Products */,
); );
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
/* /*
A NavigationBarView is a fully featured NavigationBar that supports orientation A NavigationBarView is a fully featured NavigationBar that supports orientation
changes, background images, title and detail labels, both left and right button changes, background images, title and detail labels, both left and right UIControl
sets, and status bar settings. Below are examples of its usage. sets, and status bar settings. Below is an example of its usage.
*/ */
import UIKit import UIKit
...@@ -77,8 +77,8 @@ class ViewController: UIViewController { ...@@ -77,8 +77,8 @@ class ViewController: UIViewController {
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
// Star button. // Switch control.
let switchControl: MaterialSwitch = MaterialSwitch(state: .On, style: .Light) let switchControl: MaterialSwitch = MaterialSwitch(state: .On, style: .LightContent)
// Search button. // Search button.
image = UIImage(named: "ic_search_white") image = UIImage(named: "ic_search_white")
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
96A71F0A1C718F8800C0C4AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F091C718F8800C0C4AE /* ViewController.swift */; }; 96A71F0A1C718F8800C0C4AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F091C718F8800C0C4AE /* ViewController.swift */; };
96A71F0F1C718F8800C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71F0E1C718F8800C0C4AE /* Assets.xcassets */; }; 96A71F0F1C718F8800C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71F0E1C718F8800C0C4AE /* Assets.xcassets */; };
96A71F121C718F8800C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71F101C718F8800C0C4AE /* LaunchScreen.storyboard */; }; 96A71F121C718F8800C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71F101C718F8800C0C4AE /* LaunchScreen.storyboard */; };
96A71F1A1C71904400C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F191C71904400C0C4AE /* Material.framework */; };
96A71F1B1C71904400C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F191C71904400C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96A71F1B1C71904400C0C4AE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -36,7 +33,6 @@ ...@@ -36,7 +33,6 @@
96A71F0E1C718F8800C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96A71F0E1C718F8800C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A71F111C718F8800C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96A71F111C718F8800C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A71F131C718F8800C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 96A71F131C718F8800C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71F191C71904400C0C4AE /* 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 */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71F1A1C71904400C0C4AE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
96A71EFB1C718F8800C0C4AE = { 96A71EFB1C718F8800C0C4AE = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71F191C71904400C0C4AE /* Material.framework */,
96A71F061C718F8800C0C4AE /* SearchBarView */, 96A71F061C718F8800C0C4AE /* SearchBarView */,
96A71F051C718F8800C0C4AE /* Products */, 96A71F051C718F8800C0C4AE /* Products */,
); );
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
*/ */
/* /*
The following is an example of SearchBarView. A SearchBarView is a fully featured SearchBar that supports orientation
changes, background images, both left and right UIControl sets, and status bar
settings. Below is an example of its usage.
*/ */
import UIKit import UIKit
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
967585381C569AA9001E4268 /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967585371C569AA9001E4268 /* RightViewController.swift */; }; 967585381C569AA9001E4268 /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967585371C569AA9001E4268 /* RightViewController.swift */; };
96A71F1E1C71960900C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F1D1C71960900C0C4AE /* Material.framework */; }; 96A71F1E1C71960900C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F1D1C71960900C0C4AE /* Material.framework */; };
96A71F1F1C71960900C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F1D1C71960900C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 96A71F1F1C71960900C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F1D1C71960900C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96A71F271C7275F200C0C4AE /* FeedCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */; };
96A71F291C72761700C0C4AE /* FeedCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */; };
96A71F2B1C72766700C0C4AE /* FeedCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -41,6 +44,9 @@ ...@@ -41,6 +44,9 @@
9642FA321C1B909700022BC6 /* LeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftViewController.swift; sourceTree = "<group>"; }; 9642FA321C1B909700022BC6 /* LeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftViewController.swift; sourceTree = "<group>"; };
967585371C569AA9001E4268 /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; }; 967585371C569AA9001E4268 /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; };
96A71F1D1C71960900C0C4AE /* 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>"; }; 96A71F1D1C71960900C0C4AE /* 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>"; };
96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionView.swift; sourceTree = "<group>"; };
96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionViewLayout.swift; sourceTree = "<group>"; };
96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionViewCell.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -82,6 +88,9 @@ ...@@ -82,6 +88,9 @@
9642FA211C1B50E700022BC6 /* Assets.xcassets */, 9642FA211C1B50E700022BC6 /* Assets.xcassets */,
9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */, 9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */,
9642FA261C1B50E700022BC6 /* Info.plist */, 9642FA261C1B50E700022BC6 /* Info.plist */,
96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */,
96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */,
96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */,
); );
path = SideNavigationViewController; path = SideNavigationViewController;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -158,8 +167,11 @@ ...@@ -158,8 +167,11 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9642FA1D1C1B50E700022BC6 /* MainViewController.swift in Sources */, 9642FA1D1C1B50E700022BC6 /* MainViewController.swift in Sources */,
96A71F271C7275F200C0C4AE /* FeedCollectionView.swift in Sources */,
967585381C569AA9001E4268 /* RightViewController.swift in Sources */, 967585381C569AA9001E4268 /* RightViewController.swift in Sources */,
9642FA331C1B909700022BC6 /* LeftViewController.swift in Sources */, 9642FA331C1B909700022BC6 /* LeftViewController.swift in Sources */,
96A71F291C72761700C0C4AE /* FeedCollectionViewLayout.swift in Sources */,
96A71F2B1C72766700C0C4AE /* FeedCollectionViewCell.swift in Sources */,
9642FA1B1C1B50E700022BC6 /* AppDelegate.swift in Sources */, 9642FA1B1C1B50E700022BC6 /* AppDelegate.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class FeedCollectionView : UICollectionView {
//
// :name: init
//
internal required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
//
// :name: init
//
internal override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
prepareView()
}
//
// :name: prepareView
//
internal func prepareView() {
registerClass(FeedCollectionViewCell.self, forCellWithReuseIdentifier: "FeedCollectionViewCell")
backgroundColor = MaterialColor.clear
contentInset = UIEdgeInsetsMake(0, 0, 0, 0)
showsVerticalScrollIndicator = false
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class FeedCollectionViewCell : UICollectionViewCell {
convenience init() {
self.init(frame: CGRectNull)
}
}
/*
* 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 FeedCollectionViewLayout : UICollectionViewLayout {
private var contentSize: CGSize = CGSizeZero
private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)>?
internal var height: CGFloat = 88
internal var offset: CGFloat = 0
override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
let attributes: UICollectionViewLayoutAttributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath)
let w: CGFloat = collectionView!.bounds.width
let r: CGFloat = CGFloat(indexPath.row)
let h: CGFloat = CGFloat(height)
attributes.frame = CGRectMake(0, r * CGFloat(h + (0 < r ? offset : 0)), w, h)
return attributes
}
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
}
override func shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) -> Bool {
return newBounds.width != collectionView!.bounds.width
}
override func collectionViewContentSize() -> CGSize {
return contentSize
}
override func prepareLayout() {
let dataSource: MainViewController = collectionView!.dataSource as! MainViewController
let items: Array<Item> = dataSource.items
layoutItems = Array<(UICollectionViewLayoutAttributes, NSIndexPath)>()
var indexPath: NSIndexPath?
var count: Int = 0
for _ in items {
indexPath = NSIndexPath(forItem: count++, inSection: 0)
layoutItems?.append((layoutAttributesForItemAtIndexPath(indexPath!)!, indexPath!))
}
let w: CGFloat = collectionView!.bounds.width
contentSize = CGSizeMake(w, CGFloat(layoutItems!.count) * (height + offset))
}
override func targetContentOffsetForProposedContentOffset(proposedContentOffset: CGPoint) -> CGPoint {
return proposedContentOffset
}
internal 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
}
}
...@@ -36,7 +36,7 @@ within a SideNavigationViewController. ...@@ -36,7 +36,7 @@ within a SideNavigationViewController.
import UIKit import UIKit
import Material import Material
private struct Item { private struct Cell {
var text: String var text: String
var imageName: String var imageName: String
var selected: Bool var selected: Bool
...@@ -47,12 +47,12 @@ class LeftViewController: UIViewController { ...@@ -47,12 +47,12 @@ class LeftViewController: UIViewController {
private let tableView: UITableView = UITableView() private let tableView: UITableView = UITableView()
/// A list of all the navigation items. /// A list of all the navigation items.
private var items: Array<Item> = Array<Item>() private var items: Array<Cell> = Array<Cell>()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareItems() prepareCells()
prepareProfileView() prepareProfileView()
prepareTableView() prepareTableView()
...@@ -68,13 +68,13 @@ class LeftViewController: UIViewController { ...@@ -68,13 +68,13 @@ class LeftViewController: UIViewController {
} }
/// Prepares the items that are displayed within the tableView. /// Prepares the items that are displayed within the tableView.
private func prepareItems() { private func prepareCells() {
items.append(Item(text: "Inbox", imageName: "ic_inbox", selected: true)) items.append(Cell(text: "Inbox", imageName: "ic_inbox", selected: true))
items.append(Item(text: "Today", imageName: "ic_today", selected: false)) items.append(Cell(text: "Today", imageName: "ic_today", selected: false))
items.append(Item(text: "Bookmarks", imageName: "ic_book", selected: false)) items.append(Cell(text: "Bookmarks", imageName: "ic_book", selected: false))
items.append(Item(text: "Work", imageName: "ic_work", selected: false)) items.append(Cell(text: "Work", imageName: "ic_work", selected: false))
items.append(Item(text: "Contacts", imageName: "ic_contacts", selected: false)) items.append(Cell(text: "Contacts", imageName: "ic_contacts", selected: false))
items.append(Item(text: "Settings", imageName: "ic_settings", selected: false)) items.append(Cell(text: "Settings", imageName: "ic_settings", selected: false))
} }
/// Prepares profile view. /// Prepares profile view.
...@@ -131,7 +131,7 @@ extension LeftViewController: UITableViewDataSource { ...@@ -131,7 +131,7 @@ extension LeftViewController: UITableViewDataSource {
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
cell.backgroundColor = MaterialColor.clear cell.backgroundColor = MaterialColor.clear
let item: Item = items[indexPath.row] let item: Cell = items[indexPath.row]
cell.selectionStyle = .None cell.selectionStyle = .None
cell.textLabel!.text = item.text cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.medium cell.textLabel!.font = RobotoFont.medium
...@@ -155,6 +155,6 @@ extension LeftViewController: UITableViewDelegate { ...@@ -155,6 +155,6 @@ extension LeftViewController: UITableViewDelegate {
/// Select item at row in tableView. /// Select item at row in tableView.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Item selected") print("Cell selected")
} }
} }
...@@ -38,21 +38,30 @@ SideNavigationViewController. ...@@ -38,21 +38,30 @@ SideNavigationViewController.
import UIKit import UIKit
import Material import Material
private struct Item { struct Item {
var text: String var text: String
var detail: String var detail: String
var image: UIImage? var image: UIImage?
} }
class MainViewController: UIViewController { class MainViewController: UIViewController {
/// MenuView diameter.
private let menuViewDiameter: CGFloat = 56
/// MenuView inset.
private let menuViewInset: CGFloat = 16
/// NavigationBarView.
private var navigationBarView: NavigationBarView = NavigationBarView()
/// A tableView used to display Bond entries. /// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView() private lazy var collectionView: FeedCollectionView = FeedCollectionView(frame: CGRectNull, collectionViewLayout: FeedCollectionViewLayout())
/// MenuView. /// MenuView.
let menuView: MenuView = MenuView() private let menuView: MenuView = MenuView()
/// A list of all the Author Bond types. /// A list of all the Author Bond types.
private var items: Array<Item> = Array<Item>() var items: Array<Item> = Array<Item>()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -72,7 +81,7 @@ class MainViewController: UIViewController { ...@@ -72,7 +81,7 @@ class MainViewController: UIViewController {
because any earlier may cause a race condition when instantiating because any earlier may cause a race condition when instantiating
the MainViewController and SideViewController. the MainViewController and SideViewController.
*/ */
sideNavigationViewController?.setLeftViewWidth(view.bounds.width - 88, hidden: true, animated: false) sideNavigationViewController?.setLeftViewWidth(view.bounds.width - menuViewDiameter - 2 * menuViewInset, hidden: true, animated: false)
sideNavigationViewController?.delegate = self sideNavigationViewController?.delegate = self
} }
...@@ -132,78 +141,71 @@ class MainViewController: UIViewController { ...@@ -132,78 +141,71 @@ class MainViewController: UIViewController {
/// Prepares the tableView. /// Prepares the tableView.
private func prepareTableView() { private func prepareTableView() {
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") collectionView.delegate = self
tableView.dataSource = self collectionView.dataSource = self
tableView.delegate = self
// Use MaterialLayout to easily align the tableView. view.addSubview(collectionView)
view.addSubview(tableView) collectionView.translatesAutoresizingMaskIntoConstraints = false
tableView.translatesAutoresizingMaskIntoConstraints = false MaterialLayout.alignToParent(view, child: collectionView, top: navigationBarView.height)
MaterialLayout.alignToParent(view, child: tableView, top: 70)
} }
/// Prepares the navigationBarView. /// Prepares the navigationBarView.
private func prepareNavigationBarView() { private func prepareNavigationBarView() {
let navigationBarView: NavigationBarView = NavigationBarView()
navigationBarView.backgroundColor = MaterialColor.grey.darken4
/*
To lighten the status bar - add the
"View controller-based status bar appearance = NO"
to your info.plist file and set the following property.
*/
navigationBarView.statusBarStyle = .LightContent
// Title label. // Title label.
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.text = "Inbox" titleLabel.text = "Material"
titleLabel.textAlignment = .Left titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(17) titleLabel.font = RobotoFont.regularWithSize(17)
navigationBarView.titleLabel = titleLabel
// Detail label.
let detailLabel: UILabel = UILabel()
detailLabel.text = "Build Beautiful Software"
detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12)
var image = UIImage(named: "ic_menu_white")
// Menu button. // Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white")
let menuButton: FlatButton = FlatButton() let menuButton: FlatButton = FlatButton()
menuButton.pulseColor = MaterialColor.white menuButton.pulseColor = nil
menuButton.pulseScale = false menuButton.pulseScale = false
menuButton.setImage(img1, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(img1, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside) menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
// Add menuButton to left side. // Switch control.
navigationBarView.leftControls = [menuButton] let switchControl: MaterialSwitch = MaterialSwitch()
// MaterialSwitch control.
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .Off)
// Search button. // Search button.
let img2: UIImage? = UIImage(named: "ic_more_vert_white") image = UIImage(named: "ic_search_white")
let searchButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
searchButton.pulseColor = MaterialColor.white searchButton.pulseColor = nil
searchButton.pulseScale = false searchButton.pulseScale = false
searchButton.setImage(img2, forState: .Normal) searchButton.setImage(image, forState: .Normal)
searchButton.setImage(img2, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
// Add searchButton to right side. /*
navigationBarView.rightControls = [materialSwitch, searchButton] To lighten the status bar - add the
"View controller-based status bar appearance = NO"
to your info.plist file and set the following property.
*/
navigationBarView.statusBarStyle = .LightContent
navigationBarView.backgroundColor = MaterialColor.grey.darken4
navigationBarView.titleLabel = titleLabel
navigationBarView.detailLabel = detailLabel
navigationBarView.leftControls = [menuButton]
navigationBarView.rightControls = [switchControl, searchButton]
// To support orientation changes, use MaterialLayout.
view.addSubview(navigationBarView) view.addSubview(navigationBarView)
} }
/// Prepares the add button. /// Prepares the add button.
private func prepareMenuView() { private func prepareMenuView() {
/// MenuView diameter.
let diameter: CGFloat = 56
var image: UIImage? = UIImage(named: "ic_add_white") var image: UIImage? = UIImage(named: "ic_add_white")
let btn1: FabButton = FabButton() let btn1: FabButton = FabButton()
/**
Remove the pulse animation, so the rotation animation
doesn't seem like too much with the pulse animation.
*/
btn1.pulseColor = nil btn1.pulseColor = nil
btn1.setImage(image, forState: .Normal) btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted) btn1.setImage(image, forState: .Highlighted)
...@@ -233,73 +235,39 @@ class MainViewController: UIViewController { ...@@ -233,73 +235,39 @@ class MainViewController: UIViewController {
// Initialize the menu and setup the configuration options. // Initialize the menu and setup the configuration options.
menuView.menu.direction = .Up menuView.menu.direction = .Up
menuView.menu.baseViewSize = CGSizeMake(diameter, diameter) menuView.menu.baseViewSize = CGSizeMake(menuViewDiameter, menuViewDiameter)
menuView.menu.views = [btn1, btn2, btn3, btn4] menuView.menu.views = [btn1, btn2, btn3, btn4]
view.addSubview(menuView) view.addSubview(menuView)
menuView.translatesAutoresizingMaskIntoConstraints = false menuView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.size(view, child: menuView, width: diameter, height: diameter) MaterialLayout.size(view, child: menuView, width: menuViewDiameter, height: menuViewDiameter)
MaterialLayout.alignFromBottomRight(view, child: menuView, bottom: 16, right: 16) MaterialLayout.alignFromBottomRight(view, child: menuView, bottom: menuViewInset, right: menuViewInset)
} }
} }
/// TableViewDataSource methods. /// UICollectionViewDelegate
extension MainViewController: UITableViewDataSource { extension MainViewController: UICollectionViewDelegate {
/// Determines the number of rows in the tableView. func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { let c: FeedCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("FeedCollectionViewCell", forIndexPath: indexPath) as! FeedCollectionViewCell
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: UITableViewCell = UITableViewCell(style: .Subtitle, reuseIdentifier: "Cell")
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) return c
label.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(header, child: label, left: 24)
return header
} }
} }
/// UITableViewDelegate methods. /// UICollectionViewDataSource
extension MainViewController: UITableViewDelegate { extension MainViewController: UICollectionViewDataSource {
/// Sets the tableView cell height. //
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { // :name: numberOfSectionsInTableView
return 80 //
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
} }
/// Sets the tableView header height. //
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { // :name: collectionView
return 48 //
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
} }
} }
......
...@@ -36,7 +36,7 @@ within a SideNavigationViewController. ...@@ -36,7 +36,7 @@ within a SideNavigationViewController.
import UIKit import UIKit
import Material import Material
private struct Item { private struct Cell {
var text: String var text: String
var imageName: String var imageName: String
var selected: Bool var selected: Bool
...@@ -47,12 +47,12 @@ class RightViewController: UIViewController { ...@@ -47,12 +47,12 @@ class RightViewController: UIViewController {
private let tableView: UITableView = UITableView() private let tableView: UITableView = UITableView()
/// A list of all the navigation items. /// A list of all the navigation items.
private var items: Array<Item> = Array<Item>() private var items: Array<Cell> = Array<Cell>()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareItems() prepareCells()
prepareTableView() prepareTableView()
} }
...@@ -67,13 +67,13 @@ class RightViewController: UIViewController { ...@@ -67,13 +67,13 @@ class RightViewController: UIViewController {
/// Prepares the items that are displayed within the tableView. /// Prepares the items that are displayed within the tableView.
private func prepareItems() { private func prepareCells() {
items.append(Item(text: "Inbox", imageName: "ic_inbox", selected: false)) items.append(Cell(text: "Inbox", imageName: "ic_inbox", selected: false))
items.append(Item(text: "Today", imageName: "ic_today", selected: true)) items.append(Cell(text: "Today", imageName: "ic_today", selected: true))
items.append(Item(text: "Bookmarks", imageName: "ic_book", selected: false)) items.append(Cell(text: "Bookmarks", imageName: "ic_book", selected: false))
items.append(Item(text: "Work", imageName: "ic_work", selected: false)) items.append(Cell(text: "Work", imageName: "ic_work", selected: false))
items.append(Item(text: "Contacts", imageName: "ic_contacts", selected: false)) items.append(Cell(text: "Contacts", imageName: "ic_contacts", selected: false))
items.append(Item(text: "Settings", imageName: "ic_settings", selected: false)) items.append(Cell(text: "Settings", imageName: "ic_settings", selected: false))
} }
/// Prepares the tableView. /// Prepares the tableView.
...@@ -103,7 +103,7 @@ extension RightViewController: UITableViewDataSource { ...@@ -103,7 +103,7 @@ extension RightViewController: UITableViewDataSource {
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
cell.backgroundColor = MaterialColor.clear cell.backgroundColor = MaterialColor.clear
let item: Item = items[indexPath.row] let item: Cell = items[indexPath.row]
cell.selectionStyle = .None cell.selectionStyle = .None
cell.textLabel!.text = item.text cell.textLabel!.text = item.text
cell.textLabel!.textColor = MaterialColor.white cell.textLabel!.textColor = MaterialColor.white
...@@ -128,6 +128,6 @@ extension RightViewController: UITableViewDelegate { ...@@ -128,6 +128,6 @@ extension RightViewController: UITableViewDelegate {
/// Select item at row in tableView. /// Select item at row in tableView.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Item selected") print("Cell selected")
} }
} }
...@@ -247,7 +247,7 @@ public class MaterialSwitch: UIControl { ...@@ -247,7 +247,7 @@ public class MaterialSwitch: UIControl {
- Parameter style: A MaterialSwitchStyle value. - Parameter style: A MaterialSwitchStyle value.
- Parameter size: A MaterialSwitchSize value. - Parameter size: A MaterialSwitchSize value.
*/ */
public init(state: MaterialSwitchState = .On, style: MaterialSwitchStyle = .Default, size: MaterialSwitchSize = .Default) { public init(state: MaterialSwitchState = .Off, style: MaterialSwitchStyle = .Default, size: MaterialSwitchSize = .Default) {
track = MaterialView(frame: CGRectZero) track = MaterialView(frame: CGRectZero)
button = FabButton(frame: CGRectZero) button = FabButton(frame: CGRectZero)
super.init(frame: CGRectZero) super.init(frame: CGRectZero)
......
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