Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adds tabBarPosition prop and positions tab bar accordingly.
  • Loading branch information
rpylipow committed Oct 24, 2015
commit 6bfc7360ef27c7e15d1ffbe940ac3b321d94f517
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ module.exports = CustomTabBar;
the tab bar. The component has `goToPage`, `tabs`, `activeTab` and
`ref` added to the props, and should implement `setAnimationValue` to
be able to animate itself along with the tab content.
- **`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"`.
- **`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
- **`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.
- **`hasTouch`** _(Function)_ - returns `true` when ScrollableTabView starts being panned and `false` when it is released. Not triggered when `locked` (Bool) is true.
Expand Down
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var ScrollableTabView = React.createClass({
getDefaultProps() {
return {
edgeHitWidth: 30,
tabBarPosition: 'top'
}
},

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

var tabBarProps = {
goToPage: this.goToPage,
tabs: this.props.children.map((child) => child.props.tabLabel),
activeTab: this.state.currentPage,
scrollValue: this.state.scrollValue
};

return (
<View style={{flex: 1}}>
{this.renderTabBar({goToPage: this.goToPage,
tabs: this.props.children.map((child) => child.props.tabLabel),
activeTab: this.state.currentPage,
scrollValue: this.state.scrollValue})}

{this.props.tabBarPosition === 'top' ? this.renderTabBar(tabBarProps) : null}
<Animated.View style={[sceneContainerStyle, {transform: [{translateX}]}]}
{...this._panResponder.panHandlers}>
{this.props.children}
</Animated.View>
{this.props.tabBarPosition === 'bottom' ? this.renderTabBar(tabBarProps) : null}
</View>
);
}
Expand Down