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
9e0f67a1
Commit
9e0f67a1
authored
Oct 02, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working copy of MaterialAnimation and MaterialView
parent
dc6c0098
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
64 deletions
+57
-64
MaterialKit.xcodeproj/project.pbxproj
+8
-0
Source/MaterialAnimation.swift
+6
-2
Source/MaterialBasicAnimation.swift
+5
-46
Source/MaterialKeyframeAnimation.swift
+3
-9
Source/MaterialPulseView.swift
+0
-7
Source/MaterialView.swift
+35
-0
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
9e0f67a1
...
@@ -220,6 +220,7 @@
...
@@ -220,6 +220,7 @@
65BDD1701BB8CD56006F7F2B
/* Label */
,
65BDD1701BB8CD56006F7F2B
/* Label */
,
65BDD1551BB6FC60006F7F2B
/* Button */
,
65BDD1551BB6FC60006F7F2B
/* Button */
,
65BDD1751BB8D44B006F7F2B
/* Animation */
,
65BDD1751BB8D44B006F7F2B
/* Animation */
,
96CEE8BE1BBF56E700DF9844
/* Dynamics */
,
964B17B21BBA445D002A9CA0
/* Layout */
,
964B17B21BBA445D002A9CA0
/* Layout */
,
);
);
path
=
Source
;
path
=
Source
;
...
@@ -282,6 +283,13 @@
...
@@ -282,6 +283,13 @@
name
=
Theme
;
name
=
Theme
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
96CEE8BE1BBF56E700DF9844
/* Dynamics */
=
{
isa
=
PBXGroup
;
children
=
(
);
name
=
Dynamics
;
sourceTree
=
"<group>"
;
};
9AAC38521B89553800FE6B2D
/* Font */
=
{
9AAC38521B89553800FE6B2D
/* Font */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
...
Source/MaterialAnimation.swift
View file @
9e0f67a1
...
@@ -49,8 +49,12 @@ public struct MaterialAnimation {
...
@@ -49,8 +49,12 @@ public struct MaterialAnimation {
/**
/**
:name: applyBasicAnimation
:name: applyBasicAnimation
*/
*/
internal
static
func
applyBasicAnimation
(
animation
:
CABasicAnimation
,
toLayer
layer
:
CALayer
,
completion
:
(()
->
Void
)?
=
nil
)
{
internal
static
func
applyBasicAnimation
(
animation
:
CABasicAnimation
,
toLayer
layer
:
CALayer
)
{
groupAnimation
(
layer
,
animations
:
[
animation
],
duration
:
animation
.
duration
)
// groupAnimation(layer, animations: [animation], duration: animation.duration)
// CATransaction.begin()
// CATransaction.setAnimationDuration(animation.duration)
// layer.setValue(nil == animation.toValue ? animation.byValue : animation.toValue, forKey: animation.keyPath!)
// CATransaction.commit()
}
}
/**
/**
...
...
Source/MaterialBasicAnimation.swift
View file @
9e0f67a1
...
@@ -32,17 +32,9 @@ public extension MaterialAnimation {
...
@@ -32,17 +32,9 @@ public extension MaterialAnimation {
/**
/**
:name: backgroundColor
:name: backgroundColor
*/
*/
public
static
func
backgroundColor
(
view
:
UIView
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
public
static
func
backgroundColor
(
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
return
backgroundColor
(
view
.
layer
,
color
:
color
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: backgroundColor
*/
public
static
func
backgroundColor
(
layer
:
CALayer
,
color
:
UIColor
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
backgroundColorAnimation
(
color
)
let
animation
:
CABasicAnimation
=
backgroundColorAnimation
(
color
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
return
animation
}
}
...
@@ -59,17 +51,9 @@ public extension MaterialAnimation {
...
@@ -59,17 +51,9 @@ public extension MaterialAnimation {
/**
/**
:name: cornerRadius
:name: cornerRadius
*/
*/
public
static
func
cornerRadius
(
view
:
UIView
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
public
static
func
cornerRadius
(
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
return
cornerRadius
(
view
.
layer
,
radius
:
radius
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: cornerRadius
*/
public
static
func
cornerRadius
(
layer
:
CALayer
,
radius
:
CGFloat
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
cornerRadiusAnimation
(
radius
)
let
animation
:
CABasicAnimation
=
cornerRadiusAnimation
(
radius
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
return
animation
}
}
...
@@ -86,17 +70,9 @@ public extension MaterialAnimation {
...
@@ -86,17 +70,9 @@ public extension MaterialAnimation {
/**
/**
:name: rotation
:name: rotation
*/
*/
public
static
func
rotation
(
view
:
UIView
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
public
static
func
rotation
(
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
)
->
CABasicAnimation
{
return
rotation
(
view
.
layer
,
rotations
:
rotations
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: rotation
*/
public
static
func
rotation
(
layer
:
CALayer
,
rotations
:
Int
=
1
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
rotationAnimation
(
rotations
)
let
animation
:
CABasicAnimation
=
rotationAnimation
(
rotations
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
return
animation
}
}
...
@@ -113,17 +89,9 @@ public extension MaterialAnimation {
...
@@ -113,17 +89,9 @@ public extension MaterialAnimation {
/**
/**
:name: scale
:name: scale
*/
*/
public
static
func
scale
(
view
:
UIView
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
public
static
func
scale
(
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
)
->
CABasicAnimation
{
return
scale
(
view
.
layer
,
transform
:
transform
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: scale
*/
public
static
func
scale
(
layer
:
CALayer
,
transform
:
CATransform3D
,
duration
:
CFTimeInterval
=
0.25
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
scaleAnimation
(
transform
)
let
animation
:
CABasicAnimation
=
scaleAnimation
(
transform
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
return
animation
}
}
...
@@ -140,17 +108,9 @@ public extension MaterialAnimation {
...
@@ -140,17 +108,9 @@ public extension MaterialAnimation {
/**
/**
:name: position
:name: position
*/
*/
public
static
func
position
(
view
:
UIView
,
point
:
CGPoint
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
public
static
func
position
(
point
:
CGPoint
,
duration
:
CFTimeInterval
=
0.5
)
->
CABasicAnimation
{
return
position
(
view
.
layer
,
point
:
point
,
duration
:
duration
,
completion
:
completion
)
}
/**
:name: position
*/
public
static
func
position
(
layer
:
CALayer
,
point
:
CGPoint
,
duration
:
CFTimeInterval
=
0.5
,
completion
:
(()
->
Void
)?
=
nil
)
->
CABasicAnimation
{
let
animation
:
CABasicAnimation
=
positionAnimation
(
point
)
let
animation
:
CABasicAnimation
=
positionAnimation
(
point
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyBasicAnimation
(
animation
,
toLayer
:
layer
,
completion
:
completion
)
return
animation
return
animation
}
}
}
}
\ No newline at end of file
Source/MaterialKeyframeAnimation.swift
View file @
9e0f67a1
...
@@ -55,16 +55,9 @@ public extension MaterialAnimation {
...
@@ -55,16 +55,9 @@ public extension MaterialAnimation {
/**
/**
:name: path
:name: path
*/
*/
public
static
func
path
(
view
:
UIView
,
bezierPath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
)
{
public
static
func
path
(
bezierPath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
)
->
CAKeyframeAnimation
{
path
(
view
.
layer
,
bezierPath
:
bezierPath
,
mode
:
mode
,
duration
:
duration
)
}
/**
:name: path
*/
public
static
func
path
(
layer
:
CALayer
,
bezierPath
:
UIBezierPath
,
mode
:
MaterialAnimationRotationMode
=
.
Auto
,
duration
:
CFTimeInterval
=
1
)
{
let
animation
:
CAKeyframeAnimation
=
pathAnimation
(
bezierPath
,
mode
:
mode
)
let
animation
:
CAKeyframeAnimation
=
pathAnimation
(
bezierPath
,
mode
:
mode
)
animation
.
duration
=
duration
animation
.
duration
=
duration
applyKeyframeAnimation
(
animation
,
toLayer
:
layer
)
return
animation
}
}
}
}
\ No newline at end of file
Source/MaterialPulseView.swift
View file @
9e0f67a1
...
@@ -50,13 +50,6 @@ public class MaterialPulseView : MaterialView {
...
@@ -50,13 +50,6 @@ public class MaterialPulseView : MaterialView {
}
}
/**
/**
:name: init
*/
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectNull
)
}
/**
:name: layoutSubviews
:name: layoutSubviews
*/
*/
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
...
...
Source/MaterialView.swift
View file @
9e0f67a1
...
@@ -298,6 +298,41 @@ public class MaterialView : UIView {
...
@@ -298,6 +298,41 @@ public class MaterialView : UIView {
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
/**
:name: addAnimation
*/
public
func
addAnimation
(
animation
:
CAAnimation
)
{
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
layer
.
presentationLayer
()
?
layer
:
layer
.
presentationLayer
()
as!
CALayer
)
.
valueForKeyPath
(
a
.
keyPath
!
)
a
.
delegate
=
self
a
.
fillMode
=
kCAFillModeForwards
a
.
removedOnCompletion
=
false
layer
.
addAnimation
(
animation
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAKeyframeAnimation
{
a
.
delegate
=
self
a
.
fillMode
=
kCAFillModeForwards
a
.
removedOnCompletion
=
false
layer
.
addAnimation
(
animation
,
forKey
:
a
.
keyPath
!
)
}
}
/**
:name: animationDidStart
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{}
/**
:name: animationDidStop
*/
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
=
anim
as?
CABasicAnimation
{
layer
.
setValue
(
nil
==
a
.
toValue
?
a
.
byValue
:
a
.
toValue
,
forKey
:
a
.
keyPath
!
)
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
}
else
if
let
a
=
anim
as?
CAKeyframeAnimation
{
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
}
}
//
//
// :name: prepareView
// :name: prepareView
//
//
...
...
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