Skip to content
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ The **`<Router />`** object used to initialize the navigation can take the follo
- `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} />`.
- `hideNavigationBar`: Hide the navigation bar, always
- `handleBackAndroid` (Boolean value): Apply a listener to the native back button on Android. On click, it will go to the previous route until it reach the first scene, then it will exit the app.
- `alertAndroidExit` (Boolean value): Alert the user if the Android back button is about to exit them from the app.
- `statusBarProps`: Default StatusBar props, please refer to [StatusBar Docs](https://facebook.github.io/react-native/docs/statusbar.html#content). (Android) If `backgroundColor` isn't provided, it will take the same color as defined in `headerStyle`.
- `sceneConfig`: Default animation to be used in case no `sceneConfig` is provided by the `toRoute` function. More details and possible parameters are in the `toRoute` documentation below. Defaults to `Navigator.SceneConfigs.FloatFromRight`.

Expand Down Expand Up @@ -170,7 +171,7 @@ The **`this.props.toRoute()`** callback prop takes one parameter (a JavaScript o
const {
text,
user,
} = this.props.data;
} = this.props.data;
```

The **`this.props.replaceRoute`** function takes in an object that can contain the same keys as `toRoute()`. The difference is that instead of adding a route to your stack, it replaces the route
Expand Down
15 changes: 13 additions & 2 deletions components/NavBarContainer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { PropTypes } from 'react';
import {
Alert,
BackAndroid,
Platform,
StyleSheet,
Expand All @@ -17,6 +18,7 @@ const propTypes = {
currentRoute: PropTypes.object.isRequired,
customAction: PropTypes.func,
handleBackAndroid: PropTypes.bool,
alertAndroidExit: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: alphabetical order

goToFirstRoute: PropTypes.func.isRequired,
leftProps: PropTypes.object,
navigator: PropTypes.object.isRequired,
Expand Down Expand Up @@ -70,10 +72,19 @@ class NavBarContainer extends React.Component {
BackAndroid.addEventListener('hardwareBackPress', () => {
if (this.props.currentRoute.index > 0) {
this.goBack();
return true;
} else {
console.log('dsa')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These console.log should not be commited.

console.log(this.props.alertAndroidExit)
console.log('dsa')
if (this.props.alertAndroidExit) {
Alert.alert('Leaving Current App', 'Are you sure you want to exit?', [
{ text: 'Cancel', style: 'cancel' },
{ text: 'Yes', onPress: () => BackAndroid.exitApp() }
])
}
}

return false;
return true;
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const propTypes = {
customAction: PropTypes.func,
firstRoute: PropTypes.object.isRequired,
handleBackAndroid: PropTypes.bool,
alertAndroidExit: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: alphabetical order

headerStyle: View.propTypes.style,
hideNavigationBar: PropTypes.bool,
noStatusBar: PropTypes.bool,
Expand Down Expand Up @@ -380,6 +381,7 @@ class Router extends React.Component {
titleProps={this.state.titleProps}
customAction={this.customAction}
handleBackAndroid={this.props.handleBackAndroid}
alertAndroidExit={this.props.alertAndroidExit}
/>
);
}
Expand Down