This repository has been archived by the owner on Feb 7, 2021. It is now read-only.
/
index.ios.js
138 lines (121 loc) · 3.2 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/**
* @flow
*/
"use strict";
var React = require("react-native");
var {
AppRegistry,
NavigatorIOS,
StyleSheet
} = React;
var EventEmitter = require("EventEmitter");
var AboutScreen = require("./App/Components/AboutScreen");
var PodcastsScreen = require("./App/Components/PodcastsScreen");
var ViewSubscriber = require("./App/Lib/ViewSubscriber");
var { TabBarIOS } = require('react-native-icons');
class RWpodPlayer extends React.Component {
static title: "<TabBarIOS>";
static description: "Tab-based navigation";
constructor (props) {
super(props);
/* binds*/
this._isSelectedTab = this._isSelectedTab.bind(this);
this._selectTab = this._selectTab.bind(this);
this._refreshPodcasts = this._refreshPodcasts.bind(this);
/* views */
this._renderPodcasts = this._renderPodcasts.bind(this);
this._renderAbout = this._renderAbout.bind(this);
/* event emitter */
this.emitter = new EventEmitter();
/* state */
this.state = {
selectedTab: 'podcasts'
};
}
render () {
return (
<TabBarIOS
tintColor={'#087C78'}
barTintColor={'#E2DBCB'}
style={styles.tabBar}>
<TabBarIOS.Item
title={'Подкасты'}
iconName={'ion|radio-waves'}
selectedIconName={'ion|radio-waves'}
iconSize={32}
accessibilityLabel="Подкасты"
style={styles.tabBarItem}
selected={this._isSelectedTab('podcasts')}
onPress={() => this._selectTab('podcasts')}>
{this._renderPodcasts()}
</TabBarIOS.Item>
<TabBarIOS.Item
title={'О Нас'}
iconName={'ion|ios-people'}
selectedIconName={'ion|ios-people'}
iconSize={32}
accessibilityLabel="О Нас"
style={styles.tabBarItem}
selected={this._isSelectedTab('about')}
onPress={() => this._selectTab('about')}>
{this._renderAbout()}
</TabBarIOS.Item>
</TabBarIOS>
);
}
_renderPodcasts() {
return (
<NavigatorIOS
tintColor={'#087C78'}
barTintColor={'#E2DBCB'}
style={styles.navigatorContainer}
initialRoute={{
component: PodcastsScreen,
title: "Подкасты",
rightButtonTitle: "Обновить",
passProps: { emitter: this.emitter },
onRightButtonPress: this._refreshPodcasts
}}
/>
)
}
_renderAbout() {
return (
<NavigatorIOS
tintColor={'#087C78'}
barTintColor={'#E2DBCB'}
style={styles.navigatorContainer}
initialRoute={{
component: AboutScreen,
title: "О Нас"
}}
/>
)
}
_refreshPodcasts () {
this.emitter.emit("refreshPodcasts");
}
_isSelectedTab (tabName): boolean {
return tabName === this.state.selectedTab;
}
_selectTab (tabName) {
this.setState({
selectedTab: tabName
});
}
}
var styles = StyleSheet.create({
tabBar: {
flex: 1
},
tabBarItem: {
flex: 1,
backgroundColor: "#E2DBCB",
marginBottom: 50
},
navigatorContainer: {
flex: 1,
backgroundColor: "#111111"
}
});
AppRegistry.registerComponent("RWpodPlayer", () => RWpodPlayer);