forked from fangwei716/30-days-of-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
463 lines (453 loc) · 11 KB
/
index.android.js
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
/**
* 30 Days of React Native
* Icons made by <a href="http://www.flaticon.com/authors/vectors-market" title="Vectors Market">Vectors Market</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
*/
'use strict';
import React, {AppRegistry,DeviceEventEmitter,Component,Image,Navigator,ScrollView,StyleSheet,Text,TouchableHighlight,View} from 'react-native';
import Util from './view/utils';
import Icon from 'react-native-vector-icons/Ionicons';
import IconFA from 'react-native-vector-icons/FontAwesome';
// import Day1 from './view/day1';
// import Day2 from './view/day2';
// import Day3 from './view/day3';
// import Day4 from './view/day4';
// import Day5 from './view/day5';
// import Day6 from './view/day6';
// import Day7 from './view/day7';
// import Day8 from './view/day8';
// import Day9 from './view/day9';
// import Day10 from './view/day10';
// import Day11 from './view/day11';
// import Day12 from './view/day12';
// import Day13 from './view/day13';
// import Day14 from './view/day14';
// import Day15 from './view/day15';
// import Day16 from './view/day16';
// import Day17 from './view/day17';
// import Day18 from './view/day18';
// import Day19 from './view/day19';
// import Day20 from './view/day20';
// import Day21 from './view/day21';
// import Day22 from './view/day22';
// import Day23 from './view/day23';
// import Day24 from './view/day24';
// import Day25 from './view/day25';
// import Day26 from './view/day26';
// import Day27 from './view/day27';
// import Day28 from './view/day28';
// import Day29 from './view/day29';
// import Day30 from './view/day30';
class MainView extends Component {
constructor() {
super();
this.state = {
days:[{
key:0,
title:"A stopwatch",
// component: Day1,
isFA: false,
icon: "ios-stopwatch",
size: 48,
color: "#ff856c",
hideNav: false,
},{
key:1,
title:"A weather app",
// component: Day2,
isFA: false,
icon: "ios-partlysunny",
size:60,
color:"#90bdc1",
hideNav: true,
},{
key:2,
title:"twitter",
// component: Day3,
isFA: false,
icon: "social-twitter",
size:50,
color:"#2aa2ef",
hideNav: true,
},{
key:3,
title:"cocoapods",
// component: Day4,
isFA: true,
icon: "contao",
size:50,
color:"#FF9A05",
hideNav: false,
},{
key:4,
title:"find my location",
// component: Day5,
isFA: false,
icon: "ios-location",
size:50,
color:"#00D204",
hideNav: false,
},{
key:5,
title:"Spotify",
// component: Day6,
isFA: true,
icon: "spotify",
size:50,
color:"#777",
hideNav: true,
},{
key:6,
title:"Moveable Circle",
// component: Day7,
isFA: false,
icon: "ios-baseball",
size:50,
color:"#5e2a06",
hideNav: true,
},{
key:7,
title:"Swipe Left Menu",
// component: Day8,
isFA: true,
icon: "google",
size:50,
color:"#4285f4",
hideNav: true,
},{
key:8,
title:"Twitter Parallax View",
// component: Day9,
isFA: false,
icon: "social-twitter-outline",
size:50,
color:"#2aa2ef",
hideNav: true,
},{
key:9,
title:"Tumblr Menu",
// component: Day10,
isFA: false,
icon: "social-tumblr",
size:50,
color:"#37465c",
hideNav: true,
},{
key:10,
title:"OpenGL",
// component: Day11,
isFA: false,
icon: "contrast",
size:50,
color:"#2F3600",
hideNav: false,
},{
key:11,
title:"charts",
// component: Day12,
isFA: false,
icon: "stats-bars",
size:50,
color:"#fd8f9d",
hideNav: false,
},{
key:12,
title:"tweet",
// component: Day13,
isFA: false,
icon: "chatbox-working",
size:50,
color:"#83709d",
hideNav: true,
},{
key:13,
title:"tinder",
// component: Day14,
isFA: false,
icon: "fireball",
size:50,
color:"#ff6b6b",
hideNav: true,
},{
key:14,
title:"Time picker",
// component: Day15,
isFA: false,
icon: "ios-calendar-outline",
size:50,
color:"#ec240e",
hideNav: false,
},{
key:15,
title:"Gesture unlock",
// component: Day16,
isFA: false,
icon: "unlocked",
size:50,
color:"#32A69B",
hideNav: true,
},{
key:16,
title:"Fuzzy search",
// component: Day17,
isFA: false,
icon: "search",
size:50,
color:"#69B32A",
hideNav: false,
},{
key:17,
title:"Sortable",
// component: Day18,
isFA: false,
icon: "arrow-move",
size:50,
color:"#68231A",
hideNav: true,
},{
key:18,
title:"TouchID to unlock",
// component: Day19,
isFA: false,
icon: "log-in",
size:50,
color:"#fdbded",
hideNav: true,
},{
key:19,
title:"Single page Reminder",
// component: Day20,
isFA: false,
icon: "ios-list-outline",
size:50,
color:"#68d746",
hideNav: true,
},{
key:20,
title:"Multi page Reminder",
// component: Day21,
isFA: false,
icon: "ios-paper-outline",
size:50,
color:"#fe952b",
hideNav: true,
},{
key:21,
title:"Google Now",
// component: Day22,
isFA: false,
icon: "android-microphone",
size:50,
color:"#4285f4",
hideNav: true,
},{
key:22,
title:"Local WebView",
// component: Day23,
isFA: true,
icon: "safari",
size:50,
color:"#23bfe7",
hideNav: false,
},{
key:23,
title:"Youtube scrollable tab",
// component: Day24,
isFA: false,
icon: "social-youtube",
size:50,
color:"#e32524",
hideNav: true,
},{
key:24,
title:"custome in-app browser",
// component: Day25,
isFA: false,
icon: "ios-world",
size:50,
color:"#00ab6b",
hideNav: true,
},{
key:25,
title:"swipe and switch",
// component: Day26,
isFA: false,
icon: "shuffle",
size:50,
color:"#893D54",
hideNav: true,
},{
key:26,
title:"iMessage Gradient",
// component: Day27,
isFA: false,
icon: "ios-chatbubble",
size:50,
color:"#248ef5",
hideNav: false,
},{
key:27,
title:"iMessage image picker",
// component: Day28,
isFA: false,
icon: "images",
size:50,
color:"#f5248e",
hideNav: true,
},{
key:28,
title:"iMessage image picker",
// component: Day29,
isFA: false,
icon: "navicon-round",
size:50,
color:"#48f52e",
hideNav: false,
},{
key:29,
title:"Push Notifications",
// component: Day30,
isFA: false,
icon: "android-notifications",
size:50,
color:"#f27405",
hideNav: false,
}]
}
}
componentWillMount() {
DeviceEventEmitter.addListener(
'quickActionShortcut', (data) => {
switch(data.title){
case "Day5":
this._jumpToDay(4);
break;
case "Day22":
this._jumpToDay(21);
break;
case "Day26":
this._jumpToDay(25);
break;
case "Day28":
this._jumpToDay(27);
break;
}
});
}
_jumpToDay(index){
// this.props.navigator.push({
// title: this.state.days[index].title,
// component: this.state.days[index].component,
// navigationBarHidden: this.state.days[index].hideNav,
// })
}
render() {
var onThis = this;
var boxs = this.state.days.map(function(elem, index) {
return(
<TouchableHighlight key={elem.key} style={[styles.touchBox,styles.touchBox1]} underlayColor="#eee" onPress={()=> onThis._jumpToDay(index)}>
<View style={styles.boxContainer}>
<Text style={styles.boxText}>Day{index+1}</Text>
{elem.isFA? <IconFA size={elem.size} name={elem.icon} style={[styles.boxIcon,{color:elem.color}]}></IconFA>:
<Icon size={elem.size} name={elem.icon} style={[styles.boxIcon,{color:elem.color}]}></Icon>}
</View>
</TouchableHighlight>
);
})
return(
<ScrollView>
<View style={styles.touchBoxContainer}>
{boxs}
</View>
</ScrollView>
);
}
}
class forAndroid extends Component{
componentDidMount() {
// StatusBarIOS.setStyle(0);
}
render(){
return (
<Navigator
initialRoute={{name: 'My First Scene', index: 0}}
renderScene={(route, navigator) =>
<MainView/>
}
/>
);
}
}
const styles = StyleSheet.create({
container:{
flex:1,
},
itemWrapper:{
backgroundColor: '#f3f3f3'
},
touchBox:{
width: Util.size.width/3-0.34,
height:Util.size.width/3,
backgroundColor:"#fff",
},
touchBoxContainer:{
flexDirection: "row",
flexWrap:"wrap",
width: Util.size.width,
borderTopWidth: Util.pixel,
borderTopColor:"#ccc",
borderLeftWidth: Util.pixel,
borderLeftColor:"#ccc",
borderRightWidth: Util.pixel,
borderRightColor:"#ccc",
},
touchBox1:{
borderBottomWidth: Util.pixel,
borderBottomColor:"#ccc",
borderRightWidth: Util.pixel,
borderRightColor:"#ccc",
},
touchBox2:{
borderBottomWidth: Util.pixel,
borderBottomColor:"#ccc",
},
boxContainer:{
alignItems:"center",
justifyContent:"center",
width: Util.size.width/3,
height:Util.size.width/3,
},
boxIcon:{
position:"relative",
top:-10
},
boxText:{
position:"absolute",
bottom:15,
width:Util.size.width/3,
textAlign:"center",
left: 0,
backgroundColor:"transparent"
},
slide: {
flex: 1,
height: 150,
justifyContent: 'center',
alignItems: 'center',
},
slideText:{
position:"absolute",
bottom: 0,
paddingTop:5,
paddingBottom:5,
backgroundColor:"rgba(255,255,255,0.5)",
width: Util.size.width,
textAlign:"center",
fontSize: 12
},
image:{
width: Util.size.width,
flex: 1,
alignSelf: 'stretch',
}
});
AppRegistry.registerComponent('forAndroid', () => forAndroid);