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
9fd0e15e
Commit
9fd0e15e
authored
Dec 14, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progression update for latest internal changes in Motion
parent
3bc0ad78
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
660 additions
and
634 deletions
+660
-634
Motion.xcodeproj/project.pbxproj
+54
-34
Sources/Animator/MotionAnimator.swift
+3
-3
Sources/Animator/MotionAnimatorViewContext.swift
+7
-7
Sources/Animator/MotionCoreAnimationViewContext.swift
+25
-22
Sources/Animator/MotionCoreAnimator.swift
+2
-2
Sources/Animator/MotionTransitionAnimator.swift
+4
-4
Sources/Animator/MotionViewPropertyViewContext.swift
+1
-1
Sources/Extensions/Motion+UIView.swift
+16
-16
Sources/Extensions/Motion+UIViewController.swift
+6
-6
Sources/MotionContext.swift
+18
-11
Sources/MotionModifier.swift
+197
-137
Sources/MotionPlugin.swift
+22
-17
Sources/MotionState.swift
+0
-48
Sources/MotionTargetState.swift
+19
-36
Sources/MotionTransitionObserver.swift
+3
-3
Sources/Preprocessors/ConditionalPreprocessor.swift
+3
-3
Sources/Preprocessors/MatchPreprocessor.swift
+2
-2
Sources/Preprocessors/MotionCorePreprocessor.swift
+2
-2
Sources/Preprocessors/MotionPreprocessor.swift
+1
-1
Sources/Preprocessors/TransitionPreprocessor.swift
+25
-14
Sources/Transition/MotionTransition+Animate.swift
+2
-5
Sources/Transition/MotionTransition+Complete.swift
+2
-2
Sources/Transition/MotionTransition+Start.swift
+7
-7
Sources/Transition/MotionTransition.swift
+239
-251
No files found.
Motion.xcodeproj/project.pbxproj
View file @
9fd0e15e
...
...
@@ -7,15 +7,24 @@
objects
=
{
/* Begin PBXBuildFile section */
965FE9611FDCC3AF0098BDD0
/* MotionState.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9601FDCC3AF0098BDD0
/* MotionState.swift */
;
};
965FE9631FDCCE030098BDD0
/* Motion+Complete.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9621FDCCE030098BDD0
/* Motion+Complete.swift */
;
};
965FE9631FDCCE030098BDD0
/* MotionTransition+Complete.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9621FDCCE030098BDD0
/* MotionTransition+Complete.swift */
;
};
965FE9651FDCCE910098BDD0
/* MotionProgressRunner.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9641FDCCE910098BDD0
/* MotionProgressRunner.swift */
;
};
965FE9671FDD99800098BDD0
/* Motion
+Start.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9661FDD99800098BDD0
/* Mo
tion+Start.swift */
;
};
965FE9671FDD99800098BDD0
/* Motion
Transition+Start.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9661FDD99800098BDD0
/* MotionTransi
tion+Start.swift */
;
};
965FE9691FDDA1F20098BDD0
/* MotionViewOrderStrategy.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9681FDDA1F20098BDD0
/* MotionViewOrderStrategy.swift */
;
};
965FE96B1FDDA4EA0098BDD0
/* MotionCorePreprocessor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE96A1FDDA4EA0098BDD0
/* MotionCorePreprocessor.swift */
;
};
965FE96D1FDDA6400098BDD0
/* MotionCoreAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE96C1FDDA6400098BDD0
/* MotionCoreAnimator.swift */
;
};
965FE96F1FDEFA8B0098BDD0
/* Motion
+Animate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE96E1FDEFA8B0098BDD0
/* Mo
tion+Animate.swift */
;
};
965FE96F1FDEFA8B0098BDD0
/* Motion
Transition+Animate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE96E1FDEFA8B0098BDD0
/* MotionTransi
tion+Animate.swift */
;
};
965FE9771FE0976F0098BDD0
/* ConditionalPreprocessor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9761FE0976F0098BDD0
/* ConditionalPreprocessor.swift */
;
};
965FE97A1FE1D83D0098BDD0
/* MotionTransition.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9791FE1D83D0098BDD0
/* MotionTransition.swift */
;
};
965FE9811FE304E70098BDD0
/* MotionViewOrderStrategy.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9681FDDA1F20098BDD0
/* MotionViewOrderStrategy.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE9821FE304E70098BDD0
/* MotionProgressRunner.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9641FDCCE910098BDD0
/* MotionProgressRunner.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE9831FE304E70098BDD0
/* MotionCoreAnimator.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE96C1FDDA6400098BDD0
/* MotionCoreAnimator.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE9841FE304E70098BDD0
/* MotionCorePreprocessor.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE96A1FDDA4EA0098BDD0
/* MotionCorePreprocessor.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE9851FE304E70098BDD0
/* ConditionalPreprocessor.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9761FE0976F0098BDD0
/* ConditionalPreprocessor.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE9861FE304E70098BDD0
/* MotionTransition.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9791FE1D83D0098BDD0
/* MotionTransition.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE9881FE304E70098BDD0
/* MotionTransition+Start.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9661FDD99800098BDD0
/* MotionTransition+Start.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE9891FE304E70098BDD0
/* MotionTransition+Animate.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE96E1FDEFA8B0098BDD0
/* MotionTransition+Animate.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965FE98A1FE304E70098BDD0
/* MotionTransition+Complete.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9621FDCCE030098BDD0
/* MotionTransition+Complete.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409651F24F7370015A2B5
/* MotionAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
;
};
96E409661F24F7370015A2B5
/* MotionAnimatorViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
;
};
96E409671F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4093F1F24F7370015A2B5
/* MotionCoreAnimationViewContext.swift */
;
};
...
...
@@ -31,7 +40,6 @@
96E409721F24F7370015A2B5
/* Motion+UIViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4094B1F24F7370015A2B5
/* Motion+UIViewController.swift */
;
};
96E409731F24F7370015A2B5
/* MotionAnimationFillMode.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4094C1F24F7370015A2B5
/* MotionAnimationFillMode.swift */
;
};
96E409741F24F7370015A2B5
/* Motion.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4094F1F24F7370015A2B5
/* Motion.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409751F24F7370015A2B5
/* Motion.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409501F24F7370015A2B5
/* Motion.swift */
;
};
96E409761F24F7370015A2B5
/* MotionAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409511F24F7370015A2B5
/* MotionAnimation.swift */
;
};
96E409771F24F7370015A2B5
/* MotionAnimationState.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409521F24F7370015A2B5
/* MotionAnimationState.swift */
;
};
96E409781F24F7370015A2B5
/* MotionCAAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409531F24F7370015A2B5
/* MotionCAAnimation.swift */
;
};
...
...
@@ -39,9 +47,9 @@
96E4097B1F24F7370015A2B5
/* MotionCoordinateSpace.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409561F24F7370015A2B5
/* MotionCoordinateSpace.swift */
;
};
96E4097D1F24F7370015A2B5
/* MotionPlugin.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409581F24F7370015A2B5
/* MotionPlugin.swift */
;
};
96E4097E1F24F7370015A2B5
/* MotionSnapshotType.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409591F24F7370015A2B5
/* MotionSnapshotType.swift */
;
};
96E4097F1F24F7370015A2B5
/* Motion
Transition.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095A1F24F7370015A2B5
/* MotionTransition
.swift */
;
};
96E4097F1F24F7370015A2B5
/* Motion
Modifier.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095A1F24F7370015A2B5
/* MotionModifier
.swift */
;
};
96E409801F24F7370015A2B5
/* MotionTransitionObserver.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095B1F24F7370015A2B5
/* MotionTransitionObserver.swift */
;
};
96E409811F24F7370015A2B5
/* MotionT
ransitionState.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095C1F24F7370015A2B5
/* MotionTransition
State.swift */
;
};
96E409811F24F7370015A2B5
/* MotionT
argetState.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095C1F24F7370015A2B5
/* MotionTarget
State.swift */
;
};
96E409821F24F7370015A2B5
/* CascadePreprocessor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095E1F24F7370015A2B5
/* CascadePreprocessor.swift */
;
};
96E409841F24F7370015A2B5
/* IgnoreSubviewModifiersPreprocessor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409601F24F7370015A2B5
/* IgnoreSubviewModifiersPreprocessor.swift */
;
};
96E409851F24F7370015A2B5
/* MatchPreprocessor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409611F24F7370015A2B5
/* MatchPreprocessor.swift */
;
};
...
...
@@ -62,7 +70,6 @@
96E409951F24F7570015A2B5
/* Motion+UIView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4094A1F24F7370015A2B5
/* Motion+UIView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409961F24F7570015A2B5
/* Motion+UIViewController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4094B1F24F7370015A2B5
/* Motion+UIViewController.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409971F24F7570015A2B5
/* MotionAnimationFillMode.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4094C1F24F7370015A2B5
/* MotionAnimationFillMode.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4099A1F24F7570015A2B5
/* Motion.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409501F24F7370015A2B5
/* Motion.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4099B1F24F7570015A2B5
/* MotionAnimation.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409511F24F7370015A2B5
/* MotionAnimation.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4099C1F24F7570015A2B5
/* MotionAnimationState.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409521F24F7370015A2B5
/* MotionAnimationState.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E4099D1F24F7570015A2B5
/* MotionCAAnimation.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409531F24F7370015A2B5
/* MotionCAAnimation.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
...
@@ -70,9 +77,9 @@
96E409A01F24F7570015A2B5
/* MotionCoordinateSpace.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409561F24F7370015A2B5
/* MotionCoordinateSpace.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A21F24F7570015A2B5
/* MotionPlugin.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409581F24F7370015A2B5
/* MotionPlugin.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A31F24F7570015A2B5
/* MotionSnapshotType.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409591F24F7370015A2B5
/* MotionSnapshotType.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A41F24F7570015A2B5
/* Motion
Transition.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095A1F24F7370015A2B5
/* MotionTransition
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A41F24F7570015A2B5
/* Motion
Modifier.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095A1F24F7370015A2B5
/* MotionModifier
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A51F24F7570015A2B5
/* MotionTransitionObserver.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095B1F24F7370015A2B5
/* MotionTransitionObserver.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A61F24F7570015A2B5
/* MotionT
ransitionState.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095C1F24F7370015A2B5
/* MotionTransition
State.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A61F24F7570015A2B5
/* MotionT
argetState.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095C1F24F7370015A2B5
/* MotionTarget
State.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A71F24F7570015A2B5
/* CascadePreprocessor.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E4095E1F24F7370015A2B5
/* CascadePreprocessor.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409A91F24F7570015A2B5
/* IgnoreSubviewModifiersPreprocessor.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409601F24F7370015A2B5
/* IgnoreSubviewModifiersPreprocessor.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96E409AA1F24F7570015A2B5
/* MatchPreprocessor.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E409611F24F7370015A2B5
/* MatchPreprocessor.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
...
@@ -82,15 +89,15 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
965FE9601FDCC3AF0098BDD0
/* MotionState.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionState.swift
;
sourceTree
=
"<group>"
;
};
965FE9621FDCCE030098BDD0
/* Motion+Complete.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Motion+Complete.swift"
;
sourceTree
=
"<group>"
;
};
965FE9621FDCCE030098BDD0
/* MotionTransition+Complete.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"MotionTransition+Complete.swift"
;
sourceTree
=
"<group>"
;
};
965FE9641FDCCE910098BDD0
/* MotionProgressRunner.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionProgressRunner.swift
;
sourceTree
=
"<group>"
;
};
965FE9661FDD99800098BDD0
/* Motion
+Start.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Mo
tion+Start.swift"
;
sourceTree
=
"<group>"
;
};
965FE9661FDD99800098BDD0
/* Motion
Transition+Start.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"MotionTransi
tion+Start.swift"
;
sourceTree
=
"<group>"
;
};
965FE9681FDDA1F20098BDD0
/* MotionViewOrderStrategy.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionViewOrderStrategy.swift
;
sourceTree
=
"<group>"
;
};
965FE96A1FDDA4EA0098BDD0
/* MotionCorePreprocessor.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionCorePreprocessor.swift
;
sourceTree
=
"<group>"
;
};
965FE96C1FDDA6400098BDD0
/* MotionCoreAnimator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionCoreAnimator.swift
;
sourceTree
=
"<group>"
;
};
965FE96E1FDEFA8B0098BDD0
/* Motion
+Animate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Mo
tion+Animate.swift"
;
sourceTree
=
"<group>"
;
};
965FE96E1FDEFA8B0098BDD0
/* Motion
Transition+Animate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"MotionTransi
tion+Animate.swift"
;
sourceTree
=
"<group>"
;
};
965FE9761FE0976F0098BDD0
/* ConditionalPreprocessor.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ConditionalPreprocessor.swift
;
sourceTree
=
"<group>"
;
};
965FE9791FE1D83D0098BDD0
/* MotionTransition.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionTransition.swift
;
sourceTree
=
"<group>"
;
};
96C98DD11E424AB000B22906
/* Motion.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Motion.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
96E4093D1F24F7370015A2B5
/* MotionAnimator.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimator.swift
;
sourceTree
=
"<group>"
;
};
96E4093E1F24F7370015A2B5
/* MotionAnimatorViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimatorViewContext.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -107,7 +114,6 @@
96E4094B1F24F7370015A2B5
/* Motion+UIViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Motion+UIViewController.swift"
;
sourceTree
=
"<group>"
;
};
96E4094C1F24F7370015A2B5
/* MotionAnimationFillMode.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimationFillMode.swift
;
sourceTree
=
"<group>"
;
};
96E4094F1F24F7370015A2B5
/* Motion.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
Motion.h
;
sourceTree
=
"<group>"
;
};
96E409501F24F7370015A2B5
/* Motion.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Motion.swift
;
sourceTree
=
"<group>"
;
};
96E409511F24F7370015A2B5
/* MotionAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimation.swift
;
sourceTree
=
"<group>"
;
};
96E409521F24F7370015A2B5
/* MotionAnimationState.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionAnimationState.swift
;
sourceTree
=
"<group>"
;
};
96E409531F24F7370015A2B5
/* MotionCAAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionCAAnimation.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -115,9 +121,9 @@
96E409561F24F7370015A2B5
/* MotionCoordinateSpace.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionCoordinateSpace.swift
;
sourceTree
=
"<group>"
;
};
96E409581F24F7370015A2B5
/* MotionPlugin.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionPlugin.swift
;
sourceTree
=
"<group>"
;
};
96E409591F24F7370015A2B5
/* MotionSnapshotType.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionSnapshotType.swift
;
sourceTree
=
"<group>"
;
};
96E4095A1F24F7370015A2B5
/* Motion
Transition.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionTransition
.swift
;
sourceTree
=
"<group>"
;
};
96E4095A1F24F7370015A2B5
/* Motion
Modifier.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionModifier
.swift
;
sourceTree
=
"<group>"
;
};
96E4095B1F24F7370015A2B5
/* MotionTransitionObserver.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionTransitionObserver.swift
;
sourceTree
=
"<group>"
;
};
96E4095C1F24F7370015A2B5
/* MotionT
ransitionState.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionTransition
State.swift
;
sourceTree
=
"<group>"
;
};
96E4095C1F24F7370015A2B5
/* MotionT
argetState.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionTarget
State.swift
;
sourceTree
=
"<group>"
;
};
96E4095E1F24F7370015A2B5
/* CascadePreprocessor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CascadePreprocessor.swift
;
sourceTree
=
"<group>"
;
};
96E409601F24F7370015A2B5
/* IgnoreSubviewModifiersPreprocessor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
IgnoreSubviewModifiersPreprocessor.swift
;
sourceTree
=
"<group>"
;
};
96E409611F24F7370015A2B5
/* MatchPreprocessor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MatchPreprocessor.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -129,6 +135,17 @@
/* End PBXFileReference section */
/* Begin PBXGroup section */
965FE9781FE1D8120098BDD0
/* Transition */
=
{
isa
=
PBXGroup
;
children
=
(
965FE9791FE1D83D0098BDD0
/* MotionTransition.swift */
,
965FE9661FDD99800098BDD0
/* MotionTransition+Start.swift */
,
965FE96E1FDEFA8B0098BDD0
/* MotionTransition+Animate.swift */
,
965FE9621FDCCE030098BDD0
/* MotionTransition+Complete.swift */
,
);
path
=
Transition
;
sourceTree
=
"<group>"
;
};
96C98DC71E424AB000B22906
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -151,12 +168,7 @@
96E409BB1F24FC210015A2B5
/* Info.plist */
,
96E409BC1F24FC300015A2B5
/* LICENSE */
,
96E4094F1F24F7370015A2B5
/* Motion.h */
,
96E409501F24F7370015A2B5
/* Motion.swift */
,
965FE9601FDCC3AF0098BDD0
/* MotionState.swift */
,
965FE9681FDDA1F20098BDD0
/* MotionViewOrderStrategy.swift */
,
965FE9661FDD99800098BDD0
/* Motion+Start.swift */
,
965FE96E1FDEFA8B0098BDD0
/* Motion+Animate.swift */
,
965FE9621FDCCE030098BDD0
/* Motion+Complete.swift */
,
965FE9641FDCCE910098BDD0
/* MotionProgressRunner.swift */
,
96E409511F24F7370015A2B5
/* MotionAnimation.swift */
,
96E409521F24F7370015A2B5
/* MotionAnimationState.swift */
,
...
...
@@ -165,12 +177,13 @@
96E409561F24F7370015A2B5
/* MotionCoordinateSpace.swift */
,
96E409581F24F7370015A2B5
/* MotionPlugin.swift */
,
96E409591F24F7370015A2B5
/* MotionSnapshotType.swift */
,
96E4095A1F24F7370015A2B5
/* MotionTransition.swift */
,
96E4095A1F24F7370015A2B5
/* MotionModifier.swift */
,
96E4095C1F24F7370015A2B5
/* MotionTargetState.swift */
,
96E4095B1F24F7370015A2B5
/* MotionTransitionObserver.swift */
,
96E4095C1F24F7370015A2B5
/* MotionTransitionState.swift */
,
96E4093C1F24F7370015A2B5
/* Animator */
,
96E409431F24F7370015A2B5
/* Extensions */
,
96E4095D1F24F7370015A2B5
/* Preprocessors */
,
965FE9781FE1D8120098BDD0
/* Transition */
,
);
path
=
Sources
;
sourceTree
=
"<group>"
;
...
...
@@ -240,7 +253,6 @@
96E409951F24F7570015A2B5
/* Motion+UIView.swift in Headers */
,
96E409961F24F7570015A2B5
/* Motion+UIViewController.swift in Headers */
,
96E409971F24F7570015A2B5
/* MotionAnimationFillMode.swift in Headers */
,
96E4099A1F24F7570015A2B5
/* Motion.swift in Headers */
,
96E4099B1F24F7570015A2B5
/* MotionAnimation.swift in Headers */
,
96E4099C1F24F7570015A2B5
/* MotionAnimationState.swift in Headers */
,
96E4099D1F24F7570015A2B5
/* MotionCAAnimation.swift in Headers */
,
...
...
@@ -248,9 +260,9 @@
96E409A01F24F7570015A2B5
/* MotionCoordinateSpace.swift in Headers */
,
96E409A21F24F7570015A2B5
/* MotionPlugin.swift in Headers */
,
96E409A31F24F7570015A2B5
/* MotionSnapshotType.swift in Headers */
,
96E409A41F24F7570015A2B5
/* Motion
Transition
.swift in Headers */
,
96E409A41F24F7570015A2B5
/* Motion
Modifier
.swift in Headers */
,
96E409A51F24F7570015A2B5
/* MotionTransitionObserver.swift in Headers */
,
96E409A61F24F7570015A2B5
/* MotionT
ransition
State.swift in Headers */
,
96E409A61F24F7570015A2B5
/* MotionT
arget
State.swift in Headers */
,
96E409A71F24F7570015A2B5
/* CascadePreprocessor.swift in Headers */
,
96E409A91F24F7570015A2B5
/* IgnoreSubviewModifiersPreprocessor.swift in Headers */
,
96E409AA1F24F7570015A2B5
/* MatchPreprocessor.swift in Headers */
,
...
...
@@ -258,6 +270,15 @@
96E409AC1F24F7570015A2B5
/* SourcePreprocessor.swift in Headers */
,
96E409AD1F24F7570015A2B5
/* TransitionPreprocessor.swift in Headers */
,
96E409741F24F7370015A2B5
/* Motion.h in Headers */
,
965FE9811FE304E70098BDD0
/* MotionViewOrderStrategy.swift in Headers */
,
965FE9821FE304E70098BDD0
/* MotionProgressRunner.swift in Headers */
,
965FE9831FE304E70098BDD0
/* MotionCoreAnimator.swift in Headers */
,
965FE9841FE304E70098BDD0
/* MotionCorePreprocessor.swift in Headers */
,
965FE9851FE304E70098BDD0
/* ConditionalPreprocessor.swift in Headers */
,
965FE9861FE304E70098BDD0
/* MotionTransition.swift in Headers */
,
965FE9881FE304E70098BDD0
/* MotionTransition+Start.swift in Headers */
,
965FE9891FE304E70098BDD0
/* MotionTransition+Animate.swift in Headers */
,
965FE98A1FE304E70098BDD0
/* MotionTransition+Complete.swift in Headers */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -321,7 +342,7 @@
96E409731F24F7370015A2B5
/* MotionAnimationFillMode.swift in Sources */
,
96E409791F24F7370015A2B5
/* MotionContext.swift in Sources */
,
965FE96B1FDDA4EA0098BDD0
/* MotionCorePreprocessor.swift in Sources */
,
965FE9631FDCCE030098BDD0
/* Motion+Complete.swift in Sources */
,
965FE9631FDCCE030098BDD0
/* Motion
Transition
+Complete.swift in Sources */
,
96E4097D1F24F7370015A2B5
/* MotionPlugin.swift in Sources */
,
965FE96D1FDDA6400098BDD0
/* MotionCoreAnimator.swift in Sources */
,
96E4096E1F24F7370015A2B5
/* Motion+CG.swift in Sources */
,
...
...
@@ -330,7 +351,7 @@
96E409821F24F7370015A2B5
/* CascadePreprocessor.swift in Sources */
,
96E4096C1F24F7370015A2B5
/* Motion+CALayer.swift in Sources */
,
96E409781F24F7370015A2B5
/* MotionCAAnimation.swift in Sources */
,
96E409811F24F7370015A2B5
/* MotionT
ransition
State.swift in Sources */
,
96E409811F24F7370015A2B5
/* MotionT
arget
State.swift in Sources */
,
96E409801F24F7370015A2B5
/* MotionTransitionObserver.swift in Sources */
,
96E409691F24F7370015A2B5
/* MotionTransitionAnimator.swift in Sources */
,
96E409651F24F7370015A2B5
/* MotionAnimator.swift in Sources */
,
...
...
@@ -343,19 +364,18 @@
96E409721F24F7370015A2B5
/* Motion+UIViewController.swift in Sources */
,
96E4097E1F24F7370015A2B5
/* MotionSnapshotType.swift in Sources */
,
965FE9691FDDA1F20098BDD0
/* MotionViewOrderStrategy.swift in Sources */
,
965FE97A1FE1D83D0098BDD0
/* MotionTransition.swift in Sources */
,
96E409871F24F7370015A2B5
/* SourcePreprocessor.swift in Sources */
,
96E409701F24F7370015A2B5
/* Motion+UIKit.swift in Sources */
,
965FE9771FE0976F0098BDD0
/* ConditionalPreprocessor.swift in Sources */
,
96E4097B1F24F7370015A2B5
/* MotionCoordinateSpace.swift in Sources */
,
96E409881F24F7370015A2B5
/* TransitionPreprocessor.swift in Sources */
,
965FE9671FDD99800098BDD0
/* Motion+Start.swift in Sources */
,
965FE9671FDD99800098BDD0
/* Motion
Transition
+Start.swift in Sources */
,
96E4096A1F24F7370015A2B5
/* MotionViewPropertyViewContext.swift in Sources */
,
96E409661F24F7370015A2B5
/* MotionAnimatorViewContext.swift in Sources */
,
965FE9651FDCCE910098BDD0
/* MotionProgressRunner.swift in Sources */
,
965FE9611FDCC3AF0098BDD0
/* MotionState.swift in Sources */
,
96E4097F1F24F7370015A2B5
/* MotionTransition.swift in Sources */
,
965FE96F1FDEFA8B0098BDD0
/* Motion+Animate.swift in Sources */
,
96E409751F24F7370015A2B5
/* Motion.swift in Sources */
,
96E4097F1F24F7370015A2B5
/* MotionModifier.swift in Sources */
,
965FE96F1FDEFA8B0098BDD0
/* MotionTransition+Animate.swift in Sources */
,
96E4096F1F24F7370015A2B5
/* Motion+Obj-C.swift in Sources */
,
96E409711F24F7370015A2B5
/* Motion+UIView.swift in Sources */
,
);
...
...
Sources/Animator/MotionAnimator.swift
View file @
9fd0e15e
...
...
@@ -30,7 +30,7 @@ import UIKit
public
protocol
MotionAnimator
:
class
{
/// A reference to Motion.
weak
var
motion
:
Motion
!
{
get
set
}
weak
var
motion
:
Motion
Transition
!
{
get
set
}
/// Cleans the contexts.
func
clean
()
...
...
@@ -68,8 +68,8 @@ public protocol MotionAnimator: class {
/**
Applies the given state to the given view.
- Parameter state: A Motion
TransitionState
.
- Parameter state: A Motion
Modifier
.
- Parameter to view: A UIView.
*/
func
apply
(
state
:
MotionT
ransition
State
,
to
view
:
UIView
)
func
apply
(
state
:
MotionT
arget
State
,
to
view
:
UIView
)
}
Sources/Animator/MotionAnimatorViewContext.swift
View file @
9fd0e15e
...
...
@@ -36,7 +36,7 @@ internal class MotionAnimatorViewContext {
var
snapshot
:
UIView
/// The animation target state.
var
targetState
:
MotionT
ransition
State
var
targetState
:
MotionT
arget
State
/// A boolean indicating if the view is appearing.
var
isAppearing
:
Bool
...
...
@@ -58,10 +58,10 @@ internal class MotionAnimatorViewContext {
An initializer.
- Parameter animator: A MotionAnimator.
- Parameter snapshot: A UIView.
- Parameter targetState: A Motion
TransitionState
.
- Parameter targetState: A Motion
Modifier
.
- Parameter isAppearing: A Boolean.
*/
required
init
(
animator
:
MotionCoreAnimator
,
snapshot
:
UIView
,
targetState
:
MotionT
ransition
State
,
isAppearing
:
Bool
)
{
required
init
(
animator
:
MotionCoreAnimator
,
snapshot
:
UIView
,
targetState
:
MotionT
arget
State
,
isAppearing
:
Bool
)
{
self
.
animator
=
animator
self
.
snapshot
=
snapshot
self
.
targetState
=
targetState
...
...
@@ -77,11 +77,11 @@ internal class MotionAnimatorViewContext {
A class function that determines if a view can be animated
to a given state.
- Parameter view: A UIView.
- Parameter state: A Motion
TransitionState
.
- Parameter state: A Motion
Modifier
.
- Parameter isAppearing: A boolean that determines whether the
view is appearing.
*/
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionT
ransition
State
,
isAppearing
:
Bool
)
->
Bool
{
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionT
arget
State
,
isAppearing
:
Bool
)
->
Bool
{
return
false
}
...
...
@@ -106,9 +106,9 @@ internal class MotionAnimatorViewContext {
/**
Applies the given state to the target state.
- Parameter state: A Motion
TransitionState
.
- Parameter state: A Motion
Modifier
.
*/
func
apply
(
state
:
MotionT
ransition
State
)
{}
func
apply
(
state
:
MotionT
arget
State
)
{}
/**
Starts the animations with an appearing boolean flag.
...
...
Sources/Animator/MotionCoreAnimationViewContext.swift
View file @
9fd0e15e
...
...
@@ -30,7 +30,7 @@ import UIKit
internal
class
MotionCoreAnimationViewContext
:
MotionAnimatorViewContext
{
/// The transition states.
fileprivate
var
transitionStates
=
[
String
:
(
Any
?,
Any
?)]()
fileprivate
var
state
=
[
String
:
(
Any
?,
Any
?)]()
/// A reference to the animation timing function.
fileprivate
var
timingFunction
=
CAMediaTimingFunction
.
standard
...
...
@@ -51,7 +51,7 @@ internal class MotionCoreAnimationViewContext: MotionAnimatorViewContext {
overlayLayer
=
nil
}
override
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionT
ransition
State
,
isAppearing
:
Bool
)
->
Bool
{
override
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionT
arget
State
,
isAppearing
:
Bool
)
->
Bool
{
return
nil
!=
state
.
position
||
nil
!=
state
.
size
||
nil
!=
state
.
transform
||
...
...
@@ -70,13 +70,13 @@ internal class MotionCoreAnimationViewContext: MotionAnimatorViewContext {
state
.
forceAnimate
}
override
func
apply
(
state
:
MotionT
ransition
State
)
{
override
func
apply
(
state
:
MotionT
arget
State
)
{
let
targetState
=
viewState
(
targetState
:
state
)
for
(
key
,
targetValue
)
in
targetState
{
if
nil
==
transitionStates
[
key
]
{
if
nil
==
state
[
key
]
{
let
current
=
currentValue
(
for
:
key
)
transitionStates
[
key
]
=
(
current
,
current
)
state
[
key
]
=
(
current
,
current
)
}
let
oldAnimations
=
animations
...
...
@@ -87,8 +87,8 @@ internal class MotionCoreAnimationViewContext: MotionAnimatorViewContext {
}
override
func
resume
(
at
elapsedTime
:
TimeInterval
,
isReversed
:
Bool
)
->
TimeInterval
{
for
(
key
,
(
fromValue
,
toValue
))
in
transitionStates
{
transitionStates
[
key
]
=
(
currentValue
(
for
:
key
),
isReversed
?
fromValue
:
toValue
)
for
(
key
,
(
fromValue
,
toValue
))
in
state
{
state
[
key
]
=
(
currentValue
(
for
:
key
),
isReversed
?
fromValue
:
toValue
)
}
if
isReversed
{
...
...
@@ -125,28 +125,31 @@ internal class MotionCoreAnimationViewContext: MotionAnimatorViewContext {
}
override
func
startAnimations
()
->
TimeInterval
{
if
let
beginState
=
targetState
.
beginState
?
.
state
{
if
let
beginStateModifiers
=
targetState
.
beginState
{
let
beginState
=
MotionTargetState
(
modifiers
:
beginStateModifiers
)
let
appeared
=
viewState
(
targetState
:
beginState
)
for
(
k
,
v
)
in
appeared
{
snapshot
.
layer
.
setValue
(
v
,
forKeyPath
:
k
)
}
if
let
(
k
,
v
)
=
beginState
.
overlay
{
if
let
(
color
,
opacity
)
=
beginState
.
overlay
{
let
overlay
=
getOverlayLayer
()
overlay
.
backgroundColor
=
k
overlay
.
opacity
=
Float
(
v
)
overlay
.
backgroundColor
=
color
overlay
.
opacity
=
Float
(
opacity
)
}
}
let
disappeared
=
viewState
(
targetState
:
targetState
)
for
(
k
,
v
)
in
disappeared
{
let
isAppearingState
=
currentValue
(
for
:
k
)
let
toValue
=
isAppearing
?
isAppearingState
:
v
let
fromValue
=
!
isAppearing
?
isAppearingState
:
v
transitionStates
[
k
]
=
(
fromValue
,
toValue
)
for
(
k
,
disappearedState
)
in
disappeared
{
let
appearingState
=
currentValue
(
for
:
k
)
let
toValue
=
isAppearing
?
appearingState
:
disappearedState
let
fromValue
=
!
isAppearing
?
appearingState
:
disappearedState
state
[
k
]
=
(
fromValue
,
toValue
)
}
return
animate
(
delay
:
targetState
.
delay
,
duration
:
duration
)
}
}
...
...
@@ -416,7 +419,7 @@ fileprivate extension MotionCoreAnimationViewContext {
animations
=
[]
for
(
key
,
(
fromValue
,
toValue
))
in
transitionStates
{
for
(
key
,
(
fromValue
,
toValue
))
in
state
{
let
neededTime
=
animate
(
key
:
key
,
beginTime
:
currentTime
+
delay
,
duration
:
duration
,
fromValue
:
fromValue
,
toValue
:
toValue
)
timeUntilStop
=
max
(
timeUntilStop
,
neededTime
)
}
...
...
@@ -426,10 +429,10 @@ fileprivate extension MotionCoreAnimationViewContext {
/**
Constructs a map of key paths to animation state values.
- Parameter targetState state: A Motion
TransitionState
.
- Parameter targetState state: A Motion
Modifier
.
- Returns: A map of key paths to animation values.
*/
func
viewState
(
targetState
ts
:
MotionT
ransition
State
)
->
[
String
:
Any
?]
{
func
viewState
(
targetState
ts
:
MotionT
arget
State
)
->
[
String
:
Any
?]
{
var
ts
=
ts
var
values
=
[
String
:
Any
?]()
...
...
Sources/Animator/MotionCoreAnimator.swift
View file @
9fd0e15e
...
...
@@ -29,7 +29,7 @@
import
UIKit
class
MotionCoreAnimator
:
MotionAnimator
{
weak
public
var
motion
:
Motion
!
weak
public
var
motion
:
Motion
Transition
!
/// A reference to the MotionContext.
public
var
context
:
MotionContext
!
{
...
...
@@ -52,7 +52,7 @@ class MotionCoreAnimator: MotionAnimator {
return
0
}
func
apply
(
state
:
MotionT
ransition
State
,
to
view
:
UIView
)
{}
func
apply
(
state
:
MotionT
arget
State
,
to
view
:
UIView
)
{}
}
Sources/Animator/MotionTransitionAnimator.swift
View file @
9fd0e15e
...
...
@@ -28,7 +28,7 @@
import
UIKit
internal
class
MotionT
ransition
Animator
<
T
:
MotionAnimatorViewContext
>
:
MotionCoreAnimator
{
internal
class
MotionT
argetState
Animator
<
T
:
MotionAnimatorViewContext
>
:
MotionCoreAnimator
{
/// An index of views to their corresponding animator context.
var
viewToContexts
=
[
UIView
:
T
]()
...
...
@@ -132,10 +132,10 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
/**
Applies the given state to the given view.
- Parameter state: A Motion
TransitionState
.
- Parameter state: A Motion
Modifier
.
- Parameter to view: A UIView.
*/
override
func
apply
(
state
:
MotionT
ransition
State
,
to
view
:
UIView
)
{
override
func
apply
(
state
:
MotionT
arget
State
,
to
view
:
UIView
)
{
guard
let
v
=
viewToContexts
[
view
]
else
{
return
}
...
...
@@ -144,7 +144,7 @@ internal class MotionTransitionAnimator<T: MotionAnimatorViewContext>: MotionCor
}
}
fileprivate
extension
MotionT
ransition
Animator
{
fileprivate
extension
MotionT
argetState
Animator
{
/**
Creates a view context for a given view.
- Parameter view: A UIView.
...
...
Sources/Animator/MotionViewPropertyViewContext.swift
View file @
9fd0e15e
...
...
@@ -39,7 +39,7 @@ internal class MotionViewPropertyViewContext: MotionAnimatorViewContext {
/// Starting effect.
fileprivate
var
startEffect
:
UIVisualEffect
?
override
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionT
ransition
State
,
isAppearing
:
Bool
)
->
Bool
{
override
class
func
canAnimate
(
view
:
UIView
,
state
:
MotionT
arget
State
,
isAppearing
:
Bool
)
->
Bool
{
return
view
is
UIVisualEffectView
&&
nil
!=
state
.
opacity
}
...
...
Sources/Extensions/Motion+UIView.swift
View file @
9fd0e15e
...
...
@@ -43,8 +43,8 @@ fileprivate struct AssociatedInstance {
/// An optional reference to the motion animations.
fileprivate
var
animations
:
[
MotionAnimation
]?
/// An optional reference to the motion
transition animation
s.
fileprivate
var
transitions
:
[
MotionTransition
]?
/// An optional reference to the motion
animation modifier
s.
fileprivate
var
modifiers
:
[
MotionModifier
]?
/// An alpha value.
fileprivate
var
alpha
:
CGFloat
?
...
...
@@ -55,7 +55,7 @@ fileprivate extension UIView {
fileprivate
var
associatedInstance
:
AssociatedInstance
{
get
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
AssociatedInstanceKey
)
{
return
AssociatedInstance
(
isEnabled
:
true
,
isEnabledForSubviews
:
true
,
identifier
:
nil
,
animations
:
nil
,
transition
s
:
nil
,
alpha
:
1
)
return
AssociatedInstance
(
isEnabled
:
true
,
isEnabledForSubviews
:
true
,
identifier
:
nil
,
animations
:
nil
,
modifier
s
:
nil
,
alpha
:
1
)
}
}
set
(
value
)
{
...
...
@@ -136,30 +136,30 @@ public extension UIView {
}
/**
A function that accepts a list of MotionT
ransition
values.
- Parameter transitions: A list of MotionT
ransition
values.
A function that accepts a list of MotionT
argetState
values.
- Parameter transitions: A list of MotionT
argetState
values.
*/
func
transition
(
_
transitions
:
MotionTransition
...
)
{
transition
(
transition
s
)
func
transition
(
_
modifiers
:
MotionModifier
...
)
{
transition
(
modifier
s
)
}
/**
A function that accepts an Array of MotionT
ransition
values.
- Parameter transitions: An Array of MotionT
ransition
values.
A function that accepts an Array of MotionT
argetState
values.
- Parameter transitions: An Array of MotionT
argetState
values.
*/
func
transition
(
_
transitions
:
[
MotionTransition
])
{
motion
Transitions
=
transition
s
func
transition
(
_
modifiers
:
[
MotionModifier
])
{
motion
Modifiers
=
modifier
s
}
}
internal
extension
UIView
{
/// The animations to run while in transition.
var
motion
Transitions
:
[
MotionTransition
]?
{
var
motion
Modifiers
:
[
MotionModifier
]?
{
get
{
return
associatedInstance
.
transition
s
return
associatedInstance
.
modifier
s
}
set
(
value
)
{
associatedInstance
.
transition
s
=
value
associatedInstance
.
modifier
s
=
value
}
}
...
...
@@ -286,10 +286,10 @@ internal extension UIView {
/**
Calculates the optimized duration for a view.
- Parameter targetState: A MotionT
ransition
State.
- Parameter targetState: A MotionT
arget
State.
- Returns: A TimeInterval.
*/
func
optimizedDuration
(
targetState
:
MotionT
ransition
State
)
->
TimeInterval
{
func
optimizedDuration
(
targetState
:
MotionT
arget
State
)
->
TimeInterval
{
return
optimizedDuration
(
position
:
targetState
.
position
,
size
:
targetState
.
size
,
transform
:
targetState
.
transform
)
...
...
Sources/Extensions/Motion+UIViewController.swift
View file @
9fd0e15e
...
...
@@ -32,13 +32,13 @@ fileprivate var AssociatedInstanceKey: UInt8 = 0
fileprivate
struct
AssociatedInstance
{
/// A reference to the modal animation.
var
modalTransitionType
:
MotionTransitionType
var
modalTransitionType
:
MotionTransition
Animation
Type
/// A reference to the navigation animation.
var
navigationTransitionType
:
MotionTransitionType
var
navigationTransitionType
:
MotionTransition
Animation
Type
/// A reference to the tabBar animation.
var
tabBarTransitionType
:
MotionTransitionType
var
tabBarTransitionType
:
MotionTransition
Animation
Type
/// A reference to the stored snapshot.
var
storedSnapshot
:
UIView
?
...
...
@@ -75,7 +75,7 @@ extension UIViewController {
}
/// Default motion animation type for presenting & dismissing modally.
public
var
motionTransitionType
:
MotionTransitionType
{
public
var
motionTransitionType
:
MotionTransition
Animation
Type
{
get
{
return
associatedInstance
.
modalTransitionType
}
...
...
@@ -161,7 +161,7 @@ extension UIViewController {
extension
UINavigationController
{
/// Default motion animation type for push and pop within the navigation controller.
public
var
motionNavigationTransitionType
:
MotionTransitionType
{
public
var
motionNavigationTransitionType
:
MotionTransition
Animation
Type
{
get
{
return
associatedInstance
.
navigationTransitionType
}
...
...
@@ -173,7 +173,7 @@ extension UINavigationController {
extension
UITabBarController
{
/// Default motion animation type for switching tabs within the tab bar controller.
public
var
motionTabBarTransitionType
:
MotionTransitionType
{
public
var
motionTabBarTransitionType
:
MotionTransition
Animation
Type
{
get
{
return
associatedInstance
.
tabBarTransitionType
}
...
...
Sources/MotionContext.swift
View file @
9fd0e15e
...
...
@@ -45,7 +45,7 @@ public class MotionContext {
internal
var
viewToAlphas
=
[
UIView
:
CGFloat
]()
/// A reference of view to transition target state.
internal
var
viewToTargetState
=
[
UIView
:
MotionT
ransition
State
]()
internal
var
viewToTargetState
=
[
UIView
:
MotionT
arget
State
]()
/// A reference of the superview to the subviews snapshots.
internal
var
superviewToNoSnapshotSubviewMap
=
[
UIView
:
[(
Int
,
UIView
)]]()
...
...
@@ -94,14 +94,21 @@ internal extension MotionContext {
for
v
in
views
{
v
.
layer
.
removeAllAnimations
()
if
container
.
convert
(
v
.
bounds
,
from
:
v
)
.
intersects
(
container
.
bounds
)
{
if
let
i
=
v
.
motionIdentifier
{
identifierMap
[
i
]
=
v
}
if
let
i
=
v
.
motionTransitions
{
viewToTargetState
[
v
]
=
MotionTransitionState
(
transitions
:
i
)
let
targetState
:
MotionTargetState
?
if
let
modifiers
=
v
.
motionModifiers
{
targetState
=
MotionTargetState
(
modifiers
:
modifiers
)
}
else
{
targetState
=
nil
}
if
true
==
targetState
?
.
forceAnimate
||
container
.
convert
(
v
.
bounds
,
from
:
v
)
.
intersects
(
container
.
bounds
)
{
if
let
motionIdentifier
=
v
.
motionIdentifier
{
identifierMap
[
motionIdentifier
]
=
v
}
viewToTargetState
[
v
]
=
targetState
}
}
}
...
...
@@ -110,11 +117,11 @@ internal extension MotionContext {
public
extension
MotionContext
{
/**
A subscript that takes a given view and retrieves a
Motion
TransitionState
if one exists.
Motion
Modifier
if one exists.
- Parameter view: A UIView.
- Returns: An optional MotionT
ransition
State.
- Returns: An optional MotionT
arget
State.
*/
subscript
(
view
:
UIView
)
->
MotionT
ransition
State
?
{
subscript
(
view
:
UIView
)
->
MotionT
arget
State
?
{
get
{
return
viewToTargetState
[
view
]
}
...
...
Sources/Motion
Transition
.swift
→
Sources/Motion
Modifier
.swift
View file @
9fd0e15e
...
...
@@ -28,27 +28,27 @@
import
UIKit
public
class
MotionTransition
{
/// A reference to the callback that applies the Motion
TransitionState
.
internal
let
apply
:
(
inout
MotionT
ransition
State
)
->
Void
public
final
class
MotionModifier
{
/// A reference to the callback that applies the Motion
Modifier
.
internal
let
apply
:
(
inout
MotionT
arget
State
)
->
Void
/**
An initializer that accepts a given callback.
- Parameter applyFunction: A given callback.
*/
init
(
applyFunction
:
@escaping
(
inout
MotionTransition
State
)
->
Void
)
{
public
init
(
applyFunction
:
@escaping
(
inout
MotionTarget
State
)
->
Void
)
{
apply
=
applyFunction
}
}
public
extension
Motion
Transition
{
public
extension
Motion
Modifier
{
/**
Animates the view with a matching motion identifier.
- Parameter _ identifier: A String.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
motionIdentifier
(
_
identifier
:
String
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
motionIdentifier
(
_
identifier
:
String
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
motionIdentifier
=
identifier
}
}
...
...
@@ -58,10 +58,10 @@ public extension MotionTransition {
given masksToBounds.
- Parameter masksToBounds: A boolean value indicating the
masksToBounds state.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
masksToBounds
(
_
masksToBounds
:
Bool
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
masksToBounds
(
_
masksToBounds
:
Bool
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
masksToBounds
=
masksToBounds
}
}
...
...
@@ -70,10 +70,10 @@ public extension MotionTransition {
Animates the view's current background color to the
given color.
- Parameter color: A UIColor.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
background
(
color
:
UIColor
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
background
(
color
:
UIColor
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
backgroundColor
=
color
.
cgColor
}
}
...
...
@@ -82,10 +82,10 @@ public extension MotionTransition {
Animates the view's current border color to the
given color.
- Parameter color: A UIColor.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
border
(
color
:
UIColor
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
border
(
color
:
UIColor
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
borderColor
=
color
.
cgColor
}
}
...
...
@@ -94,10 +94,10 @@ public extension MotionTransition {
Animates the view's current border width to the
given width.
- Parameter width: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
border
(
width
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
border
(
width
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
borderWidth
=
width
}
}
...
...
@@ -106,10 +106,10 @@ public extension MotionTransition {
Animates the view's current corner radius to the
given radius.
- Parameter radius: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
corner
(
radius
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
corner
(
radius
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
cornerRadius
=
radius
}
}
...
...
@@ -118,10 +118,10 @@ public extension MotionTransition {
Animates the view's current transform (perspective, scale, rotate)
to the given one.
- Parameter _ transform: A CATransform3D.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
transform
(
_
transform
:
CATransform3D
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
transform
(
_
transform
:
CATransform3D
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
transform
=
transform
}
}
...
...
@@ -130,10 +130,10 @@ public extension MotionTransition {
Animates the view's current perspective to the given one through
a CATransform3D object.
- Parameter _ perspective: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
perspective
(
_
perspective
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
perspective
(
_
perspective
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
var
t
=
$0
.
transform
??
CATransform3DIdentity
t
.
m34
=
1
/
-
perspective
$0
.
transform
=
t
...
...
@@ -146,10 +146,10 @@ public extension MotionTransition {
- Parameter x: A CGFloat.
- Parameter y: A CGFloat.
- Parameter z: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
rotate
(
x
:
CGFloat
=
0
,
y
:
CGFloat
=
0
,
z
:
CGFloat
=
0
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
rotate
(
x
:
CGFloat
=
0
,
y
:
CGFloat
=
0
,
z
:
CGFloat
=
0
)
->
Motion
Modifier
{
return
Motion
Modifier
{
var
t
=
$0
.
transform
??
CATransform3DIdentity
t
=
CATransform3DRotate
(
t
,
CGFloat
(
Double
.
pi
)
*
x
/
180
,
1
,
0
,
0
)
t
=
CATransform3DRotate
(
t
,
CGFloat
(
Double
.
pi
)
*
y
/
180
,
0
,
1
,
0
)
...
...
@@ -161,18 +161,18 @@ public extension MotionTransition {
Animates the view's current rotate to the given point.
- Parameter _ point: A CGPoint.
- Parameter z: A CGFloat, default is 0.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
rotate
(
_
point
:
CGPoint
,
z
:
CGFloat
=
0
)
->
Motion
Transition
{
static
func
rotate
(
_
point
:
CGPoint
,
z
:
CGFloat
=
0
)
->
Motion
Modifier
{
return
.
rotate
(
x
:
point
.
x
,
y
:
point
.
y
,
z
:
z
)
}
/**
Rotate 2d.
- Parameter _ z: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
rotate
(
_
z
:
CGFloat
)
->
Motion
Transition
{
static
func
rotate
(
_
z
:
CGFloat
)
->
Motion
Modifier
{
return
.
rotate
(
z
:
z
)
}
...
...
@@ -181,10 +181,10 @@ public extension MotionTransition {
- Parameter x: A CGFloat.
- Parameter y: A CGFloat.
- Parameter z: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
scale
(
x
:
CGFloat
=
1
,
y
:
CGFloat
=
1
,
z
:
CGFloat
=
1
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
scale
(
x
:
CGFloat
=
1
,
y
:
CGFloat
=
1
,
z
:
CGFloat
=
1
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
transform
=
CATransform3DScale
(
$0
.
transform
??
CATransform3DIdentity
,
x
,
y
,
z
)
}
}
...
...
@@ -192,9 +192,9 @@ public extension MotionTransition {
/**
Animates the view's current x & y scale to the given scale value.
- Parameter _ xy: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
scale
(
_
xy
:
CGFloat
)
->
Motion
Transition
{
static
func
scale
(
_
xy
:
CGFloat
)
->
Motion
Modifier
{
return
.
scale
(
x
:
xy
,
y
:
xy
)
}
...
...
@@ -204,10 +204,10 @@ public extension MotionTransition {
- Parameter x: A CGFloat.
- Parameter y: A CGFloat.
- Parameter z: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
translate
(
x
:
CGFloat
=
0
,
y
:
CGFloat
=
0
,
z
:
CGFloat
=
0
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
translate
(
x
:
CGFloat
=
0
,
y
:
CGFloat
=
0
,
z
:
CGFloat
=
0
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
transform
=
CATransform3DTranslate
(
$0
.
transform
??
CATransform3DIdentity
,
x
,
y
,
z
)
}
}
...
...
@@ -217,19 +217,19 @@ public extension MotionTransition {
point value (x & y), and a z value.
- Parameter _ point: A CGPoint.
- Parameter z: A CGFloat, default is 0.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
translate
(
_
point
:
CGPoint
,
z
:
CGFloat
=
0
)
->
Motion
Transition
{
static
func
translate
(
_
point
:
CGPoint
,
z
:
CGFloat
=
0
)
->
Motion
Modifier
{
return
.
translate
(
x
:
point
.
x
,
y
:
point
.
y
,
z
:
z
)
}
/**
Animates the view's current position to the given point.
- Parameter _ point: A CGPoint.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
position
(
_
point
:
CGPoint
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
position
(
_
point
:
CGPoint
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
position
=
point
}
}
...
...
@@ -238,30 +238,30 @@ public extension MotionTransition {
Animates a view's current position to the given x and y values.
- Parameter x: A CGloat.
- Parameter y: A CGloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
position
(
x
:
CGFloat
,
y
:
CGFloat
)
->
Motion
Transition
{
static
func
position
(
x
:
CGFloat
,
y
:
CGFloat
)
->
Motion
Modifier
{
return
.
position
(
CGPoint
(
x
:
x
,
y
:
y
))
}
/// Forces the view to not fade during a transition.
static
var
forceNonFade
=
Motion
Transition
{
static
var
forceNonFade
=
Motion
Modifier
{
$0
.
nonFade
=
true
}
/// Fades the view in during a transition.
static
var
fadeIn
=
Motion
Transition
.
fade
(
1
)
static
var
fadeIn
=
Motion
Modifier
.
fade
(
1
)
/// Fades the view out during a transition.
static
var
fadeOut
=
Motion
Transition
.
fade
(
0
)
static
var
fadeOut
=
Motion
Modifier
.
fade
(
0
)
/**
Animates the view's current opacity to the given one.
- Parameter to opacity: A Double.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
fade
(
_
opacity
:
Double
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
fade
(
_
opacity
:
Double
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
opacity
=
opacity
}
}
...
...
@@ -269,10 +269,10 @@ public extension MotionTransition {
/**
Animates the view's current zPosition to the given position.
- Parameter _ position: An Int.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
zPosition
(
_
position
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
zPosition
(
_
position
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
zPosition
=
position
}
}
...
...
@@ -280,10 +280,10 @@ public extension MotionTransition {
/**
Animates the view's current size to the given one.
- Parameter _ size: A CGSize.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
size
(
_
size
:
CGSize
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
size
(
_
size
:
CGSize
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
size
=
size
}
}
...
...
@@ -292,19 +292,19 @@ public extension MotionTransition {
Animates the view's current size to the given width and height.
- Parameter width: A CGFloat.
- Parameter height: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
size
(
width
:
CGFloat
,
height
:
CGFloat
)
->
Motion
Transition
{
static
func
size
(
width
:
CGFloat
,
height
:
CGFloat
)
->
Motion
Modifier
{
return
.
size
(
CGSize
(
width
:
width
,
height
:
height
))
}
/**
Animates the view's current shadow path to the given one.
- Parameter path: A CGPath.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
shadow
(
path
:
CGPath
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
shadow
(
path
:
CGPath
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
shadowPath
=
path
}
}
...
...
@@ -312,10 +312,10 @@ public extension MotionTransition {
/**
Animates the view's current shadow color to the given one.
- Parameter color: A UIColor.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
shadow
(
color
:
UIColor
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
shadow
(
color
:
UIColor
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
shadowColor
=
color
.
cgColor
}
}
...
...
@@ -323,10 +323,10 @@ public extension MotionTransition {
/**
Animates the view's current shadow offset to the given one.
- Parameter offset: A CGSize.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
shadow
(
offset
:
CGSize
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
shadow
(
offset
:
CGSize
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
shadowOffset
=
offset
}
}
...
...
@@ -334,10 +334,10 @@ public extension MotionTransition {
/**
Animates the view's current shadow opacity to the given one.
- Parameter opacity: A Float.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
shadow
(
opacity
:
Float
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
shadow
(
opacity
:
Float
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
shadowOpacity
=
opacity
}
}
...
...
@@ -345,10 +345,10 @@ public extension MotionTransition {
/**
Animates the view's current shadow radius to the given one.
- Parameter radius: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
shadow
(
radius
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
shadow
(
radius
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
shadowRadius
=
radius
}
}
...
...
@@ -356,10 +356,10 @@ public extension MotionTransition {
/**
Animates the view's contents rect to the given one.
- Parameter rect: A CGRect.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
contents
(
rect
:
CGRect
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
contents
(
rect
:
CGRect
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
contentsRect
=
rect
}
}
...
...
@@ -367,10 +367,10 @@ public extension MotionTransition {
/**
Animates the view's contents scale to the given one.
- Parameter scale: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
contents
(
scale
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
contents
(
scale
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
contentsScale
=
scale
}
}
...
...
@@ -378,10 +378,10 @@ public extension MotionTransition {
/**
The duration of the view's animation.
- Parameter _ duration: A TimeInterval.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
duration
(
_
duration
:
TimeInterval
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
duration
(
_
duration
:
TimeInterval
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
duration
=
duration
}
}
...
...
@@ -390,15 +390,15 @@ public extension MotionTransition {
Sets the view's animation duration to the longest
running animation within a transition.
*/
static
var
preferredDurationMatchesLongest
=
Motion
Transition
.
duration
(
.
infinity
)
static
var
preferredDurationMatchesLongest
=
Motion
Modifier
.
duration
(
.
infinity
)
/**
Delays the animation of a given view.
- Parameter _ time: TimeInterval.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
delay
(
_
time
:
TimeInterval
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
delay
(
_
time
:
TimeInterval
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
delay
=
time
}
}
...
...
@@ -406,10 +406,10 @@ public extension MotionTransition {
/**
Sets the view's timing function for the transition.
- Parameter _ timingFunction: A CAMediaTimingFunction.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
timingFunction
(
_
timingFunction
:
CAMediaTimingFunction
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
timingFunction
(
_
timingFunction
:
CAMediaTimingFunction
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
timingFunction
=
timingFunction
}
}
...
...
@@ -419,11 +419,11 @@ public extension MotionTransition {
given a stiffness and damping.
- Parameter stiffness: A CGFlloat.
- Parameter damping: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
@available(iOS 9, *)
static
func
spring
(
stiffness
:
CGFloat
,
damping
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
spring
(
stiffness
:
CGFloat
,
damping
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
spring
=
(
stiffness
,
damping
)
}
}
...
...
@@ -433,10 +433,10 @@ public extension MotionTransition {
a curve in a downward direction, and a value of -1
represents a curve in an upward direction.
- Parameter intensity: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
arc
(
intensity
:
CGFloat
=
1
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
arc
(
intensity
:
CGFloat
=
1
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
arc
=
intensity
}
}
...
...
@@ -447,10 +447,10 @@ public extension MotionTransition {
- Parameter direction: A CascadeDirection.
- Parameter animationDelayedUntilMatchedViews: A boolean indicating whether
or not to delay the subview animation until all have started.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
cascade
(
delta
:
TimeInterval
=
0.02
,
direction
:
CascadeDirection
=
.
topToBottom
,
animationDelayedUntilMatchedViews
:
Bool
=
false
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
cascade
(
delta
:
TimeInterval
=
0.02
,
direction
:
CascadeDirection
=
.
topToBottom
,
animationDelayedUntilMatchedViews
:
Bool
=
false
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
cascade
=
(
delta
,
direction
,
animationDelayedUntilMatchedViews
)
}
}
...
...
@@ -459,48 +459,108 @@ public extension MotionTransition {
Creates an overlay on the animating view with a given color and opacity.
- Parameter color: A UIColor.
- Parameter opacity: A CGFloat.
- Returns: A Motion
Transition
.
- Returns: A Motion
Modifier
.
*/
static
func
overlay
(
color
:
UIColor
,
opacity
:
CGFloat
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
overlay
(
color
:
UIColor
,
opacity
:
CGFloat
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
overlay
=
(
color
.
cgColor
,
opacity
)
}
}
}
public
extension
MotionTransition
{
/**
Apply transitions directly to the view at the start of the transition.
The transitions supplied here won't be animated.
For source views, transitions are set directly at the begining of the animation.
For destination views, they replace the target state (final appearance).
*/
static
func
beginWith
(
transitions
:
[
MotionTransition
])
->
MotionTransition
{
return
MotionTransition
{
if
$0
.
beginState
==
nil
{
$0
.
beginState
=
MotionTransitionStateWrapper
(
state
:
[])
// conditional modifiers
public
extension
MotionModifier
{
/**
Apply modifiers when the condition is true.
- Parameter _ condition: A MotionConditionalContext.
- Returns: A Boolean.
*/
static
func
when
(
_
condition
:
@escaping
(
MotionConditionalContext
)
->
Bool
,
_
modifiers
:
[
MotionModifier
])
->
MotionModifier
{
return
MotionModifier
{
if
nil
==
$0
.
conditionalModifiers
{
$0
.
conditionalModifiers
=
[]
}
$0
.
beginState
?
.
state
.
append
(
contentsOf
:
transitions
)
$0
.
conditionalModifiers
!.
append
((
condition
,
modifiers
)
)
}
}
static
func
when
(
_
condition
:
@escaping
(
MotionConditionalContext
)
->
Bool
,
_
modifiers
:
MotionModifier
...
)
->
MotionModifier
{
return
.
when
(
condition
,
modifiers
)
}
/**
Apply transitions directly to the view at the start of the transition if the view is
matched with another view. The transitions supplied here won't be animated.
Apply modifiers when matched.
- Parameter _ modifiers: A list of modifiers.
- Returns: A MotionModifier.
*/
static
func
whenMatched
(
_
modifiers
:
MotionModifier
...
)
->
MotionModifier
{
return
.
when
({
$0
.
isMatched
},
modifiers
)
}
/**
Apply modifiers when presenting.
- Parameter _ modifiers: A list of modifiers.
- Returns: A MotionModifier.
*/
static
func
whenPresenting
(
_
modifiers
:
MotionModifier
...
)
->
MotionModifier
{
return
.
when
({
$0
.
isPresenting
},
modifiers
)
}
/**
Apply modifiers when dismissing.
- Parameter _ modifiers: A list of modifiers.
- Returns: A MotionModifier.
*/
static
func
whenDismissing
(
_
modifiers
:
MotionModifier
...
)
->
MotionModifier
{
return
.
when
({
!
$0
.
isPresenting
},
modifiers
)
}
/**
Apply modifiers when appearingg.
- Parameter _ modifiers: A list of modifiers.
- Returns: A MotionModifier.
*/
static
func
whenAppearing
(
_
modifiers
:
MotionModifier
...
)
->
MotionModifier
{
return
.
when
({
$0
.
isAppearing
},
modifiers
)
}
/**
Apply modifiers when disappearing.
- Parameter _ modifiers: A list of modifiers.
- Returns: A MotionModifier.
*/
static
func
whenDisappearing
(
_
modifiers
:
MotionModifier
...
)
->
MotionModifier
{
return
.
when
({
!
$0
.
isAppearing
},
modifiers
)
}
}
public
extension
MotionModifier
{
/**
Apply transitions directly to the view at the start of the transition.
The transitions supplied here won't be animated.
For source views, transitions are set directly at the begining of the animation.
For destination views, they replace the target state (final appearance).
*/
static
func
beginWith
IfMatched
(
transitions
:
[
MotionTransition
])
->
MotionTransition
{
return
Motion
Transition
{
if
$0
.
beginState
IfMatched
==
nil
{
$0
.
beginState
IfMatched
=
[]
static
func
beginWith
(
_
modifiers
:
[
MotionModifier
])
->
MotionModifier
{
return
Motion
Modifier
{
if
$0
.
beginState
==
nil
{
$0
.
beginState
=
[]
}
$0
.
beginState
IfMatched
?
.
append
(
contentsOf
:
transition
s
)
$0
.
beginState
?
.
append
(
contentsOf
:
modifier
s
)
}
}
static
func
beginWith
(
modifiers
:
[
MotionModifier
])
->
MotionModifier
{
return
.
beginWith
(
modifiers
)
}
static
func
beginWith
(
_
modifiers
:
MotionModifier
...
)
->
MotionModifier
{
return
.
beginWith
(
modifiers
)
}
/**
Use global coordinate space.
...
...
@@ -511,20 +571,20 @@ public extension MotionTransition {
When a view is matched, this is automatically enabled.
The `source` transition will also enable this.
*/
static
var
useGlobalCoordinateSpace
=
Motion
Transition
{
static
var
useGlobalCoordinateSpace
=
Motion
Modifier
{
$0
.
coordinateSpace
=
.
global
}
/// Ignore all motion transition attributes for a view's direct subviews.
static
var
ignoreSubviewTransitions
:
Motion
Transition
=
.
ignoreSubviewTransitions
()
static
var
ignoreSubviewTransitions
:
Motion
Modifier
=
.
ignoreSubviewTransitions
()
/**
Ignore all motion transition attributes for a view's subviews.
- Parameter recursive: If false, will only ignore direct subviews' transitions.
default false.
*/
static
func
ignoreSubviewTransitions
(
recursive
:
Bool
=
false
)
->
Motion
Transition
{
return
Motion
Transition
{
static
func
ignoreSubviewTransitions
(
recursive
:
Bool
=
false
)
->
Motion
Modifier
{
return
Motion
Modifier
{
$0
.
ignoreSubviewTransitions
=
recursive
}
}
...
...
@@ -537,12 +597,12 @@ public extension MotionTransition {
This transition actually does nothing by itself since .useOptimizedSnapshot is the default.
*/
static
var
useOptimizedSnapshot
=
Motion
Transition
{
static
var
useOptimizedSnapshot
=
Motion
Modifier
{
$0
.
snapshotType
=
.
optimized
}
/// Create a snapshot using snapshotView(afterScreenUpdates:).
static
var
useNormalSnapshot
=
Motion
Transition
{
static
var
useNormalSnapshot
=
Motion
Modifier
{
$0
.
snapshotType
=
.
normal
}
...
...
@@ -551,7 +611,7 @@ public extension MotionTransition {
This is slower than .useNormalSnapshot but gives more accurate snapshots for some views
(eg. UIStackView).
*/
static
var
useLayerRenderSnapshot
=
Motion
Transition
{
static
var
useLayerRenderSnapshot
=
Motion
Modifier
{
$0
.
snapshotType
=
.
layerRender
}
...
...
@@ -560,7 +620,7 @@ public extension MotionTransition {
This will mess up the view hierarchy, therefore, view controllers have to rebuild
their view structure after the transition finishes.
*/
static
var
useNoSnapshot
=
Motion
Transition
{
static
var
useNoSnapshot
=
Motion
Modifier
{
$0
.
snapshotType
=
.
noSnapshot
}
...
...
@@ -568,7 +628,7 @@ public extension MotionTransition {
Force the view to animate (Motion will create animation contexts & snapshots for them, so
that they can be interactive).
*/
static
var
forceAnimate
=
Motion
Transition
{
static
var
forceAnimate
=
Motion
Modifier
{
$0
.
forceAnimate
=
true
}
...
...
@@ -577,7 +637,7 @@ public extension MotionTransition {
a .scale transition. This is to help Motion animate layers that doesn't support bounds animations.
This also gives better performance.
*/
static
var
useScaleBasedSizeChange
=
Motion
Transition
{
static
var
useScaleBasedSizeChange
=
Motion
Modifier
{
$0
.
useScaleBasedSizeChange
=
true
}
}
Sources/MotionPlugin.swift
View file @
9fd0e15e
...
...
@@ -125,27 +125,32 @@ class MotionPlugin: MotionCorePreprocessor, MotionAnimator {
- state: the target state to override
- view: the view to override
*/
open
func
apply
(
state
:
MotionT
ransition
State
,
to
view
:
UIView
)
{}
open
func
apply
(
state
:
MotionT
arget
State
,
to
view
:
UIView
)
{}
}
// methods for enable/disable the current plugin
extension
MotionPlugin
{
public
static
var
isEnabled
:
Bool
{
get
{
return
Motion
.
isEnabled
(
plugin
:
self
)
/// A boolean indicating whether plugins are available.
public
static
var
isEnabled
:
Bool
{
get
{
return
MotionTransition
.
isEnabled
(
plugin
:
self
)
}
set
(
value
)
{
if
value
{
enable
()
}
else
{
disable
()
}
}
}
set
{
if
newValue
{
enable
()
}
else
{
disable
()
}
/// Enable plugins.
public
static
func
enable
()
{
MotionTransition
.
enable
(
plugin
:
self
)
}
/// Disable plugins.
public
static
func
disable
()
{
MotionTransition
.
disable
(
plugin
:
self
)
}
}
public
static
func
enable
()
{
Motion
.
enable
(
plugin
:
self
)
}
public
static
func
disable
()
{
Motion
.
disable
(
plugin
:
self
)
}
}
Sources/MotionState.swift
deleted
100644 → 0
View file @
3bc0ad78
/*
* The MIT License (MIT)
*
* Copyright (C) 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Original Inspiration & Author
* Copyright (c) 2016 Luke Zhao <me@lkzhao.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@objc(MotionState)
public
enum
MotionState
:
Int
{
/// Motion is able to start a new transition.
case
possible
/// UIKit has notified Motion about a pending transition.
/// Motion hasn't started preparation.
case
notified
/// Motion's `start` method has been called. Preparing the animation.
case
starting
/// Motions's `animate` method has been called. Animation has started.
case
animating
/// Motions's `complete` method has been called. Transition has ended or has
/// been cancelled. Motion is cleaning up.
case
completing
}
Sources/MotionT
ransition
State.swift
→
Sources/MotionT
arget
State.swift
View file @
9fd0e15e
...
...
@@ -28,29 +28,12 @@
import
UIKit
internal
class
MotionTransitionStateWrapper
{
/// A reference to a MotionTransitionState.
internal
var
state
:
MotionTransitionState
/**
An initializer that accepts a given MotionTransitionState.
- Parameter state: A MotionTransitionState.
*/
internal
init
(
state
:
MotionTransitionState
)
{
self
.
state
=
state
}
}
public
struct
MotionTransitionState
{
public
struct
MotionTargetState
{
/// The initial state that the transition will start at.
internal
var
beginState
:
MotionTransitionStateWrapper
?
internal
var
beginState
:
[
MotionModifier
]
?
public
var
conditionalModifiers
:
[((
MotionConditionalContext
)
->
Bool
,
[
MotionModifier
])]?
public
var
conditionalTransitions
:
[((
MotionConditionalContext
)
->
Bool
,
[
MotionTransition
])]?
/// The start state if there is a match in the desition view controller.
public
var
beginStateIfMatched
:
[
MotionTransition
]?
/// A reference to the position.
public
var
position
:
CGPoint
?
...
...
@@ -154,29 +137,29 @@ public struct MotionTransitionState {
public
var
custom
:
[
String
:
Any
]?
/**
An initializer that accepts an Array of MotionT
ransition
s.
- Parameter transitions: An Array of MotionT
ransition
s.
An initializer that accepts an Array of MotionT
argetState
s.
- Parameter transitions: An Array of MotionT
argetState
s.
*/
init
(
transitions
:
[
MotionTransition
])
{
append
(
contentsOf
:
transition
s
)
init
(
modifiers
:
[
MotionModifier
])
{
append
(
contentsOf
:
modifier
s
)
}
}
extension
MotionT
ransition
State
{
extension
MotionT
arget
State
{
/**
Adds a MotionT
ransition
to the current state.
- Parameter _
element: A MotionTransition
.
Adds a MotionT
argetState
to the current state.
- Parameter _
modifier: A MotionTargetState
.
*/
public
mutating
func
append
(
_
element
:
MotionTransition
)
{
element
.
apply
(
&
self
)
public
mutating
func
append
(
_
modifier
:
MotionModifier
)
{
modifier
.
apply
(
&
self
)
}
/**
Adds an Array of MotionT
ransition
s to the current state.
- Parameter contentsOf
elements: An Array of MotionTransition
s.
Adds an Array of MotionT
argetState
s to the current state.
- Parameter contentsOf
modifiers: An Array of MotionTargetState
s.
*/
public
mutating
func
append
(
contentsOf
elements
:
[
MotionTransition
])
{
for
v
in
element
s
{
public
mutating
func
append
(
contentsOf
modifiers
:
[
MotionModifier
])
{
for
v
in
modifier
s
{
v
.
apply
(
&
self
)
}
}
...
...
@@ -200,12 +183,12 @@ extension MotionTransitionState {
}
}
extension
MotionT
ransition
State
:
ExpressibleByArrayLiteral
{
extension
MotionT
arget
State
:
ExpressibleByArrayLiteral
{
/**
An initializer implementing the ExpressibleByArrayLiteral protocol.
- Parameter arrayLiteral elements: A list of MotionT
ransition
s.
- Parameter arrayLiteral elements: A list of MotionT
argetState
s.
*/
public
init
(
arrayLiteral
elements
:
Motion
Transition
...
)
{
public
init
(
arrayLiteral
elements
:
Motion
Modifier
...
)
{
append
(
contentsOf
:
elements
)
}
}
Sources/MotionTransitionObserver.swift
View file @
9fd0e15e
...
...
@@ -28,11 +28,11 @@
import
Foundation
public
protocol
MotionT
ransition
Observer
{
public
protocol
MotionT
argetState
Observer
{
/**
Executed when the elapsed time changes during a transition.
- Parameter transitionObserver: A MotionT
ransition
Observer.
- Parameter transitionObserver: A MotionT
argetState
Observer.
- Parameter didUpdateWith elapsedTime: A TimeInterval.
*/
func
motion
(
transitionObserver
:
MotionT
ransition
Observer
,
didUpdateWith
elapsedTime
:
TimeInterval
)
func
motion
(
transitionObserver
:
MotionT
argetState
Observer
,
didUpdateWith
elapsedTime
:
TimeInterval
)
}
Sources/Preprocessors/ConditionalPreprocessor.swift
View file @
9fd0e15e
...
...
@@ -29,7 +29,7 @@
import
UIKit
public
struct
MotionConditionalContext
{
internal
weak
var
motion
:
Motion
!
internal
weak
var
motion
:
Motion
Transition
!
public
weak
var
view
:
UIView
!
public
private(set)
var
isAppearing
:
Bool
...
...
@@ -97,11 +97,11 @@ class ConditionalPreprocessor: MotionCorePreprocessor {
func
process
(
views
:
[
UIView
],
isAppearing
:
Bool
)
{
for
v
in
views
{
guard
let
conditional
Transitions
=
context
[
v
]?
.
conditionalTransition
s
else
{
guard
let
conditional
Modifiers
=
context
[
v
]?
.
conditionalModifier
s
else
{
continue
}
for
(
condition
,
transitions
)
in
conditional
Transition
s
{
for
(
condition
,
transitions
)
in
conditional
Modifier
s
{
if
condition
(
MotionConditionalContext
(
motion
:
motion
,
view
:
v
,
isAppearing
:
isAppearing
))
{
context
[
v
]
!.
append
(
contentsOf
:
transitions
)
}
...
...
Sources/Preprocessors/MatchPreprocessor.swift
View file @
9fd0e15e
...
...
@@ -40,8 +40,8 @@ class MatchPreprocessor: MotionCorePreprocessor {
continue
}
var
tvState
=
context
[
tv
]
??
MotionT
ransition
State
()
var
fvState
=
context
[
fv
]
??
MotionT
ransition
State
()
var
tvState
=
context
[
tv
]
??
MotionT
arget
State
()
var
fvState
=
context
[
fv
]
??
MotionT
arget
State
()
// match is just a two-way source effect
tvState
.
motionIdentifier
=
motionIdentifier
...
...
Sources/Preprocessors/MotionCorePreprocessor.swift
View file @
9fd0e15e
...
...
@@ -29,11 +29,11 @@
import
UIKit
class
MotionCorePreprocessor
:
MotionPreprocessor
{
weak
public
var
motion
:
Motion
!
weak
public
var
motion
:
Motion
Transition
!
/// A reference to the MotionContext.
public
var
context
:
MotionContext
!
{
return
motion
?
.
context
return
motion
!
.
context
}
func
process
(
fromViews
:
[
UIView
],
toViews
:
[
UIView
])
{}
...
...
Sources/Preprocessors/MotionPreprocessor.swift
View file @
9fd0e15e
...
...
@@ -30,7 +30,7 @@ import UIKit
public
protocol
MotionPreprocessor
:
class
{
/// A reference to Motion.
weak
var
motion
:
Motion
!
{
get
set
}
weak
var
motion
:
Motion
Transition
!
{
get
set
}
/**
Processes the transitionary views.
...
...
Sources/Preprocessors/TransitionPreprocessor.swift
View file @
9fd0e15e
...
...
@@ -28,7 +28,7 @@
import
UIKit
public
enum
MotionTransitionType
{
public
enum
MotionTransition
Animation
Type
{
public
enum
Direction
{
case
left
case
right
...
...
@@ -50,19 +50,19 @@ public enum MotionTransitionType {
case
zoom
case
zoomOut
indirect
case
selectBy
(
presenting
:
MotionTransition
Type
,
dismissing
:
MotionTransi
tionType
)
indirect
case
selectBy
(
presenting
:
MotionTransition
AnimationType
,
dismissing
:
MotionTransitionAnima
tionType
)
/**
Sets the presenting and dismissing transitions.
- Parameter presenting: A MotionTransitionType.
- Returns: A MotionTransitionType.
- Parameter presenting: A MotionTransition
Animation
Type.
- Returns: A MotionTransition
Animation
Type.
*/
public
static
func
autoReverse
(
presenting
:
MotionTransition
Type
)
->
MotionTransi
tionType
{
public
static
func
autoReverse
(
presenting
:
MotionTransition
AnimationType
)
->
MotionTransitionAnima
tionType
{
return
.
selectBy
(
presenting
:
presenting
,
dismissing
:
presenting
.
reversed
())
}
/// Returns a reversal transition.
func
reversed
()
->
MotionTransitionType
{
func
reversed
()
->
MotionTransition
Animation
Type
{
switch
self
{
case
.
push
(
direction
:
.
up
):
return
.
pull
(
direction
:
.
down
)
...
...
@@ -218,7 +218,9 @@ class TransitionPreprocessor: MotionCorePreprocessor {
}
if
case
.
auto
=
defaultAnimation
{
if
animators
.
contains
(
where
:
{
$0
.
canAnimate
(
view
:
tv
,
isAppearing
:
true
)
||
$0
.
canAnimate
(
view
:
fv
,
isAppearing
:
false
)
})
{
if
animators
.
contains
(
where
:
{
$0
.
canAnimate
(
view
:
tv
,
isAppearing
:
true
)
||
$0
.
canAnimate
(
view
:
fv
,
isAppearing
:
false
)
})
{
defaultAnimation
=
.
none
}
else
if
isNavigationController
{
...
...
@@ -239,14 +241,16 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
fv
]
=
[
.
timingFunction
(
.
standard
),
.
duration
(
0.35
)]
context
[
tv
]
=
[
.
timingFunction
(
.
standard
),
.
duration
(
0.35
)]
let
shadowState
:
[
Motion
Transition
]
=
[
.
shadow
(
opacity
:
0.5
),
.
shadow
(
color
:
.
black
),
.
shadow
(
radius
:
5
),
.
shadow
(
offset
:
.
zero
),
.
masksToBounds
(
false
)]
let
shadowState
:
[
Motion
Modifier
]
=
[
.
shadow
(
opacity
:
0.5
),
.
shadow
(
color
:
.
black
),
.
shadow
(
radius
:
5
),
.
shadow
(
offset
:
.
zero
),
.
masksToBounds
(
false
)]
switch
defaultAnimation
{
case
.
push
(
let
direction
):
context
.
insertToViewFirst
=
false
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transitions
:
shadowState
),
...
...
@@ -277,6 +281,8 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)),
.
scale
(
0.8
)])
case
.
cover
(
let
direction
):
context
.
insertToViewFirst
=
false
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transitions
:
shadowState
),
...
...
@@ -295,6 +301,8 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
tv
]
!.
append
(
contentsOf
:
[
.
overlay
(
color
:
.
black
,
opacity
:
0.1
)])
case
.
pageIn
(
let
direction
):
context
.
insertToViewFirst
=
false
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transitions
:
shadowState
),
...
...
@@ -333,10 +341,13 @@ class TransitionPreprocessor: MotionCorePreprocessor {
case
.
zoom
:
context
.
insertToViewFirst
=
true
context
[
fv
]
!.
append
(
contentsOf
:
[
.
scale
(
1.3
),
.
fadeOut
])
context
[
tv
]
!.
append
(
contentsOf
:
[
.
scale
(
0.7
)])
case
.
zoomOut
:
context
.
insertToViewFirst
=
false
context
[
tv
]
!.
append
(
contentsOf
:
[
.
scale
(
1.3
),
.
fadeOut
])
context
[
fv
]
!.
append
(
contentsOf
:
[
.
scale
(
0.7
)])
...
...
@@ -347,7 +358,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
/**
Shifts the transition by a given size.
- Parameter direction: A MotionTransitionType.Direction.
- Parameter direction: A MotionTransition
Animation
Type.Direction.
- Parameter isAppearing: A boolean indicating whether it is appearing
or not.
- Parameter size: An optional CGSize.
...
...
@@ -355,7 +366,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
and `y` point for `x`.
- Returns: A CGPoint.
*/
func
shift
(
direction
:
MotionTransitionType
.
Direction
,
isAppearing
:
Bool
,
size
:
CGSize
?
=
nil
,
transpose
:
Bool
=
false
)
->
CGPoint
{
func
shift
(
direction
:
MotionTransition
Animation
Type
.
Direction
,
isAppearing
:
Bool
,
size
:
CGSize
?
=
nil
,
transpose
:
Bool
=
false
)
->
CGPoint
{
let
size
=
size
??
context
.
container
.
bounds
.
size
let
point
:
CGPoint
...
...
Sources/
Mo
tion+Animate.swift
→
Sources/
Transition/MotionTransi
tion+Animate.swift
View file @
9fd0e15e
...
...
@@ -28,7 +28,7 @@
import
UIKit
extension
Motion
{
extension
Motion
Transition
{
/// Starts the transition animation.
func
animate
()
{
guard
.
starting
==
state
else
{
...
...
@@ -85,7 +85,6 @@ extension Motion {
return
animator
.
canAnimate
(
view
:
$0
,
isAppearing
:
true
)
})
print
(
"T"
,
t
,
"DURATION"
,
duration
)
if
.
infinity
==
duration
{
animatorWantsInteractive
=
true
}
else
{
...
...
@@ -95,12 +94,10 @@ extension Motion {
totalDuration
=
t
print
(
"T"
,
t
)
if
let
forceFinishing
=
forceFinishing
{
complete
(
isFinishing
:
forceFinishing
)
}
else
if
let
startingProgress
=
startingProgress
{
update
(
elapsedTime
:
startingProgress
)
update
(
startingProgress
)
}
else
if
animatorWantsInteractive
{
update
(
elapsedTime
:
0
)
}
else
{
...
...
Sources/
Mo
tion+Complete.swift
→
Sources/
Transition/MotionTransi
tion+Complete.swift
View file @
9fd0e15e
...
...
@@ -28,7 +28,7 @@
import
UIKit
extension
Motion
{
extension
Motion
Transition
{
/**
Complete the transition.
- Parameter after: A TimeInterval.
...
...
@@ -36,7 +36,7 @@ extension Motion {
has completed.
*/
func
complete
(
after
:
TimeInterval
,
isFinishing
:
Bool
)
{
guard
[
MotionState
.
animating
,
.
starting
,
.
notified
]
.
contains
(
state
)
else
{
guard
[
Motion
Transition
State
.
animating
,
.
starting
,
.
notified
]
.
contains
(
state
)
else
{
return
}
...
...
Sources/
Mo
tion+Start.swift
→
Sources/
Transition/MotionTransi
tion+Start.swift
View file @
9fd0e15e
...
...
@@ -28,7 +28,7 @@
import
UIKit
extension
Motion
{
extension
Motion
Transition
{
/// Starts the transition animation.
func
start
()
{
guard
.
notified
==
state
else
{
...
...
@@ -55,7 +55,7 @@ extension Motion {
}
}
fileprivate
extension
Motion
{
fileprivate
extension
Motion
Transition
{
/// Prepares the views frames.
func
prepareViewFrame
()
{
guard
let
fv
=
fromView
else
{
...
...
@@ -119,10 +119,10 @@ fileprivate extension Motion {
/// Prepares the animators.
func
prepareAnimators
()
{
animators
.
append
(
MotionT
ransition
Animator
<
MotionCoreAnimationViewContext
>
())
animators
.
append
(
MotionT
argetState
Animator
<
MotionCoreAnimationViewContext
>
())
if
#available(iOS 10, tvOS 10, *)
{
animators
.
append
(
MotionT
ransition
Animator
<
MotionViewPropertyViewContext
>
())
animators
.
append
(
MotionT
argetState
Animator
<
MotionViewPropertyViewContext
>
())
}
for
v
in
animators
{
...
...
@@ -132,7 +132,7 @@ fileprivate extension Motion {
/// Prepares the plugins.
func
preparePlugins
()
{
for
x
in
Motion
.
enabledPlugins
.
map
({
for
x
in
Motion
Transition
.
enabledPlugins
.
map
({
return
$0
.
init
()
})
{
plugins
.
append
(
x
)
...
...
@@ -162,7 +162,7 @@ fileprivate extension Motion {
container
=
UIView
(
frame
:
transitionContainer
?
.
bounds
??
.
zero
)
if
!
toOverFullScreen
&&
!
fromOverFullScreen
{
updateContainerBackgroundColor
()
container
.
backgroundColor
=
containerBackgroundColor
}
transitionContainer
?
.
addSubview
(
container
)
...
...
@@ -243,7 +243,7 @@ fileprivate extension Motion {
}
}
fileprivate
extension
Motion
{
fileprivate
extension
Motion
Transition
{
/// Executes the preprocessors' process function.
func
processPreprocessors
()
{
for
v
in
preprocessors
{
...
...
Sources/
Mo
tion.swift
→
Sources/
Transition/MotionTransi
tion.swift
View file @
9fd0e15e
...
...
@@ -32,81 +32,81 @@ import UIKit
public
protocol
MotionViewControllerDelegate
{
/**
An optional delegation method that is executed motion will start the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motionWillStartTransition
(
motion
:
Motion
)
optional
func
motionWillStartTransition
(
motion
:
Motion
Transition
)
/**
An optional delegation method that is executed motion did end the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motionDidEndTransition
(
motion
:
Motion
)
optional
func
motionDidEndTransition
(
motion
:
Motion
Transition
)
/**
An optional delegation method that is executed motion did cancel the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motionDidCancelTransition
(
motion
:
Motion
)
optional
func
motionDidCancelTransition
(
motion
:
Motion
Transition
)
/**
An optional delegation method that is executed when the source
view controller will start the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motion
(
motion
:
Motion
,
willStartTransitionFrom
viewController
:
UIViewController
)
optional
func
motion
(
motion
:
Motion
Transition
,
willStartTransitionFrom
viewController
:
UIViewController
)
/**
An optional delegation method that is executed when the source
view controller did end the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motion
(
motion
:
Motion
,
didEndTransitionFrom
viewController
:
UIViewController
)
optional
func
motion
(
motion
:
Motion
Transition
,
didEndTransitionFrom
viewController
:
UIViewController
)
/**
An optional delegation method that is executed when the source
view controller did cancel the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motion
(
motion
:
Motion
,
didCancelTransitionFrom
viewController
:
UIViewController
)
optional
func
motion
(
motion
:
Motion
Transition
,
didCancelTransitionFrom
viewController
:
UIViewController
)
/**
An optional delegation method that is executed when the destination
view controller will start the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motion
(
motion
:
Motion
,
willStartTransitionTo
viewController
:
UIViewController
)
optional
func
motion
(
motion
:
Motion
Transition
,
willStartTransitionTo
viewController
:
UIViewController
)
/**
An optional delegation method that is executed when the destination
view controller did end the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motion
(
motion
:
Motion
,
didEndTransitionTo
viewController
:
UIViewController
)
optional
func
motion
(
motion
:
Motion
Transition
,
didEndTransitionTo
viewController
:
UIViewController
)
/**
An optional delegation method that is executed when the destination
view controller did cancel the transition.
- Parameter motion: A Motion instance.
- Parameter motion: A Motion
Transition
instance.
- Parameter willStartTransitionFrom viewController: A UIViewController.
*/
@objc
optional
func
motion
(
motion
:
Motion
,
didCancelTransitionTo
viewController
:
UIViewController
)
optional
func
motion
(
motion
:
Motion
Transition
,
didCancelTransitionTo
viewController
:
UIViewController
)
}
/**
...
...
@@ -122,88 +122,142 @@ public protocol MotionViewControllerDelegate {
func update(progress:Double)
func end()
func cancel()
func apply(transitions: [MotionT
ransition
], to view: UIView)
func apply(transitions: [MotionT
argetState
], to view: UIView)
```
*/
import
UIKit
public
class
Motion
:
NSObject
,
MotionProgressRunnerDelegate
{
public
class
Motion
:
NSObject
{
/// Shared singleton object for controlling the transition
public
static
let
shared
=
Motion
()
/// A boolean indicating if the user may interact with the
/// view controller while in transition.
public
var
isUserInteractionEnabled
=
false
public
static
let
shared
=
MotionTransition
()
}
public
typealias
MotionCancelBlock
=
(
Bool
)
->
Void
extension
Motion
{
/**
Executes a block of code asynchronously on the main thread.
- Parameter execute: A block that is executed asynchronously on the main thread.
*/
public
class
func
async
(
_
execute
:
@escaping
()
->
Void
)
{
DispatchQueue
.
main
.
async
(
execute
:
execute
)
}
/// A reference to the MotionViewOrderStrategy.
public
var
viewOrderStrategy
=
MotionViewOrderStrategy
.
auto
/**
Executes a block of code after a time delay.
- Parameter _ time: A delay time.
- Parameter execute: A block that is executed once delay has passed.
- Returns: An optional MotionCancelBlock.
*/
@discardableResult
public
class
func
delay
(
_
time
:
TimeInterval
,
execute
:
@escaping
()
->
Void
)
->
MotionCancelBlock
?
{
var
cancelable
:
MotionCancelBlock
?
let
delayed
:
MotionCancelBlock
=
{
if
!
$0
{
async
(
execute
)
}
cancelable
=
nil
}
cancelable
=
delayed
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
time
)
{
cancelable
?(
false
)
}
return
cancelable
}
/// Plugins that are enabled during the transition.
internal
static
var
enabledPlugins
=
[
MotionPlugin
.
Type
]()
/**
Cancels the delayed MotionCancelBlock.
- Parameter delayed completion: An MotionCancelBlock.
*/
public
class
func
cancel
(
delayed
completion
:
MotionCancelBlock
)
{
completion
(
true
)
}
/// A reference to a fullscreen snapshot.
internal
var
fullScreenSnapshot
:
UIView
!
/**
Disables the default animations set on CALayers.
- Parameter animations: A callback that wraps the animations to disable.
*/
public
class
func
disable
(
_
animations
:
(()
->
Void
))
{
animate
(
duration
:
0
,
animations
:
animations
)
}
/// A reference to the MotionContext.
public
internal(set)
var
context
:
MotionContext
!
/**
Runs an animation with a specified duration.
- Parameter duration: An animation duration time.
- Parameter animations: An animation block.
- Parameter timingFunction: A CAMediaTimingFunction.
- Parameter completion: A completion block that is executed once
the animations have completed.
*/
public
class
func
animate
(
duration
:
CFTimeInterval
,
timingFunction
:
CAMediaTimingFunction
=
.
easeInOut
,
animations
:
(()
->
Void
),
completion
:
(()
->
Void
)?
=
nil
)
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
duration
)
CATransaction
.
setCompletionBlock
(
completion
)
CATransaction
.
setAnimationTimingFunction
(
timingFunction
)
animations
()
CATransaction
.
commit
()
}
/// A boolean indicating whether the transition interactive or not.
public
var
isInteractive
:
Bool
{
return
!
progressRunner
.
isRunning
/**
Creates a CAAnimationGroup.
- Parameter animations: An Array of CAAnimation objects.
- Parameter timingFunction: A CAMediaTimingFunction.
- Parameter duration: An animation duration time for the group.
- Returns: A CAAnimationGroup.
*/
public
class
func
animate
(
group
animations
:
[
CAAnimation
],
timingFunction
:
CAMediaTimingFunction
=
.
easeInOut
,
duration
:
CFTimeInterval
=
0.5
)
->
CAAnimationGroup
{
let
group
=
CAAnimationGroup
()
group
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
both
)
group
.
isRemovedOnCompletion
=
false
group
.
animations
=
animations
group
.
duration
=
duration
group
.
timingFunction
=
timingFunction
return
group
}
}
public
enum
MotionTransitionState
:
Int
{
/// Motion is able to start a new transition.
case
possible
/// Source view controller.
public
internal(set)
var
fromViewController
:
UIViewController
?
/// UIKit has notified Motion about a pending transition.
/// Motion hasn't started preparation.
case
notified
///
Destination view controller
.
public
internal(set)
var
toViewController
:
UIViewController
?
///
Motion's `start` method has been called. Preparing the animation
.
case
starting
/// A reference to the fromView, fromViewController.view.
internal
var
fromView
:
UIView
?
{
return
fromViewController
?
.
view
}
/// Motions's `animate` method has been called. Animation has started.
case
animating
/// A reference to the toView, toViewController.view.
internal
var
toView
:
UIView
?
{
return
toViewController
?
.
view
}
/// Motions's `complete` method has been called. Transition has ended or has
/// been cancelled. Motion is cleaning up.
case
completing
}
open
class
MotionTransition
:
NSObject
{
/// Default animation type.
internal
var
defaultAnimation
=
MotionTransitionAnimationType
.
auto
/// The color of the transitioning container.
internal
var
containerBackgroundColor
:
UIColor
?
internal
var
containerBackgroundColor
=
UIColor
.
black
/**
A UIViewControllerContextTransitioning object provided by UIKit, which
might be nil when isTransitioning. This happens when calling motionReplaceViewController
*/
internal
weak
var
transitionContext
:
UIViewControllerContextTransitioning
?
/// A boolean indicating if the user may interact with the
/// view controller while in transition.
public
var
isUserInteractionEnabled
=
false
/// Progress of the current transition. 0 if no transition is happening.
public
internal(set)
var
elapsedTime
:
TimeInterval
=
0
{
didSet
{
guard
.
animating
==
state
else
{
return
}
updateTransitionObservers
()
if
isInteractive
{
updateAnimators
()
}
else
{
updatePlugins
()
}
transitionContext
?
.
updateInteractiveTransition
(
CGFloat
(
elapsedTime
))
}
}
/// A reference to the MotionViewOrderStrategy.
public
var
viewOrderStrategy
=
MotionViewOrderStrategy
.
auto
/// State of the transition.
public
internal(set)
var
state
=
MotionState
.
possible
{
public
internal(set)
var
state
=
Motion
Transition
State
.
possible
{
didSet
{
guard
.
notified
!=
state
else
{
return
}
guard
.
starting
!=
state
else
{
guard
.
notified
!=
state
,
.
starting
!=
state
else
{
return
}
...
...
@@ -220,6 +274,11 @@ public class Motion: NSObject, MotionProgressRunnerDelegate {
/// Whether or not we are presenting the destination view controller.
public
internal(set)
var
isPresenting
=
true
/// A boolean indicating whether the transition interactive or not.
public
var
isInteractive
:
Bool
{
return
!
progressRunner
.
isRunning
}
/**
A view container used to hold all the animating views during a
transition.
...
...
@@ -235,22 +294,6 @@ public class Motion: NSObject, MotionProgressRunnerDelegate {
/// An optional completion callback.
internal
var
completionCallback
:
((
Bool
)
->
Void
)?
/// An Array of observers that are updated during a transition.
internal
var
transitionObservers
:
[
MotionTransitionObserver
]?
/// Max duration used by MotionAnimators and MotionPlugins.
public
internal(set)
var
totalDuration
:
TimeInterval
=
0
/// The currently running animation duration.
internal
var
currentAnimationDuration
:
TimeInterval
=
0
/// A reference to a MotionProgressRunner.
lazy
var
progressRunner
:
MotionProgressRunner
=
{
let
runner
=
MotionProgressRunner
()
runner
.
delegate
=
self
return
runner
}()
/// A boolean indicating if the transition has finished.
internal
var
isFinishing
=
true
...
...
@@ -267,8 +310,68 @@ public class Motion: NSObject, MotionProgressRunnerDelegate {
internal
var
animatingFromViews
=
[
UIView
]()
internal
var
animatingToViews
=
[
UIView
]()
/// Default animation type.
internal
var
defaultAnimation
=
MotionTransitionType
.
auto
/// Plugins that are enabled during the transition.
internal
static
var
enabledPlugins
=
[
MotionPlugin
.
Type
]()
/// Source view controller.
public
internal(set)
var
fromViewController
:
UIViewController
?
/// A reference to the fromView, fromViewController.view.
internal
var
fromView
:
UIView
?
{
return
fromViewController
?
.
view
}
/// Destination view controller.
public
internal(set)
var
toViewController
:
UIViewController
?
/// A reference to the toView, toViewController.view.
internal
var
toView
:
UIView
?
{
return
toViewController
?
.
view
}
/// An Array of observers that are updated during a transition.
internal
var
transitionObservers
:
[
MotionTargetStateObserver
]?
/// Max duration used by MotionAnimators and MotionPlugins.
public
internal(set)
var
totalDuration
:
TimeInterval
=
0
/**
A UIViewControllerContextTransitioning object provided by UIKit, which
might be nil when isTransitioning. This happens when calling motionReplaceViewController
*/
internal
weak
var
transitionContext
:
UIViewControllerContextTransitioning
?
/// A reference to the MotionContext.
public
internal(set)
var
context
:
MotionContext
!
/// A reference to a fullscreen snapshot.
internal
var
fullScreenSnapshot
:
UIView
?
/// Progress of the current transition. 0 if no transition is happening.
public
internal(set)
var
elapsedTime
:
TimeInterval
=
0
{
didSet
{
guard
.
animating
==
state
else
{
return
}
updateTransitionObservers
()
if
isInteractive
{
updateAnimators
()
}
else
{
updatePlugins
()
}
transitionContext
?
.
updateInteractiveTransition
(
CGFloat
(
elapsedTime
))
}
}
/// A reference to a MotionProgressRunner.
lazy
var
progressRunner
:
MotionProgressRunner
=
{
let
runner
=
MotionProgressRunner
()
runner
.
delegate
=
self
return
runner
}()
/**
By default, Motion will always appear to be interactive to UIKit. This forces it to appear non-interactive.
...
...
@@ -314,13 +417,19 @@ public class Motion: NSObject, MotionProgressRunnerDelegate {
}
}
public
extension
Motion
{
extension
MotionTransition
:
MotionProgressRunnerDelegate
{
func
update
(
elapsedTime
:
TimeInterval
)
{
self
.
elapsedTime
=
elapsedTime
}
}
extension
MotionTransition
{
/**
Receive callbacks on each animation frame.
Observers will be cleaned when a transition completes.
- Parameter observer: A MotionT
ransition
Observer.
- Parameter observer: A MotionT
argetState
Observer.
*/
func
addTransitionObserver
(
observer
:
MotionT
ransition
Observer
)
{
func
addTransitionObserver
(
observer
:
MotionT
argetState
Observer
)
{
if
nil
==
transitionObservers
{
transitionObservers
=
[]
}
...
...
@@ -329,7 +438,7 @@ public extension Motion {
}
}
private
extension
Mo
tion
{
fileprivate
extension
MotionTransi
tion
{
/// Updates the transition observers.
func
updateTransitionObservers
()
{
guard
let
observers
=
transitionObservers
else
{
...
...
@@ -358,44 +467,19 @@ private extension Motion {
}
}
public
extension
Motion
{
public
extension
Motion
Transition
{
/**
Updates the elapsed time for the interactive transition.
- Parameter elapsedTime t: the current progress, must be between -1...1.
*/
public
func
update
(
elapsedTim
e
:
TimeInterval
)
{
public
func
update
(
_
percentageComplet
e
:
TimeInterval
)
{
guard
.
animating
==
state
else
{
startingProgress
=
elapsedTim
e
startingProgress
=
percentageComplet
e
return
}
progressRunner
.
stop
()
self
.
elapsedTime
=
Double
(
CGFloat
(
elapsedTime
)
.
clamp
(
0
,
1
))
}
/**
Finish the interactive transition.
Will stop the interactive transition and animate from the
current state to the **end** state
- Parameter isAnimated: A boolean indicating if the completion is animated.
*/
public
func
end
(
isAnimated
:
Bool
=
true
)
{
guard
isTransitioning
else
{
return
}
guard
isAnimated
else
{
complete
(
isFinishing
:
true
)
return
}
var
t
:
TimeInterval
=
0
for
a
in
animators
{
t
=
max
(
t
,
a
.
resume
(
at
:
elapsedTime
*
totalDuration
,
isReversed
:
false
))
}
complete
(
after
:
t
,
isFinishing
:
true
)
elapsedTime
=
Double
(
CGFloat
(
percentageComplete
)
.
clamp
(
0
,
1
))
}
/**
...
...
@@ -436,36 +520,28 @@ public extension Motion {
Motion.shared.apply([.position(x:50, y:50)], to: view)
will set the view's position to 50, 50
- Parameter
transitions: An Array of MotionTransitions
.
- Parameter
modifiers: An Array of MotionModifier
.
- Parameter to view: A UIView.
*/
public
func
apply
(
transitions
:
[
MotionTransition
],
to
view
:
UIView
)
{
guard
isTransitioning
else
{
public
func
apply
(
modifiers
:
[
MotionModifier
],
to
view
:
UIView
)
{
guard
.
animating
==
state
else
{
return
}
let
s
=
MotionTransitionState
(
transitions
:
transition
s
)
let
v
=
context
.
pairedView
(
for
:
view
)
??
view
for
a
in
animators
{
a
.
apply
(
state
:
s
,
to
:
v
)
let
targetState
=
MotionTargetState
(
modifiers
:
modifier
s
)
if
let
otherView
=
context
.
pairedView
(
for
:
view
)
{
for
animator
in
animators
{
animator
.
apply
(
state
:
targetState
,
to
:
otherView
)
}
}
}
}
internal
extension
Motion
{
/// Updates the container background color.
func
updateContainerBackgroundColor
()
{
if
let
v
=
containerBackgroundColor
{
container
?
.
backgroundColor
=
v
}
else
if
!
toOverFullScreen
&&
!
fromOverFullScreen
{
container
?
.
backgroundColor
=
toView
?
.
backgroundColor
for
animator
in
self
.
animators
{
animator
.
apply
(
state
:
targetState
,
to
:
view
)
}
}
}
internal
extension
Motion
{
internal
extension
Motion
Transition
{
/**
Checks if a given plugin is enabled.
- Parameter plugin: A MotionPlugin.Type.
...
...
@@ -497,7 +573,7 @@ internal extension Motion {
}
}
public
extension
Motion
{
public
extension
Motion
Transition
{
/// Turn off built-in animations for the next transition.
func
disableDefaultAnimationForNextTransition
()
{
defaultAnimation
=
.
none
...
...
@@ -505,23 +581,23 @@ public extension Motion {
/**
Set the default animation for the next transition. This may override the
root-view's motion
Transition
s during the transition.
- Parameter animation: A MotionTransitionType.
root-view's motion
Modifier
s during the transition.
- Parameter animation: A MotionTransition
Animation
Type.
*/
func
setAnimationForNextTransition
(
_
animation
:
MotionTransitionType
)
{
func
setAnimationForNextTransition
(
_
animation
:
MotionTransition
Animation
Type
)
{
defaultAnimation
=
animation
}
/**
Set the container background color for the next transition.
- Parameter _ color: A
n optional
UIColor.
- Parameter _ color: A UIColor.
*/
func
setContainerBackgroundColorForNextTransition
(
_
color
:
UIColor
?
)
{
func
setContainerBackgroundColorForNextTransition
(
_
color
:
UIColor
)
{
containerBackgroundColor
=
color
}
}
public
extension
Motion
{
public
extension
Motion
Transition
{
/**
A helper transition function.
- Parameter from: A UIViewController.
...
...
@@ -545,7 +621,7 @@ public extension Motion {
}
}
internal
extension
Motion
{
internal
extension
Motion
Transition
{
/**
Processes the start transition delegation methods.
- Parameter fromViewController: An optional UIViewController.
...
...
@@ -661,7 +737,7 @@ internal extension Motion {
}
}
internal
extension
Motion
{
internal
extension
Motion
Transition
{
/**
Helper for processing the MotionViewControllerDelegate.
- Parameter viewController: A UIViewController of type `T`.
...
...
@@ -684,7 +760,7 @@ internal extension Motion {
}
}
extension
Motion
:
UIViewControllerAnimatedTransitioning
{
extension
Motion
Transition
:
UIViewControllerAnimatedTransitioning
{
/**
The animation method that is used to coordinate the transition.
- Parameter using transitionContext: A UIViewControllerContextTransitioning.
...
...
@@ -716,7 +792,7 @@ extension Motion: UIViewControllerAnimatedTransitioning {
}
}
extension
Motion
:
UIViewControllerTransitioningDelegate
{
extension
Motion
Transition
:
UIViewControllerTransitioningDelegate
{
/// A reference to the interactive transitioning instance.
var
interactiveTransitioning
:
UIViewControllerInteractiveTransitioning
?
{
return
forceNonInteractive
?
nil
:
self
...
...
@@ -755,7 +831,7 @@ extension Motion: UIViewControllerTransitioningDelegate {
}
}
extension
Motion
:
UIViewControllerInteractiveTransitioning
{
extension
Motion
Transition
:
UIViewControllerInteractiveTransitioning
{
public
var
wantsInteractiveStart
:
Bool
{
return
true
}
...
...
@@ -765,7 +841,7 @@ extension Motion: UIViewControllerInteractiveTransitioning {
}
}
extension
Motion
:
UINavigationControllerDelegate
{
extension
Motion
Transition
:
UINavigationControllerDelegate
{
public
func
navigationController
(
_
navigationController
:
UINavigationController
,
animationControllerFor
operation
:
UINavigationControllerOperation
,
from
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
...
...
@@ -785,7 +861,7 @@ extension Motion: UINavigationControllerDelegate {
}
}
extension
Motion
:
UITabBarControllerDelegate
{
extension
Motion
Transition
:
UITabBarControllerDelegate
{
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
shouldSelect
viewController
:
UIViewController
)
->
Bool
{
if
isTransitioning
{
cancel
(
isAnimated
:
false
)
...
...
@@ -817,91 +893,3 @@ extension Motion: UITabBarControllerDelegate {
}
}
public
typealias
MotionCancelBlock
=
(
Bool
)
->
Void
extension
Motion
{
/**
Executes a block of code asynchronously on the main thread.
- Parameter execute: A block that is executed asynchronously on the main thread.
*/
public
class
func
async
(
_
execute
:
@escaping
()
->
Void
)
{
DispatchQueue
.
main
.
async
(
execute
:
execute
)
}
/**
Executes a block of code after a time delay.
- Parameter _ time: A delay time.
- Parameter execute: A block that is executed once delay has passed.
- Returns: An optional MotionCancelBlock.
*/
@discardableResult
public
class
func
delay
(
_
time
:
TimeInterval
,
execute
:
@escaping
()
->
Void
)
->
MotionCancelBlock
?
{
var
cancelable
:
MotionCancelBlock
?
let
delayed
:
MotionCancelBlock
=
{
if
!
$0
{
async
(
execute
)
}
cancelable
=
nil
}
cancelable
=
delayed
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
time
)
{
cancelable
?(
false
)
}
return
cancelable
}
/**
Cancels the delayed MotionCancelBlock.
- Parameter delayed completion: An MotionCancelBlock.
*/
public
class
func
cancel
(
delayed
completion
:
MotionCancelBlock
)
{
completion
(
true
)
}
/**
Disables the default animations set on CALayers.
- Parameter animations: A callback that wraps the animations to disable.
*/
public
class
func
disable
(
_
animations
:
(()
->
Void
))
{
animate
(
duration
:
0
,
animations
:
animations
)
}
/**
Runs an animation with a specified duration.
- Parameter duration: An animation duration time.
- Parameter animations: An animation block.
- Parameter timingFunction: A CAMediaTimingFunction.
- Parameter completion: A completion block that is executed once
the animations have completed.
*/
public
class
func
animate
(
duration
:
CFTimeInterval
,
timingFunction
:
CAMediaTimingFunction
=
.
easeInOut
,
animations
:
(()
->
Void
),
completion
:
(()
->
Void
)?
=
nil
)
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
duration
)
CATransaction
.
setCompletionBlock
(
completion
)
CATransaction
.
setAnimationTimingFunction
(
timingFunction
)
animations
()
CATransaction
.
commit
()
}
/**
Creates a CAAnimationGroup.
- Parameter animations: An Array of CAAnimation objects.
- Parameter timingFunction: A CAMediaTimingFunction.
- Parameter duration: An animation duration time for the group.
- Returns: A CAAnimationGroup.
*/
public
class
func
animate
(
group
animations
:
[
CAAnimation
],
timingFunction
:
CAMediaTimingFunction
=
.
easeInOut
,
duration
:
CFTimeInterval
=
0.5
)
->
CAAnimationGroup
{
let
group
=
CAAnimationGroup
()
group
.
fillMode
=
MotionAnimationFillModeToValue
(
mode
:
.
both
)
group
.
isRemovedOnCompletion
=
false
group
.
animations
=
animations
group
.
duration
=
duration
group
.
timingFunction
=
timingFunction
return
group
}
}
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