forked from ptomasroos/react-native-scrollable-tab-view
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabBar.js
44 lines (38 loc) · 1.02 KB
/
tabBar.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
import React from 'react';
import {
View,
Text,
TouchableOpacity,
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
import s from './tabBar.scss';
import gs from '../../app.scss';
class TabBar extends React.Component {
icons = [];
constructor(props) {
super(props);
this.icons = [];
}
render() {
let {tabs, goToPage, activeTab, style, icons} = this.props;
return <View style={[s.tabs, style]}>
{tabs.map((tab, i) => {
return <TouchableOpacity key={tab}
onPress={() => goToPage(i)}
style={s.tab}>
<Icon
name={icons[i]}
size={25}
color={activeTab === i ? '#5e92f3' : '#999999'}
ref={(icon) => { this.icons[i] = icon; }}
/>
{
activeTab === i && tab &&
<Text style={[gs.buttonText, s.tabCaption]}> { tab } </Text>
}
</TouchableOpacity>;
})}
</View>;
}
}
export default TabBar;