-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.ios.js
95 lines (85 loc) · 1.78 KB
/
index.ios.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
'use strict';
var SITE_URL = 'http://wp-kyoto.net/';
var API_URL = SITE_URL + 'wp-json/';
var Icon = require('react-native-vector-icons/FontAwesome');
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
TabBarIOS,
View,
Text,
} = React;
var PostRow = require('./app/post.ios.js');
var MediaRow = require('./app/media.ios.js');
var reactWpApp = React.createClass({
statics: {
title: '<TabBarIOS>',
description: 'Tab-based navigation.',
},
displayName: 'TabBarExample',
getInitialState: function() {
return {
selectedTab: 'postTab',
};
},
_renderContent: function( type: string ) {
if ( 'post' == type ) {
var apiPath = API_URL + 'wp/v2/posts';
return (
<PostRow apiPath={apiPath}/>
);
} else if ( 'media' == type ) {
var apiPath = API_URL + 'wp/v2/media';
return (
<MediaRow apiPath={apiPath}/>
);
}
return (
<View>
<Text>No Data.</Text>
</View>
);
},
render: function() {
return (
<TabBarIOS
tintColor="white"
barTintColor="darkslateblue">
<Icon.TabBarItem
title="Post List"
iconName='newspaper-o'
selected={this.state.selectedTab === 'postTab'}
onPress={() => {
this.setState({
selectedTab: 'postTab',
});
}}>
{this._renderContent('post')}
</Icon.TabBarItem>
<Icon.TabBarItem
title="Media"
iconName='image'
selected={this.state.selectedTab === 'mediaTab'}
onPress={() => {
this.setState({
selectedTab: 'mediaTab',
});
}}>
{this._renderContent('media')}
</Icon.TabBarItem>
</TabBarIOS>
)
}
})
var styles = StyleSheet.create({
tabContent: {
flex: 1,
alignItems: 'center',
},
tabText: {
color: 'white',
margin: 50,
},
});
AppRegistry.registerComponent( 'reactWpApp', () => reactWpApp );