-
Notifications
You must be signed in to change notification settings - Fork 97
/
app.js
93 lines (84 loc) · 2.41 KB
/
app.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
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Button,
ToastAndroid
} from 'react-native';
const _ = require('lodash');
const JSProfile = require('./suites/JSProfile');
const RenderProfile = require('./suites/RenderProfile');
const RENDER_JS = 1;
const RENDER_PERF = 2;
const RENDER_PERF_DEEP = 4;
class MainScreen extends Component {
constructor(props) {
super(props);
this.state = {
render: undefined
};
}
componentDidMount() {
try {
const opts = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
const date = new Date();
const he = date.toLocaleDateString('he', opts);
const ja = date.toLocaleDateString('ja', opts);
const de = date.toLocaleDateString('de', opts);
const ar = date.toLocaleDateString('ar', opts);
setTimeout(() => ToastAndroid.show(`Different Locales:\n${he}\n${ja}\n${de}\n${ar}`, ToastAndroid.LONG), 1000);
} catch (e) {
setTimeout(() => ToastAndroid.show(`Different Locales:\nERROR!\n${e.message}`, ToastAndroid.LONG), 1000);
}
}
render() {
return (
<View style={{
flex: 1,
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'center',
paddingVertical: 32,
paddingHorizontal: 16
}}>
{this.renderButtonsOrMeasure()}
</View>
);
}
renderButtonsOrMeasure() {
switch (this.state.render) {
case RENDER_JS: return this.startJsProfile();
case RENDER_PERF: return this.startRenderProfile();
case RENDER_PERF_DEEP: return this.startRenderProfile(true);
default: return this.renderBtns();
}
}
renderBtns() {
return (
<View >
<View style={{ margin: 16 }}>
<Button title="Profile JavaScript" onPress={() => this.setState({ render: RENDER_JS })} />
</View>
<View style={{ margin: 16 }}>
<Button title="Profile Render Flat" onPress={() => this.setState({ render: RENDER_PERF })} />
</View>
<View style={{ margin: 16 }}>
<Button title="Profile Render Deep" onPress={() => this.setState({ render: RENDER_PERF_DEEP })} />
</View>
</View>
);
}
startJsProfile() {
return (
<JSProfile />
);
}
startRenderProfile(deep = false) {
return (
<RenderProfile deep={deep} />
);
}
}
AppRegistry.registerComponent('MainScreen', () => MainScreen);