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
609842a7
Commit
609842a7
authored
Oct 03, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated MaterialAnimation with duration management on implicit animations
parent
baf52f8b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
154 additions
and
36 deletions
+154
-36
MaterialKit.xcodeproj/project.pbxproj
+12
-0
Source/BasicCardView.swift
+1
-1
Source/MaterialAnimation.swift
+12
-4
Source/MaterialButton.swift
+50
-18
Source/MaterialLayer.swift
+35
-0
Source/MaterialPulseView.swift
+44
-13
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
609842a7
...
...
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
6585D21A1BBCDFBF00426D22
/* BasicCardView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
964B17D81BBB3911002A9CA0
/* BasicCardView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
65AD15EA1BC05B3A0068AF9C
/* MaterialLayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65AD15E91BC05B3A0068AF9C
/* MaterialLayer.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65BDD1471BB5B916006F7F2B
/* MaterialView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1461BB5B916006F7F2B
/* MaterialView.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65BDD1491BB5DC98006F7F2B
/* MaterialColor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1481BB5DC98006F7F2B
/* MaterialColor.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65BDD14B1BB5DD02006F7F2B
/* MaterialFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD14A1BB5DD02006F7F2B
/* MaterialFont.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
...
...
@@ -74,6 +75,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
65AD15E91BC05B3A0068AF9C
/* MaterialLayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialLayer.swift
;
sourceTree
=
"<group>"
;
};
65BDD1461BB5B916006F7F2B
/* MaterialView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialView.swift
;
sourceTree
=
"<group>"
;
};
65BDD1481BB5DC98006F7F2B
/* MaterialColor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialColor.swift
;
sourceTree
=
"<group>"
;
};
65BDD14A1BB5DD02006F7F2B
/* MaterialFont.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialFont.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -130,6 +132,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
65AD15E81BC05B0E0068AF9C
/* Layer */
=
{
isa
=
PBXGroup
;
children
=
(
65AD15E91BC05B3A0068AF9C
/* MaterialLayer.swift */
,
);
name
=
Layer
;
sourceTree
=
"<group>"
;
};
65B965851B8BEEB00055B139
/* View */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -214,6 +224,7 @@
9638325C1B88E3420015F710
/* Supporting Files */
,
96B57D4C1B90AF6A00DE7BBB
/* Theme */
,
9AAC38521B89553800FE6B2D
/* Font */
,
65AD15E81BC05B0E0068AF9C
/* Layer */
,
65B965851B8BEEB00055B139
/* View */
,
65BDD16F1BB89A01006F7F2B
/* Navigation */
,
964B17D71BBB38E2002A9CA0
/* Card */
,
...
...
@@ -430,6 +441,7 @@
65BDD15D1BB70D60006F7F2B
/* MaterialInsets.swift in Sources */
,
65BDD1471BB5B916006F7F2B
/* MaterialView.swift in Sources */
,
65BDD16C1BB88D1A006F7F2B
/* MaterialShape.swift in Sources */
,
65AD15EA1BC05B3A0068AF9C
/* MaterialLayer.swift in Sources */
,
65BDD1521BB6EE7C006F7F2B
/* RobotoFont.swift in Sources */
,
964B17D91BBB3911002A9CA0
/* BasicCardView.swift in Sources */
,
65BDD1591BB6FE3E006F7F2B
/* FlatButton.swift in Sources */
,
...
...
Source/BasicCardView.swift
View file @
609842a7
...
...
@@ -371,7 +371,7 @@ public class BasicCardView : MaterialPulseView {
dividerLayer
!.
backgroundColor
=
dividerColor
?
.
CGColor
dividerLayer
!.
frame
=
CGRectMake
(
0
,
y
,
width
,
1
)
dividerLayer
!.
zPosition
=
900
visualL
ayer
.
addSublayer
(
dividerLayer
!
)
l
ayer
.
addSublayer
(
dividerLayer
!
)
}
}
...
...
Source/MaterialAnimation.swift
View file @
609842a7
...
...
@@ -45,12 +45,20 @@ public func MaterialAnimationFillModeToValue(mode: MaterialAnimationFillMode) ->
public
struct
MaterialAnimation
{
/**
:name:
disableAnimation
:name:
animationDisabled
*/
public
static
func
disableAnimation
(
block
:
(()
->
Void
))
{
public
static
func
animationDisabled
(
animations
:
(()
->
Void
))
{
animationWithDuration
(
0
,
animations
:
animations
)
}
/**
:name: animationWithDuration
*/
public
static
func
animationWithDuration
(
duration
:
NSTimeInterval
,
animations
:
(()
->
Void
),
completion
:
(()
->
Void
)?
=
nil
)
{
CATransaction
.
begin
()
CATransaction
.
setAnimationDuration
(
0
)
block
()
CATransaction
.
setAnimationDuration
(
duration
)
CATransaction
.
setCompletionBlock
(
completion
)
animations
()
CATransaction
.
commit
()
}
...
...
Source/MaterialButton.swift
View file @
609842a7
...
...
@@ -19,15 +19,20 @@
import
UIKit
public
class
MaterialButton
:
UIButton
{
/
/
// :name: visualLayer
/
/
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
/
**
:name: spotlight
*
/
public
lazy
var
spotlight
:
Bool
=
false
//
// :name: pulseLayer
//
internal
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: visualLayer
*/
public
private(set)
lazy
var
visualLayer
:
MaterialLayer
=
MaterialLayer
()
/**
:name: pulseLayer
*/
public
private(set)
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: pulseColorOpacity
...
...
@@ -272,7 +277,7 @@ public class MaterialButton : UIButton {
:name: layerClass
*/
public
override
class
func
layerClass
()
->
AnyClass
{
return
CAShape
Layer
.
self
return
Material
Layer
.
self
}
/**
...
...
@@ -357,14 +362,38 @@ public class MaterialButton : UIButton {
let
point
:
CGPoint
=
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
if
true
==
layer
.
containsPoint
(
point
)
{
let
s
:
CGFloat
=
(
width
<
height
?
height
:
width
)
/
2
MaterialAnimation
.
disableAnimation
({
self
.
pulseLayer
.
bounds
=
CGRectMake
(
0
,
0
,
s
,
s
)
let
f
:
CGFloat
=
3
var
v
:
CGFloat
=
s
/
f
MaterialAnimation
.
animationDisabled
({
self
.
pulseLayer
.
hidden
=
false
self
.
pulseLayer
.
bounds
=
CGRectMake
(
0
,
0
,
v
,
v
)
self
.
pulseLayer
.
position
=
point
self
.
pulseLayer
.
cornerRadius
=
s
/
2
self
.
pulseLayer
.
cornerRadius
=
s
/
6
})
v
=
2
*
f
MaterialAnimation
.
animationWithDuration
(
0.4
,
animations
:
{
self
.
pulseLayer
.
transform
=
CATransform3DMakeScale
(
v
,
v
,
v
)
})
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
})
pulseLayer
.
hidden
=
false
pulseLayer
.
transform
=
CATransform3DMakeScale
(
3
,
3
,
3
)
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
}
}
/**
:name: touchesMoved
*/
public
override
func
touchesMoved
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesMoved
(
touches
,
withEvent
:
event
)
if
spotlight
{
let
point
:
CGPoint
=
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
if
true
==
layer
.
containsPoint
(
point
)
{
MaterialAnimation
.
animationDisabled
({
self
.
pulseLayer
.
position
=
point
})
}
}
}
...
...
@@ -425,8 +454,10 @@ public class MaterialButton : UIButton {
// :name: shrink
//
internal
func
shrink
()
{
pulseLayer
.
hidden
=
true
pulseLayer
.
transform
=
CATransform3DIdentity
layer
.
transform
=
CATransform3DIdentity
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
pulseLayer
.
hidden
=
true
self
.
pulseLayer
.
transform
=
CATransform3DIdentity
self
.
layer
.
transform
=
CATransform3DIdentity
})
}
}
\ No newline at end of file
Source/MaterialLayer.swift
0 → 100644
View file @
609842a7
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
class
MaterialLayer
:
CAShapeLayer
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
public
override
init
(
layer
:
AnyObject
)
{
super
.
init
(
layer
:
layer
)
}
public
override
init
()
{
super
.
init
()
}
}
Source/MaterialPulseView.swift
View file @
609842a7
...
...
@@ -19,10 +19,15 @@
import
UIKit
public
class
MaterialPulseView
:
MaterialView
{
//
// :name: pulseLayer
//
internal
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: spotlight
*/
public
lazy
var
spotlight
:
Bool
=
false
/**
:name: pulseLayer
*/
public
private(set)
lazy
var
pulseLayer
:
CAShapeLayer
=
CAShapeLayer
()
/**
:name: pulseColorOpacity
...
...
@@ -52,14 +57,38 @@ public class MaterialPulseView : MaterialView {
let
point
:
CGPoint
=
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
if
true
==
layer
.
containsPoint
(
point
)
{
let
s
:
CGFloat
=
(
width
<
height
?
height
:
width
)
/
2
MaterialAnimation
.
disableAnimation
({
self
.
pulseLayer
.
bounds
=
CGRectMake
(
0
,
0
,
s
,
s
)
let
f
:
CGFloat
=
3
var
v
:
CGFloat
=
s
/
f
MaterialAnimation
.
animationDisabled
({
self
.
pulseLayer
.
hidden
=
false
self
.
pulseLayer
.
bounds
=
CGRectMake
(
0
,
0
,
v
,
v
)
self
.
pulseLayer
.
position
=
point
self
.
pulseLayer
.
cornerRadius
=
s
/
2
self
.
pulseLayer
.
cornerRadius
=
s
/
6
})
v
=
2
*
f
MaterialAnimation
.
animationWithDuration
(
0.4
,
animations
:
{
self
.
pulseLayer
.
transform
=
CATransform3DMakeScale
(
v
,
v
,
v
)
})
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
})
pulseLayer
.
hidden
=
false
pulseLayer
.
transform
=
CATransform3DMakeScale
(
3
,
3
,
3
)
layer
.
transform
=
CATransform3DMakeScale
(
1.05
,
1.05
,
1.05
)
}
}
/**
:name: touchesMoved
*/
public
override
func
touchesMoved
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesMoved
(
touches
,
withEvent
:
event
)
if
spotlight
{
let
point
:
CGPoint
=
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
if
true
==
layer
.
containsPoint
(
point
)
{
MaterialAnimation
.
animationDisabled
({
self
.
pulseLayer
.
position
=
point
})
}
}
}
...
...
@@ -125,8 +154,10 @@ public class MaterialPulseView : MaterialView {
// :name: shrink
//
internal
func
shrink
()
{
pulseLayer
.
hidden
=
true
pulseLayer
.
transform
=
CATransform3DIdentity
layer
.
transform
=
CATransform3DIdentity
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
pulseLayer
.
hidden
=
true
self
.
pulseLayer
.
transform
=
CATransform3DIdentity
self
.
layer
.
transform
=
CATransform3DIdentity
})
}
}
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