Skip to content

Commit 11cff26

Browse files
committed
Merge pull request ptomasroos#57 from Structuralapp/tab-bar-position-prop
Set tab bar position above or below tabs.
2 parents 5202dd8 + 0b6abba commit 11cff26

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
@@ -16,6 +16,7 @@ var deviceWidth = Dimensions.get('window').width;
1616
var ScrollableTabView = React.createClass({
1717
getDefaultProps() {
1818
return {
19+
tabBarPosition: 'top',
1920
edgeHitWidth: 30,
2021
springTension: 50,
2122
springFriction: 10
@@ -106,17 +107,21 @@ var ScrollableTabView = React.createClass({
106107
inputRange: [0, 1], outputRange: [0, -deviceWidth]
107108
});
108109

110+
var tabBarProps = {
111+
goToPage: this.goToPage,
112+
tabs: this.props.children.map((child) => child.props.tabLabel),
113+
activeTab: this.state.currentPage,
114+
scrollValue: this.state.scrollValue
115+
};
116+
109117
return (
110118
<View style={{flex: 1}}>
111-
{this.renderTabBar({goToPage: this.goToPage,
112-
tabs: this.props.children.map((child) => child.props.tabLabel),
113-
activeTab: this.state.currentPage,
114-
scrollValue: this.state.scrollValue})}
115-
119+
{this.props.tabBarPosition === 'top' ? this.renderTabBar(tabBarProps) : null}
116120
<Animated.View style={[sceneContainerStyle, {transform: [{translateX}]}]}
117121
{...this._panResponder.panHandlers}>
118122
{this.props.children}
119123
</Animated.View>
124+
{this.props.tabBarPosition === 'bottom' ? this.renderTabBar(tabBarProps) : null}
120125
</View>
121126
);
122127
}

0 commit comments

Comments
 (0)