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
80ea4f02
Unverified
Commit
80ea4f02
authored
Feb 25, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: motion issue-2: added completion block for motion animations
parent
91591377
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
19 deletions
+30
-19
Sources/iOS/Button.swift
+2
-2
Sources/iOS/CollectionReusableView.swift
+2
-2
Sources/iOS/CollectionViewCell.swift
+2
-2
Sources/iOS/Motion.swift
+2
-2
Sources/iOS/MotionAnimation.swift
+14
-5
Sources/iOS/PulseAnimation.swift
+4
-2
Sources/iOS/PulseView.swift
+2
-2
Sources/iOS/TableViewCell.swift
+2
-2
No files found.
Sources/iOS/Button.swift
View file @
80ea4f02
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
UIKit
import
UIKit
open
class
Button
:
UIButton
,
Pulseable
{
open
class
Button
:
UIButton
,
Pulseable
,
PulseableLayer
{
/**
/**
A CAShapeLayer used to manage elements that would be affected by
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
the clipToBounds property of the backing layer. For example, this
...
@@ -43,7 +43,7 @@ open class Button: UIButton, Pulseable {
...
@@ -43,7 +43,7 @@ open class Button: UIButton, Pulseable {
internal
var
pulse
:
Pulse
!
internal
var
pulse
:
Pulse
!
/// A reference to the pulse layer.
/// A reference to the pulse layer.
public
var
pulseLayer
:
CALayer
?
{
internal
var
pulseLayer
:
CALayer
?
{
return
pulse
.
pulseLayer
return
pulse
.
pulseLayer
}
}
...
...
Sources/iOS/CollectionReusableView.swift
View file @
80ea4f02
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
import
UIKit
import
UIKit
@objc(CollectionReusableView)
@objc(CollectionReusableView)
open
class
CollectionReusableView
:
UICollectionReusableView
,
Pulseable
{
open
class
CollectionReusableView
:
UICollectionReusableView
,
Pulseable
,
PulseableLayer
{
/**
/**
A CAShapeLayer used to manage elements that would be affected by
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
the clipToBounds property of the backing layer. For example, this
...
@@ -44,7 +44,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulseable {
...
@@ -44,7 +44,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulseable {
internal
var
pulse
:
Pulse
!
internal
var
pulse
:
Pulse
!
/// A reference to the pulse layer.
/// A reference to the pulse layer.
public
var
pulseLayer
:
CALayer
?
{
internal
var
pulseLayer
:
CALayer
?
{
return
pulse
.
pulseLayer
return
pulse
.
pulseLayer
}
}
...
...
Sources/iOS/CollectionViewCell.swift
View file @
80ea4f02
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
import
UIKit
import
UIKit
@objc(CollectionViewCell)
@objc(CollectionViewCell)
open
class
CollectionViewCell
:
UICollectionViewCell
,
Pulseable
{
open
class
CollectionViewCell
:
UICollectionViewCell
,
Pulseable
,
PulseableLayer
{
/**
/**
A CAShapeLayer used to manage elements that would be affected by
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
the clipToBounds property of the backing layer. For example, this
...
@@ -44,7 +44,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable {
...
@@ -44,7 +44,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable {
internal
var
pulse
:
Pulse
!
internal
var
pulse
:
Pulse
!
/// A reference to the pulse layer.
/// A reference to the pulse layer.
public
var
pulseLayer
:
CALayer
?
{
internal
var
pulseLayer
:
CALayer
?
{
return
pulse
.
pulseLayer
return
pulse
.
pulseLayer
}
}
...
...
Sources/iOS/Motion.swift
View file @
80ea4f02
...
@@ -244,7 +244,7 @@ extension UIView {
...
@@ -244,7 +244,7 @@ extension UIView {
isHidden
=
false
isHidden
=
false
// Material specific.
// Material specific.
(
self
as?
Pulseable
)?
.
pulseLayer
?
.
isHidden
=
true
(
self
as?
Pulseable
Layer
)?
.
pulseLayer
?
.
isHidden
=
true
let
oldCornerRadius
=
layer
.
cornerRadius
let
oldCornerRadius
=
layer
.
cornerRadius
layer
.
cornerRadius
=
0
layer
.
cornerRadius
=
0
...
@@ -292,7 +292,7 @@ extension UIView {
...
@@ -292,7 +292,7 @@ extension UIView {
v
.
backgroundColor
=
backgroundColor
v
.
backgroundColor
=
backgroundColor
// Material specific.
// Material specific.
(
self
as?
Pulseable
)?
.
pulseLayer
?
.
isHidden
=
false
(
self
as?
Pulseable
Layer
)?
.
pulseLayer
?
.
isHidden
=
false
isHidden
=
shouldHide
isHidden
=
shouldHide
...
...
Sources/iOS/MotionAnimation.swift
View file @
80ea4f02
...
@@ -179,9 +179,10 @@ extension CALayer {
...
@@ -179,9 +179,10 @@ extension CALayer {
/**
/**
A function that accepts an Array of MotionAnimation values and executes them.
A function that accepts an Array of MotionAnimation values and executes them.
- Parameter animations: An Array of MotionAnimation values.
- Parameter animations: An Array of MotionAnimation values.
- Parameter completion: An optional completion block.
*/
*/
open
func
motion
(
_
animations
:
[
MotionAnimation
])
{
open
func
motion
(
_
animations
:
[
MotionAnimation
]
,
completion
:
(()
->
Void
)?
=
nil
)
{
motion
(
delay
:
0
,
duration
:
0.35
,
timingFunction
:
.
easeInEaseOut
,
animations
:
animations
)
motion
(
delay
:
0
,
duration
:
0.35
,
timingFunction
:
.
easeInEaseOut
,
animations
:
animations
,
completion
:
completion
)
}
}
/**
/**
...
@@ -190,8 +191,9 @@ extension CALayer {
...
@@ -190,8 +191,9 @@ extension CALayer {
- Parameter duration: The animation duration TimeInterval.
- Parameter duration: The animation duration TimeInterval.
- Parameter timingFunction: The animation MotionAnimationTimingFunction.
- Parameter timingFunction: The animation MotionAnimationTimingFunction.
- Parameter animations: An Array of MotionAnimations.
- Parameter animations: An Array of MotionAnimations.
- Parameter completion: An optional completion block.
*/
*/
fileprivate
func
motion
(
delay
:
TimeInterval
,
duration
:
TimeInterval
,
timingFunction
:
MotionAnimationTimingFunction
,
animations
:
[
MotionAnimation
])
{
fileprivate
func
motion
(
delay
:
TimeInterval
,
duration
:
TimeInterval
,
timingFunction
:
MotionAnimationTimingFunction
,
animations
:
[
MotionAnimation
]
,
completion
:
(()
->
Void
)?
=
nil
)
{
var
t
=
delay
var
t
=
delay
for
v
in
animations
{
for
v
in
animations
{
...
@@ -319,6 +321,12 @@ extension CALayer {
...
@@ -319,6 +321,12 @@ extension CALayer {
g
.
timingFunction
=
MotionAnimationTimingFunctionToValue
(
timingFunction
:
tf
)
g
.
timingFunction
=
MotionAnimationTimingFunctionToValue
(
timingFunction
:
tf
)
s
.
animate
(
g
)
s
.
animate
(
g
)
guard
let
execute
=
completion
else
{
return
}
Motion
.
delay
(
d
,
execute
:
execute
)
}
}
}
}
}
}
...
@@ -390,9 +398,10 @@ extension UIView {
...
@@ -390,9 +398,10 @@ extension UIView {
A function that accepts an Array of MotionAnimation values and executes
A function that accepts an Array of MotionAnimation values and executes
them on the view's backing layer.
them on the view's backing layer.
- Parameter animations: An Array of MotionAnimation values.
- Parameter animations: An Array of MotionAnimation values.
- Parameter completion: An optional completion block.
*/
*/
open
func
motion
(
_
animations
:
[
MotionAnimation
])
{
open
func
motion
(
_
animations
:
[
MotionAnimation
]
,
completion
:
(()
->
Void
)?
=
nil
)
{
layer
.
motion
(
animations
)
layer
.
motion
(
animations
,
completion
:
completion
)
}
}
}
}
...
...
Sources/iOS/PulseAnimation.swift
View file @
80ea4f02
...
@@ -51,9 +51,11 @@ public protocol Pulseable {
...
@@ -51,9 +51,11 @@ public protocol Pulseable {
/// The opcaity value for the pulse animation.
/// The opcaity value for the pulse animation.
var
pulseOpacity
:
CGFloat
{
get
set
}
var
pulseOpacity
:
CGFloat
{
get
set
}
}
internal
protocol
PulseableLayer
{
/// A reference to the pulse layer.
/// A reference to the pulse layer.
var
pulseLayer
:
CALayer
?
{
get
}
var
pulseLayer
:
CALayer
?
{
get
}
}
}
public
struct
Pulse
{
public
struct
Pulse
{
...
...
Sources/iOS/PulseView.swift
View file @
80ea4f02
...
@@ -30,12 +30,12 @@
...
@@ -30,12 +30,12 @@
import
UIKit
import
UIKit
open
class
PulseView
:
View
,
Pulseable
{
open
class
PulseView
:
View
,
Pulseable
,
PulseableLayer
{
/// A Pulse reference.
/// A Pulse reference.
internal
var
pulse
:
Pulse
!
internal
var
pulse
:
Pulse
!
/// A reference to the pulse layer.
/// A reference to the pulse layer.
public
var
pulseLayer
:
CALayer
?
{
internal
var
pulseLayer
:
CALayer
?
{
return
pulse
.
pulseLayer
return
pulse
.
pulseLayer
}
}
...
...
Sources/iOS/TableViewCell.swift
View file @
80ea4f02
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
UIKit
import
UIKit
open
class
TableViewCell
:
UITableViewCell
,
Pulseable
{
open
class
TableViewCell
:
UITableViewCell
,
Pulseable
,
PulseableLayer
{
/**
/**
A CAShapeLayer used to manage elements that would be affected by
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
the clipToBounds property of the backing layer. For example, this
...
@@ -43,7 +43,7 @@ open class TableViewCell: UITableViewCell, Pulseable {
...
@@ -43,7 +43,7 @@ open class TableViewCell: UITableViewCell, Pulseable {
internal
var
pulse
:
Pulse
!
internal
var
pulse
:
Pulse
!
/// A reference to the pulse layer.
/// A reference to the pulse layer.
public
var
pulseLayer
:
CALayer
?
{
internal
var
pulseLayer
:
CALayer
?
{
return
pulse
.
pulseLayer
return
pulse
.
pulseLayer
}
}
...
...
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