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
42b6d525
Unverified
Commit
42b6d525
authored
Dec 25, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added delegation methods to FABMenu
parent
9875036d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
240 additions
and
162 deletions
+240
-162
Sources/iOS/Button.swift
+3
-3
Sources/iOS/CollectionReusableView.swift
+3
-3
Sources/iOS/CollectionViewCell.swift
+3
-3
Sources/iOS/FABButton.swift
+0
-1
Sources/iOS/FABMenu.swift
+140
-45
Sources/iOS/FABMenuController.swift
+57
-56
Sources/iOS/Menu.swift
+1
-1
Sources/iOS/PulseMotion.swift
+6
-6
Sources/iOS/PulseView.swift
+3
-3
Sources/iOS/SpringMotion.swift
+21
-38
Sources/iOS/TableViewCell.swift
+3
-3
No files found.
Sources/iOS/Button.swift
View file @
42b6d525
...
@@ -42,8 +42,8 @@ open class Button: UIButton, PulseableMotion {
...
@@ -42,8 +42,8 @@ open class Button: UIButton, PulseableMotion {
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
fileprivate
var
pulse
:
PulseMotion
!
/// Pulse
Motion
Animation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
Pulse
Motion
Animation
{
open
var
pulseAnimation
:
PulseAnimation
{
get
{
get
{
return
pulse
.
animation
return
pulse
.
animation
}
}
...
@@ -52,7 +52,7 @@ open class Button: UIButton, PulseableMotion {
...
@@ -52,7 +52,7 @@ open class Button: UIButton, PulseableMotion {
}
}
}
}
/// Pulse
Motion
Animation color.
/// PulseAnimation color.
@IBInspectable
@IBInspectable
open
var
pulseColor
:
UIColor
{
open
var
pulseColor
:
UIColor
{
get
{
get
{
...
...
Sources/iOS/CollectionReusableView.swift
View file @
42b6d525
...
@@ -43,8 +43,8 @@ open class CollectionReusableView: UICollectionReusableView, PulseableMotion {
...
@@ -43,8 +43,8 @@ open class CollectionReusableView: UICollectionReusableView, PulseableMotion {
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
fileprivate
var
pulse
:
PulseMotion
!
/// Pulse
Motion
Animation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
Pulse
Motion
Animation
{
open
var
pulseAnimation
:
PulseAnimation
{
get
{
get
{
return
pulse
.
animation
return
pulse
.
animation
}
}
...
@@ -53,7 +53,7 @@ open class CollectionReusableView: UICollectionReusableView, PulseableMotion {
...
@@ -53,7 +53,7 @@ open class CollectionReusableView: UICollectionReusableView, PulseableMotion {
}
}
}
}
/// Pulse
Motion
Animation color.
/// PulseAnimation color.
@IBInspectable
@IBInspectable
open
var
pulseColor
:
UIColor
{
open
var
pulseColor
:
UIColor
{
get
{
get
{
...
...
Sources/iOS/CollectionViewCell.swift
View file @
42b6d525
...
@@ -43,8 +43,8 @@ open class CollectionViewCell: UICollectionViewCell, PulseableMotion {
...
@@ -43,8 +43,8 @@ open class CollectionViewCell: UICollectionViewCell, PulseableMotion {
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
fileprivate
var
pulse
:
PulseMotion
!
/// Pulse
Motion
Animation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
Pulse
Motion
Animation
{
open
var
pulseAnimation
:
PulseAnimation
{
get
{
get
{
return
pulse
.
animation
return
pulse
.
animation
}
}
...
@@ -53,7 +53,7 @@ open class CollectionViewCell: UICollectionViewCell, PulseableMotion {
...
@@ -53,7 +53,7 @@ open class CollectionViewCell: UICollectionViewCell, PulseableMotion {
}
}
}
}
/// Pulse
Motion
Animation color.
/// PulseAnimation color.
@IBInspectable
@IBInspectable
open
var
pulseColor
:
UIColor
{
open
var
pulseColor
:
UIColor
{
get
{
get
{
...
...
Sources/iOS/FABButton.swift
View file @
42b6d525
...
@@ -42,7 +42,6 @@ open class FABButton: Button {
...
@@ -42,7 +42,6 @@ open class FABButton: Button {
super
.
prepare
()
super
.
prepare
()
depthPreset
=
.
depth1
depthPreset
=
.
depth1
shapePreset
=
.
circle
shapePreset
=
.
circle
pulseAnimation
=
.
centerWithBacking
backgroundColor
=
.
white
backgroundColor
=
.
white
}
}
}
}
Sources/iOS/FABMenu.swift
View file @
42b6d525
...
@@ -41,14 +41,43 @@ public enum FABMenuDirection: Int {
...
@@ -41,14 +41,43 @@ public enum FABMenuDirection: Int {
@objc(FABMenuDelegate)
@objc(FABMenuDelegate)
public
protocol
FABMenuDelegate
{
public
protocol
FABMenuDelegate
{
/**
/**
Gets called when the user taps while the menu is opened.
A delegation method that is executed when the user taps while
- Parameter menu: A FABMenu.
the menu is opened.
- Parameter fabMenu: A FABMenu.
- Parameter tappedAt point: A CGPoint.
- Parameter tappedAt point: A CGPoint.
- Parameter isOutside: A boolean indicating whether the tap
- Parameter isOutside: A boolean indicating whether the tap
was outside the menu button area.
was outside the menu button area.
*/
*/
@objc
@objc
optional
func
fabMenu
(
fabMenu
:
FABMenu
,
tappedAt
point
:
CGPoint
,
isOutside
:
Bool
)
optional
func
fabMenu
(
fabMenu
:
FABMenu
,
tappedAt
point
:
CGPoint
,
isOutside
:
Bool
)
/**
A delegation method that is execited when the menu will open.
- Parameter fabMenu: A FABMenu.
*/
@objc
optional
func
fabMenuWillOpen
(
fabMenu
:
FABMenu
)
/**
A delegation method that is execited when the menu did open.
- Parameter fabMenu: A FABMenu.
*/
@objc
optional
func
fabMenuDidOpen
(
fabMenu
:
FABMenu
)
/**
A delegation method that is execited when the menu will close.
- Parameter fabMenu: A FABMenu.
*/
@objc
optional
func
fabMenuWillClose
(
fabMenu
:
FABMenu
)
/**
A delegation method that is execited when the menu did close.
- Parameter fabMenu: A FABMenu.
*/
@objc
optional
func
fabMenuDidClose
(
fabMenu
:
FABMenu
)
}
}
...
@@ -58,21 +87,27 @@ open class FABMenu: View, SpringableMotion {
...
@@ -58,21 +87,27 @@ open class FABMenu: View, SpringableMotion {
internal
let
spring
=
SpringMotion
()
internal
let
spring
=
SpringMotion
()
/// The direction in which the animation opens the menu.
/// The direction in which the animation opens the menu.
open
var
springDirection
=
Spring
Motion
Direction
.
up
{
open
var
springDirection
=
SpringDirection
.
up
{
didSet
{
didSet
{
layoutSubviews
()
layoutSubviews
()
}
}
}
}
open
var
baseSize
:
CGSize
{
/// A reference to the base FABButton.
get
{
open
var
fabButton
:
FABButton
?
{
return
spring
.
baseSize
didSet
{
}
oldValue
?
.
removeFromSuperview
()
set
(
value
)
{
spring
.
baseSize
=
value
guard
let
v
=
fabButton
else
{
return
}
addSubview
(
v
)
v
.
addTarget
(
self
,
action
:
#selector(
handleToggleMenu(button:)
)
,
for
:
.
touchUpInside
)
}
}
}
}
/// Size of FABMenuItems.
open
var
itemSize
:
CGSize
{
open
var
itemSize
:
CGSize
{
get
{
get
{
return
spring
.
itemSize
return
spring
.
itemSize
...
@@ -82,41 +117,43 @@ open class FABMenu: View, SpringableMotion {
...
@@ -82,41 +117,43 @@ open class FABMenu: View, SpringableMotion {
}
}
}
}
open
var
isOpened
:
Bool
{
/// A preset wrapper around interimSpace.
open
var
interimSpacePreset
:
InterimSpacePreset
{
get
{
get
{
return
spring
.
i
sOpened
return
spring
.
i
nterimSpacePreset
}
}
set
(
value
)
{
set
(
value
)
{
spring
.
i
sOpened
=
value
spring
.
i
nterimSpacePreset
=
value
}
}
}
}
open
var
isEnable
:
Bool
{
/// The space between views.
open
var
interimSpace
:
InterimSpace
{
get
{
get
{
return
spring
.
i
sEnabled
return
spring
.
i
nterimSpace
}
}
set
(
value
)
{
set
(
value
)
{
spring
.
i
sEnabled
=
value
spring
.
i
nterimSpace
=
value
}
}
}
}
/// A
preset wrapper around interimSpace
.
/// A
boolean indicating if the menu is open or not
.
open
var
i
nterimSpacePreset
:
InterimSpacePreset
{
open
var
i
sOpened
:
Bool
{
get
{
get
{
return
spring
.
i
nterimSpacePreset
return
spring
.
i
sOpened
}
}
set
(
value
)
{
set
(
value
)
{
spring
.
i
nterimSpacePreset
=
value
spring
.
i
sOpened
=
value
}
}
}
}
///
The space between views
.
///
A boolean indicating if the menu is enabled
.
open
var
i
nterimSpace
:
InterimSpace
{
open
var
i
sEnable
:
Bool
{
get
{
get
{
return
spring
.
i
nterimSpace
return
spring
.
i
sEnabled
}
}
set
(
value
)
{
set
(
value
)
{
spring
.
i
nterimSpace
=
value
spring
.
i
sEnabled
=
value
}
}
}
}
...
@@ -141,6 +178,12 @@ open class FABMenu: View, SpringableMotion {
...
@@ -141,6 +178,12 @@ open class FABMenu: View, SpringableMotion {
}
}
}
}
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
fabButton
?
.
frame
.
size
=
bounds
.
size
spring
.
baseSize
=
bounds
.
size
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
backgroundColor
=
nil
backgroundColor
=
nil
...
@@ -150,6 +193,36 @@ open class FABMenu: View, SpringableMotion {
...
@@ -150,6 +193,36 @@ open class FABMenu: View, SpringableMotion {
extension
FABMenu
{
extension
FABMenu
{
/**
/**
Open the Menu component with animation options.
- 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
(
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
}
/**
Close the Menu component with animation options.
- 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
(
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
}
}
extension
FABMenu
{
/**
Handles the hit test for the Menu and views outside of the Menu bounds.
Handles the hit test for the Menu and views outside of the Menu bounds.
- Parameter _ point: A CGPoint.
- Parameter _ point: A CGPoint.
- Parameter with event: An optional UIEvent.
- Parameter with event: An optional UIEvent.
...
@@ -170,36 +243,58 @@ extension FABMenu {
...
@@ -170,36 +243,58 @@ extension FABMenu {
delegate
?
.
fabMenu
?(
fabMenu
:
self
,
tappedAt
:
point
,
isOutside
:
true
)
delegate
?
.
fabMenu
?(
fabMenu
:
self
,
tappedAt
:
point
,
isOutside
:
true
)
closeMenu
()
return
self
.
hitTest
(
point
,
with
:
event
)
return
self
.
hitTest
(
point
,
with
:
event
)
}
}
}
}
extension
FABMenu
{
extension
FABMenu
{
/**
/**
Open the Menu component with animation options.
Handler to toggle the FABMenu open or close.
- Parameter duration: The time for each view's animation.
- Parameter button: A UIButton.
- 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
(
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
@objc
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
fileprivate
func
handleToggleMenu
(
button
:
UIButton
)
{
guard
isOpened
else
{
openMenu
()
return
}
closeMenu
()
}
}
extension
FABMenu
{
/// Opens the menu and reveals the FABMenuItems.
fileprivate
func
openMenu
()
{
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
open
{
[
weak
self
]
(
view
)
in
guard
let
s
=
self
else
{
return
}
(
view
as?
FABMenuItem
)?
.
showTitleLabel
()
if
view
==
s
.
items
.
last
{
s
.
delegate
?
.
fabMenuDidOpen
?(
fabMenu
:
s
)
}
}
}
}
/**
/// Closes the menu and hides the FABMenuItems.
Close the Menu component with animation options.
fileprivate
func
closeMenu
()
{
- Parameter duration: The time for each view's animation.
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
- Parameter delay: A delay time for each view's animation.
close
{
[
weak
self
]
(
view
)
in
- Parameter usingSpringWithDamping: A damping ratio for the animation.
guard
let
s
=
self
else
{
- Parameter initialSpringVelocity: The initial velocity for the animation.
return
- 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.
(
view
as?
FABMenuItem
)?
.
hideTitleLabel
()
*/
open
func
close
(
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
view
==
s
.
items
.
last
{
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
s
.
delegate
?
.
fabMenuDidClose
?(
fabMenu
:
s
)
}
}
}
}
}
}
Sources/iOS/FABMenuController.swift
View file @
42b6d525
...
@@ -51,7 +51,7 @@ extension UIViewController {
...
@@ -51,7 +51,7 @@ extension UIViewController {
open
class
FABMenuController
:
RootController
{
open
class
FABMenuController
:
RootController
{
/// Reference to the MenuView.
/// Reference to the MenuView.
@IBInspectable
@IBInspectable
open
let
m
enu
=
FABMenu
()
open
let
fabM
enu
=
FABMenu
()
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
...
@@ -67,67 +67,68 @@ open class FABMenuController: RootController {
...
@@ -67,67 +67,68 @@ open class FABMenuController: RootController {
*/
*/
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
prepareMenu
()
prepare
FAB
Menu
()
}
}
}
}
extension
FABMenuController
{
extension
FABMenuController
{
/// Prepares the Menu.
/// Prepares the fabMenu.
fileprivate
func
prepareMenu
()
{
fileprivate
func
prepareFABMenu
()
{
menu
.
zPosition
=
1000
fabMenu
.
delegate
=
self
view
.
addSubview
(
menu
)
fabMenu
.
zPosition
=
1000
view
.
addSubview
(
fabMenu
)
}
}
}
}
extension
FABMenuController
{
extension
FABMenuController
:
FABMenuDelegate
{
/**
Opens the menu with a callback.
- Parameter completion: An Optional callback that is executed when
all menu items have been opened.
*/
open
func
openMenu
(
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
if
true
==
isUserInteractionEnabled
{
isUserInteractionEnabled
=
false
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
guard
let
s
=
self
else
{
return
}
s
.
rootViewController
.
view
.
alpha
=
0.15
})
menu
.
open
{
[
completion
=
completion
]
(
view
)
in
completion
?(
view
)
}
}
}
/**
// /**
Opens the menu with a callback.
// Opens the menu with a callback.
- Parameter completion: An Optional callback that is executed when
// - Parameter completion: An Optional callback that is executed when
all menu items have been closed.
// all menu items have been opened.
*/
// */
open
func
closeMenu
(
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
// open func openMenu(completion: ((UIView) -> Void)? = nil) {
if
false
==
isUserInteractionEnabled
{
// if true == isUserInteractionEnabled {
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
// isUserInteractionEnabled = false
guard
let
s
=
self
else
{
//
return
// UIView.animate(withDuration: 0.15, animations: { [weak self] in
}
// guard let s = self else {
s
.
rootViewController
.
view
.
alpha
=
1
// return
})
// }
// s.rootViewController.view.alpha = 0.15
menu
.
close
{
[
weak
self
]
(
view
)
in
// })
guard
let
s
=
self
else
{
//
return
// fabMenu.open { [completion = completion] (view) in
}
// completion?(view)
// }
completion
?(
view
)
// }
// }
if
view
==
s
.
menu
.
items
.
last
{
//
s
.
isUserInteractionEnabled
=
true
// /**
}
// Opens the menu with a callback.
}
// - Parameter completion: An Optional callback that is executed when
}
// all menu items have been closed.
}
// */
// open func closeMenu(completion: ((UIView) -> Void)? = nil) {
// if false == isUserInteractionEnabled {
// UIView.animate(withDuration: 0.15, animations: { [weak self] in
// guard let s = self else {
// return
// }
// s.rootViewController.view.alpha = 1
// })
//
// fabMenu.close { [weak self] (view) in
// guard let s = self else {
// return
// }
//
// completion?(view)
//
// if view == s.fabMenu.items.last {
// s.isUserInteractionEnabled = true
// }
// }
// }
// }
}
}
Sources/iOS/Menu.swift
View file @
42b6d525
...
@@ -61,7 +61,7 @@ open class Menu: View, SpringableMotion {
...
@@ -61,7 +61,7 @@ open class Menu: View, SpringableMotion {
open
weak
var
delegate
:
MenuDelegate
?
open
weak
var
delegate
:
MenuDelegate
?
/// The direction in which the animation opens the menu.
/// The direction in which the animation opens the menu.
open
var
springDirection
=
Spring
Motion
Direction
.
up
{
open
var
springDirection
=
SpringDirection
.
up
{
didSet
{
didSet
{
layoutSubviews
()
layoutSubviews
()
}
}
...
...
Sources/iOS/PulseMotion.swift
View file @
42b6d525
...
@@ -30,8 +30,8 @@
...
@@ -30,8 +30,8 @@
import
UIKit
import
UIKit
@objc(Pulse
Motion
Animation)
@objc(PulseAnimation)
public
enum
Pulse
Motion
Animation
:
Int
{
public
enum
PulseAnimation
:
Int
{
case
none
case
none
case
center
case
center
case
centerWithBacking
case
centerWithBacking
...
@@ -43,8 +43,8 @@ public enum PulseMotionAnimation: Int {
...
@@ -43,8 +43,8 @@ public enum PulseMotionAnimation: Int {
}
}
public
protocol
PulseableMotion
{
public
protocol
PulseableMotion
{
/// A reference to the Pulse
Motion
Animation.
/// A reference to the PulseAnimation.
var
pulseAnimation
:
Pulse
Motion
Animation
{
get
set
}
var
pulseAnimation
:
PulseAnimation
{
get
set
}
/// A UIColor.
/// A UIColor.
var
pulseColor
:
UIColor
{
get
set
}
var
pulseColor
:
UIColor
{
get
set
}
...
@@ -63,8 +63,8 @@ public struct PulseMotion {
...
@@ -63,8 +63,8 @@ public struct PulseMotion {
/// Pulse layers.
/// Pulse layers.
fileprivate
var
layers
=
[
CAShapeLayer
]()
fileprivate
var
layers
=
[
CAShapeLayer
]()
/// A reference to the Pulse
Motion
Animation.
/// A reference to the PulseAnimation.
public
var
animation
=
Pulse
Motion
Animation
.
pointWithBacking
public
var
animation
=
PulseAnimation
.
pointWithBacking
/// A UIColor.
/// A UIColor.
public
var
color
=
Color
.
grey
.
base
public
var
color
=
Color
.
grey
.
base
...
...
Sources/iOS/PulseView.swift
View file @
42b6d525
...
@@ -34,8 +34,8 @@ open class PulseView: View, PulseableMotion {
...
@@ -34,8 +34,8 @@ open class PulseView: View, PulseableMotion {
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
fileprivate
var
pulse
:
PulseMotion
!
/// Pulse
Motion
Animation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
Pulse
Motion
Animation
{
open
var
pulseAnimation
:
PulseAnimation
{
get
{
get
{
return
pulse
.
animation
return
pulse
.
animation
}
}
...
@@ -44,7 +44,7 @@ open class PulseView: View, PulseableMotion {
...
@@ -44,7 +44,7 @@ open class PulseView: View, PulseableMotion {
}
}
}
}
/// Pulse
Motion
Animation color.
/// PulseAnimation color.
@IBInspectable
@IBInspectable
open
var
pulseColor
:
UIColor
{
open
var
pulseColor
:
UIColor
{
get
{
get
{
...
...
Sources/iOS/SpringMotion.swift
View file @
42b6d525
...
@@ -30,8 +30,8 @@
...
@@ -30,8 +30,8 @@
import
UIKit
import
UIKit
@objc(Spring
Motion
Direction)
@objc(SpringDirection)
public
enum
Spring
Motion
Direction
:
Int
{
public
enum
SpringDirection
:
Int
{
case
up
case
up
case
down
case
down
case
left
case
left
...
@@ -39,13 +39,13 @@ public enum SpringMotionDirection: Int {
...
@@ -39,13 +39,13 @@ public enum SpringMotionDirection: Int {
}
}
public
protocol
SpringableMotion
{
public
protocol
SpringableMotion
{
/// A Spring
Motion
Direction value.
/// A SpringDirection value.
var
springDirection
:
Spring
Motion
Direction
{
get
set
}
var
springDirection
:
SpringDirection
{
get
set
}
}
}
open
class
SpringMotion
{
open
class
SpringMotion
{
/// A Spring
Motion
Direction value.
/// A SpringDirection value.
open
var
direction
=
Spring
Motion
Direction
.
up
open
var
direction
=
SpringDirection
.
up
/// A Boolean that indicates if the menu is open or not.
/// A Boolean that indicates if the menu is open or not.
open
var
isOpened
=
false
open
var
isOpened
=
false
...
@@ -92,20 +92,13 @@ open class SpringMotion {
...
@@ -92,20 +92,13 @@ open class SpringMotion {
open
func
reload
()
{
open
func
reload
()
{
isOpened
=
false
isOpened
=
false
guard
let
first
=
views
.
first
else
{
for
i
in
0
..<
views
.
count
{
return
}
first
.
frame
.
size
=
baseSize
first
.
zPosition
=
10000
for
i
in
1
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
v
.
alpha
=
0
v
.
alpha
=
0
v
.
isHidden
=
true
v
.
isHidden
=
true
v
.
frame
.
size
=
itemSize
v
.
frame
.
size
=
itemSize
v
.
x
=
first
.
x
+
(
baseSize
.
width
-
itemSize
.
width
)
/
2
v
.
x
=
(
baseSize
.
width
-
itemSize
.
width
)
/
2
v
.
y
=
first
.
y
+
(
baseSize
.
height
-
itemSize
.
height
)
/
2
v
.
y
=
(
baseSize
.
height
-
itemSize
.
height
)
/
2
v
.
zPosition
=
CGFloat
(
10000
-
views
.
count
-
i
)
v
.
zPosition
=
CGFloat
(
10000
-
views
.
count
-
i
)
}
}
}
}
...
@@ -239,11 +232,7 @@ extension SpringMotion {
...
@@ -239,11 +232,7 @@ extension SpringMotion {
- Parameter completion: A completion block to execute on each view's animation.
- Parameter completion: A completion block to execute on each view's animation.
*/
*/
fileprivate
func
expandUp
(
duration
:
TimeInterval
,
delay
:
TimeInterval
,
usingSpringWithDamping
:
CGFloat
,
initialSpringVelocity
:
CGFloat
,
options
:
UIViewAnimationOptions
,
animations
:
((
UIView
)
->
Void
)?,
completion
:
((
UIView
)
->
Void
)?)
{
fileprivate
func
expandUp
(
duration
:
TimeInterval
,
delay
:
TimeInterval
,
usingSpringWithDamping
:
CGFloat
,
initialSpringVelocity
:
CGFloat
,
options
:
UIViewAnimationOptions
,
animations
:
((
UIView
)
->
Void
)?,
completion
:
((
UIView
)
->
Void
)?)
{
guard
let
first
=
views
.
first
else
{
for
i
in
0
..<
views
.
count
{
return
}
for
i
in
1
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
v
.
isHidden
=
false
v
.
isHidden
=
false
...
@@ -252,10 +241,9 @@ extension SpringMotion {
...
@@ -252,10 +241,9 @@ extension SpringMotion {
usingSpringWithDamping
:
usingSpringWithDamping
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
options
:
options
,
animations
:
{
[
s
=
self
,
first
=
first
,
v
=
v
]
in
animations
:
{
[
s
=
interimSpace
,
m
=
CGFloat
(
i
+
1
)
,
v
=
v
]
in
v
.
alpha
=
1
v
.
alpha
=
1
v
.
y
=
first
.
y
-
CGFloat
(
i
)
*
v
.
height
-
CGFloat
(
i
)
*
s
.
interimSpace
v
.
y
=
-
m
*
(
v
.
height
+
s
)
animations
?(
v
)
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
self
?
.
handleOpenCompletion
(
view
:
v
,
completion
:
completion
)
self
?
.
handleOpenCompletion
(
view
:
v
,
completion
:
completion
)
...
@@ -274,11 +262,7 @@ extension SpringMotion {
...
@@ -274,11 +262,7 @@ extension SpringMotion {
- Parameter completion: A completion block to execute on each view's animation.
- Parameter completion: A completion block to execute on each view's animation.
*/
*/
fileprivate
func
contractUp
(
duration
:
TimeInterval
,
delay
:
TimeInterval
,
usingSpringWithDamping
:
CGFloat
,
initialSpringVelocity
:
CGFloat
,
options
:
UIViewAnimationOptions
,
animations
:
((
UIView
)
->
Void
)?,
completion
:
((
UIView
)
->
Void
)?)
{
fileprivate
func
contractUp
(
duration
:
TimeInterval
,
delay
:
TimeInterval
,
usingSpringWithDamping
:
CGFloat
,
initialSpringVelocity
:
CGFloat
,
options
:
UIViewAnimationOptions
,
animations
:
((
UIView
)
->
Void
)?,
completion
:
((
UIView
)
->
Void
)?)
{
guard
let
first
=
views
.
first
else
{
for
i
in
0
..<
views
.
count
{
return
}
for
i
in
1
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
...
@@ -286,10 +270,9 @@ extension SpringMotion {
...
@@ -286,10 +270,9 @@ extension SpringMotion {
usingSpringWithDamping
:
usingSpringWithDamping
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
options
:
options
,
animations
:
{
[
base
=
first
,
v
=
v
]
in
animations
:
{
[
v
=
v
]
in
v
.
alpha
=
0
v
.
alpha
=
0
v
.
y
=
base
.
y
v
.
y
=
0
animations
?(
v
)
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
self
?
.
handleCloseCompletion
(
view
:
v
,
completion
:
completion
)
self
?
.
handleCloseCompletion
(
view
:
v
,
completion
:
completion
)
...
@@ -314,7 +297,7 @@ extension SpringMotion {
...
@@ -314,7 +297,7 @@ extension SpringMotion {
let
h
=
baseSize
.
height
let
h
=
baseSize
.
height
for
i
in
1
..<
views
.
count
{
for
i
in
0
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
v
.
isHidden
=
false
v
.
isHidden
=
false
...
@@ -351,7 +334,7 @@ extension SpringMotion {
...
@@ -351,7 +334,7 @@ extension SpringMotion {
let
h
=
baseSize
.
height
let
h
=
baseSize
.
height
for
i
in
1
..<
views
.
count
{
for
i
in
0
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
...
@@ -385,7 +368,7 @@ extension SpringMotion {
...
@@ -385,7 +368,7 @@ extension SpringMotion {
return
return
}
}
for
i
in
1
..<
views
.
count
{
for
i
in
0
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
v
.
isHidden
=
false
v
.
isHidden
=
false
...
@@ -420,7 +403,7 @@ extension SpringMotion {
...
@@ -420,7 +403,7 @@ extension SpringMotion {
return
return
}
}
for
i
in
1
..<
views
.
count
{
for
i
in
0
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
...
@@ -456,7 +439,7 @@ extension SpringMotion {
...
@@ -456,7 +439,7 @@ extension SpringMotion {
let
h
=
baseSize
.
height
let
h
=
baseSize
.
height
for
i
in
1
..<
views
.
count
{
for
i
in
0
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
v
.
isHidden
=
false
v
.
isHidden
=
false
...
@@ -493,7 +476,7 @@ extension SpringMotion {
...
@@ -493,7 +476,7 @@ extension SpringMotion {
let
w
=
baseSize
.
width
let
w
=
baseSize
.
width
for
i
in
1
..<
views
.
count
{
for
i
in
0
..<
views
.
count
{
let
v
=
views
[
i
]
let
v
=
views
[
i
]
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
UIView
.
animate
(
withDuration
:
Double
(
i
)
*
duration
,
...
...
Sources/iOS/TableViewCell.swift
View file @
42b6d525
...
@@ -42,8 +42,8 @@ open class TableViewCell: UITableViewCell, PulseableMotion {
...
@@ -42,8 +42,8 @@ open class TableViewCell: UITableViewCell, PulseableMotion {
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
fileprivate
var
pulse
:
PulseMotion
!
/// Pulse
Motion
Animation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
Pulse
Motion
Animation
{
open
var
pulseAnimation
:
PulseAnimation
{
get
{
get
{
return
pulse
.
animation
return
pulse
.
animation
}
}
...
@@ -52,7 +52,7 @@ open class TableViewCell: UITableViewCell, PulseableMotion {
...
@@ -52,7 +52,7 @@ open class TableViewCell: UITableViewCell, PulseableMotion {
}
}
}
}
/// Pulse
Motion
Animation color.
/// PulseAnimation color.
@IBInspectable
@IBInspectable
open
var
pulseColor
:
UIColor
{
open
var
pulseColor
:
UIColor
{
get
{
get
{
...
...
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