Commit cb15b04c by M. Porooshani

Reverted changes to NavBar and SideNav to stable

parent 11f9e26e
......@@ -38,16 +38,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let navigationController: AppNavigationController = AppNavigationController(rootViewController: RecipesViewController())
let menuController: AppMenuController = AppMenuController(rootViewController: navigationController)
menuController.edgesForExtendedLayout = .None
let bottomNavigationController: BottomNavigationController = BottomNavigationController()
bottomNavigationController.viewControllers = [navigationController, VideoViewController(), PhotoViewController()]
bottomNavigationController.viewControllers = [menuController, VideoViewController(), PhotoViewController()]
bottomNavigationController.selectedIndex = 0
bottomNavigationController.tabBar.tintColor = MaterialColor.white
bottomNavigationController.tabBar.backgroundColor = MaterialColor.grey.darken4
let menuController: AppMenuController = AppMenuController(rootViewController: bottomNavigationController)
let sideNavigationController: SideNavigationController = SideNavigationController(rootViewController: menuController, leftViewController: AppLeftViewController())
let sideNavigationController: SideNavigationController = SideNavigationController(rootViewController: bottomNavigationController, leftViewController: AppLeftViewController())
sideNavigationController.statusBarStyle = .LightContent
window = UIWindow(frame: UIScreen.mainScreen().bounds)
......
......@@ -40,11 +40,28 @@ class AppMenuController: MenuController {
/// MenuView diameter.
private let baseSize: CGSize = CGSizeMake(56, 56)
/// MenuView inset.
private let menuViewInset: CGFloat = 16
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
prepareTabBarItem()
}
override func viewDidLoad() {
super.viewDidLoad()
prepareMenuView()
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
closeMenu()
}
override func openMenu(completion: (() -> Void)? = nil) {
super.openMenu(completion)
sideNavigationController?.enabled = false
......@@ -81,22 +98,6 @@ class AppMenuController: MenuController {
}
}
/// Shows the menuView.
func showMenu() {
menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(0)
]))
}
/// Hides the menuView.
func hideMenu() {
menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(150)
]))
}
/// Prepares the menuView.
private func prepareMenuView() {
var image: UIImage? = MaterialIcon.cm.add
......@@ -138,10 +139,17 @@ class AppMenuController: MenuController {
menuView.menu.baseSize = baseSize
menuView.menu.views = [menuButton, blueButton, greenButton, yellowButton]
menuView.delegate = self
view.layout.size(menuView, width: baseSize.width, height: baseSize.height)
view.layout.align.bottomRight(menuView, bottom: 65, right: 16)
view.layout.align.bottomRight(menuView, bottom: menuViewInset, right: menuViewInset)
}
/// Prepare tabBarItem.
private func prepareTabBarItem() {
tabBarItem.image = MaterialIcon.cm.photoLibrary
tabBarItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
tabBarItem.setTitleColor(MaterialColor.white, forState: .Selected)
}
}
/// MenuViewDelegate.
......
......@@ -35,7 +35,6 @@ class AppNavigationController: NavigationController {
override func viewDidLoad() {
super.viewDidLoad()
prepareNavigationBar()
prepareTabBarItem()
}
/// Prepares the navigationBar
......@@ -43,11 +42,4 @@ class AppNavigationController: NavigationController {
navigationBar.tintColor = MaterialColor.white
navigationBar.backgroundColor = MaterialColor.blue.base
}
/// Prepare tabBarItem.
private func prepareTabBarItem() {
tabBarItem.image = MaterialIcon.cm.photoLibrary
tabBarItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
tabBarItem.setTitleColor(MaterialColor.white, forState: .Selected)
}
}
......@@ -57,7 +57,6 @@ class ItemViewController: UIViewController {
convenience init(dataSource: MaterialDataSourceItem) {
self.init(nibName: nil, bundle: nil)
self.dataSource = dataSource
hidesBottomBarWhenPushed = true
}
required init?(coder aDecoder: NSCoder) {
......@@ -75,14 +74,19 @@ class ItemViewController: UIViewController {
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
(menuController as? AppMenuController)?.hideMenu()
sideNavigationController?.enabled = false
// Stops the scrollView contentInsets from being automatically adjusted.
automaticallyAdjustsScrollViewInsets = false
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
(menuController as? AppMenuController)?.showMenu()
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// Access the navigationItem.backButton here.
// navigationItem.backButton
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
......@@ -161,6 +165,9 @@ class ItemViewController: UIViewController {
let image: UIImage? = UIImage(named: data["image"] as! String)
imageCardView.image = image
scrollView.addSubview(imageCardView)
imageCardView.translatesAutoresizingMaskIntoConstraints = false
}
}
}
......@@ -70,6 +70,27 @@ class RecipesViewController: UIViewController {
sideNavigationController?.enabled = true
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// Show the menuView.
menuController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(0)
]))
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
// Disable the SideNavigation.
// Hide the menuView.
menuController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(150)
]))
}
/// Handles the menuButton.
internal func handleMenuButton() {
sideNavigationController?.openLeftView()
......
......@@ -287,18 +287,6 @@ public class NavigationBar : UINavigationBar {
self.init(frame: CGRectZero)
}
/// Calculates the offset for the statusbar.
private func statusbarOffset() -> CGFloat {
switch MaterialDevice.type {
case .iPad:
return MaterialDevice.statusBarHidden ? 20 : 0
case .iPhone:
return MaterialDevice.isPortrait && MaterialDevice.statusBarHidden ? 20 : 0
default:
return 0
}
}
public override func intrinsicContentSize() -> CGSize {
switch navigationBarStyle {
case .Tiny:
......@@ -311,9 +299,7 @@ public class NavigationBar : UINavigationBar {
}
public override func sizeThatFits(size: CGSize) -> CGSize {
var result: CGSize = intrinsicContentSize()
result.height += statusbarOffset()
return result
return intrinsicContentSize()
}
public override func layoutSubviews() {
......@@ -337,7 +323,7 @@ public class NavigationBar : UINavigationBar {
- Parameter item: A UINavigationItem to layout.
*/
internal func layoutNavigationItem(item: UINavigationItem) {
if willRenderView && !animating {
if willRenderView {
prepareItem(item)
if let titleView: UIView = prepareTitleView(item) {
......@@ -345,7 +331,7 @@ public class NavigationBar : UINavigationBar {
if let g: Int = Int(width / gridFactor) {
let columns: Int = g + 1
titleView.frame.origin = CGPoint(x: 0, y: statusbarOffset())
titleView.frame.origin = CGPoint.zero
titleView.frame.size = intrinsicContentSize()
titleView.grid.views = []
titleView.grid.axis.columns = columns
......
......@@ -400,6 +400,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
public override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
// Portrait will be Lanscape when this method is done.
if MaterialDevice.isPortrait && .iPhone == MaterialDevice.type {
hideStatusBar()
} else {
showStatusBar()
}
closeLeftView()
closeRightView()
......@@ -1092,17 +1098,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
willHideStatusBar = false
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in
if let v: NavigationBar = (self?.rootViewController as? NavigationController)?.navigationBar as? NavigationBar {
v.animating = true
}
self?.statusBarHidden = false
}) { [weak self] _ in
if let v: NavigationBar = (self?.rootViewController as? NavigationController)?.navigationBar as? NavigationBar {
v.animating = false
}
}
self.setNeedsStatusBarAppearanceUpdate()
self?.setNeedsStatusBarAppearanceUpdate()
self?.statusBarHidden = false
})
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: false)
}
}
......@@ -1114,17 +1112,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
if !statusBarHidden {
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in
if let v: NavigationBar = (self?.rootViewController as? NavigationController)?.navigationBar as? NavigationBar {
v.animating = true
}
self?.statusBarHidden = true
}) { [weak self] _ in
if let v: NavigationBar = (self?.rootViewController as? NavigationController)?.navigationBar as? NavigationBar {
v.animating = false
}
}
self.setNeedsStatusBarAppearanceUpdate()
self?.setNeedsStatusBarAppearanceUpdate()
self?.statusBarHidden = true
})
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: true)
}
}
......
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