Commit 39244b57 by Daniel Dahan

working NavigationBar and App example

parents c46110ca f7441424
......@@ -40,7 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
// 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()
return true
}
......
......@@ -161,7 +161,7 @@ extension AppLeftViewController: UITableViewDelegate {
func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
let item: Item = items[indexPath.row]
print(sideNavigationViewController?.mainViewController.navigationController)
/**
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
......
......@@ -47,26 +47,14 @@ class FeedViewController: UIViewController {
prepareCollectionView()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
collectionView.reloadData()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationItem.title = "Feed"
navigationController?.navigationBar.leftControls = [menuButton]
sideNavigationViewController?.enabled = true
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// Handles when the page is being panned left to right.
navigationItem.title = "Feed"
navigationController?.navigationBar.leftControls = [menuButton]
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
collectionView.reloadData()
}
internal func handleMenuButton() {
......@@ -84,12 +72,12 @@ class FeedViewController: UIViewController {
prepareMenuButton()
prepareSearchButton()
navigationItem.title = "Feed"
navigationController?.navigationBar.leftControls = [menuButton]
navigationController?.navigationBar.rightControls = [searchButton]
navigationController?.navigationBar.statusBarStyle = .LightContent
navigationController?.navigationBar.tintColor = MaterialColor.white
navigationController?.navigationBar.backgroundColor = MaterialColor.blue.base
navigationController?.navigationBar.backButton.pulseColor = MaterialColor.white
navigationController?.navigationBar.rightControls = [searchButton]
}
/// Prepares the menuButton.
......@@ -213,8 +201,9 @@ extension FeedViewController: MaterialCollectionViewDataSource {
cardView!.divider = false
cardView!.depth = .None
cardView!.contentInsetPreset = .Square3
cardView!.contentInset.bottom /= 2
cardView!.cornerRadiusPreset = .None
cardView!.rightButtonsInsetPreset = .None
cardView!.rightButtonsInset.right = -8
let titleLabel: UILabel = UILabel()
titleLabel.textColor = MaterialColor.grey.darken4
......
......@@ -53,20 +53,9 @@ class InboxViewController: UIViewController {
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationItem.title = "Messages"
navigationController?.navigationBar.topItem?.title = ""
navigationController?.navigationBar.leftControls = []
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
SideNavigationViewController.
......@@ -78,6 +67,8 @@ class InboxViewController: UIViewController {
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
navigationItem.title = "Inbox"
}
/// Prepares the items Array.
......
......@@ -75,7 +75,7 @@ public class CardView : MaterialPulseView {
/**
:name: contentInsets
*/
public var contentInsetPreset: MaterialEdgeInset = .None {
public var contentInsetPreset: MaterialEdgeInset = .Square2 {
didSet {
contentInset = MaterialEdgeInsetToValue(contentInsetPreset)
}
......@@ -93,7 +93,7 @@ public class CardView : MaterialPulseView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsetPreset: MaterialEdgeInset = .None {
public var titleLabelInsetPreset: MaterialEdgeInset = .Square2 {
didSet {
titleLabelInset = MaterialEdgeInsetToValue(titleLabelInsetPreset)
}
......@@ -121,7 +121,7 @@ public class CardView : MaterialPulseView {
/**
:name: detailViewInsets
*/
public var detailViewInsetPreset: MaterialEdgeInset = .None {
public var detailViewInsetPreset: MaterialEdgeInset = .Square2 {
didSet {
detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset)
}
......
......@@ -166,7 +166,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: contentInsets
*/
public var contentInsetPreset: MaterialEdgeInset = .None {
public var contentInsetPreset: MaterialEdgeInset = .Square2 {
didSet {
contentInset = MaterialEdgeInsetToValue(contentInsetPreset)
}
......@@ -184,7 +184,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsetPreset: MaterialEdgeInset = .None {
public var titleLabelInsetPreset: MaterialEdgeInset = .Square2 {
didSet {
titleLabelInset = MaterialEdgeInsetToValue(titleLabelInsetPreset)
}
......@@ -212,7 +212,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: detailViewInsets
*/
public var detailViewInsetPreset: MaterialEdgeInset = .None {
public var detailViewInsetPreset: MaterialEdgeInset = .Square2 {
didSet {
detailViewInset = MaterialEdgeInsetToValue(detailViewInsetPreset)
}
......
......@@ -169,7 +169,7 @@ public struct MaterialColor {
// cyan
public struct cyan {
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 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)
......
......@@ -373,9 +373,6 @@ public class NavigationBar : UINavigationBar {
public override func layoutSubviews() {
super.layoutSubviews()
leftControls = leftControls
rightControls = rightControls
if nil != backItem && nil != topItem {
backButton.setImage(backButtonImage, forState: .Normal)
backButton.setImage(backButtonImage, forState: .Highlighted)
......@@ -467,8 +464,8 @@ public class NavigationBarControls {
public init() {
backButton = FlatButton()
backButton.pulseColor = nil
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