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
159f7a6c
Commit
159f7a6c
authored
Oct 03, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added pulseFill and pulseScale booleans
parent
80a0075e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
15 deletions
+42
-15
Source/MaterialButton.swift
+21
-7
Source/MaterialPulseView.swift
+17
-3
Source/MaterialTheme.swift
+1
-1
Source/MaterialView.swift
+3
-4
No files found.
Source/MaterialButton.swift
View file @
159f7a6c
...
...
@@ -35,6 +35,16 @@ public class MaterialButton : UIButton {
public
private(set)
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: pulseScale
*/
public
lazy
var
pulseScale
:
Bool
=
true
/**
:name: pulseFill
*/
public
lazy
var
pulseFill
:
Bool
=
false
/**
:name: pulseColorOpacity
*/
public
var
pulseColorOpacity
:
CGFloat
!
{
...
...
@@ -322,10 +332,9 @@ public class MaterialButton : UIButton {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
CATransaction
.
begin
()
CATransaction
.
setDisableActions
(
true
)
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
CATransaction
.
commit
()
MaterialAnimation
.
animationDisabled
({
self
.
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
})
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
visualLayer
.
removeAnimationForKey
(
a
.
keyPath
!
)
...
...
@@ -364,7 +373,7 @@ public class MaterialButton : UIButton {
let
s
:
CGFloat
=
(
width
<
height
?
height
:
width
)
/
2
let
f
:
CGFloat
=
3
let
v
:
CGFloat
=
s
/
f
let
d
:
CGFloat
=
2
*
f
let
d
:
CGFloat
=
pulseFill
?
5
*
f
:
2
*
f
MaterialAnimation
.
animationDisabled
({
self
.
pulseLayer
.
hidden
=
false
self
.
pulseLayer
.
bounds
=
CGRectMake
(
0
,
0
,
v
,
v
)
...
...
@@ -373,7 +382,9 @@ public class MaterialButton : UIButton {
})
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
pulseLayer
.
transform
=
CATransform3DMakeScale
(
d
,
d
,
d
)
self
.
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
if
self
.
pulseScale
{
self
.
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
}
})
}
}
...
...
@@ -453,7 +464,9 @@ public class MaterialButton : UIButton {
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
pulseLayer
.
hidden
=
true
self
.
pulseLayer
.
transform
=
CATransform3DIdentity
self
.
layer
.
transform
=
CATransform3DIdentity
if
self
.
pulseScale
{
self
.
layer
.
transform
=
CATransform3DIdentity
}
})
}
}
\ No newline at end of file
Source/MaterialPulseView.swift
View file @
159f7a6c
...
...
@@ -30,6 +30,16 @@ public class MaterialPulseView : MaterialView {
public
private(set)
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: pulseScale
*/
public
lazy
var
pulseScale
:
Bool
=
true
/**
:name: pulseFill
*/
public
lazy
var
pulseFill
:
Bool
=
false
/**
:name: pulseColorOpacity
*/
public
var
pulseColorOpacity
:
CGFloat
!
{
...
...
@@ -59,7 +69,7 @@ public class MaterialPulseView : MaterialView {
let
s
:
CGFloat
=
(
width
<
height
?
height
:
width
)
/
2
let
f
:
CGFloat
=
3
let
v
:
CGFloat
=
s
/
f
let
d
:
CGFloat
=
2
*
f
let
d
:
CGFloat
=
pulseFill
?
5
*
f
:
2
*
f
MaterialAnimation
.
animationDisabled
({
self
.
pulseLayer
.
hidden
=
false
self
.
pulseLayer
.
bounds
=
CGRectMake
(
0
,
0
,
v
,
v
)
...
...
@@ -68,7 +78,9 @@ public class MaterialPulseView : MaterialView {
})
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
pulseLayer
.
transform
=
CATransform3DMakeScale
(
d
,
d
,
d
)
self
.
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
if
self
.
pulseScale
{
self
.
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
}
})
}
}
...
...
@@ -153,7 +165,9 @@ public class MaterialPulseView : MaterialView {
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
pulseLayer
.
hidden
=
true
self
.
pulseLayer
.
transform
=
CATransform3DIdentity
self
.
layer
.
transform
=
CATransform3DIdentity
if
self
.
pulseScale
{
self
.
layer
.
transform
=
CATransform3DIdentity
}
})
}
}
Source/MaterialTheme.swift
View file @
159f7a6c
...
...
@@ -194,7 +194,7 @@ public extension MaterialTheme.flatButton {
// shape
public
static
var
masksToBounds
:
Bool
=
true
public
static
var
cornerRadius
:
MaterialRadius
=
.
Radius1
public
static
var
contentInsets
:
MaterialInsets
=
.
Rectangle
2
public
static
var
contentInsets
:
MaterialInsets
=
.
Rectangle
3
public
static
var
shape
:
MaterialShape
?
=
nil
// border
...
...
Source/MaterialView.swift
View file @
159f7a6c
...
...
@@ -329,10 +329,9 @@ public class MaterialView : UIView {
public
override
func
animationDidStop
(
anim
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
anim
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
CATransaction
.
begin
()
CATransaction
.
setDisableActions
(
true
)
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
CATransaction
.
commit
()
MaterialAnimation
.
animationDisabled
({
self
.
layer
.
setValue
(
nil
==
b
.
toValue
?
b
.
byValue
:
b
.
toValue
,
forKey
:
b
.
keyPath
!
)
})
}
layer
.
removeAnimationForKey
(
a
.
keyPath
!
)
visualLayer
.
removeAnimationForKey
(
a
.
keyPath
!
)
...
...
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