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
7f734fe0
Commit
7f734fe0
authored
Dec 20, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated Motion+UIVIewController transition logic
parent
7a639921
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
+18
-17
Sources/Extensions/Motion+UIViewController.swift
+13
-10
Sources/Transition/MotionTransition.swift
+5
-7
No files found.
Sources/Extensions/Motion+UIViewController.swift
View file @
7f734fe0
...
...
@@ -133,25 +133,26 @@ extension UIViewController {
}
if
value
{
transitioningDelegate
=
Motion
.
shared
transitioningDelegate
=
MotionTransition
.
shared
if
let
v
=
self
as?
UINavigationController
{
previousNavigationDelegate
=
v
.
delegate
v
.
delegate
=
Motion
.
shared
v
.
delegate
=
Motion
Transition
.
shared
}
if
let
v
=
self
as?
UITabBarController
{
previousTabBarDelegate
=
v
.
delegate
v
.
delegate
=
Motion
.
shared
v
.
delegate
=
Motion
Transition
.
shared
}
}
else
{
transitioningDelegate
=
nil
if
let
v
=
self
as?
UINavigationController
,
v
.
delegate
is
Motion
{
if
let
v
=
self
as?
UINavigationController
,
v
.
delegate
is
Motion
Transition
{
v
.
delegate
=
previousNavigationDelegate
}
if
let
v
=
self
as?
UITabBarController
,
v
.
delegate
is
Motion
{
if
let
v
=
self
as?
UITabBarController
,
v
.
delegate
is
Motion
Transition
{
v
.
delegate
=
previousTabBarDelegate
}
}
...
...
@@ -270,7 +271,7 @@ extension UIViewController {
// UIKit's UIViewController.dismiss will jump to target.presentedViewController then perform the dismiss.
// We overcome this behavior by inserting a snapshot into target.presentedViewController
// And also force Hero to use the current VC as the fromViewController
Motion
.
shared
.
fromViewController
=
fvc
Motion
Transition
.
shared
.
fromViewController
=
fvc
let
snapshotView
=
fvc
.
view
.
snapshotView
(
afterScreenUpdates
:
true
)
!
let
targetSuperview
=
tvc
.
presentedViewController
!.
view
!
...
...
@@ -291,7 +292,9 @@ extension UIViewController {
- Parameter with next: A UIViewController.
*/
public
func
motionReplaceViewController
(
with
next
:
UIViewController
)
{
guard
!
Motion
.
shared
.
isTransitioning
else
{
let
motion
=
next
.
transitioningDelegate
as?
MotionTransition
??
MotionTransition
.
shared
guard
!
motion
.
isTransitioning
else
{
print
(
"motionReplaceViewController cancelled because Motion was doing a transition. Use Motion.shared.cancel(animated: false) or Motion.shared.end(animated: false) to stop the transition first before calling motionReplaceViewController."
)
return
}
...
...
@@ -305,19 +308,19 @@ extension UIViewController {
}
if
nc
.
isMotionEnabled
{
Motion
.
shared
.
forceNonInteractive
=
true
motion
.
forceNonInteractive
=
true
}
nc
.
setViewControllers
(
v
,
animated
:
true
)
}
else
if
let
container
=
view
.
superview
{
let
presentingVC
=
presentingViewController
Motion
.
shared
.
transition
(
from
:
self
,
to
:
next
,
in
:
container
)
{
[
weak
self
]
(
isFinishing
)
in
motion
.
transition
(
from
:
self
,
to
:
next
,
in
:
container
)
{
[
weak
self
]
(
isFinishing
)
in
guard
isFinishing
else
{
return
}
UIApplication
.
shared
.
keyW
indow
?
.
addSubview
(
next
.
view
)
next
.
view
.
w
indow
?
.
addSubview
(
next
.
view
)
guard
let
pvc
=
presentingVC
else
{
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
=
next
...
...
Sources/Transition/MotionTransition.swift
View file @
7f734fe0
...
...
@@ -125,15 +125,10 @@ public protocol MotionViewControllerDelegate {
func apply(transitions: [MotionTargetState], to view: UIView)
```
*/
import
UIKit
public
class
Motion
:
NSObject
{
/// Shared singleton object for controlling the transition
public
static
let
shared
=
MotionTransition
()
}
public
typealias
MotionCancelBlock
=
(
Bool
)
->
Void
public
class
Motion
:
NSObject
{}
extension
Motion
{
/**
Executes a block of code asynchronously on the main thread.
...
...
@@ -241,6 +236,9 @@ public enum MotionTransitionState: Int {
}
open
class
MotionTransition
:
NSObject
{
/// Shared singleton object for controlling the transition
public
static
let
shared
=
MotionTransition
()
/// Default animation type.
internal
var
defaultAnimation
=
MotionTransitionAnimationType
.
auto
...
...
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