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
b048661a
Commit
b048661a
authored
Aug 27, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed refactor
parent
156f4984
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
58 deletions
+20
-58
Source/AddFabButton.swift
+2
-2
Source/FabButton.swift
+2
-20
Source/FlatButton.swift
+1
-16
Source/MaterialButton.swift
+14
-4
Source/RaisedButton.swift
+1
-16
No files found.
Source/AddFabButton.swift
View file @
b048661a
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
import
UIKit
import
UIKit
public
class
AddFabButton
:
FabButton
{
public
class
AddFabButton
:
FabButton
{
private
lazy
var
verticalLine
:
UIView
=
UIView
()
private
var
verticalLine
:
UIView
!
private
lazy
var
horizontalLine
:
UIView
=
UIView
()
private
var
horizontalLine
:
UIView
!
//
//
// :name: prepareButton
// :name: prepareButton
...
...
Source/FabButton.swift
View file @
b048661a
...
@@ -31,13 +31,6 @@ public class FabButton : MaterialButton {
...
@@ -31,13 +31,6 @@ public class FabButton : MaterialButton {
super
.
prepareButton
()
super
.
prepareButton
()
color
=
.
redColor
()
color
=
.
redColor
()
pulseColor
=
.
whiteColor
()
pulseColor
=
.
whiteColor
()
}
//
// :name: prepareBackgroundColorView
//
internal
override
func
prepareBackgroundColorView
()
{
super
.
prepareBackgroundColorView
()
backgroundColorView
.
layer
.
cornerRadius
=
bounds
.
width
/
2
backgroundColorView
.
layer
.
cornerRadius
=
bounds
.
width
/
2
}
}
...
@@ -46,20 +39,9 @@ public class FabButton : MaterialButton {
...
@@ -46,20 +39,9 @@ public class FabButton : MaterialButton {
//
//
internal
override
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{
internal
override
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{
super
.
pulseTouches
(
touches
)
super
.
pulseTouches
(
touches
)
let
touch
=
touches
.
first
as!
UITouch
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
bounds
.
width
,
bounds
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
width
/
2
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
!
)
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
3
,
3
)
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
3
,
3
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.1
,
1.1
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.1
,
1.1
)
},
})
completion
:
nil
)
}
}
}
}
Source/FlatButton.swift
View file @
b048661a
...
@@ -30,13 +30,6 @@ public class FlatButton : MaterialButton {
...
@@ -30,13 +30,6 @@ public class FlatButton : MaterialButton {
internal
override
func
prepareButton
()
{
internal
override
func
prepareButton
()
{
super
.
prepareButton
()
super
.
prepareButton
()
pulseColor
=
.
whiteColor
()
pulseColor
=
.
whiteColor
()
}
//
// :name: prepareBackgroundColorView
//
internal
override
func
prepareBackgroundColorView
()
{
super
.
prepareBackgroundColorView
()
backgroundColorView
.
layer
.
cornerRadius
=
3
backgroundColorView
.
layer
.
cornerRadius
=
3
}
}
...
@@ -45,15 +38,7 @@ public class FlatButton : MaterialButton {
...
@@ -45,15 +38,7 @@ public class FlatButton : MaterialButton {
//
//
internal
override
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{
internal
override
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{
super
.
pulseTouches
(
touches
)
super
.
pulseTouches
(
touches
)
let
touch
=
touches
.
first
as!
UITouch
textColor
=
titleLabel
?
.
textColor
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
height
,
self
.
bounds
.
size
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
height
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
!
)
textColor
=
self
.
titleLabel
?
.
textColor
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
10
,
10
)
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
10
,
10
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.05
,
1.1
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.05
,
1.1
)
...
...
Source/MaterialButton.swift
View file @
b048661a
...
@@ -93,20 +93,31 @@ public class MaterialButton : UIButton {
...
@@ -93,20 +93,31 @@ public class MaterialButton : UIButton {
*/
*/
final
public
override
func
drawRect
(
rect
:
CGRect
)
{
final
public
override
func
drawRect
(
rect
:
CGRect
)
{
prepareContext
(
rect
)
prepareContext
(
rect
)
prepareButton
()
prepareShadow
()
prepareShadow
()
prepareButton
()
prepareBackgroundColorView
()
prepareBackgroundColorView
()
}
}
//
//
// :name: prepareButton
// :name: prepareButton
//
//
internal
func
prepareButton
()
{}
internal
func
prepareButton
()
{
backgroundColorView
.
frame
=
bounds
}
//
//
// :name: pulseTouches
// :name: pulseTouches
//
//
internal
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{}
internal
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{
let
touch
=
touches
.
first
as!
UITouch
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
bounds
.
width
,
bounds
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
width
/
2
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
!
)
}
//
//
// :name: prepareBackgroundColorView
// :name: prepareBackgroundColorView
...
@@ -114,7 +125,6 @@ public class MaterialButton : UIButton {
...
@@ -114,7 +125,6 @@ public class MaterialButton : UIButton {
// We need this view so we can use the masksToBounds
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
// so the pulse doesn't animate off the button
internal
func
prepareBackgroundColorView
()
{
internal
func
prepareBackgroundColorView
()
{
backgroundColorView
.
frame
=
bounds
backgroundColorView
.
backgroundColor
=
color
backgroundColorView
.
backgroundColor
=
color
backgroundColorView
.
layer
.
masksToBounds
=
true
backgroundColorView
.
layer
.
masksToBounds
=
true
backgroundColorView
.
userInteractionEnabled
=
false
backgroundColorView
.
userInteractionEnabled
=
false
...
...
Source/RaisedButton.swift
View file @
b048661a
...
@@ -31,13 +31,6 @@ public class RaisedButton : MaterialButton {
...
@@ -31,13 +31,6 @@ public class RaisedButton : MaterialButton {
super
.
prepareButton
()
super
.
prepareButton
()
color
=
.
redColor
()
color
=
.
redColor
()
pulseColor
=
.
whiteColor
()
pulseColor
=
.
whiteColor
()
}
//
// :name: prepareBackgroundColorView
//
internal
override
func
prepareBackgroundColorView
()
{
super
.
prepareBackgroundColorView
()
backgroundColorView
.
layer
.
cornerRadius
=
3
backgroundColorView
.
layer
.
cornerRadius
=
3
}
}
...
@@ -46,15 +39,7 @@ public class RaisedButton : MaterialButton {
...
@@ -46,15 +39,7 @@ public class RaisedButton : MaterialButton {
//
//
internal
override
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{
internal
override
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{
super
.
pulseTouches
(
touches
)
super
.
pulseTouches
(
touches
)
let
touch
=
touches
.
first
as!
UITouch
textColor
=
titleLabel
?
.
textColor
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
height
,
self
.
bounds
.
size
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
height
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
!
)
textColor
=
self
.
titleLabel
?
.
textColor
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
10
,
10
)
self
.
pulseView
!.
transform
=
CGAffineTransformMakeScale
(
10
,
10
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.05
,
1.1
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.05
,
1.1
)
...
...
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