Commit 7d7e0975 by Daniel Dahan

working NavigationController -> NavigationBar Back Button

parent 0ff4ab03
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96334EFC1C8B85F40083986B /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96334EFB1C8B85F40083986B /* Material.framework */; }; 96334EFC1C8B85F40083986B /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96334EFB1C8B85F40083986B /* Material.framework */; };
96334EFD1C8B85F40083986B /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96334EFB1C8B85F40083986B /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 96334EFD1C8B85F40083986B /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96334EFB1C8B85F40083986B /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96334EFF1C8B876E0083986B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96334EFE1C8B876E0083986B /* ViewController.swift */; };
9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9311C7A744600AF0965 /* AppDelegate.swift */; }; 9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9311C7A744600AF0965 /* AppDelegate.swift */; };
9663F9341C7A744600AF0965 /* SearchListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9331C7A744600AF0965 /* SearchListViewController.swift */; }; 9663F9341C7A744600AF0965 /* SearchListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9331C7A744600AF0965 /* SearchListViewController.swift */; };
9663F9391C7A744600AF0965 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9663F9381C7A744600AF0965 /* Assets.xcassets */; }; 9663F9391C7A744600AF0965 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9663F9381C7A744600AF0965 /* Assets.xcassets */; };
...@@ -39,7 +38,6 @@ ...@@ -39,7 +38,6 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
96334EFB1C8B85F40083986B /* 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>"; }; 96334EFB1C8B85F40083986B /* 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>"; };
96334EFE1C8B876E0083986B /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
9663F92E1C7A744600AF0965 /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; 9663F92E1C7A744600AF0965 /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
9663F9311C7A744600AF0965 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 9663F9311C7A744600AF0965 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
9663F9331C7A744600AF0965 /* SearchListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchListViewController.swift; sourceTree = "<group>"; }; 9663F9331C7A744600AF0965 /* SearchListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchListViewController.swift; sourceTree = "<group>"; };
...@@ -99,7 +97,6 @@ ...@@ -99,7 +97,6 @@
9663F9381C7A744600AF0965 /* Assets.xcassets */, 9663F9381C7A744600AF0965 /* Assets.xcassets */,
9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */, 9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */,
9663F93D1C7A744600AF0965 /* Info.plist */, 9663F93D1C7A744600AF0965 /* Info.plist */,
96334EFE1C8B876E0083986B /* ViewController.swift */,
); );
path = App; path = App;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -175,7 +172,6 @@ ...@@ -175,7 +172,6 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96334EFF1C8B876E0083986B /* ViewController.swift in Sources */,
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */, 9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */, 96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */,
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */, 9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */,
......
...@@ -40,7 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -40,7 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// 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 = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: InboxViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController()) // window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: InboxViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window!.rootViewController = NavigationController(rootViewController: FeedViewController()) window!.rootViewController = SideNavigationViewController(mainViewController: NavigationController(rootViewController: FeedViewController()), leftViewController: AppLeftViewController())
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
return true return true
} }
......
...@@ -46,7 +46,6 @@ class FeedViewController: UIViewController { ...@@ -46,7 +46,6 @@ class FeedViewController: UIViewController {
override func viewWillLayoutSubviews() { override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews() super.viewWillLayoutSubviews()
collectionView.frame = view.bounds
collectionView.reloadData() collectionView.reloadData()
} }
...@@ -59,11 +58,11 @@ class FeedViewController: UIViewController { ...@@ -59,11 +58,11 @@ class FeedViewController: UIViewController {
// Menu button. // Menu button.
let menuButton: FlatButton = FlatButton() let menuButton: FlatButton = FlatButton()
menuButton.pulseColor = MaterialColor.white
menuButton.pulseScale = false menuButton.pulseScale = false
menuButton.pulseColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
// menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside) menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
// Switch control. // Switch control.
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small) let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Small)
...@@ -71,18 +70,18 @@ class FeedViewController: UIViewController { ...@@ -71,18 +70,18 @@ class FeedViewController: UIViewController {
// Search button. // Search button.
image = UIImage(named: "ic_search_white") image = UIImage(named: "ic_search_white")
let searchButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
searchButton.pulseColor = MaterialColor.white
searchButton.pulseScale = false searchButton.pulseScale = false
searchButton.pulseColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
// searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside) searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
navigationController?.navigationBar.leftControls = [menuButton] navigationController?.navigationBar.leftControls = [menuButton]
navigationController?.navigationBar.rightControls = [switchControl, searchButton] navigationController?.navigationBar.rightControls = [switchControl, searchButton]
} }
internal func handleMenuButton() { internal func handleMenuButton() {
print("handled") sideNavigationViewController?.toggleLeftView()
} }
internal func handleSearchButton() { internal func handleSearchButton() {
...@@ -94,7 +93,9 @@ class FeedViewController: UIViewController { ...@@ -94,7 +93,9 @@ class FeedViewController: UIViewController {
view.backgroundColor = MaterialColor.grey.lighten4 view.backgroundColor = MaterialColor.grey.lighten4
navigationController?.navigationBar.statusBarStyle = .LightContent navigationController?.navigationBar.statusBarStyle = .LightContent
navigationController?.navigationBar.tintColor = MaterialColor.white
navigationController?.navigationBar.backgroundColor = MaterialColor.blue.base navigationController?.navigationBar.backgroundColor = MaterialColor.blue.base
navigationController?.navigationBar.backButton.pulseColor = MaterialColor.white
} }
/// Prepares the collectionView /// Prepares the collectionView
...@@ -102,11 +103,12 @@ class FeedViewController: UIViewController { ...@@ -102,11 +103,12 @@ class FeedViewController: UIViewController {
collectionView.dataSource = self collectionView.dataSource = self
collectionView.delegate = self collectionView.delegate = self
collectionView.spacingPreset = .Spacing1 collectionView.spacingPreset = .Spacing1
collectionView.contentInsetPreset = .Square1
collectionView.registerClass(MaterialCollectionViewCell.self, forCellWithReuseIdentifier: "MaterialCollectionViewCell") collectionView.registerClass(MaterialCollectionViewCell.self, forCellWithReuseIdentifier: "MaterialCollectionViewCell")
// To avoid being hidden under the hovering MenuView. // To avoid being hidden under the hovering MenuView.
view.addSubview(collectionView) view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: collectionView)
// collectionView.scrollDirection = .Horizontal // Uncomment to see the horizontal scroll direction. // collectionView.scrollDirection = .Horizontal // Uncomment to see the horizontal scroll direction.
} }
...@@ -204,6 +206,7 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -204,6 +206,7 @@ extension FeedViewController: MaterialCollectionViewDataSource {
cardView!.pulseScale = false cardView!.pulseScale = false
cardView!.divider = false cardView!.divider = false
cardView!.depth = .None cardView!.depth = .None
cardView!.cornerRadiusPreset = .None
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.textColor = MaterialColor.grey.darken4 titleLabel.textColor = MaterialColor.grey.darken4
...@@ -246,6 +249,6 @@ extension FeedViewController: MaterialCollectionViewDelegate { ...@@ -246,6 +249,6 @@ extension FeedViewController: MaterialCollectionViewDelegate {
/// Executed when an item is selected. /// Executed when an item is selected.
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
// print(indexPath) // print(indexPath)
navigationController?.pushViewController(ViewController(), animated: true) navigationController?.pushViewController(InboxViewController(), animated: true)
} }
} }
\ No newline at end of file
...@@ -53,7 +53,10 @@ class InboxViewController: UIViewController { ...@@ -53,7 +53,10 @@ class InboxViewController: UIViewController {
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
navigationBarViewController?.navigationBarView.titleLabel?.text = "Inbox"
navigationItem.title = "Messages"
navigationController?.navigationBar.topItem?.title = ""
navigationController?.navigationBar.leftControls = []
} }
/** /**
...@@ -135,7 +138,7 @@ extension InboxViewController: UITableViewDataSource { ...@@ -135,7 +138,7 @@ extension InboxViewController: UITableViewDataSource {
header.addSubview(label) header.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false label.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(header, child: label, left: navigationBarViewController!.navigationBarView.contentInset.left + navigationBarViewController!.navigationBarView.spacing) MaterialLayout.alignToParent(header, child: label, left: navigationController!.navigationBar.contentInset.left)
return header return header
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
...@@ -30,6 +28,8 @@ ...@@ -30,6 +28,8 @@
<array> <array>
<string>armv7</string> <string>armv7</string>
</array> </array>
<key>UIStatusBarHidden</key>
<false/>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
...@@ -44,5 +44,7 @@ ...@@ -44,5 +44,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict> </dict>
</plist> </plist>
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
The following example shows how to dynamically size MaterialCollectionViewCells.
*/
import UIKit
import Material
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationItem.title = "Material"
navigationController?.navigationBar.leftControls = []
navigationController?.navigationBar.rightControls = []
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.grey.lighten4
}
}
\ No newline at end of file
...@@ -228,7 +228,7 @@ private var GridKey: UInt8 = 0 ...@@ -228,7 +228,7 @@ private var GridKey: UInt8 = 0
/// Grid extension for UIView. /// Grid extension for UIView.
public extension UIView { public extension UIView {
/// Grid reference. /// Grid reference.
public var grid: Grid { public internal(set) var grid: Grid {
get { get {
return MaterialObjectAssociatedObject(self, key: &GridKey) { return MaterialObjectAssociatedObject(self, key: &GridKey) {
return Grid() return Grid()
......
...@@ -67,9 +67,7 @@ public enum MaterialEdgeInset { ...@@ -67,9 +67,7 @@ public enum MaterialEdgeInset {
case TallRectangle9 case TallRectangle9
} }
/** /// Converts the MaterialEdgeInset to a UIEdgeInsets value.
:name: MaterialEdgeInsetToValue
*/
public func MaterialEdgeInsetToValue(inset: MaterialEdgeInset) -> UIEdgeInsets { public func MaterialEdgeInsetToValue(inset: MaterialEdgeInset) -> UIEdgeInsets {
switch inset { switch inset {
case .None: case .None:
...@@ -77,62 +75,62 @@ public func MaterialEdgeInsetToValue(inset: MaterialEdgeInset) -> UIEdgeInsets { ...@@ -77,62 +75,62 @@ public func MaterialEdgeInsetToValue(inset: MaterialEdgeInset) -> UIEdgeInsets {
// square // square
case .Square1: case .Square1:
return UIEdgeInsets(top: 4, left: 4, bottom: 4, right: 4) return UIEdgeInsetsMake(4, 4, 4, 4)
case .Square2: case .Square2:
return UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8) return UIEdgeInsetsMake(8, 8, 8, 8)
case .Square3: case .Square3:
return UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16) return UIEdgeInsetsMake(16, 16, 16, 16)
case .Square4: case .Square4:
return UIEdgeInsets(top: 24, left: 24, bottom: 24, right: 24) return UIEdgeInsetsMake(24, 24, 24, 24)
case .Square5: case .Square5:
return UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32) return UIEdgeInsetsMake(32, 32, 32, 32)
case .Square6: case .Square6:
return UIEdgeInsets(top: 40, left: 40, bottom: 40, right: 40) return UIEdgeInsetsMake(40, 40, 40, 40)
case .Square7: case .Square7:
return UIEdgeInsets(top: 48, left: 48, bottom: 48, right: 48) return UIEdgeInsetsMake(48, 48, 48, 48)
case .Square8: case .Square8:
return UIEdgeInsets(top: 56, left: 56, bottom: 56, right: 56) return UIEdgeInsetsMake(56, 56, 56, 56)
case .Square9: case .Square9:
return UIEdgeInsets(top: 64, left: 64, bottom: 64, right: 64) return UIEdgeInsetsMake(64, 64, 64, 64)
// rectangle // rectangle
case .WideRectangle1: case .WideRectangle1:
return UIEdgeInsets(top: 2, left: 4, bottom: 2, right: 4) return UIEdgeInsetsMake(2, 4, 2, 4)
case .WideRectangle2: case .WideRectangle2:
return UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8) return UIEdgeInsetsMake(4, 8, 4, 8)
case .WideRectangle3: case .WideRectangle3:
return UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16) return UIEdgeInsetsMake(8, 16, 8, 16)
case .WideRectangle4: case .WideRectangle4:
return UIEdgeInsets(top: 12, left: 24, bottom: 12, right: 24) return UIEdgeInsetsMake(12, 24, 12, 24)
case .WideRectangle5: case .WideRectangle5:
return UIEdgeInsets(top: 16, left: 32, bottom: 16, right: 32) return UIEdgeInsetsMake(16, 32, 16, 32)
case .WideRectangle6: case .WideRectangle6:
return UIEdgeInsets(top: 20, left: 40, bottom: 20, right: 40) return UIEdgeInsetsMake(20, 40, 20, 40)
case .WideRectangle7: case .WideRectangle7:
return UIEdgeInsets(top: 24, left: 48, bottom: 24, right: 48) return UIEdgeInsetsMake(24, 48, 24, 48)
case .WideRectangle8: case .WideRectangle8:
return UIEdgeInsets(top: 28, left: 56, bottom: 28, right: 56) return UIEdgeInsetsMake(28, 56, 28, 56)
case .WideRectangle9: case .WideRectangle9:
return UIEdgeInsets(top: 32, left: 64, bottom: 32, right: 64) return UIEdgeInsetsMake(32, 64, 32, 64)
// flipped rectangle // flipped rectangle
case .TallRectangle1: case .TallRectangle1:
return UIEdgeInsets(top: 4, left: 2, bottom: 4, right: 2) return UIEdgeInsetsMake(4, 2, 4, 2)
case .TallRectangle2: case .TallRectangle2:
return UIEdgeInsets(top: 8, left: 4, bottom: 8, right: 4) return UIEdgeInsetsMake(8, 4, 8, 4)
case .TallRectangle3: case .TallRectangle3:
return UIEdgeInsets(top: 16, left: 8, bottom: 16, right: 8) return UIEdgeInsetsMake(16, 8, 16, 8)
case .TallRectangle4: case .TallRectangle4:
return UIEdgeInsets(top: 24, left: 12, bottom: 24, right: 12) return UIEdgeInsetsMake(24, 12, 24, 12)
case .TallRectangle5: case .TallRectangle5:
return UIEdgeInsets(top: 32, left: 16, bottom: 32, right: 16) return UIEdgeInsetsMake(32, 16, 32, 16)
case .TallRectangle6: case .TallRectangle6:
return UIEdgeInsets(top: 40, left: 20, bottom: 40, right: 20) return UIEdgeInsetsMake(40, 20, 40, 20)
case .TallRectangle7: case .TallRectangle7:
return UIEdgeInsets(top: 48, left: 24, bottom: 48, right: 24) return UIEdgeInsetsMake(48, 24, 48, 24)
case .TallRectangle8: case .TallRectangle8:
return UIEdgeInsets(top: 56, left: 28, bottom: 56, right: 28) return UIEdgeInsetsMake(56, 28, 56, 28)
case .TallRectangle9: case .TallRectangle9:
return UIEdgeInsets(top: 64, left: 32, bottom: 64, right: 32) return UIEdgeInsetsMake(64, 32, 64, 32)
} }
} }
...@@ -34,26 +34,28 @@ public class NavigationController : UINavigationController { ...@@ -34,26 +34,28 @@ public class NavigationController : UINavigationController {
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView()
} }
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
prepareView()
} }
public override init(rootViewController: UIViewController) { public override init(rootViewController: UIViewController) {
super.init(navigationBarClass: NavigationBar.self, toolbarClass: nil) super.init(navigationBarClass: NavigationBar.self, toolbarClass: nil)
setViewControllers([rootViewController], animated: false) setViewControllers([rootViewController], animated: false)
prepareView()
} }
public override func viewDidLoad() { public override func viewWillLayoutSubviews() {
super.viewDidLoad() super.viewWillLayoutSubviews()
prepareView() if let v: NavigationBar = navigationBar as? NavigationBar {
v.layoutSubviews()
v.backButton.removeTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside)
v.backButton.addTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside)
}
} }
public func prepareView() { /// Handles the backButton.
navigationItem.title = "Title" internal func handleBackButton() {
popViewControllerAnimated(true)
} }
} }
...@@ -843,12 +843,14 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -843,12 +843,14 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/ */
private func toggleStatusBar(hide: Bool = false) { private func toggleStatusBar(hide: Bool = false) {
if hideStatusBar { if hideStatusBar {
// General alignment. UIView.animateWithDuration(0.25, animations: { [weak self] in
if .iPhone == MaterialDevice.type && MaterialDevice.landscape { // General alignment.
UIApplication.sharedApplication().statusBarHidden = true if .iPhone == MaterialDevice.type && MaterialDevice.landscape {
} else { UIApplication.sharedApplication().statusBarHidden = true
UIApplication.sharedApplication().statusBarHidden = opened ? true : hide } else {
} UIApplication.sharedApplication().statusBarHidden = true == self?.opened ? true : hide
}
})
} }
} }
......
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