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.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* 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 {
...
@@ -86,7 +86,7 @@ private class FontLoader {
let
bundle
=
Bundle
(
for
:
FontLoader
.
self
)
let
bundle
=
Bundle
(
for
:
FontLoader
.
self
)
let
identifier
=
bundle
.
bundleIdentifier
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
{
if
let
v
=
fontURL
{
let
data
=
NSData
(
contentsOf
:
v
as
URL
)
!
let
data
=
NSData
(
contentsOf
:
v
as
URL
)
!
...
...
Sources/iOS/Icon.swift
View file @
e352f7a9
...
@@ -42,7 +42,7 @@ public struct Icon {
...
@@ -42,7 +42,7 @@ public struct Icon {
if
nil
==
Icon
.
internalBundle
{
if
nil
==
Icon
.
internalBundle
{
Icon
.
internalBundle
=
Bundle
(
for
:
View
.
self
)
Icon
.
internalBundle
=
Bundle
(
for
:
View
.
self
)
let
url
=
Icon
.
internalBundle
!.
resourceURL
!
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
{
if
let
v
=
b
{
Icon
.
internalBundle
=
v
Icon
.
internalBundle
=
v
}
}
...
...
Sources/iOS/MotionAnimation.swift
View file @
e352f7a9
...
@@ -423,7 +423,7 @@ extension Motion {
...
@@ -423,7 +423,7 @@ extension Motion {
*/
*/
public
static
func
rotation
(
angle
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
rotation
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotation
)
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
return
animation
}
}
...
@@ -434,7 +434,7 @@ extension Motion {
...
@@ -434,7 +434,7 @@ extension Motion {
*/
*/
public
static
func
rotationX
(
angle
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
rotationX
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationX
)
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
return
animation
}
}
...
@@ -445,7 +445,7 @@ extension Motion {
...
@@ -445,7 +445,7 @@ extension Motion {
*/
*/
public
static
func
rotationY
(
angle
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
rotationY
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationY
)
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
return
animation
}
}
...
@@ -456,7 +456,7 @@ extension Motion {
...
@@ -456,7 +456,7 @@ extension Motion {
*/
*/
public
static
func
rotationZ
(
angle
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
rotationZ
(
angle
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationZ
)
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
return
animation
}
}
...
@@ -467,7 +467,7 @@ extension Motion {
...
@@ -467,7 +467,7 @@ extension Motion {
*/
*/
public
static
func
spin
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
spin
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotation
)
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
return
animation
}
}
...
@@ -478,7 +478,7 @@ extension Motion {
...
@@ -478,7 +478,7 @@ extension Motion {
*/
*/
public
static
func
spinX
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
spinX
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationX
)
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
return
animation
}
}
...
@@ -489,7 +489,7 @@ extension Motion {
...
@@ -489,7 +489,7 @@ extension Motion {
*/
*/
public
static
func
spinY
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
spinY
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationY
)
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
return
animation
}
}
...
@@ -500,7 +500,7 @@ extension Motion {
...
@@ -500,7 +500,7 @@ extension Motion {
*/
*/
public
static
func
spinZ
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
spinZ
(
rotations
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
rotationZ
)
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
return
animation
}
}
...
@@ -511,7 +511,7 @@ extension Motion {
...
@@ -511,7 +511,7 @@ extension Motion {
*/
*/
public
static
func
scale
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
scale
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scale
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
scale
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
return
animation
}
}
...
@@ -522,7 +522,7 @@ extension Motion {
...
@@ -522,7 +522,7 @@ extension Motion {
*/
*/
public
static
func
scaleX
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
scaleX
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleX
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleX
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
return
animation
}
}
...
@@ -533,7 +533,7 @@ extension Motion {
...
@@ -533,7 +533,7 @@ extension Motion {
*/
*/
public
static
func
scaleY
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
scaleY
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleY
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleY
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
return
animation
}
}
...
@@ -544,7 +544,7 @@ extension Motion {
...
@@ -544,7 +544,7 @@ extension Motion {
*/
*/
public
static
func
scaleZ
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
scaleZ
(
to
scale
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleZ
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
scaleZ
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
scale
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
scale
))
return
animation
return
animation
}
}
...
@@ -566,7 +566,7 @@ extension Motion {
...
@@ -566,7 +566,7 @@ extension Motion {
*/
*/
public
static
func
translateX
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
translateX
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationX
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationX
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
translation
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
translation
))
return
animation
return
animation
}
}
...
@@ -577,7 +577,7 @@ extension Motion {
...
@@ -577,7 +577,7 @@ extension Motion {
*/
*/
public
static
func
translateY
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
translateY
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationY
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationY
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
translation
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
translation
))
return
animation
return
animation
}
}
...
@@ -588,7 +588,7 @@ extension Motion {
...
@@ -588,7 +588,7 @@ extension Motion {
*/
*/
public
static
func
translateZ
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
public
static
func
translateZ
(
to
translation
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationZ
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
translationZ
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
translation
))
animation
.
toValue
=
NSNumber
(
value
:
Double
(
translation
))
return
animation
return
animation
}
}
...
...
Sources/iOS/MotionTransition.swift
View file @
e352f7a9
...
@@ -174,8 +174,6 @@ extension UIView {
...
@@ -174,8 +174,6 @@ extension UIView {
v
.
transform
=
transform
v
.
transform
=
transform
v
.
backgroundColor
=
backgroundColor
v
.
backgroundColor
=
backgroundColor
print
(
motionRotationAngle
)
isHidden
=
true
isHidden
=
true
(
self
as?
Pulseable
)?
.
pulse
.
pulseLayer
?
.
isHidden
=
false
(
self
as?
Pulseable
)?
.
pulse
.
pulseLayer
?
.
isHidden
=
false
...
@@ -290,10 +288,10 @@ extension MotionTransition: UIViewControllerAnimatedTransitioning {
...
@@ -290,10 +288,10 @@ extension MotionTransition: UIViewControllerAnimatedTransitioning {
prepareToViewController
()
prepareToViewController
()
prepareFromViewController
()
prepareFromViewController
()
prepareContainerView
()
prepareContainerView
()
prepareTransitionSnapshot
()
prepareTransitionView
()
prepareTransitionView
()
prepareTransitionBackgroundView
()
prepareTransitionBackgroundView
()
prepareTransitionSnapshot
()
prepareTransitionToView
()
prepareToView
()
prepareTransitionAnimation
()
prepareTransitionAnimation
()
}
}
...
@@ -322,9 +320,16 @@ extension MotionTransition {
...
@@ -322,9 +320,16 @@ extension MotionTransition {
containerView
=
transitionContext
.
containerView
containerView
=
transitionContext
.
containerView
}
}
fileprivate
func
prepareTransitionSnapshot
()
{
transitionSnapshot
=
fromView
.
motionTransitionSnapshot
(
afterUpdates
:
true
)
transitionSnapshot
.
frame
=
containerView
.
bounds
containerView
.
addSubview
(
transitionSnapshot
)
}
fileprivate
func
prepareTransitionView
()
{
fileprivate
func
prepareTransitionView
()
{
transitionView
.
frame
=
containerView
.
bounds
transitionView
.
frame
=
containerView
.
bounds
containerView
.
addSubview
(
transitionView
)
containerView
.
insertSubview
(
transitionView
,
belowSubview
:
transitionSnapshot
)
}
}
fileprivate
func
prepareTransitionBackgroundView
()
{
fileprivate
func
prepareTransitionBackgroundView
()
{
...
@@ -333,24 +338,29 @@ extension MotionTransition {
...
@@ -333,24 +338,29 @@ extension MotionTransition {
transitionView
.
addSubview
(
transitionBackgroundView
)
transitionView
.
addSubview
(
transitionBackgroundView
)
}
}
fileprivate
func
prepareTransitionSnapshot
()
{
fileprivate
func
prepareTransitionToView
()
{
transitionSnapshot
=
fromView
.
motionTransitionSnapshot
(
afterUpdates
:
true
)
transitionSnapshot
.
frame
=
containerView
.
bounds
transitionView
.
addSubview
(
transitionSnapshot
)
}
fileprivate
func
prepareToView
()
{
if
isPresenting
{
if
isPresenting
{
containerView
.
insertSubview
(
toView
,
belowSubview
:
transitionView
)
containerView
.
insertSubview
(
toView
,
belowSubview
:
transitionView
)
}
}
toView
.
isHidden
=
false
toView
.
updateConstraints
()
toView
.
updateConstraints
()
toView
.
setNeedsLayout
()
toView
.
setNeedsLayout
()
toView
.
layoutIfNeeded
()
toView
.
layoutIfNeeded
()
toView
.
isHidden
=
false
}
}
fileprivate
func
prepareTransitionAnimation
()
{
fileprivate
func
prepareTransitionAnimation
()
{
addTransitionAnimations
()
addBackgroundMotionAnimation
()
cleanupAnimation
()
cleanupFromView
()
cleanupTransitionSnapshot
()
}
}
extension
MotionTransition
{
fileprivate
func
addTransitionAnimations
()
{
for
fv
in
fromSubviews
{
for
fv
in
fromSubviews
{
for
tv
in
toSubviews
{
for
tv
in
toSubviews
{
if
tv
.
motionTransitionIdentifier
==
fv
.
motionTransitionIdentifier
{
if
tv
.
motionTransitionIdentifier
==
fv
.
motionTransitionIdentifier
{
...
@@ -391,7 +401,7 @@ extension MotionTransition {
...
@@ -391,7 +401,7 @@ extension MotionTransition {
snapshotChildAnimations
.
append
(
Motion
.
position
(
x
:
tv
.
bounds
.
width
/
2
,
y
:
tv
.
bounds
.
height
/
2
))
snapshotChildAnimations
.
append
(
Motion
.
position
(
x
:
tv
.
bounds
.
width
/
2
,
y
:
tv
.
bounds
.
height
/
2
))
let
snapshot
=
fv
.
motionTransitionSnapshot
(
afterUpdates
:
true
)
let
snapshot
=
fv
.
motionTransitionSnapshot
(
afterUpdates
:
true
)
transitionView
.
insertSubview
(
snapshot
,
belowSubview
:
transitionS
napshot
)
transitionView
.
addSubview
(
s
napshot
)
Motion
.
delay
(
t
)
{
Motion
.
delay
(
t
)
{
for
ta
in
tv
.
motionTransitionAnimations
{
for
ta
in
tv
.
motionTransitionAnimations
{
...
@@ -420,16 +430,8 @@ extension MotionTransition {
...
@@ -420,16 +430,8 @@ extension MotionTransition {
}
}
}
}
}
}
addBackgroundMotionAnimation
()
cleanupAnimation
()
cleanupFromView
()
cleanupTransitionSnapshot
()
}
}
}
extension
MotionTransition
{
fileprivate
func
addBackgroundMotionAnimation
()
{
fileprivate
func
addBackgroundMotionAnimation
()
{
transitionBackgroundView
.
motion
(
.
backgroundColor
(
toView
.
backgroundColor
??
.
clear
),
.
duration
(
transitionDuration
(
using
:
transitionContext
)))
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.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* 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.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* 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.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* 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