|
22 | 22 | * }]}
|
23 | 23 | * selectedTab={0}/>
|
24 | 24 | */
|
25 |
| -import React from 'react'; |
| 25 | +var React = require('react-native'); |
26 | 26 |
|
27 |
| -import { |
28 |
| - View, |
| 27 | +var { |
| 28 | + View, |
29 | 29 | TabBarIOS,
|
30 | 30 | StyleSheet,
|
31 | 31 | Platform
|
32 |
| -} from 'react-native'; |
| 32 | +} = React; |
33 | 33 |
|
34 |
| -import TabNavigator from 'react-native-tab-navigator'; |
35 | 34 | var ScrollableTabView = require('react-native-scrollable-tab-view');
|
36 | 35 | var CustomTabBar = require('./customTabBar.android.js');
|
37 | 36 |
|
38 |
| -import { FontAwesome as Icon } from '@exponent/vector-icons'; |
| 37 | +var Icon = require('react-native-vector-icons/FontAwesome'); |
39 | 38 |
|
40 | 39 | module.exports = React.createClass({
|
41 |
| - getInitialState: function(){ |
42 |
| - return { |
43 |
| - structure: this.props.structure, |
44 |
| - selectedTab: this.props.selectedTab, |
45 |
| - iconSize: this.props.iconSize ? this.props.iconSize : 30, |
46 |
| - activeTintColor: this.props.activeTintColor ? this.props.activeTintColor : null |
47 |
| - }; |
48 |
| - }, |
| 40 | + getInitialState: function(){ |
| 41 | + return { |
| 42 | + structure: this.props.structure, |
| 43 | + selectedTab: this.props.selectedTab, |
| 44 | + iconSize: this.props.iconSize ? this.props.iconSize : 30, |
| 45 | + activeTintColor: this.props.activeTintColor ? this.props.activeTintColor : null |
| 46 | + }; |
| 47 | + }, |
49 | 48 | render: function(){
|
50 |
| - return ( |
51 |
| - <TabNavigator> |
52 |
| - {this.state.structure.map((tabProps, tabIndex) => |
53 |
| - <TabNavigator.Item |
54 |
| - selected={tabIndex == this.state.selectedTab} |
55 |
| - title={tabProps.title} |
56 |
| - key={tabIndex} |
57 |
| - selectedTitleStyle={{color: '#ff6600'}} |
58 |
| - renderIcon={() => <Icon name={tabProps.iconName} size={25} color="#888" />} |
59 |
| - renderSelectedIcon={() => <Icon name={tabProps.iconName} size={25} color="#ff6600" />} |
60 |
| - onPress={() => { this.setState({selectedTab: tabIndex}); }}> |
61 |
| - {tabProps.renderContent()} |
62 |
| - </TabNavigator.Item> |
63 |
| - )} |
64 |
| - </TabNavigator> |
65 |
| - ); |
| 49 | + if (Platform.OS == 'android'){ |
| 50 | + return( |
| 51 | + <ScrollableTabView renderTabBar={() => <CustomTabBar />} |
| 52 | + onChangeTab={(o)=>{}} |
| 53 | + tabBarPosition={'bottom'} |
| 54 | + initialPage={this.state.selectedTab}> |
| 55 | + {this.state.structure.map((tabProps, tabIndex) => |
| 56 | + <View style={{flex:1}} |
| 57 | + tabLabel={tabProps.title+'!$#' |
| 58 | + +tabProps.iconName+'!$#' |
| 59 | + +this.state.iconSize} |
| 60 | + key={tabIndex}> |
| 61 | + {tabProps.renderContent()} |
| 62 | + </View> |
| 63 | + )} |
| 64 | + </ScrollableTabView> |
| 65 | + ); |
| 66 | + } |
| 67 | + return( |
| 68 | + <TabBarIOS tintColor={this.state.activeTintColor} |
| 69 | + translucent={true}> |
| 70 | + {this.state.structure.map((tabProps, tabIndex) => |
| 71 | + <Icon.TabBarItem title={tabProps.title} |
| 72 | + iconName={tabProps.iconName} |
| 73 | + iconSize={this.state.iconSize} |
| 74 | + selected={tabIndex == this.state.selectedTab} |
| 75 | + onPress={() => {this.setState({selectedTab: tabIndex});}} |
| 76 | + key={tabIndex}> |
| 77 | + {tabProps.renderContent()} |
| 78 | + </Icon.TabBarItem> |
| 79 | + )} |
| 80 | + </TabBarIOS> |
| 81 | + ); |
66 | 82 | }
|
67 | 83 | });
|
68 | 84 |
|
|
0 commit comments