This repository has been archived by the owner on Jan 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.android.js
90 lines (74 loc) · 2.62 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
import React from 'react';
import {
AppRegistry,
BackAndroid,
Navigator,
Text,
View
} from 'react-native';
import AxisLineChartScreen from './app/AxisLineChartScreen';
import BarChartScreen from './app/BarChartScreen';
import BubbleChartScreen from './app/BubbleChartScreen';
import CandleStickChartScreen from './app/CandleStickChartScreen';
import ChartsListScreen from './app/ChartsListScreen';
import LineChartScreen from './app/LineChartScreen';
import PieChartScreen from './app/PieChartScreen';
import RadarChartScreen from './app/RadarChartScreen';
import ScatterChartScreen from './app/ScatterChartScreen';
import StackedBarChartScreen from './app/StackedBarChartScreen';
import ZeroLineChartScreen from './app/ZeroLineChartScreen';
const MAIN_SCREEN = 'ChartsListScreen';
class reactNativeMPAndroidChartExample extends React.Component {
constructor() {
super();
this.state = {
initialRoute: {
name: MAIN_SCREEN
}
};
this.onRouteChange = this.onRouteChange.bind(this);
this.onBackAndroid = this.onBackAndroid.bind(this);
BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid);
}
onRouteChange(route: Object, navigator: Object) {
const routes = {
AxisLineChartScreen: <AxisLineChartScreen navigator={navigator} />,
BarChartScreen: <BarChartScreen navigator={navigator} />,
BubbleChartScreen: <BubbleChartScreen navigator={navigator} />,
CandleStickChartScreen: <CandleStickChartScreen navigator={navigator} />,
ChartsListScreen: <ChartsListScreen navigator={navigator} />,
LineChartScreen: <LineChartScreen navigator={navigator} />,
PieChartScreen: <PieChartScreen navigator={navigator} />,
RadarChartScreen: <RadarChartScreen navigator={navigator} />,
ScatterChartScreen: <ScatterChartScreen navigator={navigator} />,
StackedBarChartScreen: <StackedBarChartScreen navigator={navigator} />,
ZeroLineChartScreen: <ZeroLineChartScreen navigator={navigator} />
};
let screen = routes[route.name];
if (!screen) {
return console.error('Unhandled route!', route);
}
this.route = route;
return screen;
}
onBackAndroid() {
if (!this._isOnMainScreen()) {
this.refs.navigator.pop();
return true;
}
return false;
}
_isOnMainScreen() {
return this.route.name === MAIN_SCREEN;
}
render() {
return (
<Navigator
ref="navigator"
initialRoute={this.state.initialRoute}
renderScene={this.onRouteChange}
/>
);
}
}
AppRegistry.registerComponent('reactNativeMPAndroidChartExample', () => reactNativeMPAndroidChartExample);