Commit 1af9a3a2 by Daniel Dahan

fixed hide tabBar issue with MenuController by rearranging the hierarchy

parent 0eaec94e
...@@ -39,16 +39,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -39,16 +39,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let navigationController: AppNavigationController = AppNavigationController(rootViewController: RecipesViewController()) let navigationController: AppNavigationController = AppNavigationController(rootViewController: RecipesViewController())
let menuController: AppMenuController = AppMenuController(rootViewController: navigationController)
menuController.edgesForExtendedLayout = .None
let bottomNavigationController: BottomNavigationController = BottomNavigationController() let bottomNavigationController: BottomNavigationController = BottomNavigationController()
bottomNavigationController.viewControllers = [/*menuController*/navigationController, VideoViewController(), PhotoViewController()] bottomNavigationController.viewControllers = [navigationController, VideoViewController(), PhotoViewController()]
bottomNavigationController.selectedIndex = 0 bottomNavigationController.selectedIndex = 0
bottomNavigationController.tabBar.tintColor = MaterialColor.white bottomNavigationController.tabBar.tintColor = MaterialColor.white
bottomNavigationController.tabBar.backgroundColor = MaterialColor.grey.darken4 bottomNavigationController.tabBar.backgroundColor = MaterialColor.grey.darken4
let sideNavigationController: SideNavigationController = SideNavigationController(rootViewController: bottomNavigationController, leftViewController: AppLeftViewController()) let menuController: AppMenuController = AppMenuController(rootViewController: bottomNavigationController)
let sideNavigationController: SideNavigationController = SideNavigationController(rootViewController: menuController, leftViewController: AppLeftViewController())
sideNavigationController.statusBarStyle = .LightContent sideNavigationController.statusBarStyle = .LightContent
window = UIWindow(frame: UIScreen.mainScreen().bounds) window = UIWindow(frame: UIScreen.mainScreen().bounds)
......
...@@ -40,27 +40,11 @@ class AppMenuController: MenuController { ...@@ -40,27 +40,11 @@ class AppMenuController: MenuController {
/// MenuView diameter. /// MenuView diameter.
private let baseSize: CGSize = CGSizeMake(56, 56) 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)
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareMenuView() prepareMenuView()
} }
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
closeMenu()
}
override func openMenu(completion: (() -> Void)? = nil) { override func openMenu(completion: (() -> Void)? = nil) {
super.openMenu(completion) super.openMenu(completion)
sideNavigationController?.enabled = false sideNavigationController?.enabled = false
...@@ -97,6 +81,22 @@ class AppMenuController: MenuController { ...@@ -97,6 +81,22 @@ 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. /// Prepares the menuView.
private func prepareMenuView() { private func prepareMenuView() {
var image: UIImage? = MaterialIcon.cm.add var image: UIImage? = MaterialIcon.cm.add
...@@ -140,9 +140,8 @@ class AppMenuController: MenuController { ...@@ -140,9 +140,8 @@ class AppMenuController: MenuController {
menuView.delegate = self menuView.delegate = self
view.layout.size(menuView, width: baseSize.width, height: baseSize.height) view.layout.size(menuView, width: baseSize.width, height: baseSize.height)
view.layout.alignFromBottomRight(menuView, bottom: menuViewInset, right: menuViewInset) view.layout.alignFromBottomRight(menuView, bottom: 65, right: 16)
} }
} }
/// MenuViewDelegate. /// MenuViewDelegate.
......
...@@ -50,5 +50,4 @@ class AppNavigationController: NavigationController { ...@@ -50,5 +50,4 @@ class AppNavigationController: NavigationController {
tabBarItem.setTitleColor(MaterialColor.grey.base, forState: .Normal) tabBarItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
tabBarItem.setTitleColor(MaterialColor.white, forState: .Selected) tabBarItem.setTitleColor(MaterialColor.white, forState: .Selected)
} }
} }
...@@ -75,20 +75,13 @@ class ItemViewController: UIViewController { ...@@ -75,20 +75,13 @@ class ItemViewController: UIViewController {
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
(menuController as? AppMenuController)?.hideMenu()
sideNavigationController?.enabled = false sideNavigationController?.enabled = false
// Stops the scrollView contentInsets from being automatically adjusted.
automaticallyAdjustsScrollViewInsets = false
// Customize the navigationItem.backButton image here.
// (navigationController?.navigationBar as? NavigationBar)?.backButtonImage = MaterialIcon.cm.audioLibrary
} }
override func viewDidAppear(animated: Bool) { override func viewWillDisappear(animated: Bool) {
super.viewDidAppear(animated) super.viewWillDisappear(animated)
(menuController as? AppMenuController)?.showMenu()
// Access the navigationItem.backButton here.
// navigationItem.backButton
} }
override func viewWillLayoutSubviews() { override func viewWillLayoutSubviews() {
......
...@@ -64,7 +64,7 @@ class RecipesViewController: UIViewController { ...@@ -64,7 +64,7 @@ class RecipesViewController: UIViewController {
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
// Stops the tableView contentInsets from being automatically adjusted. // Stops the tableView contentInsets from being automatically adjusted.
automaticallyAdjustsScrollViewInsets = false automaticallyAdjustsScrollViewInsets = true
// Set the navigationBar style. // Set the navigationBar style.
navigationController?.navigationBar.statusBarStyle = .LightContent navigationController?.navigationBar.statusBarStyle = .LightContent
...@@ -73,26 +73,6 @@ class RecipesViewController: UIViewController { ...@@ -73,26 +73,6 @@ class RecipesViewController: UIViewController {
sideNavigationController?.enabled = true 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. /// Handles the menuButton.
internal func handleMenuButton() { internal func handleMenuButton() {
sideNavigationController?.openLeftView() sideNavigationController?.openLeftView()
......
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