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
b0e21e3b
Commit
b0e21e3b
authored
Dec 12, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated Extensions
parent
de05a397
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
41 deletions
+41
-41
Sources/Extensions/Motion+Array.swift
+1
-0
Sources/Extensions/Motion+UIViewController.swift
+40
-41
No files found.
Sources/Extensions/Motion+Array.swift
View file @
b0e21e3b
...
...
@@ -41,3 +41,4 @@ internal extension Array {
return
nil
}
}
Sources/Extensions/Motion+UIViewController.swift
View file @
b0e21e3b
...
...
@@ -143,6 +143,7 @@ extension UIViewController {
previousTabBarDelegate
=
v
.
delegate
v
.
delegate
=
Motion
.
shared
}
}
else
{
transitioningDelegate
=
nil
...
...
@@ -228,62 +229,60 @@ extension UIViewController {
/// Unwind to a view controller that the matchBlock returns true on.
public
func
motionUnwindToViewController
(
withMatchBlock
:
(
UIViewController
)
->
Bool
)
{
var
target
:
UIViewController
?
var
target
:
UIViewController
?
=
nil
var
current
:
UIViewController
?
=
self
while
nil
==
target
&&
nil
!=
current
{
if
let
childViewControllers
=
(
current
as?
UINavigationController
)?
.
childViewControllers
??
current
!.
navigationController
?
.
childViewControllers
{
for
v
in
childViewControllers
.
reversed
()
{
if
self
!=
v
,
withMatchBlock
(
v
)
{
target
=
v
for
vc
in
childViewControllers
.
reversed
()
{
if
self
!=
vc
,
withMatchBlock
(
vc
)
{
target
=
vc
break
}
}
}
guard
nil
==
target
else
{
continue
}
current
=
current
?
.
presentingViewController
guard
let
v
=
current
,
withMatchBlock
(
v
)
else
{
continue
if
nil
==
target
{
current
=
current
!.
presentingViewController
if
let
vc
=
current
,
true
==
withMatchBlock
(
vc
)
{
target
=
vc
}
}
target
=
v
}
guard
let
v
=
target
else
{
guard
let
t
=
target
else
{
return
}
guard
nil
!=
v
.
presentedViewController
else
{
v
.
navigationController
?
.
popToViewController
(
v
,
animated
:
true
)
guard
nil
!=
t
.
presentedViewController
else
{
_
=
t
.
navigationController
?
.
popToViewController
(
t
,
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.
We overcome this behavior by inserting a snapshot into target.presentedViewController
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
_
=
t
.
navigationController
?
.
popToViewController
(
t
,
animated
:
false
)
let
fvc
=
navigationController
??
self
let
tvc
=
t
.
navigationController
??
t
if
t
.
presentedViewController
!=
fvc
{
// 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
let
snapshotView
=
fvc
.
view
.
snapshotView
(
afterScreenUpdates
:
true
)
!
let
targetSuperview
=
tvc
.
presentedViewController
!.
view
!
if
let
visualEffectView
=
targetSuperview
as?
UIVisualEffectView
{
visualEffectView
.
contentView
.
addSubview
(
snapshotView
)
}
else
{
targetSuperview
.
addSubview
(
snapshotView
)
}
toVC
.
presentedViewController
?
.
view
.
addSubview
(
snapshot
)
}
t
oVC
.
dismiss
(
animated
:
true
)
t
vc
.
dismiss
(
animated
:
true
,
completion
:
nil
)
}
/**
...
...
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