Commit dfd7d96e by Daniel Dahan

updated NavigationBarViewController Example

parent f83591e9
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
9612606B1C78E92000BF0079 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9612606A1C78E92000BF0079 /* Material.framework */; };
9612606C1C78E92000BF0079 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9612606A1C78E92000BF0079 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9656CD211C6CFA6200EBCEF1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9656CD201C6CFA6200EBCEF1 /* AppDelegate.swift */; }; 9656CD211C6CFA6200EBCEF1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9656CD201C6CFA6200EBCEF1 /* AppDelegate.swift */; };
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 */; };
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
9612606C1C78E92000BF0079 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
9612606A1C78E92000BF0079 /* 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>"; };
9656CD1D1C6CFA6200EBCEF1 /* Grid.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Grid.app; sourceTree = BUILT_PRODUCTS_DIR; }; 9656CD1D1C6CFA6200EBCEF1 /* Grid.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Grid.app; sourceTree = BUILT_PRODUCTS_DIR; };
9656CD201C6CFA6200EBCEF1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 9656CD201C6CFA6200EBCEF1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
9656CD221C6CFA6200EBCEF1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 9656CD221C6CFA6200EBCEF1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9612606B1C78E92000BF0079 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
9656CD141C6CFA6200EBCEF1 = { 9656CD141C6CFA6200EBCEF1 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9612606A1C78E92000BF0079 /* Material.framework */,
9656CD1F1C6CFA6200EBCEF1 /* Grid */, 9656CD1F1C6CFA6200EBCEF1 /* Grid */,
9656CD1E1C6CFA6200EBCEF1 /* Products */, 9656CD1E1C6CFA6200EBCEF1 /* Products */,
); );
......
...@@ -40,10 +40,10 @@ class ViewController: UIViewController { ...@@ -40,10 +40,10 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
// prepareHorizontalGridViewExample() prepareHorizontalGridViewExample()
// prepareVerticalGridViewExample() // prepareVerticalGridViewExample()
// prepareGridDirectionNoneExample() // prepareGridDirectionNoneExample()
prepareSmallCardViewExample() // prepareSmallCardViewExample()
// prepareMediumCardViewExample() // prepareMediumCardViewExample()
// prepareLargeCardViewExample() // prepareLargeCardViewExample()
} }
...@@ -83,23 +83,49 @@ class ViewController: UIViewController { ...@@ -83,23 +83,49 @@ class ViewController: UIViewController {
btn3.setImage(image, forState: .Highlighted) btn3.setImage(image, forState: .Highlighted)
view.addSubview(btn3) view.addSubview(btn3)
btn1.grid.columns = 3 btn1.grid.rows = 2
btn2.grid.columns = 3 btn2.grid.rows = 2
btn3.grid.columns = 3 btn3.grid.rows = 2
//
view.grid.columns = 9 // view.grid.columns = 9
view.grid.axis.rows = 6
view.grid.spacing = 16 view.grid.spacing = 16
view.grid.axis.direction = .Vertical
view.grid.contentInset.left = 16 view.grid.contentInset.left = 16
view.grid.contentInset.right = 16 view.grid.contentInset.right = 16
view.grid.contentInset.top = 100 view.grid.contentInset.top = 100
view.grid.contentInset.bottom = 100 // view.grid.contentInset.bottom = 100
view.grid.views = [btn1, btn2, btn3] view.grid.views = [btn2, btn1, btn3]
btn2.backgroundColor = MaterialColor.blue.darken1
for v in view.grid.views! { for v in view.grid.views! {
print(v.frame) print(v.frame)
} }
let menuButton: FabButton = FabButton()
let mb1: FabButton = FabButton()
let mb2: FabButton = FabButton()
let mb3: FabButton = FabButton()
let menuView: MenuView = MenuView()
menuView.addSubview(mb1)
menuView.addSubview(mb2)
menuView.addSubview(mb3)
// Initialize the menu and setup the configuration options.
menuView.menu.direction = .Up
// menuView.menu.baseViewSize = CGSizeMake(56, 56)
menuView.menu.views = [menuButton, mb1, mb2, mb3]
view.addSubview(menuView)
menuView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.size(view, child: menuView, width: 56, height: 56)
MaterialLayout.alignFromBottomLeft(view, child: menuView, bottom: 16, left: (view.bounds.width - 56) / 2)
menuView.backgroundColor = MaterialColor.green.base
} }
/// Prepares the Vertical GridView example. /// Prepares the Vertical GridView example.
...@@ -203,7 +229,7 @@ class ViewController: UIViewController { ...@@ -203,7 +229,7 @@ class ViewController: UIViewController {
image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton() let moreButton: FlatButton = FlatButton()
moreButton.contentInsetPreset = .None moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
...@@ -228,7 +254,7 @@ class ViewController: UIViewController { ...@@ -228,7 +254,7 @@ class ViewController: UIViewController {
image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate)
let alarmButton: FlatButton = FlatButton() let alarmButton: FlatButton = FlatButton()
alarmButton.contentInsetPreset = .None alarmButton.contentEdgeInsetsPreset = .None
alarmButton.pulseColor = MaterialColor.blueGrey.darken4 alarmButton.pulseColor = MaterialColor.blueGrey.darken4
alarmButton.tintColor = MaterialColor.red.base alarmButton.tintColor = MaterialColor.red.base
alarmButton.setImage(image, forState: .Normal) alarmButton.setImage(image, forState: .Normal)
...@@ -301,7 +327,7 @@ class ViewController: UIViewController { ...@@ -301,7 +327,7 @@ class ViewController: UIViewController {
image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton() let moreButton: FlatButton = FlatButton()
moreButton.contentInsetPreset = .None moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
...@@ -326,7 +352,7 @@ class ViewController: UIViewController { ...@@ -326,7 +352,7 @@ class ViewController: UIViewController {
image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate)
let alarmButton: FlatButton = FlatButton() let alarmButton: FlatButton = FlatButton()
alarmButton.contentInsetPreset = .None alarmButton.contentEdgeInsetsPreset = .None
alarmButton.pulseColor = MaterialColor.blueGrey.darken4 alarmButton.pulseColor = MaterialColor.blueGrey.darken4
alarmButton.tintColor = MaterialColor.red.base alarmButton.tintColor = MaterialColor.red.base
alarmButton.setImage(image, forState: .Normal) alarmButton.setImage(image, forState: .Normal)
...@@ -411,7 +437,7 @@ class ViewController: UIViewController { ...@@ -411,7 +437,7 @@ class ViewController: UIViewController {
image = UIImage(named: "ic_more_horiz_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_more_horiz_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton() let moreButton: FlatButton = FlatButton()
moreButton.contentInsetPreset = .None moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
...@@ -436,7 +462,7 @@ class ViewController: UIViewController { ...@@ -436,7 +462,7 @@ class ViewController: UIViewController {
image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate)
let alarmButton: FlatButton = FlatButton() let alarmButton: FlatButton = FlatButton()
alarmButton.contentInsetPreset = .None alarmButton.contentEdgeInsetsPreset = .None
alarmButton.pulseColor = MaterialColor.blueGrey.darken4 alarmButton.pulseColor = MaterialColor.blueGrey.darken4
alarmButton.tintColor = MaterialColor.red.base alarmButton.tintColor = MaterialColor.red.base
alarmButton.setImage(image, forState: .Normal) alarmButton.setImage(image, forState: .Normal)
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
961260711C78EFE500BF0079 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 961260701C78EFE500BF0079 /* Material.framework */; };
961260721C78EFE500BF0079 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 961260701C78EFE500BF0079 /* 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 */; };
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
961260721C78EFE500BF0079 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
961260701C78EFE500BF0079 /* 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>"; };
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
961260711C78EFE500BF0079 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
96D88C761C132C1800B91418 = { 96D88C761C132C1800B91418 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
961260701C78EFE500BF0079 /* Material.framework */,
96D88C811C132C1800B91418 /* NavigationBarView */, 96D88C811C132C1800B91418 /* NavigationBarView */,
96D88C801C132C1800B91418 /* Products */, 96D88C801C132C1800B91418 /* Products */,
); );
......
...@@ -76,10 +76,10 @@ class ViewController: UIViewController { ...@@ -76,10 +76,10 @@ class ViewController: UIViewController {
menuButton.pulseScale = false menuButton.pulseScale = false
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
//
// Switch control. // Switch control.
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small) let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small)
//
// Search button. // Search button.
image = UIImage(named: "ic_search_white") image = UIImage(named: "ic_search_white")
let searchButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
......
...@@ -7,11 +7,18 @@ ...@@ -7,11 +7,18 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
9600361B1C7828BB00EBA579 /* BlueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9600361A1C7828BB00EBA579 /* BlueViewController.swift */; };
9600361D1C7829EF00EBA579 /* GreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9600361C1C7829EF00EBA579 /* GreenViewController.swift */; };
9626C2E01C7950AB007CA8E0 /* AppMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626C2DF1C7950AB007CA8E0 /* AppMenuViewController.swift */; };
9626C2E21C795717007CA8E0 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626C2E11C795717007CA8E0 /* AppLeftViewController.swift */; };
9626C2E41C79594B007CA8E0 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626C2E31C79594B007CA8E0 /* AppRightViewController.swift */; };
9626C2E61C7962B5007CA8E0 /* SearchListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626C2E51C7962B5007CA8E0 /* SearchListViewController.swift */; };
9626C2E81C7962D5007CA8E0 /* AppSearchBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626C2E71C7962D5007CA8E0 /* AppSearchBarViewController.swift */; };
96A71FC41C765FDF00C0C4AE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FC31C765FDF00C0C4AE /* AppDelegate.swift */; }; 96A71FC41C765FDF00C0C4AE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FC31C765FDF00C0C4AE /* AppDelegate.swift */; };
96A71FC61C765FDF00C0C4AE /* AppNavigationBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FC51C765FDF00C0C4AE /* AppNavigationBarViewController.swift */; }; 96A71FC61C765FDF00C0C4AE /* AppNavigationBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FC51C765FDF00C0C4AE /* AppNavigationBarViewController.swift */; };
96A71FCB1C765FDF00C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71FCA1C765FDF00C0C4AE /* Assets.xcassets */; }; 96A71FCB1C765FDF00C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71FCA1C765FDF00C0C4AE /* Assets.xcassets */; };
96A71FCE1C765FDF00C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71FCC1C765FDF00C0C4AE /* LaunchScreen.storyboard */; }; 96A71FCE1C765FDF00C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71FCC1C765FDF00C0C4AE /* LaunchScreen.storyboard */; };
96A71FD61C76618D00C0C4AE /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FD51C76618D00C0C4AE /* MainViewController.swift */; }; 96A71FD61C76618D00C0C4AE /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FD51C76618D00C0C4AE /* FeedViewController.swift */; };
96A7200C1C76E53A00C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200B1C76E53A00C0C4AE /* Material.framework */; }; 96A7200C1C76E53A00C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200B1C76E53A00C0C4AE /* Material.framework */; };
96A7200D1C76E53A00C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200B1C76E53A00C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 96A7200D1C76E53A00C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200B1C76E53A00C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -31,13 +38,20 @@ ...@@ -31,13 +38,20 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
9600361A1C7828BB00EBA579 /* BlueViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueViewController.swift; sourceTree = "<group>"; };
9600361C1C7829EF00EBA579 /* GreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GreenViewController.swift; sourceTree = "<group>"; };
9626C2DF1C7950AB007CA8E0 /* AppMenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMenuViewController.swift; sourceTree = "<group>"; };
9626C2E11C795717007CA8E0 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; };
9626C2E31C79594B007CA8E0 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; };
9626C2E51C7962B5007CA8E0 /* SearchListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchListViewController.swift; sourceTree = "<group>"; };
9626C2E71C7962D5007CA8E0 /* AppSearchBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppSearchBarViewController.swift; sourceTree = "<group>"; };
96A71FC01C765FDF00C0C4AE /* NavigationBarViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationBarViewController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 96A71FC01C765FDF00C0C4AE /* NavigationBarViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationBarViewController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96A71FC31C765FDF00C0C4AE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 96A71FC31C765FDF00C0C4AE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96A71FC51C765FDF00C0C4AE /* AppNavigationBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppNavigationBarViewController.swift; sourceTree = "<group>"; }; 96A71FC51C765FDF00C0C4AE /* AppNavigationBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppNavigationBarViewController.swift; sourceTree = "<group>"; };
96A71FCA1C765FDF00C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96A71FCA1C765FDF00C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A71FCD1C765FDF00C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96A71FCD1C765FDF00C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A71FCF1C765FDF00C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 96A71FCF1C765FDF00C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71FD51C76618D00C0C4AE /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; }; 96A71FD51C76618D00C0C4AE /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
96A7200B1C76E53A00C0C4AE /* 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>"; }; 96A7200B1C76E53A00C0C4AE /* 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 */
...@@ -75,7 +89,14 @@ ...@@ -75,7 +89,14 @@
children = ( children = (
96A71FC31C765FDF00C0C4AE /* AppDelegate.swift */, 96A71FC31C765FDF00C0C4AE /* AppDelegate.swift */,
96A71FC51C765FDF00C0C4AE /* AppNavigationBarViewController.swift */, 96A71FC51C765FDF00C0C4AE /* AppNavigationBarViewController.swift */,
96A71FD51C76618D00C0C4AE /* MainViewController.swift */, 9626C2E71C7962D5007CA8E0 /* AppSearchBarViewController.swift */,
9626C2DF1C7950AB007CA8E0 /* AppMenuViewController.swift */,
9626C2E11C795717007CA8E0 /* AppLeftViewController.swift */,
9626C2E31C79594B007CA8E0 /* AppRightViewController.swift */,
96A71FD51C76618D00C0C4AE /* FeedViewController.swift */,
9600361A1C7828BB00EBA579 /* BlueViewController.swift */,
9600361C1C7829EF00EBA579 /* GreenViewController.swift */,
9626C2E51C7962B5007CA8E0 /* SearchListViewController.swift */,
96A71FCA1C765FDF00C0C4AE /* Assets.xcassets */, 96A71FCA1C765FDF00C0C4AE /* Assets.xcassets */,
96A71FCC1C765FDF00C0C4AE /* LaunchScreen.storyboard */, 96A71FCC1C765FDF00C0C4AE /* LaunchScreen.storyboard */,
96A71FCF1C765FDF00C0C4AE /* Info.plist */, 96A71FCF1C765FDF00C0C4AE /* Info.plist */,
...@@ -154,9 +175,16 @@ ...@@ -154,9 +175,16 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71FD61C76618D00C0C4AE /* MainViewController.swift in Sources */, 9600361B1C7828BB00EBA579 /* BlueViewController.swift in Sources */,
9626C2E61C7962B5007CA8E0 /* SearchListViewController.swift in Sources */,
9626C2E21C795717007CA8E0 /* AppLeftViewController.swift in Sources */,
96A71FD61C76618D00C0C4AE /* FeedViewController.swift in Sources */,
9626C2E81C7962D5007CA8E0 /* AppSearchBarViewController.swift in Sources */,
9600361D1C7829EF00EBA579 /* GreenViewController.swift in Sources */,
96A71FC61C765FDF00C0C4AE /* AppNavigationBarViewController.swift in Sources */, 96A71FC61C765FDF00C0C4AE /* AppNavigationBarViewController.swift in Sources */,
9626C2E41C79594B007CA8E0 /* AppRightViewController.swift in Sources */,
96A71FC41C765FDF00C0C4AE /* AppDelegate.swift in Sources */, 96A71FC41C765FDF00C0C4AE /* AppDelegate.swift in Sources */,
9626C2E01C7950AB007CA8E0 /* AppMenuViewController.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch. // Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds) window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = AppNavigationBarViewController(mainViewController: MainViewController()) window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: FeedViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
return true return true
} }
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
The following is an example of setting a UITableView as the LeftViewController
within a SideNavigationViewController.
*/
import UIKit
import Material
private struct Cell {
var text: String
var imageName: String
var selected: Bool
}
class AppLeftViewController: UIViewController {
/// A tableView used to display navigation items.
private let tableView: UITableView = UITableView()
/// A list of all the navigation items.
private var items: Array<Cell> = Array<Cell>()
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareCells()
prepareTableView()
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
/*
The dimensions of the view will not be updated by the side navigation
until the view appears, so loading a dyanimc width is better done here.
The user will not see this, as it is hidden, by the drawer being closed
when launching the app. There are other strategies to mitigate from this.
This is one approach that works nicely here.
*/
prepareProfileView()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.blueGrey.darken4
}
/// 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))
}
/// Prepares profile view.
private func prepareProfileView() {
let backgroundView: MaterialView = MaterialView()
backgroundView.image = UIImage(named: "MaterialBackground")
let profileView: MaterialView = MaterialView()
profileView.image = UIImage(named: "Profile9")?.resize(toWidth: 72)
profileView.backgroundColor = MaterialColor.clear
profileView.shape = .Circle
profileView.borderColor = MaterialColor.white
profileView.borderWidth = 3
view.addSubview(profileView)
let nameLabel: UILabel = UILabel()
nameLabel.text = "Michael Smith"
nameLabel.textColor = MaterialColor.white
nameLabel.font = RobotoFont.mediumWithSize(18)
view.addSubview(nameLabel)
profileView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTopLeft(view, child: profileView, top: 30, left: (view.bounds.width - 72) / 2)
MaterialLayout.size(view, child: profileView, width: 72, height: 72)
nameLabel.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(view, child: nameLabel, top: 130)
MaterialLayout.alignToParentHorizontally(view, child: nameLabel, left: 20, right: 20)
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.backgroundColor = MaterialColor.clear
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .None
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView, top: 170)
}
}
/// TableViewDataSource methods.
extension AppLeftViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row]
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.medium
cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate)
cell.imageView!.tintColor = MaterialColor.grey.lighten2
cell.textLabel!.textColor = item.selected ? MaterialColor.cyan.lighten5 : MaterialColor.grey.lighten3
return cell
}
}
/// UITableViewDelegate methods.
extension AppLeftViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 64
}
/// Select item at row in tableView.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Cell selected")
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of GraphKit nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
The following is an example of using a MenuViewController to control the
flow of your application.
*/
import UIKit
import Material
class AppMenuViewController: MenuViewController {
/// MenuView diameter.
private let baseViewSize: CGSize = CGSizeMake(56, 56)
/// MenuView inset.
private let menuViewInset: CGFloat = 16
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareMenuView()
}
/**
*/
func handleBtn2() {
if navigationBarViewController?.mainViewController is BlueViewController {
return
}
handleMenu()
menuViewController?.transitionFromMainViewController(BlueViewController())
navigationBarViewController?.navigationBarView.titleLabel?.text = "Blue"
}
/**
*/
func handleBtn3() {
if navigationBarViewController?.mainViewController is GreenViewController {
return
}
handleMenu()
menuViewController?.transitionFromMainViewController(GreenViewController())
navigationBarViewController?.navigationBarView.titleLabel?.text = "Green"
}
/**
*/
func handleBtn4() {
if navigationBarViewController?.mainViewController is FeedViewController {
return
}
handleMenu()
menuViewController?.transitionFromMainViewController(AppNavigationBarViewController(mainViewController: FeedViewController()))
navigationBarViewController?.navigationBarView.titleLabel?.text = "Feed"
}
/// Handle the menuView touch event.
func handleMenu() {
var rotate: Double = -0.125
if true == menuView.menu.opened {
hideMenuBackdrop()
menuView.menu.close()
} else {
showMenuBackdrop()
rotate = 0.125
menuView.menu.open() { (v: UIView) in
(v as? MaterialButton)?.pulse()
}
}
(menuView.menu.views?.first as? MaterialButton)?.animate(MaterialAnimation.rotate(rotate))
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
}
/// Prepares the add button.
private func prepareMenuView() {
var image: UIImage? = UIImage(named: "ic_add_white")
let btn1: FabButton = FabButton()
btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: "handleMenu", forControlEvents: .TouchUpInside)
menuView.addSubview(btn1)
image = UIImage(named: "ic_create_white")
let btn2: FabButton = FabButton()
btn2.backgroundColor = MaterialColor.blue.base
btn2.setImage(image, forState: .Normal)
btn2.setImage(image, forState: .Highlighted)
menuView.addSubview(btn2)
btn2.addTarget(self, action: "handleBtn2", forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_photo_camera_white")
let btn3: FabButton = FabButton()
btn3.backgroundColor = MaterialColor.green.base
btn3.setImage(image, forState: .Normal)
btn3.setImage(image, forState: .Highlighted)
menuView.addSubview(btn3)
btn3.addTarget(self, action: "handleBtn3", forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_note_add_white")
let btn4: FabButton = FabButton()
btn4.backgroundColor = MaterialColor.yellow.base
btn4.setImage(image, forState: .Normal)
btn4.setImage(image, forState: .Highlighted)
menuView.addSubview(btn4)
btn4.addTarget(self, action: "handleBtn4", forControlEvents: .TouchUpInside)
// Initialize the menu and setup the configuration options.
menuView.menu.direction = .Up
menuView.menu.baseViewSize = baseViewSize
menuView.menu.views = [btn1, btn2, btn3, btn4]
view.addSubview(menuView)
menuView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.size(view, child: menuView, width: baseViewSize.width, height: baseViewSize.height)
MaterialLayout.alignFromBottomRight(view, child: menuView, bottom: menuViewInset, right: menuViewInset)
}
/// Displays the menuBackdrop.
private func showMenuBackdrop() {
// Disable the side nav, so users can't swipe while viewing the menu.
sideNavigationViewController?.enabled = false
navigationBarViewController?.navigationBarView.userInteractionEnabled = false
navigationBarViewController?.navigationBarView.alpha = 0.5
menuViewController?.mainViewController.view.userInteractionEnabled = false
menuViewController?.mainViewController.view.alpha = 0.5
}
/// Hides the menuBackdrop.
private func hideMenuBackdrop() {
// Enable the side nav.
sideNavigationViewController?.enabled = true
navigationBarViewController?.navigationBarView.userInteractionEnabled = true
navigationBarViewController?.navigationBarView.alpha = 1
menuViewController?.mainViewController.view.userInteractionEnabled = true
menuViewController?.mainViewController.view.alpha = 1
}
}
...@@ -37,77 +37,58 @@ import UIKit ...@@ -37,77 +37,58 @@ import UIKit
import Material import Material
class AppNavigationBarViewController: NavigationBarViewController { class AppNavigationBarViewController: NavigationBarViewController {
/// Menu backdrop layer. override var floatingViewController: UIViewController? {
private lazy var menuBackdropLayer: MaterialLayer = MaterialLayer() didSet {
if nil == floatingViewController {
/// MenuView diameter. /*
private let menuViewDiameter: CGFloat = 56 To lighten the status bar - add the
"View controller-based status bar appearance = NO"
/// MenuView inset. to your info.plist file and set the following property.
private let menuViewInset: CGFloat = 16 */
navigationBarView.statusBarStyle = .LightContent
/// MenuView. }
private let menuView: MenuView = MenuView() }
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareNavigationBarView() prepareNavigationBarView()
prepareMenuBackdropLayer()
prepareMenuView()
} }
/** override func viewWillAppear(animated: Bool) {
Handles the menu button click, which opens the super.viewWillAppear(animated)
SideNavigationBarViewController. /*
To lighten the status bar - add the
"View controller-based status bar appearance = NO"
to your info.plist file and set the following property.
*/ */
func handleMenuButton() { navigationBarView.statusBarStyle = .LightContent
sideNavigationBarViewController?.openLeftView()
} }
/** /// Prepares view.
Handles the more button click, which opens the private func prepareView() {
SideNavigationBarViewController. view.backgroundColor = MaterialColor.white
*/
func handleMoreButton() {
sideNavigationBarViewController?.openRightView()
} }
/// Handle the menuView touch event. /// Toggle SideNavigationViewController left UIViewController.
func handleMenu() { internal func handleMenuButton() {
let image: UIImage? sideNavigationViewController?.toggleLeftView()
if menuView.menu.opened {
hideMenuBackdropLayer()
menuView.menu.close()
image = UIImage(named: "ic_add_white")
} else {
showMenuBackdropLayer()
menuView.menu.open() { (v: UIView) in
(v as? MaterialButton)?.pulse()
}
image = UIImage(named: "ic_close_white")
} }
// Add a nice rotation animation to the base button. /// Toggle SideNavigationViewController right UIViewController.
let first: MaterialButton? = menuView.menu.views?.first as? MaterialButton internal func handleSearchButton() {
first?.animate(MaterialAnimation.rotate(1)) guard let v: AppSearchBarViewController = AppSearchBarViewController(mainViewController: SearchListViewController()) else {
first?.setImage(image, forState: .Normal) return
first?.setImage(image, forState: .Highlighted)
} }
navigationBarViewController?.floatingViewController = v
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
} }
/// Prepares the navigationBarView. /// Prepares the navigationBarView.
private func prepareNavigationBarView() { private func prepareNavigationBarView() {
// Title label. // Title label.
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.text = "Inbox" titleLabel.text = "Feed"
titleLabel.textAlignment = .Left titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20) titleLabel.font = RobotoFont.regularWithSize(20)
...@@ -135,107 +116,18 @@ class AppNavigationBarViewController: NavigationBarViewController { ...@@ -135,107 +116,18 @@ class AppNavigationBarViewController: NavigationBarViewController {
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small) let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small)
// Search button. // Search button.
image = UIImage(named: "ic_more_horiz_white") image = UIImage(named: "ic_search_white")
let moreButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
moreButton.pulseColor = MaterialColor.white searchButton.pulseColor = MaterialColor.white
moreButton.pulseScale = false searchButton.pulseScale = false
moreButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
moreButton.addTarget(self, action: "handleMoreButton", forControlEvents: .TouchUpInside) searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
/*
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.blue.base navigationBarView.backgroundColor = MaterialColor.blue.base
navigationBarView.titleLabel = titleLabel navigationBarView.titleLabel = titleLabel
navigationBarView.leftControls = [menuButton] navigationBarView.leftControls = [menuButton]
navigationBarView.rightControls = [switchControl, moreButton] navigationBarView.rightControls = [switchControl, searchButton]
}
/// Prepares the menuBackdropLayer.
private func prepareMenuBackdropLayer() {
menuBackdropLayer.backgroundColor = MaterialColor.white.colorWithAlphaComponent(0.75).CGColor
menuBackdropLayer.hidden = true
menuBackdropLayer.zPosition = 2000
view.layer.addSublayer(menuBackdropLayer)
}
/// Prepares the add button.
private func prepareMenuView() {
var image: UIImage? = UIImage(named: "ic_add_white")
let btn1: FabButton = FabButton()
btn1.pulseColor = nil
btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: "handleMenu", forControlEvents: .TouchUpInside)
menuView.addSubview(btn1)
image = UIImage(named: "ic_create_white")
let btn2: FabButton = FabButton()
btn2.backgroundColor = MaterialColor.blue.base
btn2.setImage(image, forState: .Normal)
btn2.setImage(image, forState: .Highlighted)
menuView.addSubview(btn2)
image = UIImage(named: "ic_photo_camera_white")
let btn3: FabButton = FabButton()
btn3.backgroundColor = MaterialColor.green.base
btn3.setImage(image, forState: .Normal)
btn3.setImage(image, forState: .Highlighted)
menuView.addSubview(btn3)
image = UIImage(named: "ic_note_add_white")
let btn4: FabButton = FabButton()
btn4.backgroundColor = MaterialColor.amber.base
btn4.setImage(image, forState: .Normal)
btn4.setImage(image, forState: .Highlighted)
menuView.addSubview(btn4)
// Initialize the menu and setup the configuration options.
menuView.menu.direction = .Up
menuView.menu.baseViewSize = CGSizeMake(menuViewDiameter, menuViewDiameter)
menuView.menu.views = [btn1, btn2, btn3, btn4]
menuView.zPosition = 3000
view.insertSubview(menuView, aboveSubview: navigationBarView)
menuView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.size(view, child: menuView, width: menuViewDiameter, height: menuViewDiameter)
MaterialLayout.alignFromBottomRight(view, child: menuView, bottom: menuViewInset, right: menuViewInset)
}
/// Displays the menuBackdropLayer.
private func showMenuBackdropLayer() {
// Disable the side nav, so users can't swipe while viewing the menu.
sideNavigationBarViewController?.enabled = false
// Position the menuBackdropLayer for the animation when opening.
MaterialAnimation.animationDisabled { [unowned self] in
self.menuBackdropLayer.frame = self.menuView.frame
self.menuBackdropLayer.shape = .Circle
self.menuBackdropLayer.hidden = false
}
menuBackdropLayer.animate(MaterialAnimation.scale(30, duration: 0.25))
}
/// Hides the menuBackdropLayer.
private func hideMenuBackdropLayer() {
// Enable the side nav.
sideNavigationBarViewController?.enabled = true
// Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer.animate(MaterialAnimation.animationGroup([
MaterialAnimation.scale(1),
MaterialAnimation.position(menuView.center)
], duration: 0.25))
MaterialAnimation.delay(0.25) { [weak self] in
self?.menuBackdropLayer.hidden = true
}
} }
} }
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
The following is an example of setting a UITableView as the RightViewController
within a SideNavigationViewController.
*/
import UIKit
import Material
private struct Cell {
var text: String
var imageName: String
var selected: Bool
}
class AppRightViewController: UIViewController {
/// A tableView used to display navigation items.
private let tableView: UITableView = UITableView()
/// A list of all the navigation items.
private var items: Array<Cell> = Array<Cell>()
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareCells()
prepareTableView()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.blueGrey.darken4
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
/// 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: "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))
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.backgroundColor = MaterialColor.clear
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .None
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView)
}
}
/// TableViewDataSource methods.
extension AppRightViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row]
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.medium
cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate)
cell.imageView!.tintColor = MaterialColor.grey.lighten2
cell.textLabel!.textColor = item.selected ? MaterialColor.cyan.lighten5 : MaterialColor.grey.lighten3
return cell
}
}
/// UITableViewDelegate methods.
extension AppRightViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 64
}
/// Select item at row in tableView.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("Cell selected")
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of GraphKit nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
The following is an example of using a SearchBarViewController to control the
flow of your application.
*/
import UIKit
import Material
class AppSearchBarViewController: SearchBarViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareSearchBarView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
}
/// Toggle SideSearchViewController left UIViewController.
internal func handleBackButton() {
navigationBarViewController?.floatingViewController = nil
}
/// Toggle SideSearchViewController right UIViewController.
internal func handleMoreButton() {
searchBarView.textField.resignFirstResponder()
sideNavigationViewController?.delegate = self
sideNavigationViewController?.enabledRightView = true
sideNavigationViewController?.toggleRightView()
}
/// Prepares the searchBarView.
private func prepareSearchBarView() {
var image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate)
let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.blueGrey.darken4
clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.blueGrey.darken4
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
// Back button.
image = UIImage(named: "ic_arrow_back_white")?.imageWithRenderingMode(.AlwaysTemplate)
let backButton: FlatButton = FlatButton()
backButton.pulseColor = MaterialColor.blueGrey.darken4
backButton.pulseScale = false
backButton.tintColor = MaterialColor.blueGrey.darken4
backButton.setImage(image, forState: .Normal)
backButton.setImage(image, forState: .Highlighted)
backButton.addTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside)
// Search button.
image = UIImage(named: "ic_more_horiz_white")?.imageWithRenderingMode(.AlwaysTemplate)
let searchButton: FlatButton = FlatButton()
searchButton.pulseColor = MaterialColor.blueGrey.darken4
searchButton.pulseScale = false
searchButton.tintColor = MaterialColor.blueGrey.darken4
searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted)
searchButton.addTarget(self, action: "handleMoreButton", forControlEvents: .TouchUpInside)
/*
To lighten the status bar - add the
"View controller-based status bar appearance = NO"
to your info.plist file and set the following property.
*/
searchBarView.statusBarStyle = .Default
searchBarView.delegate = self
searchBarView.placeholder = "Search"
searchBarView.tintColor = MaterialColor.blueGrey.darken4
searchBarView.textColor = MaterialColor.blueGrey.darken4
searchBarView.placeholderTextColor = MaterialColor.blueGrey.darken4
searchBarView.textField.font = RobotoFont.regularWithSize(17)
searchBarView.clearButton = clearButton
searchBarView.leftControls = [backButton]
searchBarView.rightControls = [searchButton]
}
}
extension AppSearchBarViewController: SideNavigationViewControllerDelegate {
func sideNavigationViewWillClose(sideNavigationViewController: SideNavigationViewController, position: SideNavigationPosition) {
sideNavigationViewController.enabledRightView = false
sideNavigationViewController.delegate = nil
searchBarView.textField.becomeFirstResponder()
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile1.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile2.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile3.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile4.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile5.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile6.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile7.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile8.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile9.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_arrow_back_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_back_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_back_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_book.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_book_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_book_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_close_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_contacts.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_contacts_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_contacts_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_create_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_create_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_create_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_inbox.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_inbox_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_inbox_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_note_add_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_note_add_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_note_add_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_search_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_settings.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_settings_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_settings_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_today.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_today_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_today_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_work.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_work_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_work_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ 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 GraphKit nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class BlueViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.blue.base
}
}
...@@ -37,7 +37,7 @@ private struct Item { ...@@ -37,7 +37,7 @@ private struct Item {
var image: UIImage? var image: UIImage?
} }
class MainViewController: UIViewController { class FeedViewController: UIViewController {
/// A tableView used to display Bond entries. /// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView() private let tableView: UITableView = UITableView()
...@@ -53,10 +53,10 @@ class MainViewController: UIViewController { ...@@ -53,10 +53,10 @@ class MainViewController: UIViewController {
/** /**
Handles the search button click, which opens the Handles the search button click, which opens the
SideNavigationBarViewController. SideNavigationViewController.
*/ */
func handleSearchButton() { func handleSearchButton() {
sideNavigationBarViewController?.openRightView() sideNavigationViewController?.openRightView()
} }
/// Prepares view. /// Prepares view.
...@@ -90,7 +90,7 @@ class MainViewController: UIViewController { ...@@ -90,7 +90,7 @@ class MainViewController: UIViewController {
} }
/// TableViewDataSource methods. /// TableViewDataSource methods.
extension MainViewController: UITableViewDataSource { extension FeedViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView. /// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count; return items.count;
...@@ -137,7 +137,7 @@ extension MainViewController: UITableViewDataSource { ...@@ -137,7 +137,7 @@ extension MainViewController: UITableViewDataSource {
} }
/// UITableViewDelegate methods. /// UITableViewDelegate methods.
extension MainViewController: UITableViewDelegate { extension FeedViewController: UITableViewDelegate {
/// Sets the tableView cell height. /// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80 return 80
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of GraphKit nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class GreenViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.green.base
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of GraphKit nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
private struct Item {
var text: String
var detail: String
var image: UIImage?
}
class SearchListViewController: 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)
searchBarViewController?.searchBarView.textField.becomeFirstResponder()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
}
/// Prepares the items Array.
private func prepareItems() {
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 SearchListViewController: 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 = "Suggestions"
header.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(header, child: label, left: searchBarViewController!.searchBarView.contentInset.left + searchBarViewController!.searchBarView.spacing)
return header
}
}
/// UITableViewDelegate methods.
extension SearchListViewController: 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
}
}
...@@ -59,18 +59,18 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -59,18 +59,18 @@ class AppSearchBarViewController: SearchBarViewController {
/** /**
Handles the menu button click, which opens the Handles the menu button click, which opens the
SideNavigationBarViewController. SideNavigationViewController.
*/ */
func handleMenuButton() { func handleMenuButton() {
sideNavigationBarViewController?.openLeftView() sideNavigationViewController?.openLeftView()
} }
/** /**
Handles the more button click, which opens the Handles the more button click, which opens the
SideNavigationBarViewController. SideNavigationViewController.
*/ */
func handleMoreButton() { func handleMoreButton() {
sideNavigationBarViewController?.openRightView() sideNavigationViewController?.openRightView()
} }
/// Handle the menuView touch event. /// Handle the menuView touch event.
...@@ -200,7 +200,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -200,7 +200,7 @@ class AppSearchBarViewController: SearchBarViewController {
/// Displays the menuBackdropLayer. /// Displays the menuBackdropLayer.
private func showMenuBackdropLayer() { private func showMenuBackdropLayer() {
// Disable the side nav, so users can't swipe while viewing the menu. // Disable the side nav, so users can't swipe while viewing the menu.
sideNavigationBarViewController?.enabled = false sideNavigationViewController?.enabled = false
// Position the menuBackdropLayer for the animation when opening. // Position the menuBackdropLayer for the animation when opening.
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
...@@ -215,7 +215,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -215,7 +215,7 @@ class AppSearchBarViewController: SearchBarViewController {
/// Hides the menuBackdropLayer. /// Hides the menuBackdropLayer.
private func hideMenuBackdropLayer() { private func hideMenuBackdropLayer() {
// Enable the side nav. // Enable the side nav.
sideNavigationBarViewController?.enabled = true sideNavigationViewController?.enabled = true
// Position the menuBackdropLayer for the animation when closing. // Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer.animate(MaterialAnimation.animationGroup([ menuBackdropLayer.animate(MaterialAnimation.animationGroup([
......
...@@ -53,10 +53,10 @@ class MainViewController: UIViewController { ...@@ -53,10 +53,10 @@ class MainViewController: UIViewController {
/** /**
Handles the search button click, which opens the Handles the search button click, which opens the
SideNavigationBarViewController. SideNavigationViewController.
*/ */
func handleSearchButton() { func handleSearchButton() {
sideNavigationBarViewController?.openRightView() sideNavigationViewController?.openRightView()
} }
/// Prepares view. /// Prepares view.
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
961260741C78F2C700BF0079 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 961260731C78F2C700BF0079 /* Material.framework */; };
961260751C78F2C700BF0079 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 961260731C78F2C700BF0079 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9642FA1B1C1B50E700022BC6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA1A1C1B50E700022BC6 /* AppDelegate.swift */; }; 9642FA1B1C1B50E700022BC6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA1A1C1B50E700022BC6 /* AppDelegate.swift */; };
9642FA1D1C1B50E700022BC6 /* AppNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA1C1C1B50E700022BC6 /* AppNavigationViewController.swift */; }; 9642FA1D1C1B50E700022BC6 /* AppNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA1C1C1B50E700022BC6 /* AppNavigationViewController.swift */; };
9642FA221C1B50E700022BC6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9642FA211C1B50E700022BC6 /* Assets.xcassets */; }; 9642FA221C1B50E700022BC6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9642FA211C1B50E700022BC6 /* Assets.xcassets */; };
...@@ -24,6 +26,7 @@ ...@@ -24,6 +26,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
961260751C78F2C700BF0079 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -31,6 +34,7 @@ ...@@ -31,6 +34,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
961260731C78F2C700BF0079 /* 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>"; };
9642FA171C1B50E700022BC6 /* SideNavigationViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SideNavigationViewController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 9642FA171C1B50E700022BC6 /* SideNavigationViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SideNavigationViewController.app; sourceTree = BUILT_PRODUCTS_DIR; };
9642FA1A1C1B50E700022BC6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 9642FA1A1C1B50E700022BC6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
9642FA1C1C1B50E700022BC6 /* AppNavigationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppNavigationViewController.swift; sourceTree = "<group>"; }; 9642FA1C1C1B50E700022BC6 /* AppNavigationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppNavigationViewController.swift; sourceTree = "<group>"; };
...@@ -48,6 +52,7 @@ ...@@ -48,6 +52,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
961260741C78F2C700BF0079 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -57,6 +62,7 @@ ...@@ -57,6 +62,7 @@
9642FA0E1C1B50E700022BC6 = { 9642FA0E1C1B50E700022BC6 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
961260731C78F2C700BF0079 /* Material.framework */,
9642FA191C1B50E700022BC6 /* SideNavigationViewController */, 9642FA191C1B50E700022BC6 /* SideNavigationViewController */,
9642FA181C1B50E700022BC6 /* Products */, 9642FA181C1B50E700022BC6 /* Products */,
); );
......
...@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch. // Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds) window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = SideNavigationBarViewController(mainViewController: AppNavigationBarViewController(mainViewController: FeedViewController()), leftViewController: LeftViewController(), rightViewController: RightViewController()) window!.rootViewController = SideNavigationViewController(mainViewController: AppNavigationBarViewController(mainViewController: FeedViewController()), leftViewController: LeftViewController(), rightViewController: RightViewController())
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
return true return true
} }
......
...@@ -53,10 +53,10 @@ class FeedViewController: UIViewController { ...@@ -53,10 +53,10 @@ class FeedViewController: UIViewController {
/** /**
Handles the search button click, which opens the Handles the search button click, which opens the
SideNavigationBarViewController. SideNavigationViewController.
*/ */
func handleSearchButton() { func handleSearchButton() {
sideNavigationBarViewController?.openRightView() sideNavigationViewController?.openRightView()
} }
/// Prepares view. /// Prepares view.
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
/* /*
The following is an example of setting a UITableView as the LeftViewController The following is an example of setting a UITableView as the LeftViewController
within a SideNavigationBarViewController. within a SideNavigationViewController.
*/ */
import UIKit import UIKit
......
...@@ -53,10 +53,10 @@ class NoteViewController: UIViewController { ...@@ -53,10 +53,10 @@ class NoteViewController: UIViewController {
/** /**
Handles the search button click, which opens the Handles the search button click, which opens the
SideNavigationBarViewController. SideNavigationViewController.
*/ */
func handleSearchButton() { func handleSearchButton() {
sideNavigationBarViewController?.openRightView() sideNavigationViewController?.openRightView()
} }
/// Prepares view. /// Prepares view.
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
/* /*
The following is an example of setting a UITableView as the RightViewController The following is an example of setting a UITableView as the RightViewController
within a SideNavigationBarViewController. within a SideNavigationViewController.
*/ */
import UIKit import UIKit
......
...@@ -43,9 +43,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -43,9 +43,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let mainViewController = storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! MainViewController let mainViewController = storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! MainViewController
let sideViewController = storyboard.instantiateViewControllerWithIdentifier("SideViewController") as! SideViewController let sideViewController = storyboard.instantiateViewControllerWithIdentifier("SideViewController") as! SideViewController
// Configure the window with the SideNavigationBarViewController as the root view controller // Configure the window with the SideNavigationViewController as the root view controller
window = UIWindow(frame: UIScreen.mainScreen().bounds) window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = SideNavigationBarViewController(mainViewController: mainViewController, leftViewController: sideViewController) window?.rootViewController = SideNavigationViewController(mainViewController: mainViewController, leftViewController: sideViewController)
window?.makeKeyAndVisible() window?.makeKeyAndVisible()
return true return true
} }
......
...@@ -36,7 +36,7 @@ class MainViewController: UIViewController { ...@@ -36,7 +36,7 @@ class MainViewController: UIViewController {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
// Toggle SideNavigationBarViewController. // Toggle SideNavigationViewController.
let img: UIImage? = UIImage(named: "ic_create_white") let img: UIImage? = UIImage(named: "ic_create_white")
let fabButton: FabButton = FabButton() let fabButton: FabButton = FabButton()
fabButton.setImage(img, forState: .Normal) fabButton.setImage(img, forState: .Normal)
...@@ -51,7 +51,7 @@ class MainViewController: UIViewController { ...@@ -51,7 +51,7 @@ class MainViewController: UIViewController {
// FabButton handler. // FabButton handler.
func handleFabButton() { func handleFabButton() {
sideNavigationBarViewController?.toggleLeftView() sideNavigationViewController?.toggleLeftView()
} }
} }
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
960B23501C38490D00E96216 /* Text.swift in Headers */ = {isa = PBXBuildFile; fileRef = 960B23431C38480E00E96216 /* Text.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 960B23501C38490D00E96216 /* Text.swift in Headers */ = {isa = PBXBuildFile; fileRef = 960B23431C38480E00E96216 /* Text.swift */; settings = {ATTRIBUTES = (Public, ); }; };
960B23511C38490D00E96216 /* TextStorage.swift in Headers */ = {isa = PBXBuildFile; fileRef = 960B23441C38480E00E96216 /* TextStorage.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 960B23511C38490D00E96216 /* TextStorage.swift in Headers */ = {isa = PBXBuildFile; fileRef = 960B23441C38480E00E96216 /* TextStorage.swift */; settings = {ATTRIBUTES = (Public, ); }; };
960B23521C38490D00E96216 /* TextView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 960B23451C38480E00E96216 /* TextView.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 960B23521C38490D00E96216 /* TextView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 960B23451C38480E00E96216 /* TextView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9626C2DE1C795017007CA8E0 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626C2DD1C795017007CA8E0 /* MenuViewController.swift */; };
963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; }; 963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; };
96442ADB1C28EEFA00C3C574 /* TextField.swift in Headers */ = {isa = PBXBuildFile; fileRef = 966F57B71C226D75009185B7 /* TextField.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96442ADB1C28EEFA00C3C574 /* TextField.swift in Headers */ = {isa = PBXBuildFile; fileRef = 966F57B71C226D75009185B7 /* TextField.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96442ADE1C28EF3700C3C574 /* MaterialTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96442ADD1C28EF3700C3C574 /* MaterialTableViewCell.swift */; }; 96442ADE1C28EF3700C3C574 /* MaterialTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96442ADD1C28EF3700C3C574 /* MaterialTableViewCell.swift */; };
...@@ -138,6 +139,7 @@ ...@@ -138,6 +139,7 @@
960B23431C38480E00E96216 /* Text.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Text.swift; sourceTree = "<group>"; }; 960B23431C38480E00E96216 /* Text.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Text.swift; sourceTree = "<group>"; };
960B23441C38480E00E96216 /* TextStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextStorage.swift; sourceTree = "<group>"; }; 960B23441C38480E00E96216 /* TextStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextStorage.swift; sourceTree = "<group>"; };
960B23451C38480E00E96216 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; }; 960B23451C38480E00E96216 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
9626C2DD1C795017007CA8E0 /* MenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; };
963832411B88DFD80015F710 /* Material.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Material.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963832411B88DFD80015F710 /* Material.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Material.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
963832591B88E31A0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 963832591B88E31A0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
...@@ -211,6 +213,32 @@ ...@@ -211,6 +213,32 @@
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
9626C2DA1C794FA5007CA8E0 /* NavigationBar */ = {
isa = PBXGroup;
children = (
96D88C151C1328D800B91418 /* NavigationBarView.swift */,
96A71F2F1C72E41100C0C4AE /* NavigationBarViewController.swift */,
);
name = NavigationBar;
sourceTree = "<group>";
};
9626C2DB1C794FBB007CA8E0 /* SearchBar */ = {
isa = PBXGroup;
children = (
96A71EF51C71127100C0C4AE /* SearchBarView.swift */,
960036141C77E1B600EBA579 /* SearchBarViewController.swift */,
);
name = SearchBar;
sourceTree = "<group>";
};
9626C2DC1C794FE5007CA8E0 /* SideNavigation */ = {
isa = PBXGroup;
children = (
96D88C1D1C1328D800B91418 /* SideNavigationViewController.swift */,
);
name = SideNavigation;
sourceTree = "<group>";
};
9638322C1B88DFD80015F710 = { 9638322C1B88DFD80015F710 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -269,6 +297,7 @@ ...@@ -269,6 +297,7 @@
children = ( children = (
65FDC2EA1C66858A00103AC2 /* Menu.swift */, 65FDC2EA1C66858A00103AC2 /* Menu.swift */,
96A71E901C6FBC2200C0C4AE /* MenuView.swift */, 96A71E901C6FBC2200C0C4AE /* MenuView.swift */,
9626C2DD1C795017007CA8E0 /* MenuViewController.swift */,
); );
name = Menu; name = Menu;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -281,14 +310,6 @@ ...@@ -281,14 +310,6 @@
name = Switch; name = Switch;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
96A71FB51C764F3D00C0C4AE /* Control */ = {
isa = PBXGroup;
children = (
96A71FB01C7649F800C0C4AE /* ControlView.swift */,
);
name = Control;
sourceTree = "<group>";
};
96D88BF41C1328D800B91418 /* Sources */ = { 96D88BF41C1328D800B91418 /* Sources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -312,8 +333,10 @@ ...@@ -312,8 +333,10 @@
965C58BD1C6B8D3300CFB4E1 /* Grid */, 965C58BD1C6B8D3300CFB4E1 /* Grid */,
96A71E921C6FBC2900C0C4AE /* Menu */, 96A71E921C6FBC2900C0C4AE /* Menu */,
96A71EC51C6FFEF300C0C4AE /* Switch */, 96A71EC51C6FFEF300C0C4AE /* Switch */,
96A71FB51C764F3D00C0C4AE /* Control */, 96D88C541C132A7700B91418 /* StatusBar */,
96D88C541C132A7700B91418 /* Navigation */, 9626C2DB1C794FBB007CA8E0 /* SearchBar */,
9626C2DA1C794FA5007CA8E0 /* NavigationBar */,
9626C2DC1C794FE5007CA8E0 /* SideNavigation */,
); );
path = Sources; path = Sources;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -444,17 +467,13 @@ ...@@ -444,17 +467,13 @@
name = View; name = View;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
96D88C541C132A7700B91418 /* Navigation */ = { 96D88C541C132A7700B91418 /* StatusBar */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71FB01C7649F800C0C4AE /* ControlView.swift */,
96A71FB21C764E3200C0C4AE /* StatusBarView.swift */, 96A71FB21C764E3200C0C4AE /* StatusBarView.swift */,
96A71EF51C71127100C0C4AE /* SearchBarView.swift */,
960036141C77E1B600EBA579 /* SearchBarViewController.swift */,
96D88C151C1328D800B91418 /* NavigationBarView.swift */,
96A71F2F1C72E41100C0C4AE /* NavigationBarViewController.swift */,
96D88C1D1C1328D800B91418 /* SideNavigationViewController.swift */,
); );
name = Navigation; name = StatusBar;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
96DB1C751C14C11B00825BE6 /* Color */ = { 96DB1C751C14C11B00825BE6 /* Color */ = {
...@@ -674,6 +693,7 @@ ...@@ -674,6 +693,7 @@
96D88C461C1328D800B91418 /* SideNavigationViewController.swift in Sources */, 96D88C461C1328D800B91418 /* SideNavigationViewController.swift in Sources */,
96D88C381C1328D800B91418 /* MaterialShape.swift in Sources */, 96D88C381C1328D800B91418 /* MaterialShape.swift in Sources */,
960B23331C383EAA00E96216 /* Material+UIImage+Size.swift in Sources */, 960B23331C383EAA00E96216 /* Material+UIImage+Size.swift in Sources */,
9626C2DE1C795017007CA8E0 /* MenuViewController.swift in Sources */,
96A71FB61C7651AA00C0C4AE /* ControlView.swift in Sources */, 96A71FB61C7651AA00C0C4AE /* ControlView.swift in Sources */,
96A71F451C74ABCB00C0C4AE /* MaterialBorder.swift in Sources */, 96A71F451C74ABCB00C0C4AE /* MaterialBorder.swift in Sources */,
96A71E911C6FBC2200C0C4AE /* MenuView.swift in Sources */, 96A71E911C6FBC2200C0C4AE /* MenuView.swift in Sources */,
......
...@@ -175,10 +175,10 @@ public class Menu { ...@@ -175,10 +175,10 @@ public class Menu {
view.alpha = 1 view.alpha = 1
view.frame.origin.y = base!.frame.origin.y - CGFloat(i) * self.itemViewSize.height - CGFloat(i) * self.spacing view.frame.origin.y = base!.frame.origin.y - CGFloat(i) * self.itemViewSize.height - CGFloat(i) * self.spacing
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = true opened = true
} }
...@@ -208,11 +208,11 @@ public class Menu { ...@@ -208,11 +208,11 @@ public class Menu {
view.alpha = 0 view.alpha = 0
view.frame.origin.y = self.origin.y view.frame.origin.y = self.origin.y
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
view.hidden = true view.hidden = true
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = false opened = false
} }
...@@ -249,10 +249,10 @@ public class Menu { ...@@ -249,10 +249,10 @@ public class Menu {
view.alpha = 1 view.alpha = 1
view.frame.origin.y = base!.frame.origin.y + h + CGFloat(i - 1) * self.itemViewSize.height + CGFloat(i) * self.spacing view.frame.origin.y = base!.frame.origin.y + h + CGFloat(i - 1) * self.itemViewSize.height + CGFloat(i) * self.spacing
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = true opened = true
} }
...@@ -283,11 +283,11 @@ public class Menu { ...@@ -283,11 +283,11 @@ public class Menu {
view.alpha = 0 view.alpha = 0
view.frame.origin.y = self.origin.y + h view.frame.origin.y = self.origin.y + h
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
view.hidden = true view.hidden = true
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = false opened = false
} }
...@@ -323,10 +323,10 @@ public class Menu { ...@@ -323,10 +323,10 @@ public class Menu {
view.alpha = 1 view.alpha = 1
view.frame.origin.x = base!.frame.origin.x - CGFloat(i) * self.itemViewSize.width - CGFloat(i) * self.spacing view.frame.origin.x = base!.frame.origin.x - CGFloat(i) * self.itemViewSize.width - CGFloat(i) * self.spacing
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = true opened = true
} }
...@@ -355,11 +355,11 @@ public class Menu { ...@@ -355,11 +355,11 @@ public class Menu {
view.alpha = 0 view.alpha = 0
view.frame.origin.x = self.origin.x view.frame.origin.x = self.origin.x
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
view.hidden = true view.hidden = true
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = false opened = false
} }
...@@ -395,10 +395,10 @@ public class Menu { ...@@ -395,10 +395,10 @@ public class Menu {
view.alpha = 1 view.alpha = 1
view.frame.origin.x = base!.frame.origin.x + h + CGFloat(i - 1) * self.itemViewSize.width + CGFloat(i) * self.spacing view.frame.origin.x = base!.frame.origin.x + h + CGFloat(i - 1) * self.itemViewSize.width + CGFloat(i) * self.spacing
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = true opened = true
} }
...@@ -429,11 +429,11 @@ public class Menu { ...@@ -429,11 +429,11 @@ public class Menu {
view.alpha = 0 view.alpha = 0
view.frame.origin.x = self.origin.x + w view.frame.origin.x = self.origin.x + w
animations?(view) animations?(view)
}, completion: { [unowned self] _ in }) { [unowned self] _ in
view.hidden = true view.hidden = true
completion?(view) completion?(view)
self.enable(view) self.enable(view)
}) }
} }
opened = false opened = 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
public extension UIViewController {
/**
A convenience property that provides access to the MenuViewController.
This is the recommended method of accessing the MenuViewController
through child UIViewControllers.
*/
public var menuViewController: MenuViewController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is MenuViewController {
return viewController as? MenuViewController
}
viewController = viewController?.parentViewController
}
return nil
}
}
public class MenuViewController: UIViewController {
/// Reference to the MenuView.
public private(set) lazy var menuView: MenuView = MenuView()
/**
A Boolean property used to enable and disable interactivity
with the mainViewController.
*/
public var userInteractionEnabled: Bool {
get {
return mainViewController.view.userInteractionEnabled
}
set(value) {
mainViewController.view.userInteractionEnabled = value
}
}
/**
A UIViewController property that references the active
main UIViewController. To swap the mainViewController, it
is recommended to use the transitionFromMainViewController
helper method.
*/
public private(set) var mainViewController: UIViewController!
/**
An initializer for the MenuViewController.
- Parameter mainViewController: The main UIViewController.
*/
public convenience init(mainViewController: UIViewController) {
self.init()
self.mainViewController = mainViewController
prepareView()
}
public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
layoutSubviews()
}
/**
A method to swap mainViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active mainViewController.
- Parameter duration: A NSTimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active mainViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active mainViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active mainViewController
to the toViewController has completed.
*/
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {
mainViewController.willMoveToParentViewController(nil)
addChildViewController(toViewController)
toViewController.view.frame = mainViewController.view.frame
transitionFromViewController(mainViewController,
toViewController: toViewController,
duration: duration,
options: options,
animations: animations,
completion: { [unowned self] (result: Bool) in
toViewController.didMoveToParentViewController(self)
self.mainViewController.removeFromParentViewController()
self.mainViewController = toViewController
self.view.sendSubviewToBack(self.mainViewController.view)
completion?(result)
})
}
/// A method that generally prepares the MenuViewController.
private func prepareView() {
prepareMenuView()
prepareMainViewController()
}
/// Prepares the MenuView.
private func prepareMenuView() {
menuView.zPosition = 1000
view.addSubview(menuView)
}
/// A method that prepares the mainViewController.
private func prepareMainViewController() {
prepareViewControllerWithinContainer(mainViewController, container: view)
}
/**
A method that adds the passed in controller as a child of
the MenuViewController within the passed in
container view.
- Parameter viewController: A UIViewController to add as a child.
- Parameter container: A UIView that is the parent of the
passed in controller view within the view hierarchy.
*/
private func prepareViewControllerWithinContainer(viewController: UIViewController?, container: UIView) {
if let v: UIViewController = viewController {
addChildViewController(v)
container.insertSubview(v.view, atIndex: 0)
v.didMoveToParentViewController(self)
}
}
/// Layout subviews.
private func layoutSubviews() {
mainViewController.view.frame = view.bounds
}
}
...@@ -49,8 +49,59 @@ public extension UIViewController { ...@@ -49,8 +49,59 @@ public extension UIViewController {
} }
public class NavigationBarViewController: UIViewController { public class NavigationBarViewController: UIViewController {
/// Reference to the NavigationBarView.
public private(set) lazy var navigationBarView: NavigationBarView = NavigationBarView() public private(set) lazy var navigationBarView: NavigationBarView = NavigationBarView()
/// Internal reference to the floatingViewController.
private var internalFloatingViewController: UIViewController?
/// A floating UIViewController.
public var floatingViewController: UIViewController? {
get {
return internalFloatingViewController
}
set(value) {
if let v: UIViewController = value {
/**
Disable the sideNavigationViewController from opening while in
noteViewController.
*/
sideNavigationViewController?.enabled = false
// Add the noteViewController! to the view.
addChildViewController(v)
v.view.frame = view.bounds
v.view.center.y = 2 * view.bounds.height
v.view.hidden = true
view.insertSubview(v.view, aboveSubview: navigationBarView)
v.view.layer.zPosition = 1500
v.didMoveToParentViewController(self)
// Animate the noteButton out and the noteViewController! in.
v.view.hidden = false
internalFloatingViewController = v
UIView.animateWithDuration(0.5,
animations: { [unowned self] in
v.view.center.y = self.view.bounds.height / 2
})
} else if let v: UIViewController = internalFloatingViewController {
sideNavigationViewController?.enabled = true
internalFloatingViewController = nil
UIView.animateWithDuration(0.5,
animations: { [unowned self] in
v.view.center.y = 2 * self.view.bounds.height
}) { _ in
v.willMoveToParentViewController(nil)
v.view.removeFromSuperview()
v.removeFromParentViewController()
}
}
}
}
/** /**
A Boolean property used to enable and disable interactivity A Boolean property used to enable and disable interactivity
with the mainViewController. with the mainViewController.
...@@ -103,10 +154,10 @@ public class NavigationBarViewController: UIViewController { ...@@ -103,10 +154,10 @@ public class NavigationBarViewController: UIViewController {
the transition animation from the active mainViewController the transition animation from the active mainViewController
to the toViewController has completed. to the toViewController has completed.
*/ */
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)?, completion: ((Bool) -> Void)?) { public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {
mainViewController.willMoveToParentViewController(nil) mainViewController.willMoveToParentViewController(nil)
addChildViewController(toViewController) addChildViewController(toViewController)
toViewController.view.frame = view.bounds toViewController.view.frame = mainViewController.view.frame
transitionFromViewController(mainViewController, transitionFromViewController(mainViewController,
toViewController: toViewController, toViewController: toViewController,
duration: duration, duration: duration,
...@@ -116,6 +167,7 @@ public class NavigationBarViewController: UIViewController { ...@@ -116,6 +167,7 @@ public class NavigationBarViewController: UIViewController {
toViewController.didMoveToParentViewController(self) toViewController.didMoveToParentViewController(self)
self.mainViewController.removeFromParentViewController() self.mainViewController.removeFromParentViewController()
self.mainViewController = toViewController self.mainViewController = toViewController
self.view.sendSubviewToBack(self.mainViewController.view)
completion?(result) completion?(result)
}) })
} }
...@@ -129,6 +181,7 @@ public class NavigationBarViewController: UIViewController { ...@@ -129,6 +181,7 @@ public class NavigationBarViewController: UIViewController {
/// Prepares the NavigationBarView. /// Prepares the NavigationBarView.
private func prepareNavigationBarView() { private func prepareNavigationBarView() {
navigationBarView.delegate = self navigationBarView.delegate = self
navigationBarView.zPosition = 1000
view.addSubview(navigationBarView) view.addSubview(navigationBarView)
} }
......
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