Skip to content

Commit 6bfc736

Browse files
committed
Adds tabBarPosition prop and positions tab bar accordingly.
1 parent f109d7e commit 6bfc736

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ module.exports = CustomTabBar;
143143
the tab bar. The component has `goToPage`, `tabs`, `activeTab` and
144144
`ref` added to the props, and should implement `setAnimationValue` to
145145
be able to animate itself along with the tab content.
146+
- **`tabBarPosition`** _(String)_ - if `"top"`, the tab bar will render above the tabs. If `"bottom"`, the tab bar will render below the tabs. Defaults to `"top"`.
146147
- **`onChangeTab`** _(Function)_ - function to call when tab changes, should accept 1 argument which is an Object containing two keys: `i`: the index of the tab that is selected, `ref`: the ref of the tab that is selected
147148
- **`edgeHitWidth`** _(Integer)_ - region (in pixels) from the left & right edges of the screen that can trigger swipe. Default is 30, which is the same as the swipe-back gesture on iOS.
148149
- **`hasTouch`** _(Function)_ - returns `true` when ScrollableTabView starts being panned and `false` when it is released. Not triggered when `locked` (Bool) is true.

index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var ScrollableTabView = React.createClass({
1717
getDefaultProps() {
1818
return {
1919
edgeHitWidth: 30,
20+
tabBarPosition: 'top'
2021
}
2122
},
2223

@@ -104,17 +105,21 @@ var ScrollableTabView = React.createClass({
104105
inputRange: [0, 1], outputRange: [0, -deviceWidth]
105106
});
106107

108+
var tabBarProps = {
109+
goToPage: this.goToPage,
110+
tabs: this.props.children.map((child) => child.props.tabLabel),
111+
activeTab: this.state.currentPage,
112+
scrollValue: this.state.scrollValue
113+
};
114+
107115
return (
108116
<View style={{flex: 1}}>
109-
{this.renderTabBar({goToPage: this.goToPage,
110-
tabs: this.props.children.map((child) => child.props.tabLabel),
111-
activeTab: this.state.currentPage,
112-
scrollValue: this.state.scrollValue})}
113-
117+
{this.props.tabBarPosition === 'top' ? this.renderTabBar(tabBarProps) : null}
114118
<Animated.View style={[sceneContainerStyle, {transform: [{translateX}]}]}
115119
{...this._panResponder.panHandlers}>
116120
{this.props.children}
117121
</Animated.View>
122+
{this.props.tabBarPosition === 'bottom' ? this.renderTabBar(tabBarProps) : null}
118123
</View>
119124
);
120125
}

0 commit comments

Comments
 (0)