liam 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/liam.gemspec +6 -4
- data/lib/liam/MMDrawerBarButtonItem.rb +38 -0
- data/lib/liam/MMDrawerBarButtonView.rb +149 -0
- data/lib/liam/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01633a4e42e7176f6b5f9806223260d801a4bbff
|
4
|
+
data.tar.gz: 622ae1b8a585f992cb9a502cd2e3eda35f943676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4831e9da04246c6763cc2f9de6bcd40cb6428be46c659751da122a86e8393eaed579aa91a7d312c7e4cb4eda8006844ed1d96593d2686c287351fc54fe3c2b24
|
7
|
+
data.tar.gz: 1d2eeeefe1d3c9f4285f93653d40505dc55c7637374e7c7cc57f84822c7b371f3375d045d4f64f6d124c121d045830016d4d59f4ef49b0990a46595d9ba75693
|
data/liam.gemspec
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
require File.expand_path('../lib/liam/version.rb', __FILE__)
|
3
|
+
|
4
|
+
# lib = File.expand_path('../lib', __FILE__)
|
5
|
+
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
# require 'liam/version'
|
5
7
|
|
6
8
|
Gem::Specification.new do |spec|
|
7
9
|
spec.name = "liam"
|
@@ -20,4 +22,4 @@ Gem::Specification.new do |spec|
|
|
20
22
|
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake"
|
23
|
-
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class MMDrawerBarButtonItem < UIBarButtonItem
|
2
|
+
|
3
|
+
attr_accessor :buttonView
|
4
|
+
|
5
|
+
# def initWithTarget:(id)target action:(SEL)action{
|
6
|
+
def initWithTarget(target, action:action)
|
7
|
+
|
8
|
+
buttonView = MMDrawerMenuButtonView.alloc.initWithFrame([[0, 0], [26, 26]])
|
9
|
+
buttonView.addTarget(target, action:action, forControlEvents:UIControlEventTouchUpInside)
|
10
|
+
|
11
|
+
self.initWithCustomView(buttonView)
|
12
|
+
|
13
|
+
if self
|
14
|
+
self.buttonView = buttonView
|
15
|
+
end
|
16
|
+
|
17
|
+
return self
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def menuButtonColorForState(state)
|
22
|
+
return self.buttonView.menuButtonColorForState(state)
|
23
|
+
end
|
24
|
+
|
25
|
+
def setMenuButtonColor(color, forState:state)
|
26
|
+
self.buttonView.setMenuButtonColor(color, forState:state)
|
27
|
+
end
|
28
|
+
|
29
|
+
def shadowColorForState(state)
|
30
|
+
return self.buttonView.shadowColorForState(state)
|
31
|
+
end
|
32
|
+
|
33
|
+
def setShadowColor(color, forState:state)
|
34
|
+
# state = UIControlState
|
35
|
+
self.buttonView.setShadowColor(color, forState:state)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
class MMDrawerMenuButtonView < UIButton
|
2
|
+
|
3
|
+
attr_accessor :menuButtonNormalColor
|
4
|
+
attr_accessor :menuButtonHighlightedColor
|
5
|
+
attr_accessor :shadowNormalColor
|
6
|
+
attr_accessor :shadowHighlightedColor
|
7
|
+
|
8
|
+
# def initWithFrame:(CGRect)frame{
|
9
|
+
def initWithFrame(frame)
|
10
|
+
# self = super.initWithFrame(frame)
|
11
|
+
if(super)
|
12
|
+
self.setMenuButtonNormalColor(UIColor.whiteColor.colorWithAlphaComponent(0.9))
|
13
|
+
self.setMenuButtonHighlightedColor(UIColor.colorWithRed(139.0/255.0, green:135.0/255.0, blue:136.0/255.0, alpha:0.9))
|
14
|
+
|
15
|
+
self.setShadowNormalColor(UIColor.blackColor.colorWithAlphaComponent(0.5))
|
16
|
+
self.setShadowHighlightedColor(UIColor.blackColor.colorWithAlphaComponent(0.2))
|
17
|
+
end
|
18
|
+
return self
|
19
|
+
end
|
20
|
+
|
21
|
+
# def menuButtonColorForState:(UIControlState)state{
|
22
|
+
def menuButtonColorForState(state)
|
23
|
+
color = UIColor.greenColor # A default color just in case, get it, that was funny.
|
24
|
+
|
25
|
+
case (state)
|
26
|
+
when UIControlStateNormal
|
27
|
+
color = self.menuButtonNormalColor
|
28
|
+
when UIControlStateHighlighted
|
29
|
+
color = self.menuButtonHighlightedColor
|
30
|
+
end
|
31
|
+
|
32
|
+
return color
|
33
|
+
end
|
34
|
+
|
35
|
+
# def setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{
|
36
|
+
def setMenuButtonColor(color, forState:state)
|
37
|
+
case (state)
|
38
|
+
when UIControlStateNormal
|
39
|
+
self.setMenuButtonNormalColor(color)
|
40
|
+
when UIControlStateHighlighted
|
41
|
+
self.setMenuButtonHighlightedColor(color)
|
42
|
+
end
|
43
|
+
|
44
|
+
self.setNeedsDisplay
|
45
|
+
end
|
46
|
+
|
47
|
+
# def shadowColorForState:(UIControlState)state{
|
48
|
+
def shadowColorForState(state)
|
49
|
+
color = UIColor.redColor # A default color
|
50
|
+
|
51
|
+
case (state)
|
52
|
+
when UIControlStateNormal
|
53
|
+
color = self.shadowNormalColor
|
54
|
+
when UIControlStateHighlighted
|
55
|
+
color = self.shadowHighlightedColor
|
56
|
+
end
|
57
|
+
|
58
|
+
return color
|
59
|
+
end
|
60
|
+
|
61
|
+
# def setShadowColor:(UIColor *)color forState:(UIControlState)state{
|
62
|
+
def setShadowColor(color, forState:state)
|
63
|
+
case (state)
|
64
|
+
when UIControlStateNormal
|
65
|
+
self.setShadowNormalColor(color)
|
66
|
+
when UIControlStateHighlighted
|
67
|
+
self.setShadowHighlightedColor(color)
|
68
|
+
end
|
69
|
+
self.setNeedsDisplay
|
70
|
+
end
|
71
|
+
|
72
|
+
# def drawRect:(CGRect)rect{
|
73
|
+
def drawRect(rect)
|
74
|
+
# General Declarations
|
75
|
+
context = UIGraphicsGetCurrentContext() #CGContextRef
|
76
|
+
|
77
|
+
# Sizes
|
78
|
+
buttonWidth = CGRectGetWidth(self.bounds) * 0.80
|
79
|
+
buttonHeight = CGRectGetHeight(self.bounds) * 0.16
|
80
|
+
xOffset = CGRectGetWidth(self.bounds) * 0.10
|
81
|
+
yOffset = CGRectGetHeight(self.bounds) * 0.12
|
82
|
+
cornerRadius = 1.0
|
83
|
+
|
84
|
+
# Color Declarations
|
85
|
+
buttonColor = self.menuButtonColorForState(self.state)
|
86
|
+
shadowColor = self.shadowColorForState(self.state)
|
87
|
+
|
88
|
+
|
89
|
+
# Shadow Declarations
|
90
|
+
shadow = shadowColor
|
91
|
+
shadowOffset = CGSizeMake(0.0, 1.0)
|
92
|
+
shadowBlurRadius = 0
|
93
|
+
|
94
|
+
# Top Bun Drawing
|
95
|
+
topBunPath = UIBezierPath.bezierPathWithRoundedRect(CGRectMake(xOffset, yOffset, buttonWidth, buttonHeight), cornerRadius:cornerRadius) # UIBezierPath
|
96
|
+
CGContextSaveGState(context)
|
97
|
+
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor)
|
98
|
+
buttonColor.setFill
|
99
|
+
topBunPath.fill
|
100
|
+
CGContextRestoreGState(context)
|
101
|
+
|
102
|
+
# Meat Drawing
|
103
|
+
meatPath = UIBezierPath.bezierPathWithRoundedRect(CGRectMake(xOffset, yOffset*2 + buttonHeight, buttonWidth, buttonHeight), cornerRadius:cornerRadius) # UIBezierPath*
|
104
|
+
CGContextSaveGState(context)
|
105
|
+
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor)
|
106
|
+
buttonColor.setFill
|
107
|
+
meatPath.fill
|
108
|
+
CGContextRestoreGState(context)
|
109
|
+
|
110
|
+
# Bottom Bun Drawing
|
111
|
+
bottomBunPath = UIBezierPath.bezierPathWithRoundedRect(CGRectMake(xOffset, yOffset*3 + buttonHeight*2, buttonWidth, buttonHeight), cornerRadius:cornerRadius) # UIBezierPath*
|
112
|
+
CGContextSaveGState(context)
|
113
|
+
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor)
|
114
|
+
buttonColor.setFill
|
115
|
+
bottomBunPath.fill
|
116
|
+
CGContextRestoreGState(context)
|
117
|
+
end
|
118
|
+
|
119
|
+
# def touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
|
120
|
+
def touchesBegan(touches, withEvent:event)
|
121
|
+
super
|
122
|
+
self.setNeedsDisplay
|
123
|
+
end
|
124
|
+
|
125
|
+
# def touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
|
126
|
+
def touchesEnded(touches, withEvent:event)
|
127
|
+
super
|
128
|
+
self.setNeedsDisplay
|
129
|
+
end
|
130
|
+
|
131
|
+
# def touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
|
132
|
+
def touchesCancelled(touches, withEvent:event)
|
133
|
+
super
|
134
|
+
self.setNeedsDisplay
|
135
|
+
end
|
136
|
+
|
137
|
+
# def setSelected:(BOOL)selected{
|
138
|
+
def selected=(selected)
|
139
|
+
super
|
140
|
+
self.setNeedsDisplay
|
141
|
+
end
|
142
|
+
|
143
|
+
# def setHighlighted:(BOOL)highlighted{
|
144
|
+
def highlighted=(highlighted)
|
145
|
+
super
|
146
|
+
self.setNeedsDisplay
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
data/lib/liam/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndrewGertig
|
@@ -53,6 +53,8 @@ files:
|
|
53
53
|
- Rakefile
|
54
54
|
- liam.gemspec
|
55
55
|
- lib/liam.rb
|
56
|
+
- lib/liam/MMDrawerBarButtonItem.rb
|
57
|
+
- lib/liam/MMDrawerBarButtonView.rb
|
56
58
|
- lib/liam/version.rb
|
57
59
|
homepage: https://github.com/AndrewGertig/liam
|
58
60
|
licenses:
|