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
e352f7a9
Unverified
Commit
e352f7a9
authored
Feb 01, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: refined MotionTransition additions
parent
3d538a63
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
44 deletions
+46
-44
Sources/iOS/CollectionViewController.swift
+1
-1
Sources/iOS/Font.swift
+1
-1
Sources/iOS/Icon.swift
+1
-1
Sources/iOS/MotionAnimation.swift
+15
-15
Sources/iOS/MotionTransition.swift
+25
-23
Sources/iOS/Reminders/Reminders.swift
+1
-1
Sources/iOS/Reminders/RemindersController.swift
+1
-1
Sources/iOS/TableViewController.swift
+1
-1
No files found.
Sources/iOS/CollectionViewController.swift
View file @
e352f7a9
/*
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
io
>.
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
com
>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
...
...
Sources/iOS/Font.swift
View file @
e352f7a9
...
...
@@ -86,7 +86,7 @@ private class FontLoader {
let
bundle
=
Bundle
(
for
:
FontLoader
.
self
)
let
identifier
=
bundle
.
bundleIdentifier
let
fontURL
=
true
==
identifier
?
.
hasPrefix
(
"org.cocoapods"
)
?
bundle
.
url
(
forResource
:
name
,
withExtension
:
"ttf"
,
subdirectory
:
"
io
.cosmicmind.material.fonts.bundle"
)
:
bundle
.
url
(
forResource
:
name
,
withExtension
:
"ttf"
)
let
fontURL
=
true
==
identifier
?
.
hasPrefix
(
"org.cocoapods"
)
?
bundle
.
url
(
forResource
:
name
,
withExtension
:
"ttf"
,
subdirectory
:
"
com
.cosmicmind.material.fonts.bundle"
)
:
bundle
.
url
(
forResource
:
name
,
withExtension
:
"ttf"
)
if
let
v
=
fontURL
{
let
data
=
NSData
(
contentsOf
:
v
as
URL
)
!
...
...
Sources/iOS/Icon.swift
View file @
e352f7a9
...
...
@@ -42,7 +42,7 @@ public struct Icon {
if
nil
==
Icon
.
internalBundle
{
Icon
.
internalBundle
=
Bundle
(
for
:
View
.
self
)
let
url
=
Icon
.
internalBundle
!.
resourceURL
!
let
b
=
Bundle
(
url
:
url
.
appendingPathComponent
(
"
io
.cosmicmind.material.icons.bundle"
))
let
b
=
Bundle
(
url
:
url
.
appendingPathComponent
(
"
com
.cosmicmind.material.icons.bundle"
))
if
let
v
=
b
{
Icon
.
internalBundle
=
v
}
...
...
Sources/iOS/MotionAnimation.swift
View file @
e352f7a9
...
...
@@ -423,7 +423,7 @@ extension Motion {
*/
public
static
func
rotation
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotation
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
return
animation
}
...
...
@@ -434,7 +434,7 @@ extension Motion {
*/
public
static
func
rotationX
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationX
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
return
animation
}
...
...
@@ -445,7 +445,7 @@ extension Motion {
*/
public
static
func
rotationY
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationY
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
return
animation
}
...
...
@@ -456,7 +456,7 @@ extension Motion {
*/
public
static
func
rotationZ
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationZ
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
angle
/
180
))
return
animation
}
...
...
@@ -467,7 +467,7 @@ extension Motion {
*/
public
static
func
spin
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotation
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
return
animation
}
...
...
@@ -478,7 +478,7 @@ extension Motion {
*/
public
static
func
spinX
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationX
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
return
animation
}
...
...
@@ -489,7 +489,7 @@ extension Motion {
*/
public
static
func
spinY
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationY
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
return
animation
}
...
...
@@ -500,7 +500,7 @@ extension Motion {
*/
public
static
func
spinZ
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationZ
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
CGFloat
(
M_PI
)
*
2
*
rotations
))
return
animation
}
...
...
@@ -511,7 +511,7 @@ extension Motion {
*/
public
static
func
scale
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scale
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
}
...
...
@@ -522,7 +522,7 @@ extension Motion {
*/
public
static
func
scaleX
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleX
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
}
...
...
@@ -533,7 +533,7 @@ extension Motion {
*/
public
static
func
scaleY
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleY
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
}
...
...
@@ -544,7 +544,7 @@ extension Motion {
*/
public
static
func
scaleZ
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleZ
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
}
...
...
@@ -566,7 +566,7 @@ extension Motion {
*/
public
static
func
translateX
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationX
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
translation
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
translation
))
return
animation
}
...
...
@@ -577,7 +577,7 @@ extension Motion {
*/
public
static
func
translateY
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationY
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
translation
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
translation
))
return
animation
}
...
...
@@ -588,7 +588,7 @@ extension Motion {
*/
public
static
func
translateZ
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationZ
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
translation
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
translation
))
return
animation
}
...
...
Sources/iOS/MotionTransition.swift
View file @
e352f7a9
...
...
@@ -174,8 +174,6 @@ extension UIView {
v
.
transform
=
transform
v
.
backgroundColor
=
backgroundColor
print
(
motionRotationAngle
)
isHidden
=
true
(
self
as?
Pulseable
)?
.
pulse
.
pulseLayer
?
.
isHidden
=
false
...
...
@@ -290,10 +288,10 @@ extension MotionTransition: UIViewControllerAnimatedTransitioning {
prepareToViewController
()
prepareFromViewController
()
prepareContainerView
()
prepareTransitionSnapshot
()
prepareTransitionView
()
prepareTransitionBackgroundView
()
prepareTransitionSnapshot
()
prepareToView
()
prepareTransitionToView
()
prepareTransitionAnimation
()
}
...
...
@@ -322,9 +320,16 @@ extension MotionTransition {
containerView
=
transitionContext
.
containerView
}
fileprivate
func
prepareTransitionSnapshot
()
{
transitionSnapshot
=
fromView
.
motionTransitionSnapshot
(
afterUpdates
:
true
)
transitionSnapshot
.
frame
=
containerView
.
bounds
containerView
.
addSubview
(
transitionSnapshot
)
}
fileprivate
func
prepareTransitionView
()
{
transitionView
.
frame
=
containerView
.
bounds
containerView
.
addSubview
(
transitionView
)
containerView
.
insertSubview
(
transitionView
,
belowSubview
:
transitionSnapshot
)
}
fileprivate
func
prepareTransitionBackgroundView
()
{
...
...
@@ -333,24 +338,29 @@ extension MotionTransition {
transitionView
.
addSubview
(
transitionBackgroundView
)
}
fileprivate
func
prepareTransitionSnapshot
()
{
transitionSnapshot
=
fromView
.
motionTransitionSnapshot
(
afterUpdates
:
true
)
transitionSnapshot
.
frame
=
containerView
.
bounds
transitionView
.
addSubview
(
transitionSnapshot
)
}
fileprivate
func
prepareToView
()
{
fileprivate
func
prepareTransitionToView
()
{
if
isPresenting
{
containerView
.
insertSubview
(
toView
,
belowSubview
:
transitionView
)
}
toView
.
isHidden
=
false
toView
.
updateConstraints
()
toView
.
setNeedsLayout
()
toView
.
layoutIfNeeded
()
toView
.
isHidden
=
false
}
fileprivate
func
prepareTransitionAnimation
()
{
addTransitionAnimations
()
addBackgroundMotionAnimation
()
cleanupAnimation
()
cleanupFromView
()
cleanupTransitionSnapshot
()
}
}
extension
MotionTransition
{
fileprivate
func
addTransitionAnimations
()
{
for
fv
in
fromSubviews
{
for
tv
in
toSubviews
{
if
tv
.
motionTransitionIdentifier
==
fv
.
motionTransitionIdentifier
{
...
...
@@ -391,7 +401,7 @@ extension MotionTransition {
snapshotChildAnimations
.
append
(
Motion
.
position
(
x
:
tv
.
bounds
.
width
/
2
,
y
:
tv
.
bounds
.
height
/
2
))
let
snapshot
=
fv
.
motionTransitionSnapshot
(
afterUpdates
:
true
)
transitionView
.
insertSubview
(
snapshot
,
belowSubview
:
transitionS
napshot
)
transitionView
.
addSubview
(
s
napshot
)
Motion
.
delay
(
t
)
{
for
ta
in
tv
.
motionTransitionAnimations
{
...
...
@@ -420,16 +430,8 @@ extension MotionTransition {
}
}
}
addBackgroundMotionAnimation
()
cleanupAnimation
()
cleanupFromView
()
cleanupTransitionSnapshot
()
}
}
extension
MotionTransition
{
fileprivate
func
addBackgroundMotionAnimation
()
{
transitionBackgroundView
.
motion
(
.
backgroundColor
(
toView
.
backgroundColor
??
.
clear
),
.
duration
(
transitionDuration
(
using
:
transitionContext
)))
}
...
...
Sources/iOS/Reminders/Reminders.swift
View file @
e352f7a9
/*
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
io
>.
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
com
>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
...
...
Sources/iOS/Reminders/RemindersController.swift
View file @
e352f7a9
/*
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
io
>.
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
com
>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
...
...
Sources/iOS/TableViewController.swift
View file @
e352f7a9
/*
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
io
>.
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.
com
>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
...
...
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