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
1c53b32f
Unverified
Commit
1c53b32f
authored
Jan 23, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated initial rotation for snapshot views within MotionTransion
parent
3983101e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
21 deletions
+57
-21
Sources/iOS/Button.swift
+1
-1
Sources/iOS/CollectionReusableView.swift
+1
-1
Sources/iOS/CollectionViewCell.swift
+1
-1
Sources/iOS/MotionAnimation.swift
+1
-1
Sources/iOS/MotionTransition.swift
+44
-11
Sources/iOS/PulseMotion.swift
+7
-4
Sources/iOS/PulseView.swift
+1
-1
Sources/iOS/TableViewCell.swift
+1
-1
No files found.
Sources/iOS/Button.swift
View file @
1c53b32f
...
@@ -40,7 +40,7 @@ open class Button: UIButton, Pulseable {
...
@@ -40,7 +40,7 @@ open class Button: UIButton, Pulseable {
open
let
visualLayer
=
CAShapeLayer
()
open
let
visualLayer
=
CAShapeLayer
()
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
internal
var
pulse
:
PulseMotion
!
/// PulseAnimation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
PulseAnimation
{
open
var
pulseAnimation
:
PulseAnimation
{
...
...
Sources/iOS/CollectionReusableView.swift
View file @
1c53b32f
...
@@ -41,7 +41,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulseable {
...
@@ -41,7 +41,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulseable {
open
let
visualLayer
=
CAShapeLayer
()
open
let
visualLayer
=
CAShapeLayer
()
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
internal
var
pulse
:
PulseMotion
!
/// PulseAnimation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
PulseAnimation
{
open
var
pulseAnimation
:
PulseAnimation
{
...
...
Sources/iOS/CollectionViewCell.swift
View file @
1c53b32f
...
@@ -41,7 +41,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable {
...
@@ -41,7 +41,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable {
open
let
visualLayer
=
CAShapeLayer
()
open
let
visualLayer
=
CAShapeLayer
()
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
internal
var
pulse
:
PulseMotion
!
/// PulseAnimation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
PulseAnimation
{
open
var
pulseAnimation
:
PulseAnimation
{
...
...
Sources/iOS/MotionAnimation.swift
View file @
1c53b32f
...
@@ -342,7 +342,7 @@ extension Motion {
...
@@ -342,7 +342,7 @@ extension Motion {
*/
*/
public
static
func
background
(
color
:
UIColor
)
->
CABasicAnimation
{
public
static
func
background
(
color
:
UIColor
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
backgroundColor
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
backgroundColor
)
animation
.
toValue
=
color
.
cgColor
animation
.
toValue
=
color
.
cgColor
return
animation
return
animation
}
}
...
...
Sources/iOS/MotionTransition.swift
View file @
1c53b32f
...
@@ -123,23 +123,34 @@ extension UIView {
...
@@ -123,23 +123,34 @@ extension UIView {
open
func
snapshot
(
view
:
UIView
,
afterUpdates
:
Bool
)
->
UIView
{
open
func
snapshot
(
view
:
UIView
,
afterUpdates
:
Bool
)
->
UIView
{
view
.
isHidden
=
false
view
.
isHidden
=
false
(
view
as?
Pulseable
)?
.
pulse
.
pulseLayer
?
.
isHidden
=
true
let
oldCornerRadius
=
view
.
cornerRadius
let
oldCornerRadius
=
view
.
cornerRadius
view
.
cornerRadius
=
0
view
.
cornerRadius
=
0
let
oldRotation
=
view
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
as?
CGFloat
??
0
view
.
layer
.
setValue
(
0
,
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
let
v
=
view
.
snapshotView
(
afterScreenUpdates
:
afterUpdates
)
!
let
v
=
view
.
snapshotView
(
afterScreenUpdates
:
afterUpdates
)
!
view
.
cornerRadius
=
oldCornerRadius
view
.
cornerRadius
=
oldCornerRadius
view
.
layer
.
setValue
(
oldRotation
,
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
v
.
layer
.
setValue
(
oldRotation
,
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
let
contentView
=
v
.
subviews
.
first
!
let
contentView
=
v
.
subviews
.
first
!
contentView
.
cornerRadius
=
view
.
cornerRadius
contentView
.
cornerRadius
=
view
.
cornerRadius
contentView
.
masksToBounds
=
true
contentView
.
masksToBounds
=
true
v
.
motionTransitionIdentifier
=
view
.
motionTransitionIdentifier
v
.
motionTransitionIdentifier
=
view
.
motionTransitionIdentifier
v
.
frame
=
convert
(
view
.
bounds
,
from
:
view
)
v
.
position
=
view
.
superview
?
.
convert
(
view
.
position
,
to
:
nil
)
??
view
.
position
v
.
bounds
=
view
.
bounds
v
.
cornerRadius
=
view
.
cornerRadius
v
.
cornerRadius
=
view
.
cornerRadius
v
.
zPosition
=
view
.
zPosition
v
.
zPosition
=
view
.
zPosition
v
.
opacity
=
view
.
opacity
v
.
opacity
=
view
.
opacity
v
.
isOpaque
=
view
.
isOpaque
v
.
isOpaque
=
view
.
isOpaque
v
.
anchorPoint
=
view
.
anchorPoint
v
.
anchorPoint
=
view
.
anchorPoint
v
.
layer
.
masksToBounds
=
view
.
layer
.
masksToBounds
v
.
masksToBounds
=
view
.
masksToBounds
v
.
backgroundColor
=
view
.
backgroundColor
v
.
borderColor
=
view
.
borderColor
v
.
borderColor
=
view
.
borderColor
v
.
borderWidth
=
view
.
borderWidth
v
.
borderWidth
=
view
.
borderWidth
v
.
shadowRadius
=
view
.
shadowRadius
v
.
shadowRadius
=
view
.
shadowRadius
...
@@ -150,6 +161,7 @@ extension UIView {
...
@@ -150,6 +161,7 @@ extension UIView {
v
.
layer
.
transform
=
view
.
layer
.
transform
v
.
layer
.
transform
=
view
.
layer
.
transform
view
.
isHidden
=
true
view
.
isHidden
=
true
(
view
as?
Pulseable
)?
.
pulse
.
pulseLayer
?
.
isHidden
=
false
addSubview
(
v
)
addSubview
(
v
)
...
@@ -315,6 +327,8 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
...
@@ -315,6 +327,8 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
open
override
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
open
override
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
super
.
animateTransition
(
using
:
transitionContext
)
super
.
animateTransition
(
using
:
transitionContext
)
transitionView
.
isHidden
=
true
let
bgView
=
UIView
()
let
bgView
=
UIView
()
bgView
.
backgroundColor
=
fromViewController
.
view
.
backgroundColor
bgView
.
backgroundColor
=
fromViewController
.
view
.
backgroundColor
bgView
.
frame
=
transitionView
.
bounds
bgView
.
frame
=
transitionView
.
bounds
...
@@ -350,7 +364,7 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
...
@@ -350,7 +364,7 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
}
}
}
}
let
b
=
toView
.
superview
?
.
convert
(
toView
.
bounds
,
from
:
toView
)
??
toView
.
bounds
let
b
=
toView
.
bounds
let
w
=
b
.
width
let
w
=
b
.
width
let
h
=
b
.
height
let
h
=
b
.
height
let
p
=
toView
.
superview
?
.
convert
(
toView
.
position
,
to
:
nil
)
??
toView
.
position
let
p
=
toView
.
superview
?
.
convert
(
toView
.
position
,
to
:
nil
)
??
toView
.
position
...
@@ -363,11 +377,17 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
...
@@ -363,11 +377,17 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
snapshotChildAnimations
.
append
(
sizeAnimation
)
snapshotChildAnimations
.
append
(
sizeAnimation
)
let
rotateAnimation
=
Motion
.
rotate
(
angle
:
toView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
as?
CGFloat
??
0
)
let
rotateAnimation
=
Motion
.
rotate
(
angle
:
toView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
as?
CGFloat
??
0
)
rotateAnimation
.
fromValue
=
fromView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
rotateAnimation
.
fromValue
=
fromView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
as?
CGFloat
??
0
snapshotAnimations
.
append
(
rotateAnimation
)
snapshot
Child
Animations
.
append
(
rotateAnimation
)
snapshotChildAnimations
.
append
(
Motion
.
background
(
color
:
toView
.
backgroundColor
??
.
clear
))
// let backgroundColorAnimation = Motion.background(color: toView.backgroundColor ?? .clear)
snapshotChildAnimations
.
append
(
Motion
.
corner
(
radius
:
toView
.
cornerRadius
))
// backgroundColorAnimation.fromValue = fromView.backgroundColor?.cgColor
// snapshotAnimations.append(backgroundColorAnimation)
// snapshotChildAnimations.append(backgroundColorAnimation)
//
let
cornerRadiusAnimation
=
Motion
.
corner
(
radius
:
toView
.
cornerRadius
)
snapshotAnimations
.
append
(
cornerRadiusAnimation
)
snapshotChildAnimations
.
append
(
cornerRadiusAnimation
)
let
snapshot
=
transitionView
.
snapshot
(
view
:
fromView
,
afterUpdates
:
true
)
let
snapshot
=
transitionView
.
snapshot
(
view
:
fromView
,
afterUpdates
:
true
)
...
@@ -419,6 +439,8 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
...
@@ -419,6 +439,8 @@ open class MotionTransitionPresentedAnimator: MotionTransitionAnimator {
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
}
}
transitionView
.
isHidden
=
false
}
}
}
}
...
@@ -427,11 +449,17 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
...
@@ -427,11 +449,17 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
open
override
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
open
override
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
super
.
animateTransition
(
using
:
transitionContext
)
super
.
animateTransition
(
using
:
transitionContext
)
transitionView
.
isHidden
=
true
let
bgView
=
UIView
()
let
bgView
=
UIView
()
bgView
.
backgroundColor
=
fromViewController
.
view
.
backgroundColor
bgView
.
backgroundColor
=
fromViewController
.
view
.
backgroundColor
bgView
.
frame
=
transitionView
.
bounds
bgView
.
frame
=
transitionView
.
bounds
transitionView
.
addSubview
(
bgView
)
transitionView
.
addSubview
(
bgView
)
toViewController
.
view
.
updateConstraints
()
toViewController
.
view
.
setNeedsLayout
()
toViewController
.
view
.
layoutIfNeeded
()
for
toView
in
toViews
{
for
toView
in
toViews
{
for
fromView
in
fromViews
{
for
fromView
in
fromViews
{
if
toView
.
motionTransitionIdentifier
==
fromView
.
motionTransitionIdentifier
{
if
toView
.
motionTransitionIdentifier
==
fromView
.
motionTransitionIdentifier
{
...
@@ -457,7 +485,7 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
...
@@ -457,7 +485,7 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
}
}
}
}
let
b
=
toView
.
superview
?
.
convert
(
toView
.
bounds
,
from
:
toView
)
??
toView
.
bounds
let
b
=
toView
.
bounds
let
w
=
b
.
width
let
w
=
b
.
width
let
h
=
b
.
height
let
h
=
b
.
height
let
p
=
toView
.
superview
?
.
convert
(
toView
.
position
,
to
:
nil
)
??
toView
.
position
let
p
=
toView
.
superview
?
.
convert
(
toView
.
position
,
to
:
nil
)
??
toView
.
position
...
@@ -470,11 +498,14 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
...
@@ -470,11 +498,14 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
snapshotChildAnimations
.
append
(
sizeAnimation
)
snapshotChildAnimations
.
append
(
sizeAnimation
)
let
rotateAnimation
=
Motion
.
rotate
(
angle
:
toView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
as?
CGFloat
??
0
)
let
rotateAnimation
=
Motion
.
rotate
(
angle
:
toView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
as?
CGFloat
??
0
)
rotateAnimation
.
fromValue
=
fromView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
rotateAnimation
.
fromValue
=
fromView
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
as?
CGFloat
??
0
snapshotAnimations
.
append
(
rotateAnimation
)
snapshot
Child
Animations
.
append
(
rotateAnimation
)
snapshotChildAnimations
.
append
(
Motion
.
background
(
color
:
toView
.
backgroundColor
??
.
clear
))
snapshotChildAnimations
.
append
(
Motion
.
background
(
color
:
toView
.
backgroundColor
??
.
clear
))
snapshotChildAnimations
.
append
(
Motion
.
corner
(
radius
:
toView
.
cornerRadius
))
let
cornerRadiusAnimation
=
Motion
.
corner
(
radius
:
toView
.
cornerRadius
)
snapshotAnimations
.
append
(
cornerRadiusAnimation
)
snapshotChildAnimations
.
append
(
cornerRadiusAnimation
)
let
snapshot
=
transitionView
.
snapshot
(
view
:
fromView
,
afterUpdates
:
true
)
let
snapshot
=
transitionView
.
snapshot
(
view
:
fromView
,
afterUpdates
:
true
)
...
@@ -532,6 +563,8 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
...
@@ -532,6 +563,8 @@ open class MotionTransitionDismissedAnimator: MotionTransitionAnimator {
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
}
}
transitionView
.
isHidden
=
false
}
}
}
}
...
...
Sources/iOS/PulseMotion.swift
View file @
1c53b32f
...
@@ -43,7 +43,7 @@ public enum PulseAnimation: Int {
...
@@ -43,7 +43,7 @@ public enum PulseAnimation: Int {
case
pointWithBacking
case
pointWithBacking
}
}
public
protocol
Pulseable
{
internal
protocol
Pulseable
{
/// A reference to the PulseAnimation.
/// A reference to the PulseAnimation.
var
pulseAnimation
:
PulseAnimation
{
get
set
}
var
pulseAnimation
:
PulseAnimation
{
get
set
}
...
@@ -52,17 +52,20 @@ public protocol Pulseable {
...
@@ -52,17 +52,20 @@ 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
}
/// The PulseMotion instance.
var
pulse
:
PulseMotion
!
{
get
set
}
}
}
public
struct
PulseMotion
{
public
struct
PulseMotion
{
/// A UIView that is Pulseable.
/// A UIView that is Pulseable.
fileprivate
weak
var
pulseView
:
UIView
?
internal
weak
var
pulseView
:
UIView
?
/// The layer the pulse layers are added to.
/// The layer the pulse layers are added to.
fileprivate
weak
var
pulseLayer
:
CALayer
?
internal
weak
var
pulseLayer
:
CALayer
?
/// Pulse layers.
/// Pulse layers.
fileprivate
var
layers
=
[
CAShapeLayer
]()
internal
var
layers
=
[
CAShapeLayer
]()
/// A reference to the PulseAnimation.
/// A reference to the PulseAnimation.
public
var
animation
=
PulseAnimation
.
pointWithBacking
public
var
animation
=
PulseAnimation
.
pointWithBacking
...
...
Sources/iOS/PulseView.swift
View file @
1c53b32f
...
@@ -32,7 +32,7 @@ import UIKit
...
@@ -32,7 +32,7 @@ import UIKit
open
class
PulseView
:
View
,
Pulseable
{
open
class
PulseView
:
View
,
Pulseable
{
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
internal
var
pulse
:
PulseMotion
!
/// PulseAnimation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
PulseAnimation
{
open
var
pulseAnimation
:
PulseAnimation
{
...
...
Sources/iOS/TableViewCell.swift
View file @
1c53b32f
...
@@ -40,7 +40,7 @@ open class TableViewCell: UITableViewCell, Pulseable {
...
@@ -40,7 +40,7 @@ open class TableViewCell: UITableViewCell, Pulseable {
open
let
visualLayer
=
CAShapeLayer
()
open
let
visualLayer
=
CAShapeLayer
()
/// A Pulse reference.
/// A Pulse reference.
fileprivate
var
pulse
:
PulseMotion
!
internal
var
pulse
:
PulseMotion
!
/// PulseAnimation value.
/// PulseAnimation value.
open
var
pulseAnimation
:
PulseAnimation
{
open
var
pulseAnimation
:
PulseAnimation
{
...
...
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