-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
96 lines (84 loc) · 1.82 KB
/
App.js
File metadata and controls
96 lines (84 loc) · 1.82 KB
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
/* eslint-disable react/no-unused-state */
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { TabViewAnimated, TabBar } from 'react-native-tab-view';
import { observer } from 'mobx-react';
import TracksMapView from './components/TracksMapView';
import TagListView from './components/TagListView';
import store from './store';
import {
blue,
white,
} from './colors';
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 20,
},
tabbar: {
backgroundColor: white,
},
indicator: {
backgroundColor: blue,
},
});
const renderScene = ({ route }) => { // eslint-disable-line react/prop-types
switch (route.key) {
case '1':
return (
<TracksMapView store={store} />
);
case '2':
return (
<TagListView store={store} />
);
default:
return null;
}
};
const renderIcon = ({ route }) => ( // eslint-disable-line react/prop-types
<Ionicons
name={route.icon}
size={24}
color={blue}
/>
);
const renderHeader = props => (
<TabBar
{...props}
indicatorStyle={styles.indicator}
renderIcon={renderIcon}
style={styles.tabbar}
/>
);
class App extends React.Component {
constructor() {
super();
store.fetchTags();
this.state = {
index: 0,
routes: [
{ key: '1', icon: 'md-map' },
{ key: '2', icon: 'md-list' },
],
};
}
handleIndexChange(index) {
this.setState({
index,
});
}
render() {
return (
<TabViewAnimated
style={styles.container}
navigationState={this.state}
renderScene={renderScene}
renderHeader={renderHeader}
onIndexChange={index => this.handleIndexChange(index)}
/>
);
}
}
export default observer(App);