Commit 952aa351 by Daniel Dahan

updated PR for closeMenu when tapping in outside space

parent 800708dd
...@@ -39,11 +39,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -39,11 +39,11 @@ 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 menuViewController: AppMenuController = AppMenuController(rootViewController: navigationController) let menuController: AppMenuController = AppMenuController(rootViewController: navigationController)
menuViewController.edgesForExtendedLayout = .None menuController.edgesForExtendedLayout = .None
let bottomNavigationController: BottomNavigationController = BottomNavigationController() let bottomNavigationController: BottomNavigationController = BottomNavigationController()
bottomNavigationController.viewControllers = [menuViewController, VideoViewController(), PhotoViewController()] bottomNavigationController.viewControllers = [menuController, 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
......
...@@ -76,7 +76,7 @@ class RecipesViewController: UIViewController { ...@@ -76,7 +76,7 @@ class RecipesViewController: UIViewController {
override func viewDidAppear(animated: Bool) { override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated) super.viewDidAppear(animated)
// Show the menuView. // Show the menuView.
menuViewController?.menuView.animate(MaterialAnimation.animationGroup([ menuController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3), MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(0) MaterialAnimation.translateY(0)
])) ]))
...@@ -87,7 +87,7 @@ class RecipesViewController: UIViewController { ...@@ -87,7 +87,7 @@ class RecipesViewController: UIViewController {
// Disable the SideNavigation. // Disable the SideNavigation.
// Hide the menuView. // Hide the menuView.
menuViewController?.menuView.animate(MaterialAnimation.animationGroup([ menuController?.menuView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 3), MaterialAnimation.rotate(rotation: 3),
MaterialAnimation.translateY(150) MaterialAnimation.translateY(150)
])) ]))
......
...@@ -10,10 +10,12 @@ ...@@ -10,10 +10,12 @@
966ECF521CF6162F00BB0BDF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF511CF6162F00BB0BDF /* AppDelegate.swift */; }; 966ECF521CF6162F00BB0BDF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF511CF6162F00BB0BDF /* AppDelegate.swift */; };
966ECF591CF6162F00BB0BDF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966ECF581CF6162F00BB0BDF /* Assets.xcassets */; }; 966ECF591CF6162F00BB0BDF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966ECF581CF6162F00BB0BDF /* Assets.xcassets */; };
966ECF5C1CF6162F00BB0BDF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 966ECF5A1CF6162F00BB0BDF /* LaunchScreen.storyboard */; }; 966ECF5C1CF6162F00BB0BDF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 966ECF5A1CF6162F00BB0BDF /* LaunchScreen.storyboard */; };
966ECF6B1CF616F500BB0BDF /* AppMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF671CF616F500BB0BDF /* AppMenuViewController.swift */; }; 966ECF6B1CF616F500BB0BDF /* AppMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF671CF616F500BB0BDF /* AppMenuController.swift */; };
966ECF6C1CF616F500BB0BDF /* BlueViewcontroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF681CF616F500BB0BDF /* BlueViewcontroller.swift */; }; 966ECF6C1CF616F500BB0BDF /* BlueViewcontroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF681CF616F500BB0BDF /* BlueViewcontroller.swift */; };
966ECF6D1CF616F500BB0BDF /* GreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF691CF616F500BB0BDF /* GreenViewController.swift */; }; 966ECF6D1CF616F500BB0BDF /* GreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF691CF616F500BB0BDF /* GreenViewController.swift */; };
966ECF6E1CF616F500BB0BDF /* YellowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF6A1CF616F500BB0BDF /* YellowViewController.swift */; }; 966ECF6E1CF616F500BB0BDF /* YellowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966ECF6A1CF616F500BB0BDF /* YellowViewController.swift */; };
96FFF57A1CFA52DC001E8048 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96FFF5791CFA52DC001E8048 /* Material.framework */; };
96FFF57B1CFA52DC001E8048 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96FFF5791CFA52DC001E8048 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -23,6 +25,7 @@ ...@@ -23,6 +25,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96FFF57B1CFA52DC001E8048 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -35,10 +38,11 @@ ...@@ -35,10 +38,11 @@
966ECF581CF6162F00BB0BDF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 966ECF581CF6162F00BB0BDF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
966ECF5B1CF6162F00BB0BDF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 966ECF5B1CF6162F00BB0BDF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
966ECF5D1CF6162F00BB0BDF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 966ECF5D1CF6162F00BB0BDF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
966ECF671CF616F500BB0BDF /* AppMenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMenuViewController.swift; sourceTree = "<group>"; }; 966ECF671CF616F500BB0BDF /* AppMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMenuController.swift; sourceTree = "<group>"; };
966ECF681CF616F500BB0BDF /* BlueViewcontroller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueViewcontroller.swift; sourceTree = "<group>"; }; 966ECF681CF616F500BB0BDF /* BlueViewcontroller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlueViewcontroller.swift; sourceTree = "<group>"; };
966ECF691CF616F500BB0BDF /* GreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GreenViewController.swift; sourceTree = "<group>"; }; 966ECF691CF616F500BB0BDF /* GreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GreenViewController.swift; sourceTree = "<group>"; };
966ECF6A1CF616F500BB0BDF /* YellowViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YellowViewController.swift; sourceTree = "<group>"; }; 966ECF6A1CF616F500BB0BDF /* YellowViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YellowViewController.swift; sourceTree = "<group>"; };
96FFF5791CFA52DC001E8048 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/CosmicMind-hgvxkqfizbxkrsfcxbtlafgqkbve/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -46,6 +50,7 @@ ...@@ -46,6 +50,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96FFF57A1CFA52DC001E8048 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -55,6 +60,7 @@ ...@@ -55,6 +60,7 @@
966ECF451CF6162F00BB0BDF = { 966ECF451CF6162F00BB0BDF = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96FFF5791CFA52DC001E8048 /* Material.framework */,
966ECF501CF6162F00BB0BDF /* MenuController */, 966ECF501CF6162F00BB0BDF /* MenuController */,
966ECF4F1CF6162F00BB0BDF /* Products */, 966ECF4F1CF6162F00BB0BDF /* Products */,
); );
...@@ -72,7 +78,7 @@ ...@@ -72,7 +78,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
966ECF511CF6162F00BB0BDF /* AppDelegate.swift */, 966ECF511CF6162F00BB0BDF /* AppDelegate.swift */,
966ECF671CF616F500BB0BDF /* AppMenuViewController.swift */, 966ECF671CF616F500BB0BDF /* AppMenuController.swift */,
966ECF681CF616F500BB0BDF /* BlueViewcontroller.swift */, 966ECF681CF616F500BB0BDF /* BlueViewcontroller.swift */,
966ECF691CF616F500BB0BDF /* GreenViewController.swift */, 966ECF691CF616F500BB0BDF /* GreenViewController.swift */,
966ECF6A1CF616F500BB0BDF /* YellowViewController.swift */, 966ECF6A1CF616F500BB0BDF /* YellowViewController.swift */,
...@@ -156,7 +162,7 @@ ...@@ -156,7 +162,7 @@
files = ( files = (
966ECF521CF6162F00BB0BDF /* AppDelegate.swift in Sources */, 966ECF521CF6162F00BB0BDF /* AppDelegate.swift in Sources */,
966ECF6C1CF616F500BB0BDF /* BlueViewcontroller.swift in Sources */, 966ECF6C1CF616F500BB0BDF /* BlueViewcontroller.swift in Sources */,
966ECF6B1CF616F500BB0BDF /* AppMenuViewController.swift in Sources */, 966ECF6B1CF616F500BB0BDF /* AppMenuController.swift in Sources */,
966ECF6E1CF616F500BB0BDF /* YellowViewController.swift in Sources */, 966ECF6E1CF616F500BB0BDF /* YellowViewController.swift in Sources */,
966ECF6D1CF616F500BB0BDF /* GreenViewController.swift in Sources */, 966ECF6D1CF616F500BB0BDF /* GreenViewController.swift in Sources */,
); );
......
...@@ -36,14 +36,14 @@ flow of your application. ...@@ -36,14 +36,14 @@ flow of your application.
import UIKit import UIKit
import Material import Material
class AppMenuController: MenuController { class AppMenuController: MenuController, MenuViewDelegate {
/// MenuView diameter. /// MenuView diameter.
private let baseSize: CGSize = CGSizeMake(56, 56) private let baseSize: CGSize = CGSizeMake(56, 56)
/// MenuView inset. /// MenuView inset.
private let menuViewInset: CGFloat = 16 private let menuViewInset: CGFloat = 16
/// Loads the BlueViewController into the menuViewControllers rootViewController. /// Loads the BlueViewController into the menuControllers rootViewController.
func handleBlueButton() { func handleBlueButton() {
if rootViewController is BlueViewController { if rootViewController is BlueViewController {
return return
...@@ -54,7 +54,7 @@ class AppMenuController: MenuController { ...@@ -54,7 +54,7 @@ class AppMenuController: MenuController {
} }
} }
/// Loads the GreenViewController into the menuViewControllers rootViewController. /// Loads the GreenViewController into the menuControllers rootViewController.
func handleGreenButton() { func handleGreenButton() {
if rootViewController is GreenViewController { if rootViewController is GreenViewController {
return return
...@@ -65,11 +65,11 @@ class AppMenuController: MenuController { ...@@ -65,11 +65,11 @@ class AppMenuController: MenuController {
} }
} }
/// Loads the YellowViewController into the menuViewControllers rootViewController. /// Loads the YellowViewController into the menuControllers rootViewController.
func handleYellowButton() { func handleYellowButton() {
// if (rootViewController as? ToolbarController)?.rootViewController is YellowViewController { if rootViewController is YellowViewController {
// return return
// } }
closeMenu { [weak self] in closeMenu { [weak self] in
self?.transitionFromRootViewController(YellowViewController(), options: [.TransitionCrossDissolve]) self?.transitionFromRootViewController(YellowViewController(), options: [.TransitionCrossDissolve])
...@@ -79,14 +79,26 @@ class AppMenuController: MenuController { ...@@ -79,14 +79,26 @@ class AppMenuController: MenuController {
/// Handle the menuView touch event. /// Handle the menuView touch event.
func handleMenu() { func handleMenu() {
if menuView.menu.opened { if menuView.menu.opened {
menuViewController?.rootViewController.view.alpha = 1
closeMenu() closeMenu()
} else { } else {
menuViewController?.rootViewController.view.alpha = 0.5
openMenu() openMenu()
} }
} }
override func openMenu(completion: (() -> Void)? = nil) {
super.openMenu(completion)
if menuView.menu.opened {
rootViewController.view.alpha = 0.5
}
}
override func closeMenu(completion: (() -> Void)? = nil) {
super.closeMenu(completion)
if !menuView.menu.opened {
rootViewController.view.alpha = 1
}
}
/// Prepares view. /// Prepares view.
override func prepareView() { override func prepareView() {
super.prepareView() super.prepareView()
...@@ -94,16 +106,20 @@ class AppMenuController: MenuController { ...@@ -94,16 +106,20 @@ class AppMenuController: MenuController {
prepareMenuView() prepareMenuView()
} }
func menuViewDidTapOutside(menuView: MenuView) {
closeMenu()
}
/// Prepares the add button. /// Prepares the add button.
private func prepareMenuView() { private func prepareMenuView() {
var image: UIImage? = UIImage(named: "ic_add_white") var image: UIImage? = MaterialIcon.cm.add
let btn1: FabButton = FabButton() let btn1: FabButton = FabButton()
btn1.setImage(image, forState: .Normal) btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted) btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: #selector(handleMenu), forControlEvents: .TouchUpInside) btn1.addTarget(self, action: #selector(handleMenu), forControlEvents: .TouchUpInside)
menuView.addSubview(btn1) menuView.addSubview(btn1)
image = UIImage(named: "ic_create_white") image = MaterialIcon.cm.videocam
let btn2: FabButton = FabButton() let btn2: FabButton = FabButton()
btn2.backgroundColor = MaterialColor.blue.base btn2.backgroundColor = MaterialColor.blue.base
btn2.setImage(image, forState: .Normal) btn2.setImage(image, forState: .Normal)
...@@ -111,7 +127,7 @@ class AppMenuController: MenuController { ...@@ -111,7 +127,7 @@ class AppMenuController: MenuController {
menuView.addSubview(btn2) menuView.addSubview(btn2)
btn2.addTarget(self, action: #selector(handleBlueButton), forControlEvents: .TouchUpInside) btn2.addTarget(self, action: #selector(handleBlueButton), forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_photo_camera_white") image = MaterialIcon.cm.photoLibrary
let btn3: FabButton = FabButton() let btn3: FabButton = FabButton()
btn3.backgroundColor = MaterialColor.green.base btn3.backgroundColor = MaterialColor.green.base
btn3.setImage(image, forState: .Normal) btn3.setImage(image, forState: .Normal)
...@@ -119,7 +135,7 @@ class AppMenuController: MenuController { ...@@ -119,7 +135,7 @@ class AppMenuController: MenuController {
menuView.addSubview(btn3) menuView.addSubview(btn3)
btn3.addTarget(self, action: #selector(handleGreenButton), forControlEvents: .TouchUpInside) btn3.addTarget(self, action: #selector(handleGreenButton), forControlEvents: .TouchUpInside)
image = UIImage(named: "ic_note_add_white") image = MaterialIcon.cm.pen
let btn4: FabButton = FabButton() let btn4: FabButton = FabButton()
btn4.backgroundColor = MaterialColor.yellow.base btn4.backgroundColor = MaterialColor.yellow.base
btn4.setImage(image, forState: .Normal) btn4.setImage(image, forState: .Normal)
...@@ -130,6 +146,7 @@ class AppMenuController: MenuController { ...@@ -130,6 +146,7 @@ class AppMenuController: MenuController {
// Initialize the menu and setup the configuration options. // Initialize the menu and setup the configuration options.
menuView.menu.baseSize = baseSize menuView.menu.baseSize = baseSize
menuView.menu.views = [btn1, btn2, btn3, btn4] menuView.menu.views = [btn1, btn2, btn3, btn4]
menuView.delegate = self
view.addSubview(menuView) view.addSubview(menuView)
MaterialLayout.size(view, child: menuView, width: baseSize.width, height: baseSize.height) MaterialLayout.size(view, child: menuView, width: baseSize.width, height: baseSize.height)
......
...@@ -94,6 +94,11 @@ public class Menu { ...@@ -94,6 +94,11 @@ public class Menu {
self.origin = origin self.origin = origin
self.spacing = spacing self.spacing = spacing
} }
/// Convenience initializer.
public convenience init() {
self.init(origin: CGPointZero)
}
/// Reload the view layout. /// Reload the view layout.
public func reloadLayout() { public func reloadLayout() {
...@@ -186,12 +191,14 @@ public class Menu { ...@@ -186,12 +191,14 @@ public class Menu {
} }
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = true
}
completion?(view)
} }
} }
} }
opened = true
} }
} }
...@@ -224,12 +231,14 @@ public class Menu { ...@@ -224,12 +231,14 @@ public class Menu {
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
view.hidden = true view.hidden = true
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = false
}
completion?(view)
} }
} }
} }
opened = false
} }
} }
...@@ -268,12 +277,14 @@ public class Menu { ...@@ -268,12 +277,14 @@ public class Menu {
} }
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = true
}
completion?(view)
} }
} }
} }
opened = true
} }
} }
...@@ -307,12 +318,14 @@ public class Menu { ...@@ -307,12 +318,14 @@ public class Menu {
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
view.hidden = true view.hidden = true
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = false
}
completion?(view)
} }
} }
} }
opened = false
} }
} }
...@@ -350,12 +363,14 @@ public class Menu { ...@@ -350,12 +363,14 @@ public class Menu {
} }
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = true
}
completion?(view)
} }
} }
} }
opened = true
} }
} }
...@@ -387,12 +402,14 @@ public class Menu { ...@@ -387,12 +402,14 @@ public class Menu {
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
view.hidden = true view.hidden = true
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = false
}
completion?(view)
} }
} }
} }
opened = false
} }
} }
...@@ -430,12 +447,14 @@ public class Menu { ...@@ -430,12 +447,14 @@ public class Menu {
} }
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = true
}
completion?(view)
} }
} }
} }
opened = true
} }
} }
...@@ -453,7 +472,7 @@ public class Menu { ...@@ -453,7 +472,7 @@ public class Menu {
if let v: Array<UIView> = views { if let v: Array<UIView> = views {
for i in 1..<v.count { for i in 1..<v.count {
let view: UIView = v[i] let view: UIView = v[i]
let w: CGFloat = nil == baseSize ? itemSize.width : baseSize!.width let w: CGFloat = nil == baseSize ? itemSize.width : baseSize!.width
UIView.animateWithDuration(Double(i) * duration, UIView.animateWithDuration(Double(i) * duration,
delay: delay, delay: delay,
...@@ -469,12 +488,14 @@ public class Menu { ...@@ -469,12 +488,14 @@ public class Menu {
}) { [weak self] _ in }) { [weak self] _ in
if let s: Menu = self { if let s: Menu = self {
view.hidden = true view.hidden = true
completion?(view)
s.enable(view) s.enable(view)
if view == v.last {
s.opened = false
}
completion?(view)
} }
} }
} }
opened = false
} }
} }
......
...@@ -36,7 +36,7 @@ public extension UIViewController { ...@@ -36,7 +36,7 @@ public extension UIViewController {
This is the recommended method of accessing the MenuController This is the recommended method of accessing the MenuController
through child UIViewControllers. through child UIViewControllers.
*/ */
public var menuViewController: MenuController? { public var menuController: MenuController? {
var viewController: UIViewController? = self var viewController: UIViewController? = self
while nil != viewController { while nil != viewController {
if viewController is MenuController { if viewController is MenuController {
......
...@@ -31,8 +31,7 @@ ...@@ -31,8 +31,7 @@
import UIKit import UIKit
@objc(MenuViewDelegate) @objc(MenuViewDelegate)
public protocol MenuViewDelegate: MaterialDelegate { public protocol MenuViewDelegate : MaterialDelegate {
/// Gets called when the user taps outside menu buttons. /// Gets called when the user taps outside menu buttons.
optional func menuViewDidTapOutside(menuView: MenuView) optional func menuViewDidTapOutside(menuView: MenuView)
...@@ -40,7 +39,7 @@ public protocol MenuViewDelegate: MaterialDelegate { ...@@ -40,7 +39,7 @@ public protocol MenuViewDelegate: MaterialDelegate {
public class MenuView : MaterialPulseView { public class MenuView : MaterialPulseView {
/// References the Menu instance. /// References the Menu instance.
public private(set) lazy var menu: Menu = Menu(origin: CGPointZero) public private(set) lazy var menu: Menu = Menu()
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
...@@ -98,15 +97,18 @@ public class MenuView : MaterialPulseView { ...@@ -98,15 +97,18 @@ public class MenuView : MaterialPulseView {
guard !hidden else { guard !hidden else {
return nil return nil
} }
for v in subviews { for v in subviews {
let p: CGPoint = v.convertPoint(point, fromView: self) let p: CGPoint = v.convertPoint(point, fromView: self)
if CGRectContainsPoint(v.bounds, p) { if CGRectContainsPoint(v.bounds, p) {
return v.hitTest(p, withEvent: event) return v.hitTest(p, withEvent: event)
} }
} }
(delegate as? MenuViewDelegate)?.menuViewDidTapOutside?(self) // if menu.opened {
// (delegate as? MenuViewDelegate)?.menuViewDidTapOutside?(self)
// }
return super.hitTest(point, withEvent: event) return super.hitTest(point, withEvent: event)
} }
} }
\ No newline at end of file
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