forked from facebookarchive/three20
/
TTDefaultStyleSheet.m
319 lines (269 loc) · 11.2 KB
/
TTDefaultStyleSheet.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#import "Three20/TTDefaultStyleSheet.h"
#import "Three20/TTStyle.h"
#import "Three20/TTShape.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation TTDefaultStyleSheet
///////////////////////////////////////////////////////////////////////////////////////////////////
// styles
- (TTStyle*)linkText {
return
[TTTextStyle styleWithColor:self.linkTextColor next:nil];
}
- (TTStyle*)linkTextHighlighted {
return
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-3, -4, -3, -4) next:
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:4.5] next:
[TTSolidFillStyle styleWithColor:[UIColor colorWithWhite:0 alpha:0.25] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(3, 4, 3, 4) next:
[TTTextStyle styleWithColor:self.linkTextColor next:nil]]]]];
}
- (TTStyle*)linkHighlighted {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:4.5] next:
[TTSolidFillStyle styleWithColor:[UIColor colorWithWhite:0 alpha:0.4] next:nil]];
}
- (TTStyle*)thumbView:(UIControlState)state {
if (state & UIControlStateHighlighted) {
return
[TTSolidFillStyle styleWithColor:RGBACOLOR(0,0,0,0.6) next:
[TTSolidBorderStyle styleWithColor:RGBACOLOR(0,0,0,0.4) width:1 next:nil]];
} else {
return
[TTSolidBorderStyle styleWithColor:RGBACOLOR(0,0,0,0.4) width:1 next:nil];
}
}
- (TTStyle*)toolbarButton:(UIControlState)state {
return [self toolbarButtonForState:state
shape:[TTRoundedRectangleShape shapeWithRadius:4.5]
tintColor:TTSTYLEVAR(navigationBarTintColor)
font:TTSTYLEVAR(toolbarButtonFont)];
}
- (TTStyle*)toolbarBackButton:(UIControlState)state {
return
[self toolbarButtonForState:state
shape:[TTRoundedLeftArrowShape shapeWithRadius:4.5]
tintColor:TTSTYLEVAR(navigationBarTintColor)
font:TTSTYLEVAR(toolbarButtonFont)];
}
- (TTStyle*)toolbarForwardButton:(UIControlState)state {
return
[self toolbarButtonForState:state
shape:[TTRoundedRightArrowShape shapeWithRadius:4.5]
tintColor:TTSTYLEVAR(navigationBarTintColor)
font:TTSTYLEVAR(toolbarButtonFont)];
}
- (TTStyle*)toolbarRoundButton:(UIControlState)state {
return
[self toolbarButtonForState:state
shape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED]
tintColor:TTSTYLEVAR(navigationBarTintColor)
font:TTSTYLEVAR(toolbarButtonFont)];
}
- (TTStyle*)blackToolbarButton:(UIControlState)state {
return
[self toolbarButtonForState:state
shape:[TTRoundedRectangleShape shapeWithRadius:4.5]
tintColor:RGBCOLOR(10, 10, 10)
font:TTSTYLEVAR(toolbarButtonFont)];
}
- (TTStyle*)blackToolbarForwardButton:(UIControlState)state {
return
[self toolbarButtonForState:state
shape:[TTRoundedRightArrowShape shapeWithRadius:4.5]
tintColor:RGBCOLOR(10, 10, 10)
font:TTSTYLEVAR(toolbarButtonFont)];
}
- (TTStyle*)blackToolbarRoundButton:(UIControlState)state {
return
[self toolbarButtonForState:state
shape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED]
tintColor:RGBCOLOR(10, 10, 10)
font:TTSTYLEVAR(toolbarButtonFont)];
}
- (TTStyle*)searchTextField {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:13] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 0, 2, 0) next:
[TTShadowStyle styleWithColor:RGBACOLOR(255,255,255,0.6) blur:0 offset:CGSizeMake(0, 1) next:
[TTSolidFillStyle styleWithColor:[UIColor whiteColor] next:
[TTInnerShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.4) blur:3 offset:CGSizeMake(0, 2) next:
[TTBevelBorderStyle styleWithHighlight:RGBACOLOR(0,0,0,0.25) shadow:RGBACOLOR(0,0,0,0.4)
width:1 lightSource:270 next:nil]]]]]];
}
- (TTStyle*)searchBar {
UIColor* color = TTSTYLEVAR(searchBarTintColor);
UIColor* highlight = [color multiplyHue:0 saturation:0 value:1.2];
UIColor* shadow = [color multiplyHue:0 saturation:0 value:0.82];
return
[TTLinearGradientFillStyle styleWithColor1:highlight color2:color next:
[TTFourBorderStyle styleWithTop:nil right:nil bottom:shadow left:nil width:1 next:nil]];
}
- (TTStyle*)searchBarBottom {
UIColor* color = TTSTYLEVAR(searchBarTintColor);
UIColor* highlight = [color multiplyHue:0 saturation:0 value:1.2];
UIColor* shadow = [color multiplyHue:0 saturation:0 value:0.82];
return
[TTLinearGradientFillStyle styleWithColor1:highlight color2:color next:
[TTFourBorderStyle styleWithTop:shadow right:nil bottom:nil left:nil width:1 next:nil]];
}
- (TTStyle*)tableHeader {
return
[TTReflectiveFillStyle styleWithColor:self.tableHeaderTintColor next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-1, 0, 0, 0) next:
[TTFourBorderStyle styleWithTop:nil right:nil bottom:RGBACOLOR(0,0,0,0.15)
left:nil width:1 next:nil]]];
}
- (TTStyle*)pickerCell:(UIControlState)state {
if (state & UIControlStateSelected) {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 1, 1, 1) next:
[TTLinearGradientFillStyle styleWithColor1:RGBCOLOR(79, 144, 255)
color2:RGBCOLOR(49, 90, 255) next:
[TTFourBorderStyle styleWithTop:RGBCOLOR(53, 94, 255)
right:RGBCOLOR(53, 94, 255) bottom:RGBCOLOR(53, 94, 255)
left:RGBCOLOR(53, 94, 255) width:1 next:nil]]]];
} else {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 1, 1, 1) next:
[TTLinearGradientFillStyle styleWithColor1:RGBCOLOR(221, 231, 248)
color2:RGBACOLOR(188, 206, 241, 1) next:
[TTFourBorderStyle styleWithTop:RGBCOLOR(161, 187, 283)
right:RGBCOLOR(118, 130, 214) bottom:RGBCOLOR(118, 130, 214)
left:RGBCOLOR(161, 187, 283) width:1 next:nil]]]];
}
}
- (TTStyle*)searchTableShadow {
return
[TTLinearGradientFillStyle styleWithColor1:RGBACOLOR(0, 0, 0, 0.18)
color2:[UIColor clearColor] next:
[TTFourBorderStyle styleWithTop:RGBCOLOR(130, 130, 130) right:nil bottom:nil left:nil
width: 1 next:nil]];
}
- (TTStyle*)blackBezel {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:10] next:
[TTSolidFillStyle styleWithColor:RGBACOLOR(0, 0, 0, 0.7) next:nil]];
}
- (TTStyle*)whiteBezel {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:10] next:
[TTSolidFillStyle styleWithColor:RGBCOLOR(255, 255, 255) next:
[TTSolidBorderStyle styleWithColor:RGBCOLOR(178, 178, 178) width:1 next:nil]]];
}
- (TTStyle*)badge {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 1, 1, 1) next:
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,1) blur:3 offset:CGSizeMake(0, 4) next:
[TTReflectiveFillStyle styleWithColor:RGBCOLOR(221, 17, 27) next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-1, -1, -1, -1) next:
[TTSolidBorderStyle styleWithColor:[UIColor whiteColor] width:2 next:
[TTPaddingStyle styleWithPadding:UIEdgeInsetsMake(-4, 0, -4, 0) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
color:[UIColor whiteColor] next:nil]]]]]]]];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// public colors
- (UIColor*)navigationBarTintColor {
return RGBCOLOR(119, 140, 168);
}
- (UIColor*)toolbarTintColor {
return RGBCOLOR(109, 132, 162);
}
- (UIColor*)searchBarTintColor {
return RGBCOLOR(200, 200, 200);
}
- (UIColor*)linkTextColor {
return RGBCOLOR(87, 107, 149);
}
- (UIColor*)moreLinkTextColor {
return RGBCOLOR(36, 112, 216);
}
- (UIColor*)tableActivityTextColor {
return RGBCOLOR(99, 109, 125);
}
- (UIColor*)tableErrorTextColor {
return RGBCOLOR(99, 109, 125);
}
- (UIColor*)tableSubTextColor {
return RGBCOLOR(99, 109, 125);
}
- (UIColor*)tableTitleTextColor {
return RGBCOLOR(99, 109, 125);
}
- (UIColor*)placeholderTextColor {
return RGBCOLOR(180, 180, 180);
}
- (UIColor*)searchTableBackgroundColor {
return RGBCOLOR(235, 235, 235);
}
- (UIColor*)searchTableSeparatorColor {
return [UIColor colorWithWhite:0.85 alpha:1];
}
- (UIColor*)tableHeaderTextColor {
return nil;
}
- (UIColor*)tableHeaderShadowColor {
return nil;
}
- (UIColor*)tableHeaderTintColor {
return nil;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// public fonts
- (UIFont*)toolbarButtonFont {
return [UIFont boldSystemFontOfSize:12];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// private
- (UIColor*)toolbarButtonColorWithTintColor:(UIColor*)color forState:(UIControlState)state {
if (state & UIControlStateHighlighted) {
if (color.value < 0.2) {
return [color addHue:0 saturation:0 value:0.2];
} else if (color.saturation > 0.3) {
return [color multiplyHue:1 saturation:1 value:0.4];
} else {
return [color multiplyHue:1 saturation:2.3 value:0.64];
}
} else if (state & UIControlStateDisabled) {
return [color multiplyHue:1 saturation:0.5 value:1];
} else {
if (color.saturation < 0.5) {
return [color multiplyHue:1 saturation:1.6 value:0.97];
} else {
return [color multiplyHue:1 saturation:1.25 value:0.75];
}
}
}
- (UIColor*)toolbarButtonTextColorForState:(UIControlState)state {
if (state & UIControlStateDisabled) {
return [UIColor colorWithWhite:1 alpha:0.4];
} else {
return [UIColor whiteColor];
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// public
- (TTStyle*)toolbarButtonForState:(UIControlState)state shape:(TTShape*)shape
tintColor:(UIColor*)tintColor font:(UIFont*)font {
UIColor* stateTintColor = [self toolbarButtonColorWithTintColor:tintColor forState:state];
UIColor* stateTextColor = [self toolbarButtonTextColorForState:state];
return
[TTShapeStyle styleWithShape:shape next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, 0, 1, 0) next:
[TTShadowStyle styleWithColor:RGBACOLOR(255,255,255,0.55) blur:0 offset:CGSizeMake(0, 1) next:
[TTReflectiveFillStyle styleWithColor:stateTintColor next:
[TTBevelBorderStyle styleWithHighlight:[stateTintColor multiplyHue:1 saturation:0.9 value:0.7]
shadow:[stateTintColor multiplyHue:1 saturation:0.5 value:0.45]
width:1 lightSource:270 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, -1, 0, -1) next:
[TTBevelBorderStyle styleWithHighlight:nil shadow:RGBACOLOR(0,0,0,0.15)
width:1 lightSource:270 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(4, 5, 2, 7) next:
[TTTextStyle styleWithFont:font
color:stateTextColor shadowColor:[UIColor colorWithWhite:0 alpha:0.4]
shadowOffset:CGSizeMake(0, -1) next:nil]]]]]]]]];
}
@end