44 Text ,
55 View ,
66 TouchableOpacity ,
7- Animated ,
87} from 'react-native' ;
98import Icon from 'react-native-vector-icons/Ionicons' ;
109
@@ -18,7 +17,6 @@ const FacebookTabBar = React.createClass({
1817 } ,
1918
2019 componentDidMount ( ) {
21- this . setAnimationValue ( { value : this . props . activeTab , } ) ;
2220 this . _listener = this . props . scrollValue . addListener ( this . setAnimationValue ) ;
2321 } ,
2422
@@ -42,25 +40,17 @@ const FacebookTabBar = React.createClass({
4240 } ,
4341
4442 render ( ) {
45- const tabWidth = this . props . containerWidth / this . props . tabs . length ;
46- const left = this . props . scrollValue . interpolate ( {
47- inputRange : [ 0 , 1 , ] , outputRange : [ 0 , tabWidth , ] ,
48- } ) ;
49-
50- return < View >
51- < View style = { [ styles . tabs , this . props . style , ] } >
52- { this . props . tabs . map ( ( tab , i ) => {
53- return < TouchableOpacity key = { tab } onPress = { ( ) => this . props . goToPage ( i ) } style = { styles . tab } >
54- < Icon
55- name = { tab }
56- size = { 30 }
57- color = { this . props . activeTab == i ? 'rgb(59,89,152)' : 'rgb(204,204,204)' }
58- ref = { ( icon ) => { this . tabIcons [ i ] = icon ; } }
59- />
60- </ TouchableOpacity > ;
61- } ) }
62- </ View >
63- < Animated . View style = { [ styles . tabUnderlineStyle , { width : tabWidth } , { left, } , ] } />
43+ return < View style = { [ styles . tabs , this . props . style , ] } >
44+ { this . props . tabs . map ( ( tab , i ) => {
45+ return < TouchableOpacity key = { tab } onPress = { ( ) => this . props . goToPage ( i ) } style = { styles . tab } >
46+ < Icon
47+ name = { tab }
48+ size = { 30 }
49+ color = { this . props . activeTab === i ? 'rgb(59,89,152)' : 'rgb(204,204,204)' }
50+ ref = { ( icon ) => { this . tabIcons [ i ] = icon ; } }
51+ />
52+ </ TouchableOpacity > ;
53+ } ) }
6454 </ View > ;
6555 } ,
6656} ) ;
@@ -82,12 +72,6 @@ const styles = StyleSheet.create({
8272 borderRightWidth : 0 ,
8373 borderBottomColor : 'rgba(0,0,0,0.05)' ,
8474 } ,
85- tabUnderlineStyle : {
86- position : 'absolute' ,
87- height : 3 ,
88- backgroundColor : '#3b5998' ,
89- bottom : 0 ,
90- } ,
9175} ) ;
9276
9377export default FacebookTabBar ;
0 commit comments