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
14ca5674
Unverified
Commit
14ca5674
authored
Feb 26, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added depth to Material+Motion animations
parent
99a3eceb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
44 deletions
+96
-44
Material.xcodeproj/project.pbxproj
+0
-0
Sources/iOS/FABToToolbarController.swift
+0
-9
Sources/iOS/Material+CALayer.swift
+1
-1
Sources/iOS/Material+Motion.swift
+24
-12
Sources/iOS/Material+MotionAnimation.swift
+71
-22
No files found.
Material.xcodeproj/project.pbxproj
View file @
14ca5674
This diff is collapsed.
Click to expand it.
Sources/iOS/FABToToolbarController.swift
deleted
100644 → 0
View file @
99a3eceb
//
// FABToToolbarController.swift
// Material
//
// Created by Daniel Dahan on 2017-12-22.
// Copyright © 2017 CosmicMind, Inc. All rights reserved.
//
import
Foundation
Sources/iOS/Material+CALayer.swift
View file @
14ca5674
...
...
@@ -280,7 +280,7 @@ extension CALayer {
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
motion
(
.
shadow
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
))
motion
(
.
shadow
Path
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
))
}
}
}
Sources/iOS/Motion.swift
→
Sources/iOS/M
aterial+M
otion.swift
View file @
14ca5674
...
...
@@ -306,15 +306,10 @@ open class MotionPresentationController: UIPresentationController {
return
}
presentedViewController
.
transitionCoordinator
?
.
animate
(
alongsideTransition
:
{
(
context
)
in
print
(
"Animating"
)
})
print
(
"presentationTransitionWillBegin"
)
presentedViewController
.
transitionCoordinator
?
.
animate
(
alongsideTransition
:
{
(
context
)
in
})
}
open
override
func
presentationTransitionDidEnd
(
_
completed
:
Bool
)
{
print
(
"presentationTransitionDidEnd"
)
}
open
override
func
dismissalTransitionWillBegin
()
{
...
...
@@ -322,15 +317,10 @@ open class MotionPresentationController: UIPresentationController {
return
}
presentedViewController
.
transitionCoordinator
?
.
animate
(
alongsideTransition
:
{
(
context
)
in
print
(
"Animating"
)
})
print
(
"dismissalTransitionWillBegin"
)
presentedViewController
.
transitionCoordinator
?
.
animate
(
alongsideTransition
:
{
(
context
)
in
})
}
open
override
func
dismissalTransitionDidEnd
(
_
completed
:
Bool
)
{
print
(
"dismissalTransitionDidEnd"
)
}
open
override
var
frameOfPresentedViewInContainerView
:
CGRect
{
...
...
@@ -631,6 +621,28 @@ extension Motion {
snapshotAnimations
.
append
(
Motion
.
transform
(
transform
:
to
.
motionTransform
))
snapshotAnimations
.
append
(
Motion
.
background
(
color
:
to
.
backgroundColor
??
.
clear
))
if
let
v
=
to
.
shadowPath
{
snapshotAnimations
.
append
(
Motion
.
shadow
(
path
:
v
))
}
if
let
path
=
to
.
shadowPath
{
let
shadowPath
=
Motion
.
shadow
(
path
:
path
)
shadowPath
.
fromValue
=
fromView
.
shadowPath
snapshotAnimations
.
append
(
shadowPath
)
}
let
shadowOffset
=
Motion
.
shadow
(
offset
:
to
.
shadowOffset
)
shadowOffset
.
fromValue
=
fromView
.
shadowOffset
snapshotAnimations
.
append
(
shadowOffset
)
let
shadowOpacity
=
Motion
.
shadow
(
opacity
:
to
.
shadowOpacity
)
shadowOpacity
.
fromValue
=
fromView
.
shadowOpacity
snapshotAnimations
.
append
(
shadowOpacity
)
let
shadowRadius
=
Motion
.
shadow
(
radius
:
to
.
shadowRadius
)
shadowRadius
.
fromValue
=
fromView
.
shadowRadius
snapshotAnimations
.
append
(
shadowRadius
)
snapshotChildAnimations
.
append
(
cornerRadiusAnimation
)
snapshotChildAnimations
.
append
(
sizeAnimation
)
snapshotChildAnimations
.
append
(
Motion
.
position
(
x
:
to
.
bounds
.
width
/
2
,
y
:
to
.
bounds
.
height
/
2
))
...
...
Sources/iOS/MotionAnimation.swift
→
Sources/iOS/M
aterial+M
otionAnimation.swift
View file @
14ca5674
...
...
@@ -48,12 +48,15 @@ public enum MotionAnimationKeyPath: String {
case
translationY
=
"transform.translation.y"
case
translationZ
=
"transform.translation.z"
case
position
case
shadowPath
case
opacity
case
zPosition
case
width
=
"bounds.size.width"
case
height
=
"bounds.size.height"
case
size
=
"bounds.size"
case
shadowPath
case
shadowOffset
case
shadowOpacity
case
shadowRadius
}
public
enum
MotionAnimation
{
...
...
@@ -85,13 +88,16 @@ public enum MotionAnimation {
case
y
(
CGFloat
)
case
point
(
x
:
CGFloat
,
y
:
CGFloat
)
case
position
(
x
:
CGFloat
,
y
:
CGFloat
)
case
shadow
(
path
:
CGPath
)
case
fade
(
Double
)
case
zPosition
(
Int
)
case
width
(
CGFloat
)
case
height
(
CGFloat
)
case
size
(
width
:
CGFloat
,
height
:
CGFloat
)
case
depth
(
offset
:
CGSize
,
opacity
:
Float
,
radius
:
CGFloat
)
case
shadowPath
(
CGPath
)
case
shadowOffset
(
CGSize
)
case
shadowOpacity
(
Float
)
case
shadowRadius
(
CGFloat
)
case
depth
(
shadowOffset
:
CGSize
,
shadowOpacity
:
Float
,
shadowRadius
:
CGFloat
)
}
@available(iOS 10, *)
...
...
@@ -300,8 +306,6 @@ extension CALayer {
a
.
append
(
position
)
case
let
.
position
(
x
,
y
):
a
.
append
(
Motion
.
position
(
to
:
CGPoint
(
x
:
x
,
y
:
y
)))
case
let
.
shadow
(
path
):
a
.
append
(
Motion
.
shadow
(
path
:
path
))
case
let
.
fade
(
opacity
):
let
fade
=
Motion
.
fade
(
opacity
:
opacity
)
fade
.
fromValue
=
s
.
value
(
forKey
:
MotionAnimationKeyPath
.
opacity
.
rawValue
)
??
NSNumber
(
floatLiteral
:
1
)
...
...
@@ -312,10 +316,40 @@ extension CALayer {
a
.
append
(
zPosition
)
case
.
width
(
_
),
.
height
(
_
),
.
size
(
_
,
_
):
a
.
append
(
Motion
.
size
(
CGSize
(
width
:
w
,
height
:
h
)))
case
let
.
shadowPath
(
path
):
let
shadowPath
=
Motion
.
shadow
(
path
:
path
)
shadowPath
.
fromValue
=
s
.
shadowPath
a
.
append
(
shadowPath
)
case
let
.
shadowOffset
(
offset
):
let
shadowOffset
=
Motion
.
shadow
(
offset
:
offset
)
shadowOffset
.
fromValue
=
s
.
shadowOffset
a
.
append
(
shadowOffset
)
case
let
.
shadowOpacity
(
opacity
):
let
shadowOpacity
=
Motion
.
shadow
(
opacity
:
opacity
)
shadowOpacity
.
fromValue
=
s
.
shadowOpacity
a
.
append
(
shadowOpacity
)
case
let
.
shadowRadius
(
radius
):
let
shadowRadius
=
Motion
.
shadow
(
radius
:
radius
)
shadowRadius
.
fromValue
=
s
.
shadowRadius
a
.
append
(
shadowRadius
)
case
let
.
depth
(
offset
,
opacity
,
radius
):
a
.
append
(
Motion
.
shadow
(
offset
:
offset
))
a
.
append
(
Motion
.
shadow
(
opacity
:
opacity
))
a
.
append
(
Motion
.
shadow
(
radius
:
radius
))
if
let
path
=
s
.
shadowPath
{
let
shadowPath
=
Motion
.
shadow
(
path
:
path
)
shadowPath
.
fromValue
=
s
.
shadowPath
a
.
append
(
shadowPath
)
}
let
shadowOffset
=
Motion
.
shadow
(
offset
:
offset
)
shadowOffset
.
fromValue
=
s
.
shadowOffset
a
.
append
(
shadowOffset
)
let
shadowOpacity
=
Motion
.
shadow
(
opacity
:
opacity
)
shadowOpacity
.
fromValue
=
s
.
shadowOpacity
a
.
append
(
shadowOpacity
)
let
shadowRadius
=
Motion
.
shadow
(
radius
:
radius
)
shadowRadius
.
fromValue
=
s
.
shadowRadius
a
.
append
(
shadowRadius
)
default
:
break
}
}
...
...
@@ -665,17 +699,6 @@ extension Motion {
}
/**
Creates a CABasicAnimation for the shadowPath key path.
- Parameter path: A CGPath.
- Returns: A CABasicAnimation.
*/
public
static
func
shadow
(
path
:
CGPath
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
shadowPath
)
animation
.
toValue
=
path
return
animation
}
/**
Creates a CABasicAnimation for the opacity key path.
- Parameter opacity: A Double.
- Returns: A CABasicAnimation.
...
...
@@ -730,20 +753,46 @@ extension Motion {
return
animation
}
/**
Creates a CABasicAnimation for the shadowPath key path.
- Parameter path: A CGPath.
- Returns: A CABasicAnimation.
*/
public
static
func
shadow
(
path
:
CGPath
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
.
shadowPath
)
animation
.
toValue
=
path
return
animation
}
/**
Creates a CABasicAnimation for the shadowOffset key path.
- Parameter offset: CGSize.
- Returns: A CABasicAnimation.
*/
public
static
func
shadow
(
offset
:
CGSize
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
"shadowOffset"
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
shadowOffset
)
animation
.
toValue
=
NSValue
(
cgSize
:
offset
)
return
animation
}
/**
Creates a CABasicAnimation for the shadowOpacity key path.
- Parameter opacity: Float.
- Returns: A CABasicAnimation.
*/
public
static
func
shadow
(
opacity
:
Float
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
"shadowOpacity"
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
shadowOpacity
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
opacity
))
return
animation
}
/**
Creates a CABasicAnimation for the shadowRadius key path.
- Parameter radius: CGFloat.
- Returns: A CABasicAnimation.
*/
public
static
func
shadow
(
radius
:
CGFloat
)
->
CABasicAnimation
{
let
animation
=
CABasicAnimation
(
keyPath
:
"shadowRadius"
)
let
animation
=
CABasicAnimation
(
keyPath
:
.
shadowRadius
)
animation
.
toValue
=
NSNumber
(
floatLiteral
:
Double
(
radius
))
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