Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Motion
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
Motion
Commits
19664a2f
Unverified
Commit
19664a2f
authored
Jun 07, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
partial work completed for reworking Motion and MotionController
parent
baf1bf57
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
27 additions
and
19 deletions
+27
-19
Motion.xcodeproj/project.pbxproj
+1
-1
Sources/Animator/MotionCoreAnimationViewContext.swift
+5
-0
Sources/Debug Plugin/MotionDebugPlugin.swift
+4
-4
Sources/DefaultAnimationPreprocessor.swift
+3
-3
Sources/Extensions/Motion+UIViewController.swift
+2
-1
Sources/Motion.swift
+0
-0
Sources/MotionContext.swift
+2
-2
Sources/MotionController.swift
+4
-2
Sources/MotionTargetState.swift
+6
-6
No files found.
Motion.xcodeproj/project.pbxproj
View file @
19664a2f
...
@@ -198,8 +198,8 @@
...
@@ -198,8 +198,8 @@
96AEB6691EE4610F009A3BE0
/* Debug Plugin */
,
96AEB6691EE4610F009A3BE0
/* Debug Plugin */
,
96AEB66D1EE4610F009A3BE0
/* Extensions */
,
96AEB66D1EE4610F009A3BE0
/* Extensions */
,
96AEB6771EE4610F009A3BE0
/* Motion.swift */
,
96AEB6771EE4610F009A3BE0
/* Motion.swift */
,
963150D41EE51C7A002B0D42
/* MotionAnimation.swift */
,
96AEB6781EE4610F009A3BE0
/* MotionController.swift */
,
96AEB6781EE4610F009A3BE0
/* MotionController.swift */
,
963150D41EE51C7A002B0D42
/* MotionAnimation.swift */
,
96AEB6791EE4610F009A3BE0
/* MotionContext.swift */
,
96AEB6791EE4610F009A3BE0
/* MotionContext.swift */
,
96AEB67A1EE4610F009A3BE0
/* MotionIndependentController.swift */
,
96AEB67A1EE4610F009A3BE0
/* MotionIndependentController.swift */
,
96AEB67B1EE4610F009A3BE0
/* MotionTransition.swift */
,
96AEB67B1EE4610F009A3BE0
/* MotionTransition.swift */
,
...
...
Sources/Animator/MotionCoreAnimationViewContext.swift
View file @
19664a2f
...
@@ -410,6 +410,11 @@ extension MotionCoreAnimationViewContext {
...
@@ -410,6 +410,11 @@ extension MotionCoreAnimationViewContext {
return
values
return
values
}
}
/**
Moves a layer's animation to a given elapsed time.
- Parameter layer: A CALayer.
- Parameter elapsedTime: A TimeInterval.
*/
fileprivate
func
seek
(
layer
:
CALayer
,
elapsedTime
:
TimeInterval
)
{
fileprivate
func
seek
(
layer
:
CALayer
,
elapsedTime
:
TimeInterval
)
{
let
timeOffset
=
elapsedTime
-
targetState
.
delay
let
timeOffset
=
elapsedTime
-
targetState
.
delay
for
(
key
,
anim
)
in
layer
.
animations
{
for
(
key
,
anim
)
in
layer
.
animations
{
...
...
Sources/Debug Plugin/MotionDebugPlugin.swift
View file @
19664a2f
...
@@ -38,13 +38,13 @@ public class MotionDebugPlugin: MotionPlugin {
...
@@ -38,13 +38,13 @@ public class MotionDebugPlugin: MotionPlugin {
var
updating
=
false
var
updating
=
false
override
public
func
animate
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
->
TimeInterval
{
override
public
func
animate
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
->
TimeInterval
{
if
Motion
.
shared
.
forceNo
t
Interactive
{
return
0
}
if
Motion
.
shared
.
forceNo
n
Interactive
{
return
0
}
var
hasArc
=
false
var
hasArc
=
false
for
v
in
context
.
fromViews
+
context
.
toViews
where
context
[
v
]?
.
arc
!=
nil
&&
context
[
v
]?
.
position
!=
nil
{
for
v
in
context
.
fromViews
+
context
.
toViews
where
context
[
v
]?
.
arc
!=
nil
&&
context
[
v
]?
.
position
!=
nil
{
hasArc
=
true
hasArc
=
true
break
break
}
}
let
debugView
=
MotionDebugView
(
initialProcess
:
Motion
.
shared
.
p
resenting
?
0.0
:
1.0
,
showCurveButton
:
hasArc
,
showOnTop
:
MotionDebugPlugin
.
showOnTop
)
let
debugView
=
MotionDebugView
(
initialProcess
:
Motion
.
shared
.
isP
resenting
?
0.0
:
1.0
,
showCurveButton
:
hasArc
,
showOnTop
:
MotionDebugPlugin
.
showOnTop
)
debugView
.
frame
=
Motion
.
shared
.
container
.
bounds
debugView
.
frame
=
Motion
.
shared
.
container
.
bounds
debugView
.
delegate
=
self
debugView
.
delegate
=
self
UIApplication
.
shared
.
keyWindow
!.
addSubview
(
debugView
)
UIApplication
.
shared
.
keyWindow
!.
addSubview
(
debugView
)
...
@@ -81,7 +81,7 @@ public class MotionDebugPlugin: MotionPlugin {
...
@@ -81,7 +81,7 @@ public class MotionDebugPlugin: MotionPlugin {
extension
MotionDebugPlugin
:
MotionDebugViewDelegate
{
extension
MotionDebugPlugin
:
MotionDebugViewDelegate
{
public
func
onDone
()
{
public
func
onDone
()
{
guard
let
debugView
=
debugView
else
{
return
}
guard
let
debugView
=
debugView
else
{
return
}
let
seekValue
=
Motion
.
shared
.
p
resenting
?
debugView
.
progress
:
1.0
-
debugView
.
progress
let
seekValue
=
Motion
.
shared
.
isP
resenting
?
debugView
.
progress
:
1.0
-
debugView
.
progress
if
seekValue
>
0.5
{
if
seekValue
>
0.5
{
Motion
.
shared
.
end
()
Motion
.
shared
.
end
()
}
else
{
}
else
{
...
@@ -90,7 +90,7 @@ extension MotionDebugPlugin:MotionDebugViewDelegate {
...
@@ -90,7 +90,7 @@ extension MotionDebugPlugin:MotionDebugViewDelegate {
}
}
public
func
onProcessSliderChanged
(
progress
:
Float
)
{
public
func
onProcessSliderChanged
(
progress
:
Float
)
{
let
seekValue
=
Motion
.
shared
.
p
resenting
?
progress
:
1.0
-
progress
let
seekValue
=
Motion
.
shared
.
isP
resenting
?
progress
:
1.0
-
progress
Motion
.
shared
.
update
(
progress
:
Double
(
seekValue
))
Motion
.
shared
.
update
(
progress
:
Double
(
seekValue
))
}
}
...
...
Sources/DefaultAnimationPreprocessor.swift
View file @
19664a2f
...
@@ -235,11 +235,11 @@ class DefaultAnimationPreprocessor: BasePreprocessor {
...
@@ -235,11 +235,11 @@ class DefaultAnimationPreprocessor: BasePreprocessor {
override
func
process
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
{
override
func
process
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
{
guard
let
motion
=
motion
else
{
return
}
guard
let
motion
=
motion
else
{
return
}
var
defaultAnimation
=
motion
.
defaultAnimation
var
defaultAnimation
=
motion
.
defaultAnimation
let
inNavigationController
=
motion
.
i
n
NavigationController
let
inNavigationController
=
motion
.
i
s
NavigationController
let
inTabBarController
=
motion
.
i
n
TabBarController
let
inTabBarController
=
motion
.
i
s
TabBarController
let
toViewController
=
motion
.
toViewController
let
toViewController
=
motion
.
toViewController
let
fromViewController
=
motion
.
fromViewController
let
fromViewController
=
motion
.
fromViewController
let
presenting
=
motion
.
p
resenting
let
presenting
=
motion
.
isP
resenting
let
fromOverFullScreen
=
motion
.
fromOverFullScreen
let
fromOverFullScreen
=
motion
.
fromOverFullScreen
let
toOverFullScreen
=
motion
.
toOverFullScreen
let
toOverFullScreen
=
motion
.
toOverFullScreen
let
toView
=
motion
.
toView
let
toView
=
motion
.
toView
...
...
Sources/Extensions/Motion+UIViewController.swift
View file @
19664a2f
...
@@ -312,6 +312,7 @@ extension UIViewController {
...
@@ -312,6 +312,7 @@ extension UIViewController {
/**
/**
Replace the current view controller with another view controller on the
Replace the current view controller with another view controller on the
navigation/modal stack.
navigation/modal stack.
- Parameter with next: A UIViewController.
*/
*/
public
func
motion_replaceViewController
(
with
next
:
UIViewController
)
{
public
func
motion_replaceViewController
(
with
next
:
UIViewController
)
{
guard
!
Motion
.
shared
.
isTransitioning
else
{
guard
!
Motion
.
shared
.
isTransitioning
else
{
...
@@ -328,7 +329,7 @@ extension UIViewController {
...
@@ -328,7 +329,7 @@ extension UIViewController {
}
}
if
navigationController
.
isMotionEnabled
{
if
navigationController
.
isMotionEnabled
{
Motion
.
shared
.
forceNo
t
Interactive
=
true
Motion
.
shared
.
forceNo
n
Interactive
=
true
}
}
navigationController
.
setViewControllers
(
v
,
animated
:
true
)
navigationController
.
setViewControllers
(
v
,
animated
:
true
)
...
...
Sources/Motion.swift
View file @
19664a2f
This diff is collapsed.
Click to expand it.
Sources/MotionContext.swift
View file @
19664a2f
...
@@ -56,8 +56,8 @@ public class MotionContext {
...
@@ -56,8 +56,8 @@ public class MotionContext {
if
let
motionIdentifier
=
view
.
motionIdentifier
{
if
let
motionIdentifier
=
view
.
motionIdentifier
{
idMap
[
motionIdentifier
]
=
view
idMap
[
motionIdentifier
]
=
view
}
}
if
let
modifier
s
=
view
.
motionTransitions
{
if
let
transition
s
=
view
.
motionTransitions
{
targetStates
[
view
]
=
MotionTargetState
(
modifiers
:
modifier
s
)
targetStates
[
view
]
=
MotionTargetState
(
transitions
:
transition
s
)
}
}
}
}
}
}
...
...
Sources/MotionController.swift
View file @
19664a2f
...
@@ -195,9 +195,9 @@ public extension MotionController {
...
@@ -195,9 +195,9 @@ public extension MotionController {
- modifiers: the modifiers to override
- modifiers: the modifiers to override
- view: the view to override to
- view: the view to override to
*/
*/
public
func
apply
(
modifier
s
:
[
MotionTransition
],
to
view
:
UIView
)
{
public
func
apply
(
transition
s
:
[
MotionTransition
],
to
view
:
UIView
)
{
guard
isTransitioning
else
{
return
}
guard
isTransitioning
else
{
return
}
let
targetState
=
MotionTargetState
(
modifiers
:
modifier
s
)
let
targetState
=
MotionTargetState
(
transitions
:
transition
s
)
if
let
otherView
=
self
.
context
.
pairedView
(
for
:
view
)
{
if
let
otherView
=
self
.
context
.
pairedView
(
for
:
view
)
{
for
animator
in
self
.
animators
{
for
animator
in
self
.
animators
{
animator
.
apply
(
state
:
targetState
,
to
:
otherView
)
animator
.
apply
(
state
:
targetState
,
to
:
otherView
)
...
@@ -272,6 +272,8 @@ internal extension MotionController {
...
@@ -272,6 +272,8 @@ internal extension MotionController {
}
}
}
}
func
processContext
()
{
func
processContext
()
{
guard
isTransitioning
else
{
fatalError
()
}
guard
isTransitioning
else
{
fatalError
()
}
for
processor
in
processors
{
for
processor
in
processors
{
...
...
Sources/MotionTargetState.swift
View file @
19664a2f
...
@@ -105,16 +105,16 @@ public struct MotionTargetState {
...
@@ -105,16 +105,16 @@ public struct MotionTargetState {
public
var
forceAnimate
:
Bool
=
false
public
var
forceAnimate
:
Bool
=
false
public
var
custom
:
[
String
:
Any
]?
public
var
custom
:
[
String
:
Any
]?
init
(
modifier
s
:
[
MotionTransition
])
{
init
(
transition
s
:
[
MotionTransition
])
{
append
(
contentsOf
:
modifier
s
)
append
(
contentsOf
:
transition
s
)
}
}
public
mutating
func
append
(
_
modifier
:
MotionTransition
)
{
public
mutating
func
append
(
_
transition
:
MotionTransition
)
{
modifier
.
apply
(
&
self
)
transition
.
apply
(
&
self
)
}
}
public
mutating
func
append
(
contentsOf
modifier
s
:
[
MotionTransition
])
{
public
mutating
func
append
(
contentsOf
transition
s
:
[
MotionTransition
])
{
for
modifier
in
modifier
s
{
for
modifier
in
transition
s
{
modifier
.
apply
(
&
self
)
modifier
.
apply
(
&
self
)
}
}
}
}
...
...
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