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
ef6923c7
Unverified
Commit
ef6923c7
authored
Jan 19, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added deep embedded subviews to motion transitions
parent
6081a64f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
150 additions
and
244 deletions
+150
-244
Sources/iOS/BottomNavigationController.swift
+1
-1
Sources/iOS/MotionTransition.swift
+149
-243
No files found.
Sources/iOS/BottomNavigationController.swift
View file @
ef6923c7
...
@@ -116,7 +116,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel
...
@@ -116,7 +116,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel
/// Handles transitions when tabBarItems are pressed.
/// Handles transitions when tabBarItems are pressed.
open
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
open
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
return
FadeMotionTransition
()
return
nil
}
}
/// Prepares the tabBar.
/// Prepares the tabBar.
...
...
Sources/iOS/MotionTransition.swift
View file @
ef6923c7
...
@@ -102,7 +102,7 @@ extension UIView {
...
@@ -102,7 +102,7 @@ extension UIView {
}
}
}
}
open
var
t
ransitionIdentifier
:
String
{
open
var
motionT
ransitionIdentifier
:
String
{
get
{
get
{
return
motionTransition
.
identifier
return
motionTransition
.
identifier
}
}
...
@@ -111,7 +111,7 @@ extension UIView {
...
@@ -111,7 +111,7 @@ extension UIView {
}
}
}
}
open
var
t
ransitionAnimations
:
[
MotionAnimation
]
{
open
var
motionT
ransitionAnimations
:
[
MotionAnimation
]
{
get
{
get
{
return
motionTransition
.
animations
return
motionTransition
.
animations
}
}
...
@@ -168,7 +168,9 @@ open class MotionTransitionDelegate: NSObject {
...
@@ -168,7 +168,9 @@ open class MotionTransitionDelegate: NSObject {
open
var
toView
:
UIView
!
open
var
toView
:
UIView
!
open
var
toViews
:
[
UIView
]
{
open
var
toViews
:
[
UIView
]
{
return
[
toViewController
.
view
]
+
toViewController
.
view
.
subviews
var
views
:
[
UIView
]
=
0
<
toViewController
.
view
.
motionTransitionIdentifier
.
utf16
.
count
?
[
toViewController
.
view
]
:
[]
subviews
(
of
:
toViewController
.
view
,
views
:
&
views
)
return
views
}
}
open
var
toViewController
:
UIViewController
!
open
var
toViewController
:
UIViewController
!
...
@@ -180,13 +182,17 @@ open class MotionTransitionDelegate: NSObject {
...
@@ -180,13 +182,17 @@ open class MotionTransitionDelegate: NSObject {
open
var
fromView
:
UIView
!
open
var
fromView
:
UIView
!
open
var
fromViews
:
[
UIView
]
{
open
var
fromViews
:
[
UIView
]
{
return
[
fromViewController
.
view
]
+
fromViewController
.
view
.
subviews
var
views
:
[
UIView
]
=
0
<
fromViewController
.
view
.
motionTransitionIdentifier
.
utf16
.
count
?
[
fromViewController
.
view
]
:
[]
subviews
(
of
:
fromViewController
.
view
,
views
:
&
views
)
return
views
}
}
open
var
fromViewController
:
UIViewController
!
open
var
fromViewController
:
UIViewController
!
open
var
fromViewFinalFrame
:
CGRect
!
open
var
fromViewFinalFrame
:
CGRect
!
}
extension
MotionTransitionDelegate
{
@objc(animateTransition:)
@objc(animateTransition:)
open
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
open
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
...
@@ -198,7 +204,18 @@ open class MotionTransitionDelegate: NSObject {
...
@@ -198,7 +204,18 @@ open class MotionTransitionDelegate: NSObject {
}
}
open
func
animationEnded
(
_
transitionCompleted
:
Bool
)
{
open
func
animationEnded
(
_
transitionCompleted
:
Bool
)
{
// print("MotionTransitionAnimator", #function)
// print("MotionTransitionAnimator", #function)
}
}
extension
MotionTransitionDelegate
{
fileprivate
func
subviews
(
of
view
:
UIView
,
views
:
inout
[
UIView
])
{
for
v
in
view
.
subviews
{
if
0
<
v
.
motionTransitionIdentifier
.
utf16
.
count
{
views
.
append
(
v
)
}
subviews
(
of
:
v
,
views
:
&
views
)
}
}
}
}
}
...
@@ -378,8 +395,8 @@ open class MotionTransitionAnimator: MotionTransitionDelegate, UIViewControllerA
...
@@ -378,8 +395,8 @@ open class MotionTransitionAnimator: MotionTransitionDelegate, UIViewControllerA
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
for
v
in
toViews
{
for
v
in
toViews
{
if
0
<
v
.
t
ransitionIdentifier
.
utf16
.
count
{
if
0
<
v
.
motionT
ransitionIdentifier
.
utf16
.
count
{
for
a
in
v
.
t
ransitionAnimations
{
for
a
in
v
.
motionT
ransitionAnimations
{
switch
a
{
switch
a
{
case
let
.
duration
(
dur
):
case
let
.
duration
(
dur
):
if
dur
>
duration
{
if
dur
>
duration
{
...
@@ -388,7 +405,7 @@ open class MotionTransitionAnimator: MotionTransitionDelegate, UIViewControllerA
...
@@ -388,7 +405,7 @@ open class MotionTransitionAnimator: MotionTransitionDelegate, UIViewControllerA
default
:
break
default
:
break
}
}
}
}
v
.
motion
(
v
.
t
ransitionAnimations
)
v
.
motion
(
v
.
motionT
ransitionAnimations
)
}
}
}
}
...
@@ -437,87 +454,87 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -437,87 +454,87 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
for
v
in
toViews
{
for
v
in
toViews
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
for
v2
in
fromViews
{
for
v2
in
fromViews
{
if
v
.
motionTransitionIdentifier
==
v2
.
motionTransitionIdentifier
{
if
v
.
transitionIdentifier
==
v2
.
transitionIdentifier
{
var
t
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
var
a
=
[
CABasicAnimation
]()
var
a
=
[
CABasicAnimation
]()
var
tf
=
MotionAnimationTimingFunction
.
easeInEaseOut
var
tf
=
MotionAnimationTimingFunction
.
easeInEaseOut
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
0
var
h
:
CGFloat
=
0
var
h
:
CGFloat
=
0
for
ta
in
v
.
transitionAnimations
{
for
ta
in
v
.
motionTransitionAnimations
{
switch
ta
{
switch
ta
{
case
let
.
delay
(
time
):
case
let
.
delay
(
time
):
if
time
>
delay
{
if
time
>
delay
{
delay
=
time
delay
=
time
}
d
=
time
case
let
.
duration
(
time
):
if
time
>
duration
{
duration
=
time
}
case
let
.
width
(
width
):
w
=
width
case
let
.
height
(
height
):
h
=
height
default
:
break
}
}
t
=
time
case
let
.
duration
(
time
):
if
time
>
duration
{
duration
=
time
}
d
=
time
case
let
.
width
(
width
):
w
=
width
case
let
.
height
(
height
):
h
=
height
default
:
break
}
}
}
var
px
:
CGFloat
=
v
.
position
.
x
var
py
:
CGFloat
=
v
.
position
.
y
var
px
:
CGFloat
=
v
.
position
.
x
var
py
:
CGFloat
=
v
.
position
.
y
for
ta
in
v
.
transitionAnimations
{
for
ta
in
v
.
motionTransitionAnimations
{
switch
ta
{
case
let
.
x
(
x
):
px
=
x
+
w
/
2
case
let
.
y
(
y
):
py
=
y
+
h
/
2
default
:
break
}
}
Motion
.
delay
(
t
)
{
for
ta
in
v
.
motionTransitionAnimations
{
switch
ta
{
switch
ta
{
case
let
.
timingFunction
(
timingFunction
):
tf
=
timingFunction
case
let
.
rotate
(
angle
):
let
rotate
=
Motion
.
rotate
(
angle
:
angle
)
let
radians
=
CGFloat
(
atan2f
(
Float
(
v2
.
transform
.
b
),
Float
(
v2
.
transform
.
a
)))
rotate
.
fromValue
=
v2
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
a
.
append
(
rotate
)
case
let
.
backgroundColor
(
color
):
a
.
append
(
Motion
.
background
(
color
:
color
))
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
radius
))
case
let
.
x
(
x
):
case
let
.
x
(
x
):
px
=
x
+
w
/
2
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
+
w
/
2
,
y
:
py
)))
case
let
.
y
(
y
):
case
let
.
y
(
y
):
py
=
y
+
h
/
2
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
px
,
y
:
y
+
h
/
2
)))
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
shadow
(
path
):
a
.
append
(
Motion
.
shadow
(
path
:
path
))
case
let
.
width
(
w
):
a
.
append
(
Motion
.
width
(
w
))
case
let
.
height
(
h
):
a
.
append
(
Motion
.
height
(
h
))
default
:
break
default
:
break
}
}
}
}
let
g
=
Motion
.
animate
(
group
:
a
,
duration
:
d
)
g
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
g
.
isRemovedOnCompletion
=
false
g
.
timingFunction
=
MotionAnimationTimingFunctionToValue
(
timingFunction
:
tf
)
Motion
.
delay
(
d
)
{
v
.
animate
(
g
)
for
ta
in
v
.
transitionAnimations
{
switch
ta
{
case
let
.
timingFunction
(
timingFunction
):
tf
=
timingFunction
case
let
.
rotate
(
angle
):
let
rotate
=
Motion
.
rotate
(
angle
:
angle
)
let
radians
=
CGFloat
(
atan2f
(
Float
(
v2
.
transform
.
b
),
Float
(
v2
.
transform
.
a
)))
rotate
.
fromValue
=
v2
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
a
.
append
(
rotate
)
case
let
.
backgroundColor
(
color
):
a
.
append
(
Motion
.
background
(
color
:
color
))
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
radius
))
case
let
.
x
(
x
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
+
w
/
2
,
y
:
py
)))
case
let
.
y
(
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
px
,
y
:
y
+
h
/
2
)))
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
shadow
(
path
):
a
.
append
(
Motion
.
shadow
(
path
:
path
))
case
let
.
width
(
w
):
a
.
append
(
Motion
.
width
(
w
))
case
let
.
height
(
h
):
a
.
append
(
Motion
.
height
(
h
))
default
:
break
}
}
let
g
=
Motion
.
animate
(
group
:
a
,
duration
:
duration
)
g
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
g
.
isRemovedOnCompletion
=
false
g
.
timingFunction
=
MotionAnimationTimingFunctionToValue
(
timingFunction
:
tf
)
v
.
animate
(
g
)
}
}
}
}
}
}
}
...
@@ -566,63 +583,60 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -566,63 +583,60 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
var
duration
=
transitionDuration
(
using
:
nil
)
var
duration
=
transitionDuration
(
using
:
nil
)
for
v
in
fromViews
{
for
v
in
fromViews
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
for
v2
in
toViews
{
for
v2
in
toViews
{
if
v
.
motionTransitionIdentifier
==
v2
.
motionTransitionIdentifier
{
if
v
.
transitionIdentifier
==
v2
.
transitionIdentifier
{
var
t
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
var
a
=
[
CABasicAnimation
]()
var
a
=
[
CABasicAnimation
]()
var
tf
=
MotionAnimationTimingFunction
.
easeInEaseOut
var
tf
=
MotionAnimationTimingFunction
.
easeInEaseOut
for
ta
in
v
.
transitionAnimations
{
for
ta
in
v
.
motionTransitionAnimations
{
switch
ta
{
switch
ta
{
case
let
.
delay
(
time
):
case
let
.
delay
(
time
):
if
time
>
delay
{
if
time
>
delay
{
delay
=
time
delay
=
time
}
d
=
time
case
let
.
duration
(
time
):
if
time
>
duration
{
duration
=
time
}
case
let
.
timingFunction
(
timingFunction
):
tf
=
timingFunction
case
let
.
rotate
(
angle
):
let
radians
=
CGFloat
(
atan2f
(
Float
(
v2
.
transform
.
b
),
Float
(
v2
.
transform
.
a
)))
let
rotate
=
Motion
.
rotate
(
angle
:
radians
*
180
/
CGFloat
(
M_PI
))
rotate
.
fromValue
=
v
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
a
.
append
(
rotate
)
case
let
.
backgroundColor
(
color
):
guard
let
bgColor
=
v2
.
backgroundColor
else
{
continue
}
a
.
append
(
Motion
.
background
(
color
:
bgColor
))
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
v2
.
cornerRadius
))
case
let
.
x
(
x
):
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
y
(
y
):
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
shadow
(
path
):
a
.
append
(
Motion
.
shadow
(
path
:
path
))
case
let
.
width
(
w
):
a
.
append
(
Motion
.
width
(
v2
.
bounds
.
width
))
case
let
.
height
(
h
):
a
.
append
(
Motion
.
height
(
v2
.
bounds
.
height
))
default
:
break
}
}
t
=
time
case
let
.
duration
(
time
):
if
time
>
duration
{
duration
=
time
}
d
=
time
case
let
.
timingFunction
(
timingFunction
):
tf
=
timingFunction
case
let
.
rotate
(
angle
):
let
radians
=
CGFloat
(
atan2f
(
Float
(
v2
.
transform
.
b
),
Float
(
v2
.
transform
.
a
)))
let
rotate
=
Motion
.
rotate
(
angle
:
radians
*
180
/
CGFloat
(
M_PI
))
rotate
.
fromValue
=
v
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
a
.
append
(
rotate
)
case
let
.
backgroundColor
(
color
):
a
.
append
(
Motion
.
background
(
color
:
.
clear
))
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
v2
.
cornerRadius
))
case
let
.
x
(
x
):
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
y
(
y
):
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
v2
.
position
))
case
let
.
shadow
(
path
):
a
.
append
(
Motion
.
shadow
(
path
:
path
))
case
let
.
width
(
w
):
a
.
append
(
Motion
.
width
(
v2
.
bounds
.
width
))
case
let
.
height
(
h
):
a
.
append
(
Motion
.
height
(
v2
.
bounds
.
height
))
default
:
break
}
}
}
Motion
.
delay
(
t
)
{
let
g
=
Motion
.
animate
(
group
:
a
,
duration
:
d
)
g
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
g
.
isRemovedOnCompletion
=
false
g
.
timingFunction
=
MotionAnimationTimingFunctionToValue
(
timingFunction
:
tf
)
Motion
.
delay
(
d
)
{
v
.
animate
(
g
)
let
g
=
Motion
.
animate
(
group
:
a
,
duration
:
duration
)
g
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
forwards
)
g
.
isRemovedOnCompletion
=
false
g
.
timingFunction
=
MotionAnimationTimingFunctionToValue
(
timingFunction
:
tf
)
v
.
animate
(
g
)
}
}
}
}
}
}
}
...
@@ -640,111 +654,3 @@ open class MotionTransitionInteractiveAnimator: MotionTransitionInteractiveDeleg
...
@@ -640,111 +654,3 @@ open class MotionTransitionInteractiveAnimator: MotionTransitionInteractiveDeleg
}
}
}
}
open
class
FadeMotionTransition
:
NSObject
,
UIViewControllerAnimatedTransitioning
{
open
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
guard
let
fromView
=
transitionContext
.
view
(
forKey
:
.
from
)
else
{
return
}
guard
let
toView
=
transitionContext
.
view
(
forKey
:
.
to
)
else
{
return
}
toView
.
alpha
=
0
transitionContext
.
containerView
.
addSubview
(
fromView
)
transitionContext
.
containerView
.
addSubview
(
toView
)
UIView
.
animate
(
withDuration
:
transitionDuration
(
using
:
transitionContext
),
animations
:
{
_
in
toView
.
alpha
=
1
fromView
.
alpha
=
0
})
{
_
in
transitionContext
.
completeTransition
(
!
transitionContext
.
transitionWasCancelled
)
}
}
open
func
transitionDuration
(
using
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
return
0.35
}
open
func
animationEnded
(
_
transitionCompleted
:
Bool
)
{
// print("FadeMotionTransition ANIMATION ENDED")
}
}
open
class
SlideMotionTransition
:
NSObject
,
UIViewControllerAnimatedTransitioning
{
var
operation
:
UINavigationControllerOperation
init
(
operation
:
UINavigationControllerOperation
)
{
self
.
operation
=
operation
}
open
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
guard
let
fromView
=
transitionContext
.
view
(
forKey
:
.
from
)
else
{
return
}
guard
let
toView
=
transitionContext
.
view
(
forKey
:
.
to
)
else
{
return
}
var
duration
=
transitionDuration
(
using
:
nil
)
if
operation
==
.
push
{
transitionContext
.
containerView
.
addSubview
(
toView
)
for
v
in
toView
.
subviews
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
for
a
in
v
.
transitionAnimations
{
switch
a
{
case
let
.
duration
(
dur
):
if
dur
>
duration
{
duration
=
dur
}
default
:
break
}
}
v
.
motion
(
v
.
transitionAnimations
)
}
}
Motion
.
delay
(
duration
)
{
transitionContext
.
completeTransition
(
!
transitionContext
.
transitionWasCancelled
)
}
}
if
operation
==
.
pop
{
transitionContext
.
containerView
.
addSubview
(
fromView
)
for
v
in
fromView
.
subviews
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
for
a
in
v
.
transitionAnimations
{
switch
a
{
case
let
.
duration
(
dur
):
if
dur
>
duration
{
duration
=
dur
}
default
:
break
}
}
v
.
motion
(
v
.
transitionAnimations
)
}
}
Motion
.
delay
(
duration
)
{
transitionContext
.
containerView
.
addSubview
(
toView
)
transitionContext
.
completeTransition
(
!
transitionContext
.
transitionWasCancelled
)
}
}
}
open
func
transitionDuration
(
using
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
return
0.35
}
open
func
animationEnded
(
_
transitionCompleted
:
Bool
)
{
// print("SlideMotionTransition ANIMATION ENDED")
}
}
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