Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
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
Material
Commits
6081a64f
Unverified
Commit
6081a64f
authored
Jan 19, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added view controller view to list of views to detect for transitions
parent
f11fd48d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
163 deletions
+26
-163
Sources/iOS/MotionTransition.swift
+26
-163
No files found.
Sources/iOS/MotionTransition.swift
View file @
6081a64f
...
@@ -166,12 +166,25 @@ open class MotionTransitionDelegate: NSObject {
...
@@ -166,12 +166,25 @@ open class MotionTransitionDelegate: NSObject {
open
var
containerView
:
UIView
!
open
var
containerView
:
UIView
!
open
var
toView
:
UIView
!
open
var
toView
:
UIView
!
open
var
toViews
:
[
UIView
]
{
return
[
toViewController
.
view
]
+
toViewController
.
view
.
subviews
}
open
var
toViewController
:
UIViewController
!
open
var
toViewController
:
UIViewController
!
open
var
toViewStartFrame
:
CGRect
!
open
var
toViewStartFrame
:
CGRect
!
open
var
toViewFinalFrame
:
CGRect
!
open
var
toViewFinalFrame
:
CGRect
!
open
var
fromView
:
UIView
!
open
var
fromView
:
UIView
!
open
var
fromViews
:
[
UIView
]
{
return
[
fromViewController
.
view
]
+
fromViewController
.
view
.
subviews
}
open
var
fromViewController
:
UIViewController
!
open
var
fromViewController
:
UIViewController
!
open
var
fromViewFinalFrame
:
CGRect
!
open
var
fromViewFinalFrame
:
CGRect
!
@objc(animateTransition:)
@objc(animateTransition:)
...
@@ -364,7 +377,7 @@ open class MotionTransitionAnimator: MotionTransitionDelegate, UIViewControllerA
...
@@ -364,7 +377,7 @@ open class MotionTransitionAnimator: MotionTransitionDelegate, UIViewControllerA
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
for
v
in
toView
Controller
.
view
.
subview
s
{
for
v
in
toViews
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
for
a
in
v
.
transitionAnimations
{
for
a
in
v
.
transitionAnimations
{
switch
a
{
switch
a
{
...
@@ -423,9 +436,9 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -423,9 +436,9 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
transitionContext
.
containerView
.
addSubview
(
toViewController
.
view
)
for
v
in
toView
Controller
.
view
.
subview
s
{
for
v
in
toViews
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
for
v2
in
fromView
Controller
.
view
.
subview
s
{
for
v2
in
fromViews
{
if
v
.
transitionIdentifier
==
v2
.
transitionIdentifier
{
if
v
.
transitionIdentifier
==
v2
.
transitionIdentifier
{
var
d
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
...
@@ -434,8 +447,6 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -434,8 +447,6 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
0
var
h
:
CGFloat
=
0
var
h
:
CGFloat
=
0
var
px
:
CGFloat
=
v
.
position
.
x
var
py
:
CGFloat
=
v
.
position
.
y
for
ta
in
v
.
transitionAnimations
{
for
ta
in
v
.
transitionAnimations
{
switch
ta
{
switch
ta
{
...
@@ -456,6 +467,10 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -456,6 +467,10 @@ open class MotionTransitionPresentedAnimator: MotionTransitionDelegate, UIViewCo
}
}
}
}
var
px
:
CGFloat
=
v
.
position
.
x
var
py
:
CGFloat
=
v
.
position
.
y
for
ta
in
v
.
transitionAnimations
{
for
ta
in
v
.
transitionAnimations
{
switch
ta
{
switch
ta
{
case
let
.
x
(
x
):
case
let
.
x
(
x
):
...
@@ -550,9 +565,9 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -550,9 +565,9 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
var
delay
:
TimeInterval
=
0
var
delay
:
TimeInterval
=
0
var
duration
=
transitionDuration
(
using
:
nil
)
var
duration
=
transitionDuration
(
using
:
nil
)
for
v
in
fromView
Controller
.
view
.
subview
s
{
for
v
in
fromViews
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
if
0
<
v
.
transitionIdentifier
.
utf16
.
count
{
for
v2
in
toView
Controller
.
view
.
subview
s
{
for
v2
in
toViews
{
if
v
.
transitionIdentifier
==
v2
.
transitionIdentifier
{
if
v
.
transitionIdentifier
==
v2
.
transitionIdentifier
{
var
d
:
TimeInterval
=
0
var
d
:
TimeInterval
=
0
...
@@ -578,7 +593,10 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
...
@@ -578,7 +593,10 @@ open class MotionTransitionDismissedAnimator: MotionTransitionDelegate, UIViewCo
rotate
.
fromValue
=
v
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
rotate
.
fromValue
=
v
.
layer
.
value
(
forKeyPath
:
MotionAnimationKeyPath
.
rotation
.
rawValue
)
a
.
append
(
rotate
)
a
.
append
(
rotate
)
case
let
.
backgroundColor
(
color
):
case
let
.
backgroundColor
(
color
):
a
.
append
(
Motion
.
background
(
color
:
v2
.
backgroundColor
??
.
clear
))
guard
let
bgColor
=
v2
.
backgroundColor
else
{
continue
}
a
.
append
(
Motion
.
background
(
color
:
bgColor
))
case
let
.
corners
(
radius
):
case
let
.
corners
(
radius
):
a
.
append
(
Motion
.
corner
(
radius
:
v2
.
cornerRadius
))
a
.
append
(
Motion
.
corner
(
radius
:
v2
.
cornerRadius
))
case
let
.
x
(
x
):
case
let
.
x
(
x
):
...
@@ -730,158 +748,3 @@ open class SlideMotionTransition: NSObject, UIViewControllerAnimatedTransitionin
...
@@ -730,158 +748,3 @@ open class SlideMotionTransition: NSObject, UIViewControllerAnimatedTransitionin
// print("SlideMotionTransition ANIMATION ENDED")
// print("SlideMotionTransition ANIMATION ENDED")
}
}
}
}
//open class MotionTransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning {
// var presenting = false
//
// open func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
// let containerView = transitionContext.containerView
//
// guard let fromVC = transitionContext.viewController(forKey: .from) else {
// return
// }
//
// guard let toVC = transitionContext.viewController(forKey: .to) else {
// return
// }
//
// guard let fromView = transitionContext.view(forKey: .from) else {
// return
// }
//
// guard let toView = transitionContext.view(forKey: .to) else {
// return
// }
//
// let containerFrame = containerView.frame
// var toViewStartFrame = transitionContext.initialFrame(for: toVC)
// let toViewFinalFrame = transitionContext.finalFrame(for: toVC)
// var fromViewFinalFrame = transitionContext.finalFrame(for: fromVC)
//
// // Set up the animation parameters.
// if (presenting) {
// // Modify the frame of the presented view so that it starts
// // offscreen at the lower-right corner of the container.
// toViewStartFrame.origin.x = containerFrame.size.width;
// toViewStartFrame.origin.y = containerFrame.size.height;
// }
// else {
// // Modify the frame of the dismissed view so it ends in
// // the lower-right corner of the container view.
// fromViewFinalFrame = CGRect(x: containerFrame.size.width,
// y: containerFrame.size.height,
// width: toView.frame.size.width,
// height: toView.frame.size.height);
// }
//
// // Always add the "to" view to the container.
// // And it doesn't hurt to set its start frame.
// containerView.addSubview(toView)
// toView.frame = toViewStartFrame;
//
// UIView.animate(withDuration: transitionDuration(using: nil), animations: { [weak self] in
// guard let s = self else {
// return
// }
//
// if s.presenting {
// toView.frame = toViewFinalFrame
// } else {
// fromView.frame = fromViewFinalFrame
// }
//
// }, completion: { [weak self] _ in
// guard let s = self else {
// return
// }
//
// let success = !transitionContext.transitionWasCancelled
// if (s.presenting && !success) || (!s.presenting && success) {
// toView.removeFromSuperview()
// }
//
// transitionContext.completeTransition(success)
// })
// }
//
// open func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
// return 0.25
// }
//}
//@objc(TransitionMotion)
//public enum TransitionMotion: Int {
// case fade
// case moveIn
// case push
// case reveal
//}
//
//@objc(TransitionMotionDirection)
//public enum TransitionMotionDirection: Int {
// case `default`
// case right
// case left
// case top
// case bottom
//}
//
///**
// Converts an TransitionMotion to a corresponding CATransition key.
// - Parameter transition: An TransitionMotion.
// - Returns: A CATransition key String.
// */
//public func TransitionMotionToValue(transition type: TransitionMotion) -> String {
// switch type {
// case .fade:
// return kCATransitionFade
// case .moveIn:
// return kCATransitionMoveIn
// case .push:
// return kCATransitionPush
// case .reveal:
// return kCATransitionReveal
// }
//}
//
///**
// Converts an TransitionMotionDirection to a corresponding CATransition direction key.
// - Parameter direction: An TransitionMotionDirection.
// - Returns: An optional CATransition direction key String.
// */
//public func TransitionMotionDirectionToValue(direction: TransitionMotionDirection) -> String? {
// switch direction {
// case .default:
// return nil
// case .right:
// return kCATransitionFromRight
// case .left:
// return kCATransitionFromLeft
// case .top:
// return kCATransitionFromBottom
// case .bottom:
// return kCATransitionFromTop
// }
//}
//
//extension Motion {
// /**
// Creates a CATransition animation.
// - Parameter type: An TransitionMotion.
// - Parameter direction: An optional TransitionMotionDirection.
// - Parameter duration: An optional duration time.
// - Returns: A CATransition.
// */
// public static func transition(type: TransitionMotion, direction: TransitionMotionDirection = .default, duration: CFTimeInterval? = nil) -> CATransition {
// let animation = CATransition()
// animation.type = TransitionMotionToValue(transition: type)
// animation.subtype = TransitionMotionDirectionToValue(direction: direction)
//
// if let v = duration {
// animation.duration = v
// }
//
// return animation
// }
//}
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