Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Commit

Permalink
Removed left button in navigator and actived Android back button.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasider41 committed Oct 25, 2016
1 parent fef73e8 commit 8d7cce0
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions src/container/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import {
StyleSheet,
TouchableOpacity,
TouchableHighlight,
PixelRatio,
BackAndroid,
} from 'react-native';

import Map from '../component/Map';

let navigator;

class NavigationBar extends Navigator.NavigationBar {
render() {
var routes = this.props.navState.routeStack;
Expand All @@ -34,23 +36,38 @@ export default class App extends React.Component{

routeMapper = {
LeftButton: (route, navigator, index, navState) =>
{
if(route.index > 0) {
return <TouchableOpacity
underlayColor='transparent'
onPress={() => {if (index > 0) {navigator.pop()}}}>
<Text style={styles.navBackBtn}> Back </Text>
</TouchableOpacity>;
}else{
return null;
}
},
// {
// if(route.index > 0) {
// return <TouchableOpacity
// underlayColor='transparent'
// onPress={() => {if (index > 0) {navigator.pop()}}}>
// <Text style={styles.navBackBtn}> Back </Text>
// </TouchableOpacity>;
// }else{
// return null;
// }
// },
{ return null; },
RightButton: (route, navigator, index, navState) =>
{ return null; },
Title: (route, navigator, index, navState) =>
{ return (<Text style={styles.navTitle}>{route.title}</Text>); },
{
return (
<Text style={styles.navTitle}>{route.title}</Text>
);
},
};

componentDidMount() {
BackAndroid.addEventListener('hardwareBackPress', () => {
if (navigator && navigator.getCurrentRoutes().length > 0) {
navigator.pop();
return true;
}
return false;
});
}

render(){
return (
<Navigator
Expand All @@ -60,6 +77,7 @@ export default class App extends React.Component{
display: true,
component: Map,
}}
ref={(nav) => { navigator = nav; }}
configureScene={this.configureScene}
renderScene={(route, navigator) => {
return <route.component
Expand Down

0 comments on commit 8d7cce0

Please sign in to comment.