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
5bf12299
Commit
5bf12299
authored
Aug 27, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progressive cleanup
parent
b1aeb2d5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
77 deletions
+102
-77
Source/AddFabButton.swift
+3
-13
Source/FabButton.swift
+32
-4
Source/FlatButton.swift
+25
-18
Source/MaterialButton.swift
+15
-31
Source/RaisedButton.swift
+27
-11
No files found.
Source/AddFabButton.swift
View file @
5bf12299
...
@@ -22,21 +22,11 @@ public class AddFabButton : FabButton {
...
@@ -22,21 +22,11 @@ public class AddFabButton : FabButton {
private
lazy
var
verticalLine
:
UIView
=
UIView
()
private
lazy
var
verticalLine
:
UIView
=
UIView
()
private
lazy
var
horizontalLine
:
UIView
=
UIView
()
private
lazy
var
horizontalLine
:
UIView
=
UIView
()
/**
:name: prepareButton
*/
public
override
func
prepareButton
()
{
super
.
prepareButton
()
preparePlus
()
}
//
//
// :name:
preparePlus
// :name:
prepareButton
//
//
// I make the + with two views because
public
override
func
prepareButton
()
{
// The label is not actually vertically and horizontally aligned
super
.
prepareButton
()
// Quick hack instead of subclassing UILabel and override drawTextInRect
private
func
preparePlus
()
{
prepareVerticalLine
()
prepareVerticalLine
()
prepareHorizontalLine
()
prepareHorizontalLine
()
}
}
...
...
Source/FabButton.swift
View file @
5bf12299
...
@@ -29,7 +29,6 @@ public class FabButton : MaterialButton {
...
@@ -29,7 +29,6 @@ public class FabButton : MaterialButton {
*/
*/
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
initialize
()
}
}
/**
/**
...
@@ -37,14 +36,43 @@ public class FabButton : MaterialButton {
...
@@ -37,14 +36,43 @@ public class FabButton : MaterialButton {
*/
*/
public
required
init
(
frame
:
CGRect
)
{
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
initialize
()
}
/**
:name: init
*/
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectZero
)
}
}
//
//
// :name:
initialize
// :name:
prepareButton
//
//
internal
func
initialize
()
{
internal
override
func
prepareButton
()
{
super
.
prepareButton
()
color
=
.
redColor
()
color
=
.
redColor
()
pulseColor
=
.
whiteColor
()
pulseColor
=
.
whiteColor
()
}
}
//
// :name: pulseTouches
//
// public override func pulseTouches(touches: Set<NSObject>) {
// super.pulseTouches(touches)
// 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.0
// pulseView!.center = touchLocation
// pulseView!.backgroundColor = pulseColor?.colorWithAlphaComponent(0.5)
// backgroundColorView.addSubview(pulseView!)
// UIView.animateWithDuration(0.3,
// animations: {
// self.pulseView!.transform = CGAffineTransformMakeScale(3, 3)
// self.transform = CGAffineTransformMakeScale(1.1, 1.1)
// },
// completion: nil
// )
// }
}
}
Source/FlatButton.swift
View file @
5bf12299
...
@@ -21,25 +21,32 @@ import UIKit
...
@@ -21,25 +21,32 @@ import UIKit
public
class
FlatButton
:
MaterialButton
{
public
class
FlatButton
:
MaterialButton
{
public
var
textColor
:
UIColor
?
public
var
textColor
:
UIColor
?
/
**
/
/
:name: prepareButton
//
:name: prepareButton
*
/
/
/
public
override
func
prepareButton
()
{
internal
override
func
prepareButton
()
{
super
.
prepareButton
()
super
.
prepareButton
()
}
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
initialize
()
}
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initialize
()
}
func
initialize
()
{
pulseColor
=
.
whiteColor
()
pulseColor
=
.
whiteColor
()
}
}
//
// :name: pulseTouches
//
// public override func pulseTouches(touches: Set<NSObject>) {
// super.pulseTouches(touches)
// let touch = touches.first as! UITouch
// 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: {
// self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
// self.transform = CGAffineTransformMakeScale(1.05, 1.1)
// self.setTitleColor(.whiteColor(), forState: .Normal)
// }, completion: nil)
// }
}
}
Source/MaterialButton.swift
View file @
5bf12299
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
import
UIKit
import
UIKit
public
class
MaterialButton
:
UIButton
{
public
class
MaterialButton
:
UIButton
{
private
lazy
var
pulseView
:
UIView
=
UIView
()
internal
lazy
var
backgroundColorView
:
UIView
=
UIView
()
internal
lazy
var
backgroundColorView
:
UIView
=
UIView
()
internal
var
pulseView
:
UIView
?
public
var
color
:
UIColor
?
public
var
color
:
UIColor
?
public
var
pulseColor
:
UIColor
?
public
var
pulseColor
:
UIColor
?
...
@@ -31,7 +31,6 @@ public class MaterialButton : UIButton {
...
@@ -31,7 +31,6 @@ public class MaterialButton : UIButton {
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareView
()
prepareView
()
prepareShadow
()
}
}
/**
/**
...
@@ -40,7 +39,6 @@ public class MaterialButton : UIButton {
...
@@ -40,7 +39,6 @@ public class MaterialButton : UIButton {
public
required
override
init
(
frame
:
CGRect
)
{
public
required
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
prepareView
()
prepareView
()
prepareShadow
()
}
}
/**
/**
...
@@ -82,16 +80,21 @@ public class MaterialButton : UIButton {
...
@@ -82,16 +80,21 @@ public class MaterialButton : UIButton {
final
public
override
func
drawRect
(
rect
:
CGRect
)
{
final
public
override
func
drawRect
(
rect
:
CGRect
)
{
prepareContext
(
rect
)
prepareContext
(
rect
)
prepareButton
()
prepareButton
()
}
prepareShadow
()
/**
:name: prepareButton
*/
public
func
prepareButton
()
{
prepareBackgroundColorView
()
prepareBackgroundColorView
()
}
}
//
//
// :name: prepareButton
//
internal
func
prepareButton
()
{}
//
// :name: pulseTouches
//
internal
func
pulseTouches
(
touches
:
Set
<
NSObject
>
)
{}
//
// :name: prepareView
// :name: prepareView
//
//
internal
func
prepareView
()
{
internal
func
prepareView
()
{
...
@@ -135,26 +138,6 @@ public class MaterialButton : UIButton {
...
@@ -135,26 +138,6 @@ public class MaterialButton : UIButton {
}
}
//
//
// :name: pulseTouches
//
internal
func
pulseTouches
(
touches
:
NSSet
)
{
let
touch
=
touches
.
allObjects
.
last
as!
UITouch
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
.
frame
=
CGRectMake
(
0
,
0
,
bounds
.
width
,
bounds
.
height
)
pulseView
.
layer
.
cornerRadius
=
bounds
.
width
/
2.0
pulseView
.
center
=
touchLocation
pulseView
.
backgroundColor
=
pulseColor
?
.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
)
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
self
.
pulseView
.
transform
=
CGAffineTransformMakeScale
(
3
,
3
)
self
.
transform
=
CGAffineTransformMakeScale
(
1.1
,
1.1
)
},
completion
:
nil
)
}
//
// :name: shrink
// :name: shrink
//
//
internal
func
shrink
()
{
internal
func
shrink
()
{
...
@@ -176,10 +159,11 @@ public class MaterialButton : UIButton {
...
@@ -176,10 +159,11 @@ public class MaterialButton : UIButton {
internal
func
removePulse
()
{
internal
func
removePulse
()
{
UIView
.
animateWithDuration
(
0.3
,
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
_
in
animations
:
{
_
in
self
.
pulseView
.
alpha
=
0.0
self
.
pulseView
?
.
alpha
=
0.0
}
}
)
{
_
in
)
{
_
in
self
.
pulseView
.
removeFromSuperview
()
self
.
pulseView
?
.
removeFromSuperview
()
self
.
pulseView
=
nil
}
}
}
}
}
}
Source/RaisedButton.swift
View file @
5bf12299
...
@@ -19,19 +19,35 @@
...
@@ -19,19 +19,35 @@
import
UIKit
import
UIKit
public
class
RaisedButton
:
MaterialButton
{
public
class
RaisedButton
:
MaterialButton
{
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
//
super
.
init
(
coder
:
aDecoder
)
// :name: prepareButton
initialize
()
//
}
internal
override
func
prepareButton
()
{
super
.
prepareButton
()
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initialize
()
}
func
initialize
()
{
color
=
.
redColor
()
color
=
.
redColor
()
pulseColor
=
.
whiteColor
()
pulseColor
=
.
whiteColor
()
}
}
//
// :name: pulseTouches
//
// public override func pulseTouches(touches: Set<NSObject>) {
// super.pulseTouches(touches)
// let touch = touches.first as! UITouch
// 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!)
// UIView.animateWithDuration(0.3,
// animations: {
// self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
// self.transform = CGAffineTransformMakeScale(1.05, 1.1)
// },
// completion: nil
// )
// }
}
}
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