Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ The **`<Router \>`** object used to initialize the navigation can take the follo
- `firstRoute` (required): A React class corresponding to the first page of your navigation
- `headerStyle`: Apply a StyleSheet to the navigation bar. You'll probably want to change the backgroundColor for example.
- `titleStyle`: Apply a StyleSheet to the navigation bar titles. Useful for changing the font or text color.
- `backButtonStyle`: Apply a StyleSheet to the back button. Useful for changing the color.
- `backButtonComponent`: By default, the navigation bar will display a simple "Back" text for the back button. To change this, you can specify your own backButton component (like in the Twitter app).
- `rightCorner`: If you have the same occuring action buttons on the right side of your navigation bar (like the Twitter "Compose"-button), you can specify a component for that view.
- `customAction`: A special callback prop for your action buttons (this can be handy for triggering a side menu for example). The action gets triggered from your custom `leftCorner` or `rightCorner` components by calling `this.props.customAction("someActionName")` from them. It is then picked up like this: `<Router customAction={this.doSomething} />`.
Expand All @@ -124,4 +125,3 @@ Questions?
---------

If something is unclear or if you just want to say hi, feel free to [follow me on Twitter](https://twitter.com/t4t5)!

12 changes: 7 additions & 5 deletions components/NavBarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ var NavBarContainer = React.createClass({
render: function() {
return (
<View style={[styles.navbarContainer, this.props.style]}>
<NavBarContent
route={this.state.previousRoute}
<NavBarContent
route={this.state.previousRoute}
backButtonComponent={this.props.backButtonComponent}
backButtonStyle={this.props.backButtonStyle}
rightCorner={this.props.rightCorner}
titleStyle={this.props.titleStyle}
willDisappear="true"
willDisappear="true"
/>
<NavBarContent
route={this.props.currentRoute}
<NavBarContent
route={this.props.currentRoute}
backButtonComponent={this.props.backButtonComponent}
backButtonStyle={this.props.backButtonStyle}
rightCorner={this.props.rightCorner}
titleStyle={this.props.titleStyle}
goBack={this.goBack}
Expand Down
8 changes: 5 additions & 3 deletions components/NavBarContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ var NavBarContent = React.createClass({
},

render() {
var transitionStyle = {
var transitionStyle = {
opacity: this.getTweeningValue('opacity'),
};

var leftCorner;
var rightCorner;
var titleComponent;


/**
* Set leftCorner
Expand All @@ -72,7 +72,9 @@ var NavBarContent = React.createClass({
var LeftCorner = this.props.route.leftCorner;
leftCornerContent = <LeftCorner toRoute={this.goForward} customAction={this.customAction} />;
} else if (this.props.route.index > 0) {
leftCornerContent = <NavButton onPress={this.goBack} backButtonComponent={this.props.backButtonComponent} />;
leftCornerContent = <NavButton onPress={this.goBack}
backButtonComponent={this.props.backButtonComponent}
backButtonStyle={this.props.backButtonStyle} />;
}

leftCorner = (
Expand Down
3 changes: 2 additions & 1 deletion components/NavButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var NavButton = React.createClass({
var BackButton = this.props.backButtonComponent;
backButton = <View><BackButton /></View>
} else {
backButton = <Text style={styles.navbarText}>Back</Text>
var hasBackButtonStyle = this.props.backButtonStyle;
backButton = <Text style={[styles.navbarText, hasBackButtonStyle && this.props.backButtonStyle]}>Back</Text>
}

return (
Expand Down
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ var Router = React.createClass({
var didStartDrag = function(evt) {
var x = evt.nativeEvent.pageX;
if (x < 28) {
this.setState({
dragStartX: x,
this.setState({
dragStartX: x,
didSwitchView: false
});
return true;
Expand All @@ -85,7 +85,7 @@ var Router = React.createClass({
};

var Content = route.component;

return (
<View
style={[styles.container, this.props.bgStyle]}
Expand All @@ -102,7 +102,7 @@ var Router = React.createClass({
/>
</View>
)

},

render: function() {
Expand All @@ -115,9 +115,10 @@ var Router = React.createClass({
navigationBar={
<NavBarContainer
style={this.props.headerStyle}
navigator={navigator}
navigator={navigator}
currentRoute={this.state.route}
backButtonComponent={this.props.backButtonComponent}
backButtonStyle={this.props.backButtonStyle}
rightCorner={this.props.rightCorner}
titleStyle={this.props.titleStyle}
toRoute={this.onForward}
Expand Down