Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
dd741ff0
Unverified
Commit
dd741ff0
authored
Jun 02, 2018
by
Daniel Dahan
Committed by
GitHub
Jun 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1046 from mjurenka/master
added ShouldOpen and ShouldClose delegate methods to FABMenuDelegate
parents
e8691249
854e9057
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
Sources/iOS/FABMenu.swift
+62
-0
No files found.
Sources/iOS/FABMenu.swift
View file @
dd741ff0
...
@@ -140,6 +140,13 @@ extension FABMenuItem {
...
@@ -140,6 +140,13 @@ 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 +161,13 @@ public protocol FABMenuDelegate {
...
@@ -154,6 +161,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.
*/
*/
...
@@ -364,6 +378,29 @@ extension FABMenu {
...
@@ -364,6 +378,29 @@ extension FABMenu {
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
}
}
/**
Open the Menu component with animation options.
- Parameter isTriggeredByUserInteraction: A boolean indicating whether the
state was changed by a user interaction, true if yes, false otherwise.
- Parameter duration: The time for each view's animation.
- Parameter delay: A delay time for each view's animation.
- Parameter usingSpringWithDamping: A damping ratio for the animation.
- Parameter initialSpringVelocity: The initial velocity for the animation.
- Parameter options: Options to pass to the animation.
- Parameter animations: An animation 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
)
{
if
delegate
?
.
fabMenuShouldOpen
?(
fabMenu
:
self
)
==
false
{
return
}
handleOpenCallback
?()
if
isTriggeredByUserInteraction
{
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
}
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
completion
=
completion
]
(
view
)
in
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
completion
=
completion
]
(
view
)
in
guard
let
`
self
`
=
self
else
{
guard
let
`
self
`
=
self
else
{
return
return
...
@@ -379,6 +416,7 @@ extension FABMenu {
...
@@ -379,6 +416,7 @@ extension FABMenu {
self
.
handleCompletionCallback
?(
view
)
self
.
handleCompletionCallback
?(
view
)
}
}
}
}
}
/**
/**
Close the Menu component with animation options.
Close the Menu component with animation options.
...
@@ -413,6 +451,29 @@ extension FABMenu {
...
@@ -413,6 +451,29 @@ extension FABMenu {
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
}
}
/**
Close the Menu component with animation options.
- Parameter isTriggeredByUserInteraction: A boolean indicating whether the
state was changed by a user interaction, true if yes, false otherwise.
- Parameter duration: The time for each view's animation.
- Parameter delay: A delay time for each view's animation.
- Parameter usingSpringWithDamping: A damping ratio for the animation.
- Parameter initialSpringVelocity: The initial velocity for the animation.
- Parameter options: Options to pass to the animation.
- Parameter animations: An animation 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
)
{
if
delegate
?
.
fabMenuShouldClose
?(
fabMenu
:
self
)
==
false
{
return
}
handleCloseCallback
?()
if
isTriggeredByUserInteraction
{
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
}
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
completion
=
completion
]
(
view
)
in
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
completion
=
completion
]
(
view
)
in
guard
let
`
self
`
=
self
else
{
guard
let
`
self
`
=
self
else
{
return
return
...
@@ -428,6 +489,7 @@ extension FABMenu {
...
@@ -428,6 +489,7 @@ extension FABMenu {
self
.
handleCompletionCallback
?(
view
)
self
.
handleCompletionCallback
?(
view
)
}
}
}
}
}
}
}
extension
FABMenu
{
extension
FABMenu
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment