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
1a298e0f
Commit
1a298e0f
authored
Oct 14, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating internal layout updates
parent
d20bca54
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
69 deletions
+112
-69
Source/MaterialButton.swift
+27
-15
Source/MaterialCollectionViewCell.swift
+58
-40
Source/MaterialPulseView.swift
+11
-5
Source/MaterialView.swift
+16
-9
No files found.
Source/MaterialButton.swift
View file @
1a298e0f
...
...
@@ -67,7 +67,7 @@ public class MaterialButton : UIButton {
*/
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
...
...
@@ -76,7 +76,7 @@ public class MaterialButton : UIButton {
*/
public
var
pulseColor
:
UIColor
?
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
...
...
@@ -302,6 +302,7 @@ public class MaterialButton : UIButton {
shape
=
.
None
contentInsets
=
.
None
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
...
...
@@ -449,15 +450,26 @@ public class MaterialButton : UIButton {
:name: prepareView
*/
public
func
prepareView
()
{
// visualLayer
prepareVisualLayer
()
preparePulseLayer
()
}
//
// :name: prepareVisualLayer
//
internal
func
prepareVisualLayer
()
{
visualLayer
.
zPosition
=
-
1
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
// pulseLayer
pulseLayer
.
hidden
=
true
pulseLayer
.
zPosition
=
1
visualLayer
.
addSublayer
(
pulseLayer
)
}
//
// :name: layoutVisualLayer
//
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
//
...
...
@@ -470,18 +482,18 @@ public class MaterialButton : UIButton {
}
//
// :name:
layoutVisual
Layer
// :name:
preparePulse
Layer
//
internal
func
layoutVisual
Layer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
internal
func
preparePulse
Layer
()
{
pulseLayer
.
hidden
=
true
pulseLayer
.
zPosition
=
1
visualLayer
.
addSublayer
(
pulseLayer
)
}
//
// :name:
prepar
ePulseLayer
// :name:
updat
ePulseLayer
//
internal
func
prepar
ePulseLayer
()
{
internal
func
updat
ePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
...
...
Source/MaterialCollectionViewCell.swift
View file @
1a298e0f
...
...
@@ -80,7 +80,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
*/
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
...
...
@@ -89,7 +89,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
*/
public
var
pulseColor
:
UIColor
?
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
...
...
@@ -304,6 +304,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
shadowDepth
=
.
None
shape
=
.
None
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
...
...
@@ -325,15 +326,14 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
}
/**
:name: layoutSub
views
:name: layoutSub
layersOfLayer
*/
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
layoutShape
()
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
public
override
func
layoutSublayersOfLayer
(
layer
:
CALayer
)
{
super
.
layoutSublayersOfLayer
(
layer
)
if
self
.
layer
==
layer
{
layoutShape
()
layoutVisualLayer
()
}
}
/**
...
...
@@ -457,21 +457,64 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
borderColor
=
MaterialTheme
.
flatButton
.
bordercolor
shape
=
MaterialTheme
.
flatButton
.
shape
// visualLayer
prepareVisualLayer
()
preparePulseLayer
()
preparePanGesture
()
}
//
// :name: prepareVisualLayer
//
internal
func
prepareVisualLayer
()
{
visualLayer
.
zPosition
=
-
1
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
// pulseLayer
}
//
// :name: layoutVisualLayer
//
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
//
// :name: layoutShape
//
internal
func
layoutShape
()
{
if
.
Circle
==
shape
{
layer
.
cornerRadius
=
width
/
2
}
}
//
// :name: preparePulseLayer
//
internal
func
preparePulseLayer
()
{
pulseLayer
.
hidden
=
true
pulseLayer
.
zPosition
=
1
visualLayer
.
addSublayer
(
pulseLayer
)
// gesture
}
//
// :name: updatePulseLayer
//
internal
func
updatePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
//
// :name: preparePanGesture
//
internal
func
preparePanGesture
()
{
panRecognizer
=
UIPanGestureRecognizer
(
target
:
self
,
action
:
"handlePanGesture:"
)
panRecognizer
.
delegate
=
self
addGestureRecognizer
(
panRecognizer
)
}
//
// :name: handlePanGesture
//
...
...
@@ -526,31 +569,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
}
//
// :name: layoutShape
//
internal
func
layoutShape
()
{
if
.
Circle
==
shape
{
layer
.
cornerRadius
=
width
/
2
}
}
//
// :name: layoutVisualLayer
//
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
//
// :name: preparePulseLayer
//
internal
func
preparePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
//
// :name: shrink
//
internal
func
shrink
()
{
...
...
Source/MaterialPulseView.swift
View file @
1a298e0f
...
...
@@ -56,7 +56,7 @@ public class MaterialPulseView : MaterialView {
*/
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
didSet
{
prepare
PulseLayer
()
updated
PulseLayer
()
}
}
...
...
@@ -65,7 +65,7 @@ public class MaterialPulseView : MaterialView {
*/
public
var
pulseColor
:
UIColor
?
{
didSet
{
prepare
PulseLayer
()
updated
PulseLayer
()
}
}
...
...
@@ -156,16 +156,22 @@ public class MaterialPulseView : MaterialView {
borderWidth
=
MaterialTheme
.
pulseView
.
borderWidth
borderColor
=
MaterialTheme
.
pulseView
.
bordercolor
// pulseLayer
preparePulseLayer
()
}
//
// :name: preparePulseLayer
//
internal
func
preparePulseLayer
()
{
pulseLayer
.
hidden
=
true
pulseLayer
.
zPosition
=
1
visualLayer
.
addSublayer
(
pulseLayer
)
}
//
// :name:
prepare
PulseLayer
// :name:
updated
PulseLayer
//
internal
func
prepare
PulseLayer
()
{
internal
func
updated
PulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
...
...
Source/MaterialView.swift
View file @
1a298e0f
...
...
@@ -291,6 +291,7 @@ public class MaterialView : UIView {
shape
=
.
None
cornerRadius
=
.
None
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
...
...
@@ -390,19 +391,16 @@ public class MaterialView : UIView {
zPosition
=
MaterialTheme
.
view
.
zPosition
borderColor
=
MaterialTheme
.
view
.
bordercolor
// visualLayer
visualLayer
.
zPosition
=
-
1
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
prepareVisualLayer
()
}
//
// :name:
layoutShape
// :name:
prepareVisualLayer
//
internal
func
layoutShape
()
{
if
.
Circle
==
shape
{
layer
.
cornerRadius
=
width
/
2
}
internal
func
prepareVisualLayer
()
{
visualLayer
.
zPosition
=
-
1
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
}
//
...
...
@@ -413,4 +411,13 @@ public class MaterialView : UIView {
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
//
// :name: layoutShape
//
internal
func
layoutShape
()
{
if
.
Circle
==
shape
{
layer
.
cornerRadius
=
width
/
2
}
}
}
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