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
1c31140b
Commit
1c31140b
authored
Jul 30, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor code cleanup
parent
2fd5d3b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
33 deletions
+34
-33
Motion.xcodeproj/project.pbxproj
+2
-2
Sources/Extensions/Motion+CAMediaTimingFunction.swift
+5
-5
Sources/Motion.swift
+27
-26
No files found.
Motion.xcodeproj/project.pbxproj
View file @
1c31140b
...
@@ -142,8 +142,6 @@
...
@@ -142,8 +142,6 @@
96E4093B1F24F7370015A2B5
/* Sources */
=
{
96E4093B1F24F7370015A2B5
/* Sources */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
96E4093C1F24F7370015A2B5
/* Animator */
,
96E409431F24F7370015A2B5
/* Extensions */
,
96E409BB1F24FC210015A2B5
/* Info.plist */
,
96E409BB1F24FC210015A2B5
/* Info.plist */
,
96E409BC1F24FC300015A2B5
/* LICENSE */
,
96E409BC1F24FC300015A2B5
/* LICENSE */
,
96E4094F1F24F7370015A2B5
/* Motion.h */
,
96E4094F1F24F7370015A2B5
/* Motion.h */
,
...
@@ -160,6 +158,8 @@
...
@@ -160,6 +158,8 @@
96E4095A1F24F7370015A2B5
/* MotionTransition.swift */
,
96E4095A1F24F7370015A2B5
/* MotionTransition.swift */
,
96E4095B1F24F7370015A2B5
/* MotionTransitionObserver.swift */
,
96E4095B1F24F7370015A2B5
/* MotionTransitionObserver.swift */
,
96E4095C1F24F7370015A2B5
/* MotionTransitionState.swift */
,
96E4095C1F24F7370015A2B5
/* MotionTransitionState.swift */
,
96E4093C1F24F7370015A2B5
/* Animator */
,
96E409431F24F7370015A2B5
/* Extensions */
,
96E4095D1F24F7370015A2B5
/* Preprocessors */
,
96E4095D1F24F7370015A2B5
/* Preprocessors */
,
);
);
path
=
Sources
;
path
=
Sources
;
...
...
Sources/Extensions/Motion+CAMediaTimingFunction.swift
View file @
1c31140b
...
@@ -25,22 +25,22 @@
...
@@ -25,22 +25,22 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* THE SOFTWARE.
*/
*/
import
UIKit
import
UIKit
public
extension
CAMediaTimingFunction
{
public
extension
CAMediaTimingFunction
{
//
d
efault
//
D
efault
static
let
linear
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionLinear
)
static
let
linear
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionLinear
)
static
let
easeIn
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseIn
)
static
let
easeIn
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseIn
)
static
let
easeOut
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseOut
)
static
let
easeOut
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseOut
)
static
let
easeInOut
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
static
let
easeInOut
=
CAMediaTimingFunction
(
name
:
kCAMediaTimingFunctionEaseInEaseOut
)
//
m
aterial
//
M
aterial
static
let
standard
=
CAMediaTimingFunction
(
controlPoints
:
0.4
,
0.0
,
0.2
,
1.0
)
static
let
standard
=
CAMediaTimingFunction
(
controlPoints
:
0.4
,
0.0
,
0.2
,
1.0
)
static
let
deceleration
=
CAMediaTimingFunction
(
controlPoints
:
0.0
,
0.0
,
0.2
,
1
)
static
let
deceleration
=
CAMediaTimingFunction
(
controlPoints
:
0.0
,
0.0
,
0.2
,
1
)
static
let
acceleration
=
CAMediaTimingFunction
(
controlPoints
:
0.4
,
0.0
,
1
,
1
)
static
let
acceleration
=
CAMediaTimingFunction
(
controlPoints
:
0.4
,
0.0
,
1
,
1
)
static
let
sharp
=
CAMediaTimingFunction
(
controlPoints
:
0.4
,
0.0
,
0.6
,
1
)
static
let
sharp
=
CAMediaTimingFunction
(
controlPoints
:
0.4
,
0.0
,
0.6
,
1
)
//
e
asing.net
//
E
asing.net
static
let
easeOutBack
=
CAMediaTimingFunction
(
controlPoints
:
0.175
,
0.885
,
0.32
,
1.75
)
static
let
easeOutBack
=
CAMediaTimingFunction
(
controlPoints
:
0.175
,
0.885
,
0.32
,
1.75
)
}
}
Sources/Motion.swift
View file @
1c31140b
...
@@ -111,13 +111,13 @@ public protocol MotionViewControllerDelegate {
...
@@ -111,13 +111,13 @@ public protocol MotionViewControllerDelegate {
/**
/**
### The singleton class/object for controlling interactive transitions.
### The singleton class/object for controlling interactive transitions.
```swift
```swift
Motion.shared
Motion.shared
```
```
#### Use the following methods for controlling the interactive transition:
#### Use the following methods for controlling the interactive transition:
```swift
```swift
func update(progress:Double)
func update(progress:Double)
func end()
func end()
...
@@ -128,16 +128,16 @@ public protocol MotionViewControllerDelegate {
...
@@ -128,16 +128,16 @@ public protocol MotionViewControllerDelegate {
public
class
Motion
:
MotionController
{
public
class
Motion
:
MotionController
{
/// Shared singleton object for controlling the transition
/// Shared singleton object for controlling the transition
public
static
let
shared
=
Motion
()
public
static
let
shared
=
Motion
()
/// Source view controller.
/// Source view controller.
public
internal(set)
var
fromViewController
:
UIViewController
?
public
internal(set)
var
fromViewController
:
UIViewController
?
/// Destination view controller.
/// Destination view controller.
public
internal(set)
var
toViewController
:
UIViewController
?
public
internal(set)
var
toViewController
:
UIViewController
?
/// Whether or not we are presenting the destination view controller.
/// Whether or not we are presenting the destination view controller.
public
internal(set)
var
isPresenting
=
true
public
internal(set)
var
isPresenting
=
true
/// Progress of the current transition, 0 if a transition is not happening.
/// Progress of the current transition, 0 if a transition is not happening.
public
override
var
elapsedTime
:
TimeInterval
{
public
override
var
elapsedTime
:
TimeInterval
{
didSet
{
didSet
{
...
@@ -148,22 +148,22 @@ public class Motion: MotionController {
...
@@ -148,22 +148,22 @@ public class Motion: MotionController {
transitionContext
?
.
updateInteractiveTransition
(
CGFloat
(
elapsedTime
))
transitionContext
?
.
updateInteractiveTransition
(
CGFloat
(
elapsedTime
))
}
}
}
}
/// Indicates whether the transition is animating or not.
/// Indicates whether the transition is animating or not.
public
var
isAnimating
=
false
public
var
isAnimating
=
false
/**
/**
A UIViewControllerContextTransitioning object provided by UIKit, which
A UIViewControllerContextTransitioning object provided by UIKit, which
might be nil when isTransitioning. This happens when calling motionReplaceViewController
might be nil when isTransitioning. This happens when calling motionReplaceViewController
*/
*/
internal
weak
var
transitionContext
:
UIViewControllerContextTransitioning
?
internal
weak
var
transitionContext
:
UIViewControllerContextTransitioning
?
/// A reference to a fullscreen snapshot.
/// A reference to a fullscreen snapshot.
internal
var
fullScreenSnapshot
:
UIView
!
internal
var
fullScreenSnapshot
:
UIView
!
/// Default animation type.
/// Default animation type.
internal
var
defaultAnimation
=
MotionTransitionType
.
auto
internal
var
defaultAnimation
=
MotionTransitionType
.
auto
/// The color of the transitioning container.
/// The color of the transitioning container.
internal
var
containerBackgroundColor
:
UIColor
?
internal
var
containerBackgroundColor
:
UIColor
?
...
@@ -173,16 +173,16 @@ public class Motion: MotionController {
...
@@ -173,16 +173,16 @@ public class Motion: MotionController {
UINavigationController.setViewControllers not able to handle interactive transitions.
UINavigationController.setViewControllers not able to handle interactive transitions.
*/
*/
internal
var
forceNonInteractive
=
false
internal
var
forceNonInteractive
=
false
/// Inserts the toViews first.
/// Inserts the toViews first.
internal
var
insertToViewFirst
=
false
internal
var
insertToViewFirst
=
false
/// Indicates whether a UINavigationController is transitioning.
/// Indicates whether a UINavigationController is transitioning.
internal
var
isNavigationController
=
false
internal
var
isNavigationController
=
false
/// Indicates whether a UITabBarController is transitioning.
/// Indicates whether a UITabBarController is transitioning.
internal
var
isTabBarController
=
false
internal
var
isTabBarController
=
false
/// Indicates whether a UINavigationController or UITabBarController is transitioning.
/// Indicates whether a UINavigationController or UITabBarController is transitioning.
internal
var
isContainerController
:
Bool
{
internal
var
isContainerController
:
Bool
{
return
isNavigationController
||
isTabBarController
return
isNavigationController
||
isTabBarController
...
@@ -205,7 +205,7 @@ public class Motion: MotionController {
...
@@ -205,7 +205,7 @@ public class Motion: MotionController {
return
!
isContainerController
&&
(
.
overFullScreen
==
v
.
modalPresentationStyle
||
.
overCurrentContext
==
v
.
modalPresentationStyle
)
return
!
isContainerController
&&
(
.
overFullScreen
==
v
.
modalPresentationStyle
||
.
overCurrentContext
==
v
.
modalPresentationStyle
)
}
}
/// A reference to the fromView, fromViewController.view.
/// A reference to the fromView, fromViewController.view.
internal
var
fromView
:
UIView
?
{
internal
var
fromView
:
UIView
?
{
return
fromViewController
?
.
view
return
fromViewController
?
.
view
...
@@ -215,7 +215,7 @@ public class Motion: MotionController {
...
@@ -215,7 +215,7 @@ public class Motion: MotionController {
internal
var
toView
:
UIView
?
{
internal
var
toView
:
UIView
?
{
return
toViewController
?
.
view
return
toViewController
?
.
view
}
}
/// An initializer.
/// An initializer.
internal
override
init
()
{
internal
override
init
()
{
super
.
init
()
super
.
init
()
...
@@ -236,7 +236,7 @@ public extension Motion {
...
@@ -236,7 +236,7 @@ public extension Motion {
func
setAnimationForNextTransition
(
_
animation
:
MotionTransitionType
)
{
func
setAnimationForNextTransition
(
_
animation
:
MotionTransitionType
)
{
defaultAnimation
=
animation
defaultAnimation
=
animation
}
}
/**
/**
Set the container background color for the next transition.
Set the container background color for the next transition.
- Parameter _ color: An optional UIColor.
- Parameter _ color: An optional UIColor.
...
@@ -305,7 +305,7 @@ internal extension Motion {
...
@@ -305,7 +305,7 @@ internal extension Motion {
context
.
clean
()
context
.
clean
()
if
isFinished
&&
isPresenting
&&
toOverFullScreen
{
if
isFinished
&&
isPresenting
&&
toOverFullScreen
{
// finished presenting a overFullScreen
VC
// finished presenting a overFullScreen
view controller.
context
.
unhide
(
rootView
:
tv
)
context
.
unhide
(
rootView
:
tv
)
context
.
removeSnapshots
(
rootView
:
tv
)
context
.
removeSnapshots
(
rootView
:
tv
)
context
.
storeViewAlpha
(
rootView
:
fv
)
context
.
storeViewAlpha
(
rootView
:
fv
)
...
@@ -314,7 +314,7 @@ internal extension Motion {
...
@@ -314,7 +314,7 @@ internal extension Motion {
fv
.
removeFromSuperview
()
fv
.
removeFromSuperview
()
fv
.
addSubview
(
c
)
fv
.
addSubview
(
c
)
}
else
if
!
isFinished
&&
!
isPresenting
&&
fromOverFullScreen
{
}
else
if
!
isFinished
&&
!
isPresenting
&&
fromOverFullScreen
{
//
cancelled dismissing a overFullScreen VC
//
Cancelled dismissing a overFullScreen view controller.
context
.
unhide
(
rootView
:
fv
)
context
.
unhide
(
rootView
:
fv
)
context
.
removeSnapshots
(
rootView
:
fv
)
context
.
removeSnapshots
(
rootView
:
fv
)
context
.
storeViewAlpha
(
rootView
:
tv
)
context
.
storeViewAlpha
(
rootView
:
tv
)
...
@@ -328,7 +328,7 @@ internal extension Motion {
...
@@ -328,7 +328,7 @@ internal extension Motion {
c
.
removeFromSuperview
()
c
.
removeFromSuperview
()
}
}
//
move fromView & toView back from our container back to the one supplied by UIKit
//
Move fromView & toView back from our container back to the one supplied by UIKit.
if
(
toOverFullScreen
&&
isFinished
)
||
(
fromOverFullScreen
&&
!
isFinished
)
{
if
(
toOverFullScreen
&&
isFinished
)
||
(
fromOverFullScreen
&&
!
isFinished
)
{
tc
.
addSubview
(
isFinished
?
fv
:
tv
)
tc
.
addSubview
(
isFinished
?
fv
:
tv
)
}
}
...
@@ -336,7 +336,7 @@ internal extension Motion {
...
@@ -336,7 +336,7 @@ internal extension Motion {
tc
.
addSubview
(
isFinished
?
tv
:
fv
)
tc
.
addSubview
(
isFinished
?
tv
:
fv
)
if
isPresenting
!=
isFinished
,
!
isContainerController
{
if
isPresenting
!=
isFinished
,
!
isContainerController
{
//
only happens when present a .overFullScreen VC
//
Only happens when present a .overFullScreen view controller.
// bug: http://openradar.appspot.com/radar?id=5320103646199808
// bug: http://openradar.appspot.com/radar?id=5320103646199808
UIApplication
.
shared
.
keyWindow
!.
addSubview
(
isPresenting
?
fv
:
tv
)
UIApplication
.
shared
.
keyWindow
!.
addSubview
(
isPresenting
?
fv
:
tv
)
}
}
...
@@ -418,8 +418,9 @@ fileprivate extension Motion {
...
@@ -418,8 +418,9 @@ fileprivate extension Motion {
}
}
context
.
loadViewAlpha
(
rootView
:
tv
)
context
.
loadViewAlpha
(
rootView
:
tv
)
context
.
loadViewAlpha
(
rootView
:
fv
)
v
.
addSubview
(
tv
)
v
.
addSubview
(
tv
)
context
.
loadViewAlpha
(
rootView
:
fv
)
v
.
addSubview
(
fv
)
v
.
addSubview
(
fv
)
}
}
...
@@ -540,11 +541,11 @@ fileprivate extension Motion {
...
@@ -540,11 +541,11 @@ fileprivate extension Motion {
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
$0
.
motion
?(
motion
:
s
,
didEndTransitionTo
:
tvc
)
$0
.
motion
?(
motion
:
s
,
didEndTransitionTo
:
tvc
)
$0
.
motionDidEndTransition
?(
motion
:
s
)
$0
.
motionDidEndTransition
?(
motion
:
s
)
}
}
processForMotionDelegate
(
viewController
:
tvc
)
{
[
weak
self
]
in
processForMotionDelegate
(
viewController
:
tvc
)
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
...
@@ -620,7 +621,7 @@ internal extension Motion {
...
@@ -620,7 +621,7 @@ internal extension Motion {
/**
/**
A helper transition function.
A helper transition function.
- Parameter from: A UIViewController.
- Parameter from: A UIViewController.
- Parameter to: A UIViewController.
- Parameter to: A UIViewController.
- Parameter in view: A UIView.
- Parameter in view: A UIView.
- Parameter completion: An optional completion handler.
- Parameter completion: An optional completion handler.
*/
*/
...
@@ -654,7 +655,7 @@ internal extension Motion {
...
@@ -654,7 +655,7 @@ internal extension Motion {
let
delegate
=
v
.
topViewController
as?
MotionViewControllerDelegate
{
let
delegate
=
v
.
topViewController
as?
MotionViewControllerDelegate
{
execute
(
delegate
)
execute
(
delegate
)
}
}
if
let
v
=
viewController
as?
UITabBarController
,
if
let
v
=
viewController
as?
UITabBarController
,
let
delegate
=
v
.
viewControllers
?[
v
.
selectedIndex
]
as?
MotionViewControllerDelegate
{
let
delegate
=
v
.
viewControllers
?[
v
.
selectedIndex
]
as?
MotionViewControllerDelegate
{
execute
(
delegate
)
execute
(
delegate
)
...
...
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