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
430cc140
Unverified
Commit
430cc140
authored
Jun 13, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated container and transitionContainer in MotionController to no longer use unwrapped optionals
parent
650dd64c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
18 deletions
+43
-18
Sources/Motion.swift
+28
-11
Sources/MotionController.swift
+15
-7
No files found.
Sources/Motion.swift
View file @
430cc140
...
...
@@ -282,6 +282,15 @@ internal extension Motion {
return
}
guard
let
c
=
container
else
{
return
}
guard
let
tc
=
transitionContainer
else
{
return
}
context
.
clean
()
if
isFinished
&&
isPresenting
&&
toOverFullScreen
{
...
...
@@ -292,7 +301,7 @@ internal extension Motion {
fromViewController
!.
motionStoredSnapshot
=
container
fromView
.
removeFromSuperview
()
fromView
.
addSubview
(
c
ontainer
)
fromView
.
addSubview
(
c
)
}
else
if
!
isFinished
&&
!
isPresenting
&&
fromOverFullScreen
{
// cancelled dismissing a overFullScreen VC
context
.
unhide
(
rootView
:
fromView
)
...
...
@@ -301,19 +310,19 @@ internal extension Motion {
toViewController
!.
motionStoredSnapshot
=
container
toView
.
removeFromSuperview
()
toView
.
addSubview
(
c
ontainer
)
toView
.
addSubview
(
c
)
}
else
{
context
.
unhideAll
()
context
.
removeAllSnapshots
()
c
ontainer
.
removeFromSuperview
()
c
.
removeFromSuperview
()
}
// move fromView & toView back from our container back to the one supplied by UIKit
if
(
toOverFullScreen
&&
isFinished
)
||
(
fromOverFullScreen
&&
!
isFinished
)
{
t
ransitionContainer
.
addSubview
(
isFinished
?
fromView
:
toView
)
t
c
.
addSubview
(
isFinished
?
fromView
:
toView
)
}
t
ransitionContainer
.
addSubview
(
isFinished
?
toView
:
fromView
)
t
c
.
addSubview
(
isFinished
?
toView
:
fromView
)
if
isPresenting
!=
isFinished
,
!
isContainerController
{
// only happens when present a .overFullScreen VC
...
...
@@ -365,8 +374,12 @@ fileprivate extension Motion {
/// Prepares the snapshot view, which hides any flashing that may occur.
func
prepareSnapshotView
()
{
fullScreenSnapshot
=
transitionContainer
.
window
?
.
snapshotView
(
afterScreenUpdates
:
true
)
??
fromView
.
snapshotView
(
afterScreenUpdates
:
true
)
(
transitionContainer
.
window
??
transitionContainer
)?
.
addSubview
(
fullScreenSnapshot
)
guard
let
v
=
transitionContainer
else
{
return
}
fullScreenSnapshot
=
v
.
window
?
.
snapshotView
(
afterScreenUpdates
:
true
)
??
fromView
.
snapshotView
(
afterScreenUpdates
:
true
)
(
v
.
window
??
transitionContainer
)?
.
addSubview
(
fullScreenSnapshot
)
if
let
v
=
fromViewController
?
.
motionStoredSnapshot
{
v
.
removeFromSuperview
()
...
...
@@ -381,10 +394,14 @@ fileprivate extension Motion {
/// Prepares the MotionContext instance.
func
prepareContext
()
{
guard
let
v
=
container
else
{
return
}
context
.
loadViewAlpha
(
rootView
:
toView
)
context
.
loadViewAlpha
(
rootView
:
fromView
)
container
.
addSubview
(
toView
)
container
.
addSubview
(
fromView
)
v
.
addSubview
(
toView
)
v
.
addSubview
(
fromView
)
}
/// Prepares the toView instance.
...
...
@@ -541,9 +558,9 @@ fileprivate extension Motion {
/// Updates the container background color.
func
updateContainerBackgroundColor
()
{
if
let
v
=
containerBackgroundColor
{
container
.
backgroundColor
=
v
container
?
.
backgroundColor
=
v
}
else
if
!
toOverFullScreen
&&
!
fromOverFullScreen
{
container
.
backgroundColor
=
toView
.
backgroundColor
container
?
.
backgroundColor
=
toView
.
backgroundColor
}
}
...
...
Sources/MotionController.swift
View file @
430cc140
...
...
@@ -64,10 +64,10 @@ public class MotionController: NSObject {
A view container used to hold all the animating views during a
transition.
*/
public
internal(set)
var
container
:
UIView
!
public
internal(set)
var
container
:
UIView
?
/// UIKit's supplied transition container.
internal
var
transitionContainer
:
UIView
!
internal
var
transitionContainer
:
UIView
?
/// An optional completion callback.
internal
var
completionCallback
:
((
Bool
)
->
Void
)?
...
...
@@ -259,7 +259,7 @@ public extension MotionController {
}
guard
isAnimated
else
{
complete
(
isFinished
:
false
)
complete
(
isFinished
:
false
)
return
}
...
...
@@ -455,16 +455,24 @@ internal extension MotionController {
fileprivate
extension
MotionController
{
/// Prepares the transition container.
func
prepareTransitionContainer
()
{
transitionContainer
.
isUserInteractionEnabled
=
false
guard
let
v
=
transitionContainer
else
{
return
}
v
.
isUserInteractionEnabled
=
false
// a view to hold all the animating views
container
=
UIView
(
frame
:
transitionContainer
.
bounds
)
transitionContainer
.
addSubview
(
container
)
container
=
UIView
(
frame
:
v
.
bounds
)
v
.
addSubview
(
container
!
)
}
/// Prepares the context.
func
prepareContext
()
{
context
=
MotionContext
(
container
:
container
)
guard
let
v
=
container
else
{
return
}
context
=
MotionContext
(
container
:
v
)
}
/// Prepares the preprocessors.
...
...
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