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
83ab6b00
Commit
83ab6b00
authored
Oct 26, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UIViewController.motionModalTransitionType renamed to UIViewController.motionTransitionType
parent
b9a25764
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
47 deletions
+59
-47
CHANGELOG.md
+4
-0
Sources/Extensions/Motion+UIViewController.swift
+55
-47
Sources/Preprocessors/TransitionPreprocessor.swift
+0
-0
No files found.
CHANGELOG.md
View file @
83ab6b00
## 1.2.5
*
`UIViewController.motionModalTransitionType`
renamed to
`UIViewController.motionTransitionType`
.
## 1.2.4
*
Added begin / end transition methods for from / to view controllers.
...
...
Sources/Extensions/Motion+UIViewController.swift
View file @
83ab6b00
...
...
@@ -33,24 +33,24 @@ fileprivate var AssociatedInstanceKey: UInt8 = 0
fileprivate
struct
AssociatedInstance
{
/// A reference to the modal animation.
var
modalTransitionType
:
MotionTransitionType
/// A reference to the navigation animation.
var
navigationTransitionType
:
MotionTransitionType
/// A reference to the tabBar animation.
var
tabBarTransitionType
:
MotionTransitionType
/// A reference to the stored snapshot.
var
storedSnapshot
:
UIView
?
/**
A reference to the previous navigation controller delegate
/**
A reference to the previous navigation controller delegate
before Motion was enabled.
*/
weak
var
previousNavigationDelegate
:
UINavigationControllerDelegate
?
/**
A reference to the previous tab bar controller delegate
A reference to the previous tab bar controller delegate
before Motion was enabled.
*/
weak
var
previousTabBarDelegate
:
UITabBarControllerDelegate
?
...
...
@@ -73,9 +73,9 @@ extension UIViewController {
AssociatedObject
.
set
(
base
:
self
,
key
:
&
AssociatedInstanceKey
,
value
:
value
)
}
}
///
default motion animation type for presenting & dismissing modally
public
var
motion
Modal
TransitionType
:
MotionTransitionType
{
///
Default motion animation type for presenting & dismissing modally.
public
var
motionTransitionType
:
MotionTransitionType
{
get
{
return
associatedInstance
.
modalTransitionType
}
...
...
@@ -83,8 +83,8 @@ extension UIViewController {
associatedInstance
.
modalTransitionType
=
value
}
}
///
used for .overFullScreen presentation
///
Used for .overFullScreen presentation.
internal
var
motionStoredSnapshot
:
UIView
?
{
get
{
return
associatedInstance
.
storedSnapshot
...
...
@@ -93,7 +93,7 @@ extension UIViewController {
associatedInstance
.
storedSnapshot
=
value
}
}
/**
A reference to the previous navigation controller delegate
before Motion was enabled.
...
...
@@ -184,8 +184,8 @@ extension UITabBarController {
extension
UIViewController
{
/**
Dismiss the current view controller with animation. Will perform a
navigationController.popViewController if the current view controller
Dismiss the current view controller with animation. Will perform a
navigationController.popViewController if the current view controller
is contained inside a navigationController
*/
@IBAction
...
...
@@ -196,33 +196,41 @@ extension UIViewController {
dismiss
(
animated
:
true
)
}
}
/// Unwind to the root view controller using Motion.
@IBAction
public
func
motionUnwindToRootViewController
()
{
motionUnwindToViewController
{
$0
.
presentingViewController
==
nil
}
motionUnwindToViewController
{
nil
==
$0
.
presentingViewController
}
}
/// Unwind to a specific view controller using Motion.
public
func
motionUnwindToViewController
(
_
toViewController
:
UIViewController
)
{
motionUnwindToViewController
{
$0
==
toViewController
}
motionUnwindToViewController
{
$0
==
toViewController
}
}
/// Unwind to a view controller that responds to the given selector using Motion.
public
func
motionUnwindToViewController
(
withSelector
:
Selector
)
{
motionUnwindToViewController
{
$0
.
responds
(
to
:
withSelector
)
}
motionUnwindToViewController
{
$0
.
responds
(
to
:
withSelector
)
}
}
/// Unwind to a view controller with given class using Motion
public
func
motionUnwindToViewController
(
withClass
:
AnyClass
)
{
motionUnwindToViewController
{
$0
.
isKind
(
of
:
withClass
)
}
motionUnwindToViewController
{
$0
.
isKind
(
of
:
withClass
)
}
}
/// Unwind to a view controller that the matchBlock returns true on.
public
func
motionUnwindToViewController
(
withMatchBlock
:
(
UIViewController
)
->
Bool
)
{
var
target
:
UIViewController
?
var
current
:
UIViewController
?
=
self
while
nil
==
target
&&
nil
!=
current
{
if
let
childViewControllers
=
(
current
as?
UINavigationController
)?
.
childViewControllers
??
current
!.
navigationController
?
.
childViewControllers
{
for
v
in
childViewControllers
.
reversed
()
{
...
...
@@ -232,34 +240,34 @@ extension UIViewController {
}
}
}
guard
nil
==
target
else
{
continue
}
current
=
current
?
.
presentingViewController
guard
let
v
=
current
,
withMatchBlock
(
v
)
else
{
continue
}
target
=
v
}
guard
let
v
=
target
else
{
return
}
guard
nil
!=
v
.
presentedViewController
else
{
v
.
navigationController
?
.
popToViewController
(
v
,
animated
:
true
)
return
}
v
.
navigationController
?
.
popToViewController
(
v
,
animated
:
false
)
let
fromVC
=
navigationController
??
self
let
toVC
=
v
.
navigationController
??
v
if
v
.
presentedViewController
!=
fromVC
{
/**
UIKit's UIViewController.dismiss will jump to target.presentedViewController then perform the dismiss.
...
...
@@ -267,17 +275,17 @@ extension UIViewController {
And also force Motion to use the current view controller as the fromViewController.
*/
Motion
.
shared
.
fromViewController
=
fromVC
guard
let
snapshot
=
fromVC
.
view
.
snapshotView
(
afterScreenUpdates
:
true
)
else
{
return
}
toVC
.
presentedViewController
?
.
view
.
addSubview
(
snapshot
)
}
toVC
.
dismiss
(
animated
:
true
)
}
/**
Replace the current view controller with another view controller within the
navigation/modal stack.
...
...
@@ -288,35 +296,35 @@ extension UIViewController {
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
}
if
let
nc
=
navigationController
{
var
v
=
nc
.
childViewControllers
if
!
v
.
isEmpty
{
v
.
removeLast
()
v
.
append
(
next
)
}
if
nc
.
isMotionEnabled
{
Motion
.
shared
.
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
]
(
isFinished
)
in
guard
isFinished
else
{
return
}
UIApplication
.
shared
.
keyWindow
?
.
addSubview
(
next
.
view
)
guard
let
pvc
=
presentingVC
else
{
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
=
next
return
}
self
?
.
dismiss
(
animated
:
false
)
{
pvc
.
present
(
next
,
animated
:
false
)
}
...
...
Sources/Preprocessors/TransitionPreprocessor.swift
View file @
83ab6b00
This diff is collapsed.
Click to expand it.
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