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
40cbb847
Unverified
Commit
40cbb847
authored
Jun 10, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
phase 1 update for string convertable animation types
parent
a0a1e257
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
47 deletions
+47
-47
Motion.xcodeproj/project.pbxproj
+4
-4
Sources/Extensions/Motion+UIViewController.swift
+26
-26
Sources/Motion.swift
+4
-4
Sources/TransitionPreprocessor.swift
+13
-13
No files found.
Motion.xcodeproj/project.pbxproj
View file @
40cbb847
...
...
@@ -22,7 +22,7 @@
96AEB6901EE4610F009A3BE0
/* MotionViewPropertyViewContext.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB6681EE4610F009A3BE0
/* MotionViewPropertyViewContext.swift */
;
};
96AEB6911EE4610F009A3BE0
/* MotionDebugPlugin.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB66A1EE4610F009A3BE0
/* MotionDebugPlugin.swift */
;
};
96AEB6921EE4610F009A3BE0
/* MotionDebugView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB66B1EE4610F009A3BE0
/* MotionDebugView.swift */
;
};
96AEB6931EE4610F009A3BE0
/*
DefaultAnimationPreprocessor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB66C1EE4610F009A3BE0
/* DefaultAnima
tionPreprocessor.swift */
;
};
96AEB6931EE4610F009A3BE0
/*
TransitionPreprocessor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB66C1EE4610F009A3BE0
/* Transi
tionPreprocessor.swift */
;
};
96AEB6941EE4610F009A3BE0
/* Motion+Array.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB66E1EE4610F009A3BE0
/* Motion+Array.swift */
;
};
96AEB6951EE4610F009A3BE0
/* Motion+CALayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB66F1EE4610F009A3BE0
/* Motion+CALayer.swift */
;
};
96AEB6961EE4610F009A3BE0
/* Motion+CAMediaTimingFunction.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96AEB6701EE4610F009A3BE0
/* Motion+CAMediaTimingFunction.swift */
;
};
...
...
@@ -67,7 +67,7 @@
96AEB6681EE4610F009A3BE0
/* MotionViewPropertyViewContext.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionViewPropertyViewContext.swift
;
sourceTree
=
"<group>"
;
};
96AEB66A1EE4610F009A3BE0
/* MotionDebugPlugin.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionDebugPlugin.swift
;
sourceTree
=
"<group>"
;
};
96AEB66B1EE4610F009A3BE0
/* MotionDebugView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MotionDebugView.swift
;
sourceTree
=
"<group>"
;
};
96AEB66C1EE4610F009A3BE0
/*
DefaultAnimationPreprocessor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
name
=
DefaultAnimationPreprocessor.swift
;
path
=
../DefaultAnima
tionPreprocessor.swift
;
sourceTree
=
"<group>"
;
};
96AEB66C1EE4610F009A3BE0
/*
TransitionPreprocessor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
name
=
TransitionPreprocessor.swift
;
path
=
../Transi
tionPreprocessor.swift
;
sourceTree
=
"<group>"
;
};
96AEB66E1EE4610F009A3BE0
/* Motion+Array.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Motion+Array.swift"
;
sourceTree
=
"<group>"
;
};
96AEB66F1EE4610F009A3BE0
/* Motion+CALayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Motion+CALayer.swift"
;
sourceTree
=
"<group>"
;
};
96AEB6701EE4610F009A3BE0
/* Motion+CAMediaTimingFunction.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Motion+CAMediaTimingFunction.swift"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -165,12 +165,12 @@
isa
=
PBXGroup
;
children
=
(
968989DB1EE65F2B003B8F3D
/* MotionPreprocessor.swift */
,
96AEB66C1EE4610F009A3BE0
/* TransitionPreprocessor.swift */
,
96AEB6881EE4610F009A3BE0
/* CascadePreprocessor.swift */
,
96AEB6891EE4610F009A3BE0
/* DurationPreprocessor.swift */
,
96AEB68A1EE4610F009A3BE0
/* IgnoreSubviewModifiersPreprocessor.swift */
,
96AEB68B1EE4610F009A3BE0
/* MatchPreprocessor.swift */
,
96AEB68C1EE4610F009A3BE0
/* SourcePreprocessor.swift */
,
96AEB66C1EE4610F009A3BE0
/* DefaultAnimationPreprocessor.swift */
,
);
path
=
Preprocessors
;
sourceTree
=
"<group>"
;
...
...
@@ -304,7 +304,7 @@
96AEB6A31EE4610F009A3BE0
/* MotionPlugin.swift in Sources */
,
96AEB69A1EE4610F009A3BE0
/* Motion+UIView.swift in Sources */
,
96AEB6AD1EE4610F009A3BE0
/* DurationPreprocessor.swift in Sources */
,
96AEB6931EE4610F009A3BE0
/*
DefaultAnima
tionPreprocessor.swift in Sources */
,
96AEB6931EE4610F009A3BE0
/*
Transi
tionPreprocessor.swift in Sources */
,
96AEB68F1EE4610F009A3BE0
/* MotionDefaultAnimator.swift in Sources */
,
96AEB69D1EE4610F009A3BE0
/* Motion.swift in Sources */
,
963150D61EE51C7A002B0D42
/* MotionAnimation.swift in Sources */
,
...
...
Sources/Extensions/Motion+UIViewController.swift
View file @
40cbb847
...
...
@@ -32,13 +32,13 @@ fileprivate var AssociatedInstanceKey: UInt8 = 0
fileprivate
struct
AssociatedInstance
{
/// A reference to the modal animation.
var
modal
AnimationType
:
MotionDefaultAnima
tionType
var
modal
TransitionType
:
MotionTransi
tionType
/// A reference to the navigation animation.
var
navigation
AnimationType
:
MotionDefaultAnima
tionType
var
navigation
TransitionType
:
MotionTransi
tionType
/// A reference to the tabBar animation.
var
tabBar
AnimationType
:
MotionDefaultAnima
tionType
var
tabBar
TransitionType
:
MotionTransi
tionType
/// A reference to the stored snapshot.
var
storedSnapshot
:
UIView
?
...
...
@@ -61,9 +61,9 @@ extension UIViewController {
fileprivate
var
associatedInstance
:
AssociatedInstance
{
get
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
AssociatedInstanceKey
)
{
return
AssociatedInstance
(
modal
Anima
tionType
:
.
auto
,
navigation
Anima
tionType
:
.
auto
,
tabBar
Anima
tionType
:
.
auto
,
return
AssociatedInstance
(
modal
Transi
tionType
:
.
auto
,
navigation
Transi
tionType
:
.
auto
,
tabBar
Transi
tionType
:
.
auto
,
storedSnapshot
:
nil
,
previousNavigationDelegate
:
nil
,
previousTabBarDelegate
:
nil
)
...
...
@@ -75,22 +75,22 @@ extension UIViewController {
}
/// default motion animation type for presenting & dismissing modally
public
var
motionModal
AnimationType
:
MotionDefaultAnima
tionType
{
public
var
motionModal
TransitionType
:
MotionTransi
tionType
{
get
{
return
associatedInstance
.
modal
Anima
tionType
return
associatedInstance
.
modal
Transi
tionType
}
set
(
value
)
{
associatedInstance
.
modal
Anima
tionType
=
value
associatedInstance
.
modal
Transi
tionType
=
value
}
}
@IBInspectable
public
var
motionModal
Anima
tionTypeString
:
String
?
{
public
var
motionModal
Transi
tionTypeString
:
String
?
{
get
{
return
associatedInstance
.
modal
Anima
tionType
.
label
return
associatedInstance
.
modal
Transi
tionType
.
label
}
set
(
value
)
{
associatedInstance
.
modal
Anima
tionType
=
value
?
.
parseOne
()
??
.
auto
associatedInstance
.
modal
Transi
tionType
=
value
?
.
parseOne
()
??
.
auto
}
}
...
...
@@ -170,45 +170,45 @@ extension UIViewController {
extension
UINavigationController
{
/// Default motion animation type for push and pop within the navigation controller.
public
var
motionNavigation
AnimationType
:
MotionDefaultAnima
tionType
{
public
var
motionNavigation
TransitionType
:
MotionTransi
tionType
{
get
{
return
associatedInstance
.
navigation
Anima
tionType
return
associatedInstance
.
navigation
Transi
tionType
}
set
(
value
)
{
associatedInstance
.
navigation
Anima
tionType
=
value
associatedInstance
.
navigation
Transi
tionType
=
value
}
}
/// A String representation for the motionNavigation
Anima
tionType.
/// A String representation for the motionNavigation
Transi
tionType.
@IBInspectable
public
var
motionNavigation
Anima
tionTypeString
:
String
?
{
public
var
motionNavigation
Transi
tionTypeString
:
String
?
{
get
{
return
associatedInstance
.
navigation
Anima
tionType
.
label
return
associatedInstance
.
navigation
Transi
tionType
.
label
}
set
(
value
)
{
associatedInstance
.
navigation
Anima
tionType
=
value
?
.
parseOne
()
??
.
auto
associatedInstance
.
navigation
Transi
tionType
=
value
?
.
parseOne
()
??
.
auto
}
}
}
extension
UITabBarController
{
/// Default motion animation type for switching tabs within the tab bar controller.
public
var
motionTabBar
AnimationType
:
MotionDefaultAnima
tionType
{
public
var
motionTabBar
TransitionType
:
MotionTransi
tionType
{
get
{
return
associatedInstance
.
tabBar
Anima
tionType
return
associatedInstance
.
tabBar
Transi
tionType
}
set
(
value
)
{
associatedInstance
.
tabBar
Anima
tionType
=
value
associatedInstance
.
tabBar
Transi
tionType
=
value
}
}
/// A String representation for the motionTabBar
Anima
tionTypeString.
/// A String representation for the motionTabBar
Transi
tionTypeString.
@IBInspectable
public
var
motionTabBar
Anima
tionTypeString
:
String
?
{
public
var
motionTabBar
Transi
tionTypeString
:
String
?
{
get
{
return
associatedInstance
.
tabBar
Anima
tionType
.
label
}
return
associatedInstance
.
tabBar
Transi
tionType
.
label
}
set
(
value
)
{
associatedInstance
.
tabBar
Anima
tionType
=
value
?
.
parseOne
()
??
.
auto
associatedInstance
.
tabBar
Transi
tionType
=
value
?
.
parseOne
()
??
.
auto
}
}
}
...
...
Sources/Motion.swift
View file @
40cbb847
...
...
@@ -81,7 +81,7 @@ public class Motion: MotionController {
internal
var
fullScreenSnapshot
:
UIView
!
/// Default animation type.
internal
var
defaultAnimation
=
Motion
DefaultAnima
tionType
.
auto
internal
var
defaultAnimation
=
Motion
Transi
tionType
.
auto
/// The color of the transitioning container.
internal
var
containerBackgroundColor
:
UIColor
?
...
...
@@ -142,9 +142,9 @@ public extension Motion {
/**
Set the default animation for the next transition. This may override the
root-view's motionTransitions during the transition.
- Parameter animation: A Motion
DefaultAnima
tionType.
- Parameter animation: A Motion
Transi
tionType.
*/
func
setDefaultAnimationForNextTransition
(
_
animation
:
Motion
DefaultAnima
tionType
)
{
func
setDefaultAnimationForNextTransition
(
_
animation
:
Motion
Transi
tionType
)
{
defaultAnimation
=
animation
}
...
...
@@ -344,7 +344,7 @@ fileprivate extension Motion {
internal
extension
Motion
{
override
func
prepareTransition
()
{
super
.
prepareTransition
()
insert
(
preprocessor
:
DefaultAnima
tionPreprocessor
(
motion
:
self
),
before
:
DurationPreprocessor
.
self
)
insert
(
preprocessor
:
Transi
tionPreprocessor
(
motion
:
self
),
before
:
DurationPreprocessor
.
self
)
}
override
func
prepareTransitionPairs
()
{
...
...
Sources/
DefaultAnima
tionPreprocessor.swift
→
Sources/
Transi
tionPreprocessor.swift
View file @
40cbb847
...
...
@@ -28,7 +28,7 @@
import
UIKit
public
enum
Motion
DefaultAnima
tionType
{
public
enum
Motion
Transi
tionType
{
public
enum
Direction
:
MotionStringConvertible
{
case
left
,
right
,
up
,
down
public
static
func
from
(
node
:
ExprNode
)
->
Direction
?
{
...
...
@@ -54,15 +54,15 @@ public enum MotionDefaultAnimationType {
case
zoom
case
zoomOut
indirect
case
selectBy
(
presenting
:
Motion
DefaultAnimationType
,
dismissing
:
MotionDefaultAnima
tionType
)
indirect
case
selectBy
(
presenting
:
Motion
TransitionType
,
dismissing
:
MotionTransi
tionType
)
public
static
func
autoReverse
(
presenting
:
Motion
DefaultAnimationType
)
->
MotionDefaultAnima
tionType
{
public
static
func
autoReverse
(
presenting
:
Motion
TransitionType
)
->
MotionTransi
tionType
{
return
.
selectBy
(
presenting
:
presenting
,
dismissing
:
presenting
.
reversed
())
}
case
none
func
reversed
()
->
Motion
DefaultAnima
tionType
{
func
reversed
()
->
Motion
Transi
tionType
{
switch
self
{
case
.
push
(
direction
:
.
up
):
return
.
pull
(
direction
:
.
down
)
...
...
@@ -152,8 +152,8 @@ public enum MotionDefaultAnimationType {
}
}
extension
Motion
DefaultAnima
tionType
:
MotionStringConvertible
{
public
static
func
from
(
node
:
ExprNode
)
->
Motion
DefaultAnima
tionType
?
{
extension
Motion
Transi
tionType
:
MotionStringConvertible
{
public
static
func
from
(
node
:
ExprNode
)
->
Motion
Transi
tionType
?
{
let
name
:
String
=
node
.
name
let
parameters
:
[
ExprNode
]
=
(
node
as?
CallNode
)?
.
arguments
??
[]
...
...
@@ -197,9 +197,9 @@ extension MotionDefaultAnimationType: MotionStringConvertible {
case
"zoomOut"
:
return
.
zoomOut
case
"selectBy"
:
if
let
presentingNode
=
parameters
.
get
(
0
),
let
presenting
=
Motion
DefaultAnima
tionType
.
from
(
node
:
presentingNode
),
let
presenting
=
Motion
Transi
tionType
.
from
(
node
:
presentingNode
),
let
dismissingNode
=
parameters
.
get
(
1
),
let
dismissing
=
Motion
DefaultAnima
tionType
.
from
(
node
:
dismissingNode
)
{
let
dismissing
=
Motion
Transi
tionType
.
from
(
node
:
dismissingNode
)
{
return
.
selectBy
(
presenting
:
presenting
,
dismissing
:
dismissing
)
}
case
"none"
:
return
.
none
...
...
@@ -209,7 +209,7 @@ extension MotionDefaultAnimationType: MotionStringConvertible {
}
}
class
DefaultAnima
tionPreprocessor
:
MotionPreprocessor
{
class
Transi
tionPreprocessor
:
MotionPreprocessor
{
/// A reference to a MotionContext.
weak
var
context
:
MotionContext
!
...
...
@@ -219,7 +219,7 @@ class DefaultAnimationPreprocessor: MotionPreprocessor {
self
.
motion
=
motion
}
func
shift
(
direction
:
Motion
DefaultAnima
tionType
.
Direction
,
isAppearing
:
Bool
,
size
:
CGSize
?
=
nil
,
transpose
:
Bool
=
false
)
->
CGPoint
{
func
shift
(
direction
:
Motion
Transi
tionType
.
Direction
,
isAppearing
:
Bool
,
size
:
CGSize
?
=
nil
,
transpose
:
Bool
=
false
)
->
CGPoint
{
let
size
=
size
??
context
.
container
.
bounds
.
size
let
rtn
:
CGPoint
switch
direction
{
...
...
@@ -254,11 +254,11 @@ class DefaultAnimationPreprocessor: MotionPreprocessor {
let
animators
=
motion
.
animators
if
case
.
auto
=
defaultAnimation
{
if
inNavigationController
,
let
navAnim
=
toViewController
?
.
navigationController
?
.
motionNavigation
Anima
tionType
{
if
inNavigationController
,
let
navAnim
=
toViewController
?
.
navigationController
?
.
motionNavigation
Transi
tionType
{
defaultAnimation
=
navAnim
}
else
if
inTabBarController
,
let
tabAnim
=
toViewController
?
.
tabBarController
?
.
motionTabBar
Anima
tionType
{
}
else
if
inTabBarController
,
let
tabAnim
=
toViewController
?
.
tabBarController
?
.
motionTabBar
Transi
tionType
{
defaultAnimation
=
tabAnim
}
else
if
let
modalAnim
=
(
presenting
?
toViewController
:
fromViewController
)?
.
motionModal
Anima
tionType
{
}
else
if
let
modalAnim
=
(
presenting
?
toViewController
:
fromViewController
)?
.
motionModal
Transi
tionType
{
defaultAnimation
=
modalAnim
}
}
...
...
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