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
24b2bdfb
Commit
24b2bdfb
authored
Oct 07, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated MaterialAnimation internals and added delegation handling
parent
ac8fb0e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
46 deletions
+23
-46
Source/MaterialAnimation.swift
+13
-0
Source/MaterialButton.swift
+6
-23
Source/MaterialView.swift
+4
-23
No files found.
Source/MaterialAnimation.swift
View file @
24b2bdfb
...
...
@@ -18,6 +18,19 @@
import
UIKit
@objc(MaterialAnimationDelegate)
public
protocol
MaterialAnimationDelegate
{
/**
:name: materialAnimationDidStart
*/
optional
func
materialAnimationDidStart
(
animation
:
CAAnimation
)
/**
:name: materialAnimationDidStop
*/
optional
func
materialAnimationDidStop
(
animation
:
CAAnimation
,
finished
flag
:
Bool
)
}
public
typealias
MaterialAnimationFillModeType
=
String
public
enum
MaterialAnimationFillMode
{
...
...
Source/MaterialButton.swift
View file @
24b2bdfb
...
...
@@ -18,19 +18,6 @@
import
UIKit
@objc(MaterialButtonDelegate)
public
protocol
MaterialButtonDelegate
{
/**
:name: animationDidStart
*/
optional
func
animationDidStart
(
materialButton
:
MaterialButton
,
animation
:
CAAnimation
)
/**
:name: animationDidStop
*/
optional
func
animationDidStop
(
materialButton
:
MaterialButton
,
animation
:
CAAnimation
,
finished
flag
:
Bool
)
}
@objc(MaterialButton)
public
class
MaterialButton
:
UIButton
{
/**
...
...
@@ -46,7 +33,7 @@ public class MaterialButton : UIButton {
/**
:name: delegate
*/
public
weak
var
delegate
:
Material
Butt
onDelegate
?
public
weak
var
delegate
:
Material
Animati
onDelegate
?
/**
:name: pulseScale
...
...
@@ -343,6 +330,7 @@ public class MaterialButton : UIButton {
prepareShape
()
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
...
...
@@ -356,13 +344,10 @@ public class MaterialButton : UIButton {
}
if
let
a
:
CAPropertyAnimation
=
animation
as?
CAPropertyAnimation
{
layer
.
addAnimation
(
a
,
forKey
:
a
.
keyPath
!
)
if
true
==
filterAnimations
(
a
)
{
visualLayer
.
addAnimation
(
a
,
forKey
:
a
.
keyPath
!
)
}
}
else
if
let
a
:
CAAnimationGroup
=
animation
as?
CAAnimationGroup
{
layer
.
addAnimation
(
a
,
forKey
:
nil
)
filterAnimations
(
a
)
visualLayer
.
addAnimation
(
a
,
forKey
:
nil
)
}
else
if
let
a
:
CATransition
=
animation
as?
CATransition
{
layer
.
addAnimation
(
a
,
forKey
:
kCATransition
)
}
}
...
...
@@ -370,7 +355,7 @@ public class MaterialButton : UIButton {
:name: animationDidStart
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
delegate
?
.
animationDidStart
?(
self
,
animation
:
anim
)
delegate
?
.
materialAnimationDidStart
?(
anim
)
}
/**
...
...
@@ -382,16 +367,14 @@ public class MaterialButton : UIButton {
MaterialAnimation
.
animationDisabled
({
self
.
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
})
delegate
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
visualLayer
.
removeAnimationForKey
(
a
.
keyPath
!
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
delegate
?
.
animationDidStop
?(
self
,
animation
:
anim
,
finished
:
flag
)
}
//
...
...
Source/MaterialView.swift
View file @
24b2bdfb
...
...
@@ -18,19 +18,6 @@
import
UIKit
@objc(MaterialViewDelegate)
public
protocol
MaterialViewDelegate
{
/**
:name: animationDidStart
*/
optional
func
animationDidStart
(
materialView
:
MaterialView
,
animation
:
CAAnimation
)
/**
:name: animationDidStop
*/
optional
func
animationDidStop
(
materialView
:
MaterialView
,
animation
:
CAAnimation
,
finished
flag
:
Bool
)
}
@objc(MaterialView)
public
class
MaterialView
:
UIView
{
//
...
...
@@ -41,7 +28,7 @@ public class MaterialView : UIView {
/**
:name: visualLayer
*/
public
weak
var
delegate
:
Material
View
Delegate
?
public
weak
var
delegate
:
Material
Animation
Delegate
?
/**
:name: image
...
...
@@ -335,6 +322,7 @@ public class MaterialView : UIView {
prepareShape
()
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
...
...
@@ -348,13 +336,8 @@ public class MaterialView : UIView {
}
if
let
a
:
CAPropertyAnimation
=
animation
as?
CAPropertyAnimation
{
layer
.
addAnimation
(
a
,
forKey
:
a
.
keyPath
!
)
if
true
==
filterAnimations
(
a
)
{
visualLayer
.
addAnimation
(
a
,
forKey
:
a
.
keyPath
!
)
}
}
else
if
let
a
:
CAAnimationGroup
=
animation
as?
CAAnimationGroup
{
layer
.
addAnimation
(
a
,
forKey
:
nil
)
filterAnimations
(
a
)
visualLayer
.
addAnimation
(
a
,
forKey
:
nil
)
}
else
if
let
a
:
CATransition
=
animation
as?
CATransition
{
layer
.
addAnimation
(
a
,
forKey
:
kCATransition
)
}
...
...
@@ -364,7 +347,7 @@ public class MaterialView : UIView {
:name: animationDidStart
*/
public
override
func
animationDidStart
(
anim
:
CAAnimation
)
{
delegate
?
.
animationDidStart
?(
self
,
animation
:
anim
)
delegate
?
.
materialAnimationDidStart
?(
anim
)
}
/**
...
...
@@ -376,16 +359,14 @@ public class MaterialView : UIView {
MaterialAnimation
.
animationDisabled
({
self
.
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
})
delegate
?
.
materialAnimationDidStop
?(
anim
,
finished
:
flag
)
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
visualLayer
.
removeAnimationForKey
(
a
.
keyPath
!
)
}
else
if
let
a
:
CAAnimationGroup
=
anim
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
delegate
?
.
animationDidStop
?(
self
,
animation
:
anim
,
finished
:
flag
)
}
//
...
...
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