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 {
...
@@ -282,6 +282,15 @@ internal extension Motion {
return
return
}
}
guard
let
c
=
container
else
{
return
}
guard
let
tc
=
transitionContainer
else
{
return
}
context
.
clean
()
context
.
clean
()
if
isFinished
&&
isPresenting
&&
toOverFullScreen
{
if
isFinished
&&
isPresenting
&&
toOverFullScreen
{
...
@@ -292,7 +301,7 @@ internal extension Motion {
...
@@ -292,7 +301,7 @@ internal extension Motion {
fromViewController
!.
motionStoredSnapshot
=
container
fromViewController
!.
motionStoredSnapshot
=
container
fromView
.
removeFromSuperview
()
fromView
.
removeFromSuperview
()
fromView
.
addSubview
(
c
ontainer
)
fromView
.
addSubview
(
c
)
}
else
if
!
isFinished
&&
!
isPresenting
&&
fromOverFullScreen
{
}
else
if
!
isFinished
&&
!
isPresenting
&&
fromOverFullScreen
{
// cancelled dismissing a overFullScreen VC
// cancelled dismissing a overFullScreen VC
context
.
unhide
(
rootView
:
fromView
)
context
.
unhide
(
rootView
:
fromView
)
...
@@ -301,19 +310,19 @@ internal extension Motion {
...
@@ -301,19 +310,19 @@ internal extension Motion {
toViewController
!.
motionStoredSnapshot
=
container
toViewController
!.
motionStoredSnapshot
=
container
toView
.
removeFromSuperview
()
toView
.
removeFromSuperview
()
toView
.
addSubview
(
c
ontainer
)
toView
.
addSubview
(
c
)
}
else
{
}
else
{
context
.
unhideAll
()
context
.
unhideAll
()
context
.
removeAllSnapshots
()
context
.
removeAllSnapshots
()
c
ontainer
.
removeFromSuperview
()
c
.
removeFromSuperview
()
}
}
// move fromView & toView back from our container back to the one supplied by UIKit
// move fromView & toView back from our container back to the one supplied by UIKit
if
(
toOverFullScreen
&&
isFinished
)
||
(
fromOverFullScreen
&&
!
isFinished
)
{
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
{
if
isPresenting
!=
isFinished
,
!
isContainerController
{
// only happens when present a .overFullScreen VC
// only happens when present a .overFullScreen VC
...
@@ -365,8 +374,12 @@ fileprivate extension Motion {
...
@@ -365,8 +374,12 @@ fileprivate extension Motion {
/// Prepares the snapshot view, which hides any flashing that may occur.
/// Prepares the snapshot view, which hides any flashing that may occur.
func
prepareSnapshotView
()
{
func
prepareSnapshotView
()
{
fullScreenSnapshot
=
transitionContainer
.
window
?
.
snapshotView
(
afterScreenUpdates
:
true
)
??
fromView
.
snapshotView
(
afterScreenUpdates
:
true
)
guard
let
v
=
transitionContainer
else
{
(
transitionContainer
.
window
??
transitionContainer
)?
.
addSubview
(
fullScreenSnapshot
)
return
}
fullScreenSnapshot
=
v
.
window
?
.
snapshotView
(
afterScreenUpdates
:
true
)
??
fromView
.
snapshotView
(
afterScreenUpdates
:
true
)
(
v
.
window
??
transitionContainer
)?
.
addSubview
(
fullScreenSnapshot
)
if
let
v
=
fromViewController
?
.
motionStoredSnapshot
{
if
let
v
=
fromViewController
?
.
motionStoredSnapshot
{
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
...
@@ -381,10 +394,14 @@ fileprivate extension Motion {
...
@@ -381,10 +394,14 @@ fileprivate extension Motion {
/// Prepares the MotionContext instance.
/// Prepares the MotionContext instance.
func
prepareContext
()
{
func
prepareContext
()
{
guard
let
v
=
container
else
{
return
}
context
.
loadViewAlpha
(
rootView
:
toView
)
context
.
loadViewAlpha
(
rootView
:
toView
)
context
.
loadViewAlpha
(
rootView
:
fromView
)
context
.
loadViewAlpha
(
rootView
:
fromView
)
container
.
addSubview
(
toView
)
v
.
addSubview
(
toView
)
container
.
addSubview
(
fromView
)
v
.
addSubview
(
fromView
)
}
}
/// Prepares the toView instance.
/// Prepares the toView instance.
...
@@ -541,9 +558,9 @@ fileprivate extension Motion {
...
@@ -541,9 +558,9 @@ fileprivate extension Motion {
/// Updates the container background color.
/// Updates the container background color.
func
updateContainerBackgroundColor
()
{
func
updateContainerBackgroundColor
()
{
if
let
v
=
containerBackgroundColor
{
if
let
v
=
containerBackgroundColor
{
container
.
backgroundColor
=
v
container
?
.
backgroundColor
=
v
}
else
if
!
toOverFullScreen
&&
!
fromOverFullScreen
{
}
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 {
...
@@ -64,10 +64,10 @@ public class MotionController: NSObject {
A view container used to hold all the animating views during a
A view container used to hold all the animating views during a
transition.
transition.
*/
*/
public
internal(set)
var
container
:
UIView
!
public
internal(set)
var
container
:
UIView
?
/// UIKit's supplied transition container.
/// UIKit's supplied transition container.
internal
var
transitionContainer
:
UIView
!
internal
var
transitionContainer
:
UIView
?
/// An optional completion callback.
/// An optional completion callback.
internal
var
completionCallback
:
((
Bool
)
->
Void
)?
internal
var
completionCallback
:
((
Bool
)
->
Void
)?
...
@@ -259,7 +259,7 @@ public extension MotionController {
...
@@ -259,7 +259,7 @@ public extension MotionController {
}
}
guard
isAnimated
else
{
guard
isAnimated
else
{
complete
(
isFinished
:
false
)
complete
(
isFinished
:
false
)
return
return
}
}
...
@@ -455,16 +455,24 @@ internal extension MotionController {
...
@@ -455,16 +455,24 @@ internal extension MotionController {
fileprivate
extension
MotionController
{
fileprivate
extension
MotionController
{
/// Prepares the transition container.
/// Prepares the transition container.
func
prepareTransitionContainer
()
{
func
prepareTransitionContainer
()
{
transitionContainer
.
isUserInteractionEnabled
=
false
guard
let
v
=
transitionContainer
else
{
return
}
v
.
isUserInteractionEnabled
=
false
// a view to hold all the animating views
// a view to hold all the animating views
container
=
UIView
(
frame
:
transitionContainer
.
bounds
)
container
=
UIView
(
frame
:
v
.
bounds
)
transitionContainer
.
addSubview
(
container
)
v
.
addSubview
(
container
!
)
}
}
/// Prepares the context.
/// Prepares the context.
func
prepareContext
()
{
func
prepareContext
()
{
context
=
MotionContext
(
container
:
container
)
guard
let
v
=
container
else
{
return
}
context
=
MotionContext
(
container
:
v
)
}
}
/// Prepares the preprocessors.
/// 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