Commit f22face7 by Martin Jurenka

added ShouldOpen and ShouldClose delegate methods to FABMenuDelegate

parent 904324b9
...@@ -139,6 +139,14 @@ extension FABMenuItem { ...@@ -139,6 +139,14 @@ extension FABMenuItem {
@objc(FABMenuDelegate) @objc(FABMenuDelegate)
public protocol FABMenuDelegate { public protocol FABMenuDelegate {
/**
A delegation method that is executed to determine whether fabMenu should open.
- Parameter fabMenu: A FABMenu.
*/
@objc
optional func fabMenuShouldOpen(fabMenu: FABMenu) -> Bool
/** /**
A delegation method that is execited when the fabMenu will open. A delegation method that is execited when the fabMenu will open.
- Parameter fabMenu: A FABMenu. - Parameter fabMenu: A FABMenu.
...@@ -154,6 +162,13 @@ public protocol FABMenuDelegate { ...@@ -154,6 +162,13 @@ public protocol FABMenuDelegate {
optional func fabMenuDidOpen(fabMenu: FABMenu) optional func fabMenuDidOpen(fabMenu: FABMenu)
/** /**
A delegation method that is executed to determine whether fabMenu should close.
- Parameter fabMenu: A FABMenu.
*/
@objc
optional func fabMenuShouldClose(fabMenu: FABMenu) -> Bool
/**
A delegation method that is execited when the fabMenu will close. A delegation method that is execited when the fabMenu will close.
- Parameter fabMenu: A FABMenu. - Parameter fabMenu: A FABMenu.
*/ */
...@@ -358,6 +373,10 @@ extension FABMenu { ...@@ -358,6 +373,10 @@ extension FABMenu {
- Parameter completion: A completion block to execute on each view's animation. - Parameter completion: A completion block to execute on each view's animation.
*/ */
open func open(isTriggeredByUserInteraction: Bool, duration: TimeInterval = 0.15, delay: TimeInterval = 0, usingSpringWithDamping: CGFloat = 0.5, initialSpringVelocity: CGFloat = 0, options: UIViewAnimationOptions = [], animations: ((UIView) -> Void)? = nil, completion: ((UIView) -> Void)? = nil) { open func open(isTriggeredByUserInteraction: Bool, duration: TimeInterval = 0.15, delay: TimeInterval = 0, usingSpringWithDamping: CGFloat = 0.5, initialSpringVelocity: CGFloat = 0, options: UIViewAnimationOptions = [], animations: ((UIView) -> Void)? = nil, completion: ((UIView) -> Void)? = nil) {
if delegate?.fabMenuShouldOpen?(fabMenu: self) == false {
return
}
handleOpenCallback?() handleOpenCallback?()
if isTriggeredByUserInteraction { if isTriggeredByUserInteraction {
...@@ -407,6 +426,10 @@ extension FABMenu { ...@@ -407,6 +426,10 @@ extension FABMenu {
- Parameter completion: A completion block to execute on each view's animation. - Parameter completion: A completion block to execute on each view's animation.
*/ */
open func close(isTriggeredByUserInteraction: Bool, duration: TimeInterval = 0.15, delay: TimeInterval = 0, usingSpringWithDamping: CGFloat = 0.5, initialSpringVelocity: CGFloat = 0, options: UIViewAnimationOptions = [], animations: ((UIView) -> Void)? = nil, completion: ((UIView) -> Void)? = nil) { open func close(isTriggeredByUserInteraction: Bool, duration: TimeInterval = 0.15, delay: TimeInterval = 0, usingSpringWithDamping: CGFloat = 0.5, initialSpringVelocity: CGFloat = 0, options: UIViewAnimationOptions = [], animations: ((UIView) -> Void)? = nil, completion: ((UIView) -> Void)? = nil) {
if delegate?.fabMenuShouldClose?(fabMenu: self) == false {
return
}
handleCloseCallback?() handleCloseCallback?()
if isTriggeredByUserInteraction { if isTriggeredByUserInteraction {
......
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