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 {
...
@@ -67,7 +67,7 @@ public class MaterialButton : UIButton {
*/
*/
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
didSet
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
}
}
...
@@ -76,7 +76,7 @@ public class MaterialButton : UIButton {
...
@@ -76,7 +76,7 @@ public class MaterialButton : UIButton {
*/
*/
public
var
pulseColor
:
UIColor
?
{
public
var
pulseColor
:
UIColor
?
{
didSet
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
}
}
...
@@ -302,6 +302,7 @@ public class MaterialButton : UIButton {
...
@@ -302,6 +302,7 @@ public class MaterialButton : UIButton {
shape
=
.
None
shape
=
.
None
contentInsets
=
.
None
contentInsets
=
.
None
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
}
/**
/**
...
@@ -449,15 +450,26 @@ public class MaterialButton : UIButton {
...
@@ -449,15 +450,26 @@ public class MaterialButton : UIButton {
:name: prepareView
:name: prepareView
*/
*/
public
func
prepareView
()
{
public
func
prepareView
()
{
// visualLayer
prepareVisualLayer
()
preparePulseLayer
()
}
//
// :name: prepareVisualLayer
//
internal
func
prepareVisualLayer
()
{
visualLayer
.
zPosition
=
-
1
visualLayer
.
zPosition
=
-
1
visualLayer
.
masksToBounds
=
true
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
layer
.
addSublayer
(
visualLayer
)
}
// pulseLayer
pulseLayer
.
hidden
=
true
//
pulseLayer
.
zPosition
=
1
// :name: layoutVisualLayer
visualLayer
.
addSublayer
(
pulseLayer
)
//
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 {
...
@@ -470,18 +482,18 @@ public class MaterialButton : UIButton {
}
}
//
//
// :name:
layoutVisual
Layer
// :name:
preparePulse
Layer
//
//
internal
func
layoutVisual
Layer
()
{
internal
func
preparePulse
Layer
()
{
visualLayer
.
frame
=
bounds
pulseLayer
.
hidden
=
true
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
pulseLayer
.
zPosition
=
1
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
visualLayer
.
addSublayer
(
pulseLayer
)
}
}
//
//
// :name:
prepar
ePulseLayer
// :name:
updat
ePulseLayer
//
//
internal
func
prepar
ePulseLayer
()
{
internal
func
updat
ePulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
}
...
...
Source/MaterialCollectionViewCell.swift
View file @
1a298e0f
...
@@ -80,7 +80,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
...
@@ -80,7 +80,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
*/
*/
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
didSet
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
}
}
...
@@ -89,7 +89,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
...
@@ -89,7 +89,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
*/
*/
public
var
pulseColor
:
UIColor
?
{
public
var
pulseColor
:
UIColor
?
{
didSet
{
didSet
{
prepar
ePulseLayer
()
updat
ePulseLayer
()
}
}
}
}
...
@@ -304,6 +304,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
...
@@ -304,6 +304,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
shadowDepth
=
.
None
shadowDepth
=
.
None
shape
=
.
None
shape
=
.
None
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
}
/**
/**
...
@@ -325,15 +326,14 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
...
@@ -325,15 +326,14 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
}
}
/**
/**
:name: layoutSub
views
:name: layoutSub
layersOfLayer
*/
*/
public
override
func
layoutSubviews
()
{
public
override
func
layoutSublayersOfLayer
(
layer
:
CALayer
)
{
super
.
layoutSubviews
()
super
.
layoutSublayersOfLayer
(
layer
)
layoutShape
()
if
self
.
layer
==
layer
{
layoutShape
()
visualLayer
.
frame
=
bounds
layoutVisualLayer
()
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
}
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
/**
/**
...
@@ -457,21 +457,64 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
...
@@ -457,21 +457,64 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
borderColor
=
MaterialTheme
.
flatButton
.
bordercolor
borderColor
=
MaterialTheme
.
flatButton
.
bordercolor
shape
=
MaterialTheme
.
flatButton
.
shape
shape
=
MaterialTheme
.
flatButton
.
shape
// visualLayer
prepareVisualLayer
()
preparePulseLayer
()
preparePanGesture
()
}
//
// :name: prepareVisualLayer
//
internal
func
prepareVisualLayer
()
{
visualLayer
.
zPosition
=
-
1
visualLayer
.
zPosition
=
-
1
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
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
.
hidden
=
true
pulseLayer
.
zPosition
=
1
pulseLayer
.
zPosition
=
1
visualLayer
.
addSublayer
(
pulseLayer
)
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
=
UIPanGestureRecognizer
(
target
:
self
,
action
:
"handlePanGesture:"
)
panRecognizer
.
delegate
=
self
panRecognizer
.
delegate
=
self
addGestureRecognizer
(
panRecognizer
)
addGestureRecognizer
(
panRecognizer
)
}
}
//
//
// :name: handlePanGesture
// :name: handlePanGesture
//
//
...
@@ -526,31 +569,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell, UIGestureRecogni
...
@@ -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
// :name: shrink
//
//
internal
func
shrink
()
{
internal
func
shrink
()
{
...
...
Source/MaterialPulseView.swift
View file @
1a298e0f
...
@@ -56,7 +56,7 @@ public class MaterialPulseView : MaterialView {
...
@@ -56,7 +56,7 @@ public class MaterialPulseView : MaterialView {
*/
*/
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
public
var
pulseColorOpacity
:
CGFloat
=
MaterialTheme
.
pulseView
.
pulseColorOpacity
{
didSet
{
didSet
{
prepare
PulseLayer
()
updated
PulseLayer
()
}
}
}
}
...
@@ -65,7 +65,7 @@ public class MaterialPulseView : MaterialView {
...
@@ -65,7 +65,7 @@ public class MaterialPulseView : MaterialView {
*/
*/
public
var
pulseColor
:
UIColor
?
{
public
var
pulseColor
:
UIColor
?
{
didSet
{
didSet
{
prepare
PulseLayer
()
updated
PulseLayer
()
}
}
}
}
...
@@ -156,16 +156,22 @@ public class MaterialPulseView : MaterialView {
...
@@ -156,16 +156,22 @@ public class MaterialPulseView : MaterialView {
borderWidth
=
MaterialTheme
.
pulseView
.
borderWidth
borderWidth
=
MaterialTheme
.
pulseView
.
borderWidth
borderColor
=
MaterialTheme
.
pulseView
.
bordercolor
borderColor
=
MaterialTheme
.
pulseView
.
bordercolor
// pulseLayer
preparePulseLayer
()
}
//
// :name: preparePulseLayer
//
internal
func
preparePulseLayer
()
{
pulseLayer
.
hidden
=
true
pulseLayer
.
hidden
=
true
pulseLayer
.
zPosition
=
1
pulseLayer
.
zPosition
=
1
visualLayer
.
addSublayer
(
pulseLayer
)
visualLayer
.
addSublayer
(
pulseLayer
)
}
}
//
//
// :name:
prepare
PulseLayer
// :name:
updated
PulseLayer
//
//
internal
func
prepare
PulseLayer
()
{
internal
func
updated
PulseLayer
()
{
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
pulseLayer
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
pulseColorOpacity
)
.
CGColor
}
}
...
...
Source/MaterialView.swift
View file @
1a298e0f
...
@@ -291,6 +291,7 @@ public class MaterialView : UIView {
...
@@ -291,6 +291,7 @@ public class MaterialView : UIView {
shape
=
.
None
shape
=
.
None
cornerRadius
=
.
None
cornerRadius
=
.
None
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
}
/**
/**
...
@@ -390,19 +391,16 @@ public class MaterialView : UIView {
...
@@ -390,19 +391,16 @@ public class MaterialView : UIView {
zPosition
=
MaterialTheme
.
view
.
zPosition
zPosition
=
MaterialTheme
.
view
.
zPosition
borderColor
=
MaterialTheme
.
view
.
bordercolor
borderColor
=
MaterialTheme
.
view
.
bordercolor
// visualLayer
prepareVisualLayer
()
visualLayer
.
zPosition
=
-
1
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
}
}
//
//
// :name:
layoutShape
// :name:
prepareVisualLayer
//
//
internal
func
layoutShape
()
{
internal
func
prepareVisualLayer
()
{
if
.
Circle
==
shape
{
visualLayer
.
zPosition
=
-
1
layer
.
cornerRadius
=
width
/
2
visualLayer
.
masksToBounds
=
true
}
layer
.
addSublayer
(
visualLayer
)
}
}
//
//
...
@@ -413,4 +411,13 @@ public class MaterialView : UIView {
...
@@ -413,4 +411,13 @@ public class MaterialView : UIView {
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
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