-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #743 from joenoon/jn-wip
WIP old tab bar
- Loading branch information
Showing
8 changed files
with
185 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
import StaticContainer from 'react-static-container'; | ||
|
||
const styles = StyleSheet.create({ | ||
scene: { | ||
bottom: 0, | ||
left: 0, | ||
position: 'absolute', | ||
right: 0, | ||
top: 0, | ||
}, | ||
}); | ||
|
||
class TabbedView extends Component { | ||
|
||
static propTypes = { | ||
navigationState: PropTypes.object.isRequired, | ||
renderScene: PropTypes.func.isRequired, | ||
style: View.propTypes.style, | ||
}; | ||
|
||
constructor(props, context) { | ||
super(props, context); | ||
this.renderedSceneKeys = {}; | ||
this.renderScene = this.renderScene.bind(this); | ||
} | ||
|
||
renderScene(navigationState, index) { | ||
const isSelected = index === this.props.navigationState.index; | ||
return ( | ||
<View | ||
key={navigationState.key} | ||
pointerEvents={isSelected ? 'auto' : 'none'} | ||
removeClippedSubviews={!isSelected} | ||
style={[ | ||
styles.scene, | ||
{ opacity: isSelected ? 1 : 0 }, | ||
]} | ||
> | ||
<StaticContainer shouldUpdate={isSelected}> | ||
{this.props.renderScene(navigationState, index)} | ||
</StaticContainer> | ||
</View> | ||
); | ||
} | ||
|
||
render() { | ||
const scenes = []; | ||
const { index, children } = this.props.navigationState; | ||
children.forEach((item, i) => { | ||
const key = item.key; | ||
if (i !== index && !this.renderedSceneKeys[key]) { | ||
return; | ||
} | ||
this.renderedSceneKeys[key] = true; | ||
scenes.push(this.renderScene(item, i)); | ||
}); | ||
return ( | ||
<View style={this.props.style}> | ||
{scenes} | ||
</View> | ||
); | ||
} | ||
|
||
} | ||
|
||
export default TabbedView; |