TabBottom.js
2.26 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
'use strict';
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
export default class TabBottom extends Component {
static propType = {
goToPage: PropTypes.func,
activeTab: PropTypes.number,
tabs: PropTypes.array,
tabNames: PropTypes.array,
tabIconNames: PropTypes.array,
selectedTabIconNames: PropTypes.array
};
componentDidMount() {
this.props.scrollValue.addListener(this.setAnimationValue);
}
setAnimationValue({value}) {
console.log(value);
}
render() {
return (
<View style={styles.tabs}>
{this.props.tabs.map((tab, i) => {
let color = this.props.activeTab === i ? 'green' : 'gray';
let icon = this.props.activeTab === i ? this.props.selectedTabIconNames[i] : this.props.tabIconNames[i];
return (
<TouchableOpacity key={i} activeOpacity={0.8} style={styles.tab} onPress={() => this.props.goToPage(i)}>
<View style={styles.tabItem}>
<Image
style={styles.icon}
source={icon}/>
{/*<Text style={{color: color, fontSize: 12}}>*/}
{/*{this.props.tabNames[i]}*/}
{/*</Text>*/}
</View>
</TouchableOpacity>
)
})}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ffffff',
marginTop: 20
},
tabs: {
flexDirection: 'row',
height: 51,
borderTopColor: '#E0E0E0',
borderTopWidth: 1
},
tab: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
tabItem: {
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'space-around'
},
icon: {
width: 24,
height: 38,
}
});