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
150344a1
Commit
150344a1
authored
Dec 15, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated MotionTransition handling before animation stepping
parent
9fd0e15e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
242 additions
and
144 deletions
+242
-144
Motion.xcodeproj/project.pbxproj
+12
-0
Sources/Animator/MotionCoreAnimationViewContext.swift
+2
-2
Sources/Preprocessors/TransitionPreprocessor.swift
+7
-7
Sources/Transition/MotionTransition+Start.swift
+4
-1
Sources/Transition/MotionTransition+UINavigationControllerDelegate.swift
+49
-0
Sources/Transition/MotionTransition+UITabBarControllerDelegate.swift
+62
-0
Sources/Transition/MotionTransition+UIViewControllerTransitioningDelegate.swift
+106
-0
Sources/Transition/MotionTransition.swift
+0
-134
No files found.
Motion.xcodeproj/project.pbxproj
View file @
150344a1
...
...
@@ -25,6 +25,9 @@
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
,
);
};
};
965FE98D1FE334E10098BDD0
/* MotionTransition+UIViewControllerTransitioningDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE98C1FE334E10098BDD0
/* MotionTransition+UIViewControllerTransitioningDelegate.swift */
;
};
965FE9911FE43DA60098BDD0
/* MotionTransition+UITabBarControllerDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9901FE43DA60098BDD0
/* MotionTransition+UITabBarControllerDelegate.swift */
;
};
965FE9931FE43DE10098BDD0
/* MotionTransition+UINavigationControllerDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965FE9921FE43DE10098BDD0
/* MotionTransition+UINavigationControllerDelegate.swift */
;
};
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 */
;
};
...
...
@@ -98,6 +101,9 @@
965FE96E1FDEFA8B0098BDD0
/* MotionTransition+Animate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"MotionTransition+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>"
;
};
965FE98C1FE334E10098BDD0
/* MotionTransition+UIViewControllerTransitioningDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"MotionTransition+UIViewControllerTransitioningDelegate.swift"
;
sourceTree
=
"<group>"
;
};
965FE9901FE43DA60098BDD0
/* MotionTransition+UITabBarControllerDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"MotionTransition+UITabBarControllerDelegate.swift"
;
sourceTree
=
"<group>"
;
};
965FE9921FE43DE10098BDD0
/* MotionTransition+UINavigationControllerDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"MotionTransition+UINavigationControllerDelegate.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>"
;
};
...
...
@@ -142,6 +148,9 @@
965FE9661FDD99800098BDD0
/* MotionTransition+Start.swift */
,
965FE96E1FDEFA8B0098BDD0
/* MotionTransition+Animate.swift */
,
965FE9621FDCCE030098BDD0
/* MotionTransition+Complete.swift */
,
965FE98C1FE334E10098BDD0
/* MotionTransition+UIViewControllerTransitioningDelegate.swift */
,
965FE9901FE43DA60098BDD0
/* MotionTransition+UITabBarControllerDelegate.swift */
,
965FE9921FE43DE10098BDD0
/* MotionTransition+UINavigationControllerDelegate.swift */
,
);
path
=
Transition
;
sourceTree
=
"<group>"
;
...
...
@@ -345,8 +354,10 @@
965FE9631FDCCE030098BDD0
/* MotionTransition+Complete.swift in Sources */
,
96E4097D1F24F7370015A2B5
/* MotionPlugin.swift in Sources */
,
965FE96D1FDDA6400098BDD0
/* MotionCoreAnimator.swift in Sources */
,
965FE9911FE43DA60098BDD0
/* MotionTransition+UITabBarControllerDelegate.swift in Sources */
,
96E4096E1F24F7370015A2B5
/* Motion+CG.swift in Sources */
,
96E409851F24F7370015A2B5
/* MatchPreprocessor.swift in Sources */
,
965FE9931FE43DE10098BDD0
/* MotionTransition+UINavigationControllerDelegate.swift in Sources */
,
96E409861F24F7370015A2B5
/* MotionPreprocessor.swift in Sources */
,
96E409821F24F7370015A2B5
/* CascadePreprocessor.swift in Sources */
,
96E4096C1F24F7370015A2B5
/* Motion+CALayer.swift in Sources */
,
...
...
@@ -365,6 +376,7 @@
96E4097E1F24F7370015A2B5
/* MotionSnapshotType.swift in Sources */
,
965FE9691FDDA1F20098BDD0
/* MotionViewOrderStrategy.swift in Sources */
,
965FE97A1FE1D83D0098BDD0
/* MotionTransition.swift in Sources */
,
965FE98D1FE334E10098BDD0
/* MotionTransition+UIViewControllerTransitioningDelegate.swift in Sources */
,
96E409871F24F7370015A2B5
/* SourcePreprocessor.swift in Sources */
,
96E409701F24F7370015A2B5
/* Motion+UIKit.swift in Sources */
,
965FE9771FE0976F0098BDD0
/* ConditionalPreprocessor.swift in Sources */
,
...
...
Sources/Animator/MotionCoreAnimationViewContext.swift
View file @
150344a1
...
...
@@ -74,9 +74,9 @@ internal class MotionCoreAnimationViewContext: MotionAnimatorViewContext {
let
targetState
=
viewState
(
targetState
:
state
)
for
(
key
,
targetValue
)
in
targetState
{
if
nil
==
state
[
key
]
{
if
nil
==
s
elf
.
s
tate
[
key
]
{
let
current
=
currentValue
(
for
:
key
)
state
[
key
]
=
(
current
,
current
)
s
elf
.
s
tate
[
key
]
=
(
current
,
current
)
}
let
oldAnimations
=
animations
...
...
Sources/Preprocessors/TransitionPreprocessor.swift
View file @
150344a1
...
...
@@ -53,7 +53,7 @@ public enum MotionTransitionAnimationType {
indirect
case
selectBy
(
presenting
:
MotionTransitionAnimationType
,
dismissing
:
MotionTransitionAnimationType
)
/**
Sets the presenting and dismissing
transition
s.
Sets the presenting and dismissing
modifier
s.
- Parameter presenting: A MotionTransitionAnimationType.
- Returns: A MotionTransitionAnimationType.
*/
...
...
@@ -253,7 +253,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transition
s
:
shadowState
),
.
beginWith
(
modifier
s
:
shadowState
),
.
timingFunction
(
.
deceleration
)])
context
[
fv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
false
)
/
3
),
...
...
@@ -265,7 +265,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
fv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
false
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transition
s
:
shadowState
)])
.
beginWith
(
modifier
s
:
shadowState
)])
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)
/
3
),
.
overlay
(
color
:
.
black
,
opacity
:
0.1
)])
...
...
@@ -285,7 +285,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transition
s
:
shadowState
),
.
beginWith
(
modifier
s
:
shadowState
),
.
timingFunction
(
.
deceleration
)])
context
[
fv
]
!.
append
(
contentsOf
:
[
.
overlay
(
color
:
.
black
,
opacity
:
0.1
),
...
...
@@ -296,7 +296,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
fv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
false
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transition
s
:
shadowState
)])
.
beginWith
(
modifier
s
:
shadowState
)])
context
[
tv
]
!.
append
(
contentsOf
:
[
.
overlay
(
color
:
.
black
,
opacity
:
0.1
)])
...
...
@@ -305,7 +305,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
tv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
true
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transition
s
:
shadowState
),
.
beginWith
(
modifier
s
:
shadowState
),
.
timingFunction
(
.
deceleration
)])
context
[
fv
]
!.
append
(
contentsOf
:
[
.
scale
(
0.7
),
...
...
@@ -317,7 +317,7 @@ class TransitionPreprocessor: MotionCorePreprocessor {
context
[
fv
]
!.
append
(
contentsOf
:
[
.
translate
(
shift
(
direction
:
direction
,
isAppearing
:
false
)),
.
shadow
(
opacity
:
0
),
.
beginWith
(
transition
s
:
shadowState
)])
.
beginWith
(
modifier
s
:
shadowState
)])
context
[
tv
]
!.
append
(
contentsOf
:
[
.
scale
(
0.7
),
.
overlay
(
color
:
.
black
,
opacity
:
0.1
)])
...
...
Sources/Transition/MotionTransition+Start.swift
View file @
150344a1
...
...
@@ -88,7 +88,10 @@ fileprivate extension MotionTransition {
}
fullScreenSnapshot
=
v
.
window
?
.
snapshotView
(
afterScreenUpdates
:
false
)
??
fromView
?
.
snapshotView
(
afterScreenUpdates
:
false
)
(
v
.
window
??
v
)?
.
addSubview
(
fullScreenSnapshot
)
if
let
snapshot
=
fullScreenSnapshot
{
(
v
.
window
??
v
)?
.
addSubview
(
snapshot
)
}
if
let
v
=
fromViewController
?
.
motionStoredSnapshot
{
v
.
removeFromSuperview
()
...
...
Sources/Transition/MotionTransition+UINavigationControllerDelegate.swift
0 → 100644
View file @
150344a1
/*
* 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.
*/
import
UIKit
extension
MotionTransition
:
UINavigationControllerDelegate
{
public
func
navigationController
(
_
navigationController
:
UINavigationController
,
animationControllerFor
operation
:
UINavigationControllerOperation
,
from
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
isPresenting
=
.
push
==
operation
fromViewController
=
fromViewController
??
fromVC
toViewController
=
toViewController
??
toVC
isNavigationController
=
true
return
self
}
public
func
navigationController
(
_
navigationController
:
UINavigationController
,
interactionControllerFor
animationController
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
}
Sources/Transition/MotionTransition+UITabBarControllerDelegate.swift
0 → 100644
View file @
150344a1
/*
* 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.
*/
import
UIKit
extension
MotionTransition
:
UITabBarControllerDelegate
{
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
shouldSelect
viewController
:
UIViewController
)
->
Bool
{
if
isTransitioning
{
cancel
(
isAnimated
:
false
)
}
return
true
}
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
interactionControllerFor
animationController
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
let
fromVCIndex
=
tabBarController
.
childViewControllers
.
index
(
of
:
fromVC
)
!
let
toVCIndex
=
tabBarController
.
childViewControllers
.
index
(
of
:
toVC
)
!
isPresenting
=
toVCIndex
>
fromVCIndex
fromViewController
=
fromViewController
??
fromVC
toViewController
=
toViewController
??
toVC
isTabBarController
=
true
return
self
}
}
Sources/Transition/MotionTransition+UIViewControllerTransitioningDelegate.swift
0 → 100644
View file @
150344a1
/*
* 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.
*/
import
UIKit
extension
MotionTransition
:
UIViewControllerTransitioningDelegate
{
/// A reference to the interactive transitioning instance.
var
interactiveTransitioning
:
UIViewControllerInteractiveTransitioning
?
{
return
forceNonInteractive
?
nil
:
self
}
public
func
animationController
(
forPresented
presented
:
UIViewController
,
presenting
:
UIViewController
,
source
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
isPresenting
=
true
fromViewController
=
fromViewController
??
presenting
toViewController
=
toViewController
??
presented
return
self
}
public
func
animationController
(
forDismissed
dismissed
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
isPresenting
=
false
fromViewController
=
fromViewController
??
dismissed
return
self
}
public
func
interactionControllerForDismissal
(
using
animator
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
public
func
interactionControllerForPresentation
(
using
animator
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
}
extension
MotionTransition
:
UIViewControllerAnimatedTransitioning
{
/**
The animation method that is used to coordinate the transition.
- Parameter using transitionContext: A UIViewControllerContextTransitioning.
*/
public
func
animateTransition
(
using
context
:
UIViewControllerContextTransitioning
)
{
transitionContext
=
context
fromViewController
=
fromViewController
??
context
.
viewController
(
forKey
:
.
from
)
toViewController
=
toViewController
??
context
.
viewController
(
forKey
:
.
to
)
transitionContainer
=
context
.
containerView
start
()
}
/**
Returns the transition duration time interval.
- Parameter using transitionContext: An optional UIViewControllerContextTransitioning.
- Returns: A TimeInterval that is the total animation time including delays.
*/
public
func
transitionDuration
(
using
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
return
0
// Time will be updated dynamically.
}
public
func
animationEnded
(
_
transitionCompleted
:
Bool
)
{
state
=
.
possible
}
}
extension
MotionTransition
:
UIViewControllerInteractiveTransitioning
{
public
var
wantsInteractiveStart
:
Bool
{
return
true
}
public
func
startInteractiveTransition
(
_
transitionContext
:
UIViewControllerContextTransitioning
)
{
animateTransition
(
using
:
transitionContext
)
}
}
Sources/Transition/MotionTransition.swift
View file @
150344a1
...
...
@@ -759,137 +759,3 @@ internal extension MotionTransition {
}
}
}
extension
MotionTransition
:
UIViewControllerAnimatedTransitioning
{
/**
The animation method that is used to coordinate the transition.
- Parameter using transitionContext: A UIViewControllerContextTransitioning.
*/
public
func
animateTransition
(
using
context
:
UIViewControllerContextTransitioning
)
{
guard
!
isTransitioning
else
{
return
}
transitionContext
=
context
fromViewController
=
fromViewController
??
context
.
viewController
(
forKey
:
.
from
)
toViewController
=
toViewController
??
context
.
viewController
(
forKey
:
.
to
)
transitionContainer
=
context
.
containerView
start
()
}
/**
Returns the transition duration time interval.
- Parameter using transitionContext: An optional UIViewControllerContextTransitioning.
- Returns: A TimeInterval that is the total animation time including delays.
*/
public
func
transitionDuration
(
using
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
return
0
// Time will be updated dynamically.
}
public
func
animationEnded
(
_
transitionCompleted
:
Bool
)
{
state
=
.
possible
}
}
extension
MotionTransition
:
UIViewControllerTransitioningDelegate
{
/// A reference to the interactive transitioning instance.
var
interactiveTransitioning
:
UIViewControllerInteractiveTransitioning
?
{
return
forceNonInteractive
?
nil
:
self
}
public
func
animationController
(
forPresented
presented
:
UIViewController
,
presenting
:
UIViewController
,
source
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
isPresenting
=
true
fromViewController
=
fromViewController
??
presenting
toViewController
=
toViewController
??
presented
return
self
}
public
func
animationController
(
forDismissed
dismissed
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
isPresenting
=
false
fromViewController
=
fromViewController
??
dismissed
return
self
}
public
func
interactionControllerForDismissal
(
using
animator
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
public
func
interactionControllerForPresentation
(
using
animator
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
}
extension
MotionTransition
:
UIViewControllerInteractiveTransitioning
{
public
var
wantsInteractiveStart
:
Bool
{
return
true
}
public
func
startInteractiveTransition
(
_
transitionContext
:
UIViewControllerContextTransitioning
)
{
animateTransition
(
using
:
transitionContext
)
}
}
extension
MotionTransition
:
UINavigationControllerDelegate
{
public
func
navigationController
(
_
navigationController
:
UINavigationController
,
animationControllerFor
operation
:
UINavigationControllerOperation
,
from
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
isPresenting
=
.
push
==
operation
fromViewController
=
fromViewController
??
fromVC
toViewController
=
toViewController
??
toVC
isNavigationController
=
true
return
self
}
public
func
navigationController
(
_
navigationController
:
UINavigationController
,
interactionControllerFor
animationController
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
}
extension
MotionTransition
:
UITabBarControllerDelegate
{
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
shouldSelect
viewController
:
UIViewController
)
->
Bool
{
if
isTransitioning
{
cancel
(
isAnimated
:
false
)
}
return
true
}
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
interactionControllerFor
animationController
:
UIViewControllerAnimatedTransitioning
)
->
UIViewControllerInteractiveTransitioning
?
{
return
interactiveTransitioning
}
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
guard
!
isTransitioning
else
{
return
nil
}
state
=
.
notified
let
fromVCIndex
=
tabBarController
.
childViewControllers
.
index
(
of
:
fromVC
)
!
let
toVCIndex
=
tabBarController
.
childViewControllers
.
index
(
of
:
toVC
)
!
isPresenting
=
toVCIndex
>
fromVCIndex
fromViewController
=
fromViewController
??
fromVC
toViewController
=
toViewController
??
toVC
isTabBarController
=
true
return
self
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment