Commit 39244b57 by Daniel Dahan

working NavigationBar and App example

parents c46110ca f7441424
...@@ -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 = SideNavigationViewController(mainViewController: NavigationController(rootViewController: FeedViewController()), leftViewController: AppLeftViewController()) window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: NavigationController(rootViewController: FeedViewController())), leftViewController: AppLeftViewController())
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
return true return true
} }
......
...@@ -161,7 +161,7 @@ extension AppLeftViewController: UITableViewDelegate { ...@@ -161,7 +161,7 @@ extension AppLeftViewController: UITableViewDelegate {
func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? { func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
let item: Item = items[indexPath.row] let item: Item = items[indexPath.row]
print(sideNavigationViewController?.mainViewController.navigationController)
/** /**
An example of loading a new UIViewController in the AppNavigationBarViewController An example of loading a new UIViewController in the AppNavigationBarViewController
if the UIViewController is not already loaded. This is a bit of a tricky example, as if the UIViewController is not already loaded. This is a bit of a tricky example, as
......
...@@ -47,26 +47,14 @@ class FeedViewController: UIViewController { ...@@ -47,26 +47,14 @@ class FeedViewController: UIViewController {
prepareCollectionView() prepareCollectionView()
} }
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
collectionView.reloadData()
}
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
navigationItem.title = "Feed"
navigationController?.navigationBar.leftControls = [menuButton]
sideNavigationViewController?.enabled = true sideNavigationViewController?.enabled = true
} }
override func viewDidAppear(animated: Bool) { override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewDidAppear(animated) super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
collectionView.reloadData()
// Handles when the page is being panned left to right.
navigationItem.title = "Feed"
navigationController?.navigationBar.leftControls = [menuButton]
} }
internal func handleMenuButton() { internal func handleMenuButton() {
...@@ -84,12 +72,12 @@ class FeedViewController: UIViewController { ...@@ -84,12 +72,12 @@ class FeedViewController: UIViewController {
prepareMenuButton() prepareMenuButton()
prepareSearchButton() prepareSearchButton()
navigationItem.title = "Feed"
navigationController?.navigationBar.leftControls = [menuButton]
navigationController?.navigationBar.rightControls = [searchButton]
navigationController?.navigationBar.statusBarStyle = .LightContent navigationController?.navigationBar.statusBarStyle = .LightContent
navigationController?.navigationBar.tintColor = MaterialColor.white navigationController?.navigationBar.tintColor = MaterialColor.white
navigationController?.navigationBar.backgroundColor = MaterialColor.blue.base navigationController?.navigationBar.backgroundColor = MaterialColor.blue.base
navigationController?.navigationBar.backButton.pulseColor = MaterialColor.white
navigationController?.navigationBar.rightControls = [searchButton]
} }
/// Prepares the menuButton. /// Prepares the menuButton.
...@@ -213,8 +201,9 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -213,8 +201,9 @@ extension FeedViewController: MaterialCollectionViewDataSource {
cardView!.divider = false cardView!.divider = false
cardView!.depth = .None cardView!.depth = .None
cardView!.contentInsetPreset = .Square3 cardView!.contentInsetPreset = .Square3
cardView!.contentInset.bottom /= 2
cardView!.cornerRadiusPreset = .None cardView!.cornerRadiusPreset = .None
cardView!.rightButtonsInsetPreset = .None cardView!.rightButtonsInset.right = -8
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.textColor = MaterialColor.grey.darken4 titleLabel.textColor = MaterialColor.grey.darken4
......
...@@ -53,20 +53,9 @@ class InboxViewController: UIViewController { ...@@ -53,20 +53,9 @@ class InboxViewController: UIViewController {
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
navigationItem.title = "Messages"
navigationController?.navigationBar.topItem?.title = ""
navigationController?.navigationBar.leftControls = []
sideNavigationViewController?.enabled = false sideNavigationViewController?.enabled = false
} }
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
navigationItem.title = "Messages"
navigationController?.navigationBar.leftControls = []
}
/** /**
Handles the search button click, which opens the Handles the search button click, which opens the
SideNavigationViewController. SideNavigationViewController.
...@@ -78,6 +67,8 @@ class InboxViewController: UIViewController { ...@@ -78,6 +67,8 @@ class InboxViewController: UIViewController {
/// Prepares view. /// Prepares view.
private func prepareView() { private func prepareView() {
view.backgroundColor = MaterialColor.white view.backgroundColor = MaterialColor.white
navigationItem.title = "Inbox"
} }
/// Prepares the items Array. /// Prepares the items Array.
......
...@@ -75,7 +75,7 @@ public class CardView : MaterialPulseView { ...@@ -75,7 +75,7 @@ public class CardView : MaterialPulseView {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsetPreset: MaterialEdgeInset = .None { public var contentInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
contentInset = MaterialEdgeInsetToValue(contentInsetPreset) contentInset = MaterialEdgeInsetToValue(contentInsetPreset)
} }
...@@ -93,7 +93,7 @@ public class CardView : MaterialPulseView { ...@@ -93,7 +93,7 @@ public class CardView : MaterialPulseView {
/** /**
:name: titleLabelInsets :name: titleLabelInsets
*/ */
public var titleLabelInsetPreset: MaterialEdgeInset = .None { public var titleLabelInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
titleLabelInset = MaterialEdgeInsetToValue(titleLabelInsetPreset) titleLabelInset = MaterialEdgeInsetToValue(titleLabelInsetPreset)
} }
...@@ -121,7 +121,7 @@ public class CardView : MaterialPulseView { ...@@ -121,7 +121,7 @@ public class CardView : MaterialPulseView {
/** /**
:name: detailViewInsets :name: detailViewInsets
*/ */
public var detailViewInsetPreset: MaterialEdgeInset = .None { public var detailViewInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset) detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset)
} }
......
...@@ -166,7 +166,7 @@ public class ImageCardView : MaterialPulseView { ...@@ -166,7 +166,7 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsetPreset: MaterialEdgeInset = .None { public var contentInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
contentInset = MaterialEdgeInsetToValue(contentInsetPreset) contentInset = MaterialEdgeInsetToValue(contentInsetPreset)
} }
...@@ -184,7 +184,7 @@ public class ImageCardView : MaterialPulseView { ...@@ -184,7 +184,7 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: titleLabelInsets :name: titleLabelInsets
*/ */
public var titleLabelInsetPreset: MaterialEdgeInset = .None { public var titleLabelInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
titleLabelInset = MaterialEdgeInsetToValue(titleLabelInsetPreset) titleLabelInset = MaterialEdgeInsetToValue(titleLabelInsetPreset)
} }
...@@ -212,7 +212,7 @@ public class ImageCardView : MaterialPulseView { ...@@ -212,7 +212,7 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: detailViewInsets :name: detailViewInsets
*/ */
public var detailViewInsetPreset: MaterialEdgeInset = .None { public var detailViewInsetPreset: MaterialEdgeInset = .Square2 {
didSet { didSet {
detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset) detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset)
} }
......
...@@ -169,7 +169,7 @@ public struct MaterialColor { ...@@ -169,7 +169,7 @@ public struct MaterialColor {
// cyan // cyan
public struct cyan { public struct cyan {
public static let lighten5: UIColor = UIColor(red: 224/255, green: 247/255, blue: 250/255, alpha: 1) public static let lighten5: UIColor = UIColor(red: 224/255, green: 247/255, blue: 250/255, alpha: 1)
public static let lighten4: UIColor = UIColor(red: 1178/255, green: 235/255, blue: 242/255, alpha: 1) public static let lighten4: UIColor = UIColor(red: 178/255, green: 235/255, blue: 242/255, alpha: 1)
public static let lighten3: UIColor = UIColor(red: 128/255, green: 222/255, blue: 2343/255, alpha: 1) public static let lighten3: UIColor = UIColor(red: 128/255, green: 222/255, blue: 2343/255, alpha: 1)
public static let lighten2: UIColor = UIColor(red: 77/255, green: 208/255, blue: 225/255, alpha: 1) public static let lighten2: UIColor = UIColor(red: 77/255, green: 208/255, blue: 225/255, alpha: 1)
public static let lighten1: UIColor = UIColor(red: 38/255, green: 198/255, blue: 218/255, alpha: 1) public static let lighten1: UIColor = UIColor(red: 38/255, green: 198/255, blue: 218/255, alpha: 1)
......
...@@ -373,9 +373,6 @@ public class NavigationBar : UINavigationBar { ...@@ -373,9 +373,6 @@ public class NavigationBar : UINavigationBar {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
leftControls = leftControls
rightControls = rightControls
if nil != backItem && nil != topItem { if nil != backItem && nil != topItem {
backButton.setImage(backButtonImage, forState: .Normal) backButton.setImage(backButtonImage, forState: .Normal)
backButton.setImage(backButtonImage, forState: .Highlighted) backButton.setImage(backButtonImage, forState: .Highlighted)
...@@ -467,8 +464,8 @@ public class NavigationBarControls { ...@@ -467,8 +464,8 @@ public class NavigationBarControls {
public init() { public init() {
backButton = FlatButton() backButton = FlatButton()
backButton.pulseColor = nil
backButton.pulseScale = false backButton.pulseScale = false
backButton.pulseColor = MaterialColor.white
} }
} }
......
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