/
index.android.js
114 lines (102 loc) · 2.78 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, {
AppRegistry,
BackAndroid,
Component,
ListView,
ScrollView,
Navigator,
View,
Text,
TextInput,
} from 'react-native';
import CameraViewAndroid from './components/CameraViewAndroid';
import LedgerViewAndroid from './components/LedgerViewAndroid';
import RecordFormViewAndroid from './components/RecordFormViewAndroid';
import ResultViewAndroid from './components/ResultViewAndroid';
import styles from './styles/Initial';
import MockData from './data/records';
import LoginANDROID from './components/LoginANDROID';
const actions = [
{title: 'Settings', icon: require('image!app_logo'), show: 'always'},
{title: 'Boom', icon: require('image!app_logo'), show: 'always'},
];
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import { addRecord } from './actions';
import basicApp from './reducers';
// TODO: refactor to central file for both iOS and Android
const initialState = {
auth: {},
records: [],
};
const store = createStore(basicApp, initialState);
class ABCTotaalCockpit extends Component {
constructor(props) {
super(props);
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(MockData.records),
colorProps: {
titleColor: 'red'
}
};
}
render() {
return (
<Provider store={store}>
<Navigator
initialRoute={{name: 'Resultaat', id:'overview' ,index: 0}}
renderScene={this.renderScene.bind(this)}
configureScene={route => (
route.sceneConfig || Navigator.SceneConfigs.HorizontalSwipeJump
)}
ref="navigator"/>
</Provider>
);
}
renderScene(route, navigator) {
BackAndroid.addEventListener('hardwareBackPress', function() {
if(navigator && navigator.getCurrentRoutes().length > 1) {
console.log(navigator.getCurrentRoutes());
navigator.pop();
return true;
}
return false;
});
switch (route.id) {
case 'overview':
return(
<ResultViewAndroid
navigator={navigator} />
);
case 'ledger':
return(
<LedgerViewAndroid
navigator={navigator}
records={this.state.dataSource} />
);
case 'new':
return (
<RecordFormViewAndroid
navigator={navigator} />
);
case 'camera':
return (
<CameraViewAndroid
navigator={navigator}
route={route} {...this.props} />
);
case 'login':
return (
<LoginANDROID
navigator={navigator}
route={route} {...this.props} />
);
}
}
}
AppRegistry.registerComponent('ABCTotaalCockpit', () => ABCTotaalCockpit);