import React from 'react';
import {
	Navigator,
	Text,
	TouchableHighlight,
	View,
} from 'react-native';

import Icon from 'react-native-vector-icons/FontAwesome';
import PreferencesView from './preferences/PreferencesView';

const css = require('../styles/css');

export default class NavigationBarWithRouteMapper extends React.Component {
	render() {
		return (
			<Navigator
				ref="navRef"
				initialRoute={this.props.route}
				renderScene={this.props.renderScene}
				navigationBar={
					<Navigator.NavigationBar
						style={css.navigator}
						navigationStyles={Navigator.NavigationBar.StylesIOS}
						routeMapper={{
							LeftButton: function(route, navigator, index, navState) {
								if (route.id === 'Home') {
									return null;
								} else {
									return (
										<TouchableHighlight underlayColor={'rgba(200,200,200,.1)'} onPress={() => navigator.pop()}>
											<Icon style={css.navigatorLeft} name='angle-left' />
										</TouchableHighlight>
									);
								}
							},

							Title: function(route, navigator, index, navState) {
								return (
										<Text style={css.navigatorTitle}>{route.title}</Text>
								);
							},

							RightButton: function(route, navigator, index, navState) {
								if (route.id !== 'Home') {
									//return null;
								}

								// for the home view, show the preferences button
								return (
									<TouchableHighlight
										underlayColor={'rgba(200,200,200,.1)'}
										onPress={() => {
											navigator.push({
												id: 'PreferencesView',
												component: PreferencesView,
												title: 'Preferences'
											});
										}}
									>
										<Icon style={css.navigatorRight} name='cog' />
									</TouchableHighlight>
								);
							}
						}}
					/>
				}
			/>
		);
	}
}

@@ -1098,17 +1098,16 @@
 %09%09%09%09%09%09%09%09
-%09
 %3CText st
@@ -1152,16 +1152,16 @@
 %3C/Text%3E%0A
+
 %09%09%09%09%09%09%09%09
@@ -1284,18 +1284,16 @@
 %09%09%09%09%09%09%09%09
-//
 return n
@@ -1306,18 +1306,25 @@
 %09%09%09%09%09%09%09%7D
-%0A%0A
+ else %7B%0A%09
 %09%09%09%09%09%09%09%09
@@ -1373,32 +1373,33 @@
  button%0A%09%09%09%09%09%09%09%09
+%09
 return (%0A%09%09%09%09%09%09%09
@@ -1383,32 +1383,33 @@
 %09%09%09%09%09%09%09return (%0A
+%09
 %09%09%09%09%09%09%09%09%09%3CToucha
@@ -1421,16 +1421,17 @@
 ghlight%0A
+%09
 %09%09%09%09%09%09%09%09
@@ -1481,16 +1481,17 @@
 %09%09%09%09%09%09%09%09
+%09
 onPress=
@@ -1499,16 +1499,17 @@
 () =%3E %7B%0A
+%09
 %09%09%09%09%09%09%09%09
@@ -1540,16 +1540,17 @@
 %09%09%09%09%09%09%09%09
+%09
 id: 'Pre
@@ -1564,16 +1564,17 @@
 sView',%0A
+%09
 %09%09%09%09%09%09%09%09
@@ -1617,16 +1617,17 @@
 %09%09%09%09%09%09%09%09
+%09
 title: '
@@ -1654,12 +1654,14 @@
 %09%09%09%09
+%09
 %7D);%0A
+%09
 %09%09%09%09
@@ -1678,18 +1678,20 @@
 %09%09%09%09%09%09%09%09
+%09
 %3E%0A
+%09
 %09%09%09%09%09%09%09%09
@@ -1740,32 +1740,33 @@
 og' /%3E%0A%09%09%09%09%09%09%09%09%09
+%09
 %3C/TouchableHighl
@@ -1771,35 +1771,46 @@
 hlight%3E%0A%09%09%09%09%09%09%09%09
+%09
 );%0A
+%09%09%09%09%09%09%09%09%7D%0A
 %09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%7D

reset navigator home return value